'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');
'value' => '#' . $bgcolor->hexValue()));
$this->elementEnd('li');
-
$ccolor = new WebColor($design->contentcolor);
$this->elementStart('li');
$design->backgroundimage = $defaults['backgroundimage'];
- $deisng->tile = $defaults['tile'];
+ $deisng->disposition = $defaults['disposition'];
} catch (WebColorException $e) {
common_log(LOG_ERR, _('Bad default color settings: ' .
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();
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
$design->backgroundimage = $filepath;
- $design->tile = $tile;
+
+ $design->setDisposition($on, $off, $tile);
$result = $design->update($original);
$design->textcolor = $tcolor->intValue();
$design->linkcolor = $lcolor->intValue();
$design->backgroundimage = $filepath;
- $design->tile = $tile;
+
+ $design->setDisposition($on, $off, $tile);
$id = $design->insert();
$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);
- }
-
}
exit(1);
}
+define('BACKGROUND_ON', 1);
+define('BACKGROUND_OFF', 2);
+define('BACKGROUND_TILE', 4);
+
/**
* Table Definition for design
*/
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); }
$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(' .
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;
+ }
+ }
+
}