]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Enable tiling of background imgs for Designs
authorZach Copley <zach@controlyourself.ca>
Wed, 17 Jun 2009 05:18:25 +0000 (22:18 -0700)
committerZach Copley <zach@controlyourself.ca>
Wed, 17 Jun 2009 05:18:25 +0000 (22:18 -0700)
actions/designsettings.php
classes/Design.php
lib/common.php

index e97d01ceb74d30e6fef5d2660303012f697bd03c..866d8aaeb7c267e80c367ee53c6c15b86c29984a 100644 (file)
@@ -71,6 +71,12 @@ class DesignsettingsAction extends AccountSettingsAction
     function showContent()
     {
         $user = common_current_user();
+        $design = $user->getDesign();
+
+        if (empty($design)) {
+            $design = $this->defaultDesign();
+        }
+
         $this->elementStart('form', array('method' => 'post',
                                           'enctype' => 'multipart/form-data',
                                           'id' => 'form_settings_design',
@@ -122,7 +128,7 @@ class DesignsettingsAction extends AccountSettingsAction
         $this->elementStart('li');
         $this->checkbox('design_background-image_repeat',
                         _('Tile background image'),
-                        false, null, true, false);
+                        $design->tile);
         $this->elementEnd('li');
 
         $this->elementEnd('ul');
@@ -132,12 +138,6 @@ class DesignsettingsAction extends AccountSettingsAction
         $this->element('legend', null, _('Change colours'));
         $this->elementStart('ul', 'form_data');
 
-        $design = $user->getDesign();
-
-        if (empty($design)) {
-            $design = $this->defaultDesign();
-        }
-
         try {
 
             $bgcolor = new WebColor($design->backgroundcolor);
@@ -340,6 +340,8 @@ class DesignsettingsAction extends AccountSettingsAction
 
             $design->backgroundimage = $defaults['backgroundimage'];
 
+            $deisng->tile = $defaults['tile'];
+
         } catch (WebColorException $e) {
             common_log(LOG_ERR, _('Bad default color settings: ' .
                 $e->getMessage()));
@@ -369,6 +371,8 @@ class DesignsettingsAction extends AccountSettingsAction
             return;
         }
 
+        $tile = $this->boolean('design_background-image_repeat');
+
         $user = common_current_user();
         $design = $user->getDesign();
 
@@ -382,6 +386,7 @@ class DesignsettingsAction extends AccountSettingsAction
             $design->textcolor       = $tcolor->intValue();
             $design->linkcolor       = $lcolor->intValue();
             $design->backgroundimage = $filepath;
+            $design->tile            = $tile;
 
             $result = $design->update($original);
 
@@ -405,6 +410,7 @@ class DesignsettingsAction extends AccountSettingsAction
             $design->textcolor       = $tcolor->intValue();
             $design->linkcolor       = $lcolor->intValue();
             $design->backgroundimage = $filepath;
+            $design->tile            = $tile;
 
             $id = $design->insert();
 
index acc94d1969099c18e10a03a09c4eaaaec3d0c465..4ea176677bdf971c0b97d7afda4e887de5d61263 100644 (file)
@@ -41,7 +41,7 @@ class Design extends Memcached_DataObject
     public $textcolor;                       // int(4)
     public $linkcolor;                       // int(4)
     public $backgroundimage;                 // varchar(255)
-    public $tile;                            // tinyint(1)  
+    public $tile;                            // tinyint(1)
 
     /* Static get */
     function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Design',$k,$v); }
@@ -64,23 +64,26 @@ class Design extends Memcached_DataObject
             common_log(LOG_ERR, "Unable to create color for design $id.",
                 __FILE__);
         }
-        
+
         $css  = 'html, body { background-color: #' . $bgcolor->hexValue() . '} ' . "\n";
         $css .= '#content, #site_nav_local_views .current a { background-color: #';
         $css .= $ccolor->hexValue() . '} '."\n";
         $css .= '#aside_primary { background-color: #'. $sbcolor->hexValue() . '} ' . "\n";
         $css .= 'html body { color: #'. $tcolor->hexValue() . '} '. "\n";
         $css .= 'a { color: #' . $lcolor->hexValue() . '} ' . "\n";
-        
+
         if (!empty($this->backgroundimage)) {
-        
-            $css .= 'body { background-image:url(' . 
-                Design::url($this->backgroundimage) . 
-                '); background-repeat:no-repeat; }' . "\n";
+
+           $repeat = ($this->tile) ? 'background-repeat:repeat;' :
+               'background-repeat:no-repeat;';
+
+            $css .= 'body { background-image:url(' .
+                Design::url($this->backgroundimage) .
+                '); ' . $repeat . ' }' . "\n";
         }
-        
+
         $out->element('style', array('type' => 'text/css'), $css);
-    
+
     }
 
     static function filename($id, $extension, $extra=null)
@@ -98,7 +101,7 @@ class Design extends Memcached_DataObject
 
         return $dir . $filename;
     }
-    
+
     static function url($filename)
     {
         $path = common_config('background', 'path');
@@ -121,5 +124,5 @@ class Design extends Memcached_DataObject
 
         return 'http://'.$server.$path.$filename;
     }
-    
+
 }
index 0e710625c7d9aaac02611b4467ecb55a61112d63..629fee25b269b65721e2ee8022b141b2984a5abc 100644 (file)
@@ -78,7 +78,8 @@ $config =
                     'sidebarcolor' => '#CEE1E9',
                     'textcolor' => '#000000',
                     'linkcolor' => '#002E6E',
-                    'backgroundimage' => null),
+                    'backgroundimage' => null,
+                    'tile' => true),
               'path' => $_path,
               'logfile' => null,
               'logo' => null,