]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/designsettings.php
Only unbind privacy checkbox when actually on mobile profile, oops.
[quix0rs-gnu-social.git] / lib / designsettings.php
index 98ef8256cd9859d1af679901b69691ff34889fee..cb65ca14cbfa80b2d7395817dfd116658fe42d4a 100644 (file)
@@ -32,9 +32,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/accountsettingsaction.php';
-require_once INSTALLDIR . '/lib/webcolor.php';
-
 /**
  * Base class for setting a user or group design
  *
@@ -49,9 +46,8 @@ require_once INSTALLDIR . '/lib/webcolor.php';
  * @link     http://status.net/
  */
 
-class DesignSettingsAction extends AccountSettingsAction
+class DesignSettingsAction extends SettingsAction
 {
-
     var $submitaction = null;
 
     /**
@@ -59,9 +55,9 @@ class DesignSettingsAction extends AccountSettingsAction
      *
      * @return string Title of the page
      */
-
     function title()
     {
+        // TRANS: Page title for profile design page.
         return _('Profile design');
     }
 
@@ -70,9 +66,9 @@ class DesignSettingsAction extends AccountSettingsAction
      *
      * @return instructions for use
      */
-
     function getInstructions()
     {
+        // TRANS: Instructions for profile design page.
         return _('Customize the way your profile looks ' .
         'with a background image and a colour palette of your choice.');
     }
@@ -84,11 +80,11 @@ class DesignSettingsAction extends AccountSettingsAction
      *
      * @return nothing
      */
-
     function showDesignForm($design)
     {
         $form = new DesignForm($this, $design, $this->selfUrl());
         $form->show();
+
     }
 
     /**
@@ -99,7 +95,6 @@ class DesignSettingsAction extends AccountSettingsAction
      *
      * @return void
      */
-
     function handlePost()
     {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -111,8 +106,10 @@ class DesignSettingsAction extends AccountSettingsAction
                 && empty($_POST)
                 && ($_SERVER['CONTENT_LENGTH'] > 0)
             ) {
-                $msg = _('The server was unable to handle that much POST ' .
-                    'data (%s bytes) due to its current configuration.');
+                // TRANS: Form validation error in design settings form. POST should remain untranslated.
+                $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.',
+                          'The server was unable to handle that much POST data (%s bytes) due to its current configuration.',
+                          intval($_SERVER['CONTENT_LENGTH']));
 
                 $this->showForm(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
                 return;
@@ -122,6 +119,7 @@ class DesignSettingsAction extends AccountSettingsAction
         // CSRF protection
         $token = $this->trimmed('token');
         if (!$token || $token != common_session_token()) {
+            // TRANS: Client error displayed when the session token does not match or is not given.
             $this->showForm(_('There was a problem with your session token. '.
                               'Try again, please.'));
             return;
@@ -132,6 +130,7 @@ class DesignSettingsAction extends AccountSettingsAction
         } else if ($this->arg('defaults')) {
             $this->restoreDefaults();
         } else {
+            // TRANS: Unknown form validation error in design settings form.
             $this->showForm(_('Unexpected form submission.'));
         }
     }
@@ -141,7 +140,6 @@ class DesignSettingsAction extends AccountSettingsAction
      *
      * @return void
      */
-
     function showStylesheets()
     {
         parent::showStylesheets();
@@ -153,7 +151,6 @@ class DesignSettingsAction extends AccountSettingsAction
      *
      * @return void
      */
-
     function showScripts()
     {
         parent::showScripts();
@@ -171,31 +168,28 @@ class DesignSettingsAction extends AccountSettingsAction
      *
      * @return nothing
      */
-
     function saveBackgroundImage($design)
     {
-
         // Now that we have a Design ID we can add a file to the design.
         // XXX: This is an additional DB hit, but figured having the image
         // associated with the Design rather than the User was worth
         // it. -- Zach
 
-        if ($_FILES['design_background-image_file']['error'] ==
-            UPLOAD_ERR_OK) {
+        if (array_key_exists('design_background-image_file', $_FILES) &&
+          $_FILES['design_background-image_file']['error'] == UPLOAD_ERR_OK) {
 
             $filepath = null;
 
             try {
-                $imagefile =
-                    ImageFile::fromUpload('design_background-image_file');
+                $imagefile = ImageFile::fromUpload('design_background-image_file');
             } catch (Exception $e) {
                 $this->showForm($e->getMessage());
                 return;
             }
 
             $filename = Design::filename($design->id,
-                image_type_to_extension($imagefile->type),
-                    common_timestamp());
+                                         image_type_to_extension($imagefile->type),
+                                         common_timestamp());
 
             $filepath = Design::path($filename);
 
@@ -219,7 +213,8 @@ class DesignSettingsAction extends AccountSettingsAction
 
             if ($result === false) {
                 common_log_db_error($design, 'UPDATE', __FILE__);
-                $this->showForm(_('Couldn\'t update your design.'));
+                // TRANS: Error message displayed if design settings could not be saved.
+                $this->showForm(_('Could not update your design.'));
                 return;
             }
         }
@@ -230,7 +225,6 @@ class DesignSettingsAction extends AccountSettingsAction
      *
      * @return nothing
      */
-
     function restoreDefaults()
     {
         $design = $this->getWorkingDesign();
@@ -241,12 +235,13 @@ class DesignSettingsAction extends AccountSettingsAction
 
             if ($result === false) {
                 common_log_db_error($design, 'DELETE', __FILE__);
-                $this->showForm(_('Couldn\'t update your design.'));
+                // TRANS: Error message displayed if design settings could not be saved after clicking "Use defaults".
+                $this->showForm(_('Could not update your design.'));
                 return;
             }
         }
 
+        // TRANS: Success message displayed if design settings were saved after clicking "Use defaults".
         $this->showForm(_('Design defaults restored.'), true);
     }
-
 }