summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/designsettings.php100
-rw-r--r--classes/Design.php33
-rwxr-xr-xclasses/laconica.ini2
-rw-r--r--db/laconica.sql2
-rw-r--r--lib/common.php2
5 files changed, 93 insertions, 46 deletions
diff --git a/actions/designsettings.php b/actions/designsettings.php
index fbec3fc67..3dfaddd7b 100644
--- a/actions/designsettings.php
+++ b/actions/designsettings.php
@@ -104,37 +104,52 @@ class DesignsettingsAction extends AccountSettingsAction
'value' => ImageFile::maxFileSizeInt()));
$this->elementEnd('li');
- $this->elementStart('li', array('id' => 'design_background-image_onoff'));
-
if (!empty($design->backgroundimage)) {
+
+ $this->elementStart('li', array('id' => 'design_background-image_onoff'));
+
$this->element('img', array('src' =>
Design::url($design->backgroundimage)));
- }
- $this->element('input', array('name' => 'design_background-image_onoff',
- 'type' => 'radio',
- 'id' => 'design_background-image_on',
- 'class' => 'radio',
- 'value' => 'true',
- 'checked'=> 'checked'));
- $this->element('label', array('for' => 'design_background-image_on',
- 'class' => 'radio'),
- _('On'));
- $this->element('input', array('name' => 'design_background-image_onoff',
- 'type' => 'radio',
- 'id' => 'design_background-image_off',
- 'class' => 'radio',
- 'value' => 'false'));
- $this->element('label', array('for' => 'design_background-image_off',
- 'class' => 'radio'),
- _('Off'));
- $this->element('p', 'form_guide', _('Turn background image on or off.'));
- $this->elementEnd('li');
+ $attrs = array('name' => 'design_background-image_onoff',
+ 'type' => 'radio',
+ 'id' => 'design_background-image_on',
+ 'class' => 'radio',
+ 'value' => 'on');
+
+ if ($design->disposition & BACKGROUND_ON) {
+ $attrs['checked'] = 'checked';
+ }
+
+ $this->element('input', $attrs);
+
+ $this->element('label', array('for' => 'design_background-image_on',
+ 'class' => 'radio'),
+ _('On'));
+
+ $attrs = array('name' => 'design_background-image_onoff',
+ 'type' => 'radio',
+ 'id' => 'design_background-image_off',
+ 'class' => 'radio',
+ 'value' => 'off');
+
+ if ($design->disposition & BACKGROUND_OFF) {
+ $attrs['checked'] = 'checked';
+ }
+
+ $this->element('input', $attrs);
+
+ $this->element('label', array('for' => 'design_background-image_off',
+ 'class' => 'radio'),
+ _('Off'));
+ $this->element('p', 'form_guide', _('Turn background image on or off.'));
+ $this->elementEnd('li');
+ }
$this->elementStart('li');
$this->checkbox('design_background-image_repeat',
_('Tile background image'),
- $design->tile);
+ ($design->disposition & BACKGROUND_TILE) ? true : false );
$this->elementEnd('li');
$this->elementEnd('ul');
@@ -159,7 +174,6 @@ class DesignsettingsAction extends AccountSettingsAction
'value' => '#' . $bgcolor->hexValue()));
$this->elementEnd('li');
-
$ccolor = new WebColor($design->contentcolor);
$this->elementStart('li');
@@ -346,7 +360,7 @@ class DesignsettingsAction extends AccountSettingsAction
$design->backgroundimage = $defaults['backgroundimage'];
- $deisng->tile = $defaults['tile'];
+ $deisng->disposition = $defaults['disposition'];
} catch (WebColorException $e) {
common_log(LOG_ERR, _('Bad default color settings: ' .
@@ -377,7 +391,23 @@ class DesignsettingsAction extends AccountSettingsAction
return;
}
- $tile = $this->boolean('design_background-image_repeat');
+ $onoff = $this->arg('design_background-image_onoff');
+
+ $on = false;
+ $off = false;
+ $tile = false;
+
+ if ($onoff == 'on') {
+ $on = true;
+ } else {
+ $off = true;
+ }
+
+ $repeat = $this->boolean('design_background-image_repeat');
+
+ if ($repeat) {
+ $tile = true;
+ }
$user = common_current_user();
$design = $user->getDesign();
@@ -392,7 +422,8 @@ class DesignsettingsAction extends AccountSettingsAction
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
$design->backgroundimage = $filepath;
- $design->tile = $tile;
+
+ $design->setDisposition($on, $off, $tile);
$result = $design->update($original);
@@ -416,7 +447,8 @@ class DesignsettingsAction extends AccountSettingsAction
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
$design->backgroundimage = $filepath;
- $design->tile = $tile;
+
+ $design->setDisposition($on, $off, $tile);
$id = $design->insert();
@@ -481,16 +513,4 @@ class DesignsettingsAction extends AccountSettingsAction
$this->showForm(_('Design preferences saved.'), true);
}
- /**
- * Reset design settings to previous saved value if any, or
- * the defaults
- *
- * @return void
- */
-
- function resetDesign()
- {
- $this->showForm(_('Design preferences reset.'), true);
- }
-
}
diff --git a/classes/Design.php b/classes/Design.php
index 4ea176677..5b28bf014 100644
--- a/classes/Design.php
+++ b/classes/Design.php
@@ -21,6 +21,10 @@ if (!defined('LACONICA')) {
exit(1);
}
+define('BACKGROUND_ON', 1);
+define('BACKGROUND_OFF', 2);
+define('BACKGROUND_TILE', 4);
+
/**
* Table Definition for design
*/
@@ -41,7 +45,7 @@ class Design extends Memcached_DataObject
public $textcolor; // int(4)
public $linkcolor; // int(4)
public $backgroundimage; // varchar(255)
- public $tile; // tinyint(1)
+ public $disposition; // tinyint(1) default_1
/* Static get */
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Design',$k,$v); }
@@ -72,9 +76,11 @@ class Design extends Memcached_DataObject
$css .= 'html body { color: #'. $tcolor->hexValue() . '} '. "\n";
$css .= 'a { color: #' . $lcolor->hexValue() . '} ' . "\n";
- if (!empty($this->backgroundimage)) {
+ if (!empty($this->backgroundimage) &&
+ $this->disposition & BACKGROUND_ON) {
- $repeat = ($this->tile) ? 'background-repeat:repeat;' :
+ $repeat = ($this->disposition & BACKGROUND_TILE) ?
+ 'background-repeat:repeat;' :
'background-repeat:no-repeat;';
$css .= 'body { background-image:url(' .
@@ -125,4 +131,25 @@ class Design extends Memcached_DataObject
return 'http://'.$server.$path.$filename;
}
+ function setDisposition($on, $off, $tile)
+ {
+ if ($on) {
+ $this->disposition |= BACKGROUND_ON;
+ } else {
+ $this->disposition &= ~BACKGROUND_ON;
+ }
+
+ if ($off) {
+ $this->disposition |= BACKGROUND_OFF;
+ } else {
+ $this->disposition &= ~BACKGROUND_OFF;
+ }
+
+ if ($tile) {
+ $this->disposition |= BACKGROUND_TILE;
+ } else {
+ $this->disposition &= ~BACKGROUND_TILE;
+ }
+ }
+
}
diff --git a/classes/laconica.ini b/classes/laconica.ini
index 569681984..1a650aba5 100755
--- a/classes/laconica.ini
+++ b/classes/laconica.ini
@@ -46,7 +46,7 @@ sidebarcolor = 1
textcolor = 1
linkcolor = 1
backgroundimage = 2
-tile = 17
+disposition = 17
[design__keys]
id = N
diff --git a/db/laconica.sql b/db/laconica.sql
index 1f302de16..b018afec8 100644
--- a/db/laconica.sql
+++ b/db/laconica.sql
@@ -496,7 +496,7 @@ create table design (
textcolor integer comment 'text color',
linkcolor integer comment 'link color',
backgroundimage varchar(255) comment 'background image, if any',
- tile tinyint default 0 comment 'tile background image'
+ disposition tinyint default 1 comment 'bit 1 = hide background image, bit 2 = display background image, bit 4 = tile background image'
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
create table group_block (
diff --git a/lib/common.php b/lib/common.php
index 629fee25b..bcf2e5d0c 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -79,7 +79,7 @@ $config =
'textcolor' => '#000000',
'linkcolor' => '#002E6E',
'backgroundimage' => null,
- 'tile' => true),
+ 'disposition' => 1),
'path' => $_path,
'logfile' => null,
'logo' => null,