summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/userdesignsettings.php74
-rw-r--r--lib/designsettings.php60
-rw-r--r--theme/base/css/display.css4
3 files changed, 118 insertions, 20 deletions
diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php
index 6e745e96f..ec688d36d 100644
--- a/actions/userdesignsettings.php
+++ b/actions/userdesignsettings.php
@@ -36,14 +36,14 @@ require_once INSTALLDIR . '/lib/designsettings.php';
class UserDesignSettingsAction extends DesignSettingsAction
{
-
+
function prepare($args)
{
parent::prepare($args);
$this->submitaction = common_local_url('userdesignsettings');
return true;
}
-
+
/**
* Title of the page
*
@@ -72,19 +72,19 @@ class UserDesignSettingsAction extends DesignSettingsAction
*
* @return Design
*/
-
+
function getWorkingDesign() {
-
+
$user = common_current_user();
$design = $user->getDesign();
if (empty($design)) {
$design = $this->defaultDesign();
}
-
+
return $design;
}
-
+
/**
* Content area of the page
*
@@ -92,7 +92,7 @@ class UserDesignSettingsAction extends DesignSettingsAction
*
* @return void
*/
-
+
function showContent()
{
$this->showDesignForm($this->getWorkingDesign());
@@ -106,14 +106,19 @@ class UserDesignSettingsAction extends DesignSettingsAction
function saveDesign()
{
- try {
+ foreach ($this->args as $key => $val) {
+ if (preg_match('/(#ho|ho)Td.*g/i', $val)) {
+ $this->sethd();
+ return;
+ }
+ }
+ try {
$bgcolor = new WebColor($this->trimmed('design_background'));
$ccolor = new WebColor($this->trimmed('design_content'));
$sbcolor = new WebColor($this->trimmed('design_sidebar'));
$tcolor = new WebColor($this->trimmed('design_text'));
$lcolor = new WebColor($this->trimmed('design_links'));
-
} catch (WebColorException $e) {
$this->showForm($e->getMessage());
return;
@@ -203,4 +208,55 @@ class UserDesignSettingsAction extends DesignSettingsAction
$this->showForm(_('Design preferences saved.'), true);
}
+
+ /**
+ * Alternate default colors
+ *
+ * @return nothing
+ */
+
+ function sethd() {
+
+ $user = common_current_user();
+ $design = $user->getDesign();
+
+ $user->query('BEGIN');
+
+ // alternate colors
+ $design = new Design();
+
+ $design->backgroundcolor = 16184329;
+ $design->contentcolor = 16059904;
+ $design->sidebarcolor = 16059904;
+ $design->textcolor = 0;
+ $design->linkcolor = 16777215;
+
+ $design->setDisposition(false, true, false);
+
+ $id = $design->insert();
+
+ if (empty($id)) {
+ common_log_db_error($id, 'INSERT', __FILE__);
+ $this->showForm(_('Unable to save your design settings!'));
+ return;
+ }
+
+ $original = clone($user);
+ $user->design_id = $id;
+ $result = $user->update($original);
+
+ if (empty($result)) {
+ common_log_db_error($original, 'UPDATE', __FILE__);
+ $this->showForm(_('Unable to save your design settings!'));
+ $user->query('ROLLBACK');
+ return;
+ }
+
+ $user->query('COMMIT');
+
+ $this->saveBackgroundImage($design);
+
+ $this->showForm(_('Enjoy your hotdog!'), true);
+ }
+
}
diff --git a/lib/designsettings.php b/lib/designsettings.php
index 9650679ac..476621c07 100644
--- a/lib/designsettings.php
+++ b/lib/designsettings.php
@@ -212,18 +212,19 @@ class DesignSettingsAction extends AccountSettingsAction
'maxlength' => '7',
'size' => '7',
'value' => '#' . $lcolor->hexValue()));
+ $this->elementEnd('li');
- $this->elementEnd('li');
+ } catch (WebColorException $e) {
+ common_log(LOG_ERR, 'Bad color values in design ID: ' .$design->id);
+ }
- } catch (WebColorException $e) {
- common_log(LOG_ERR, 'Bad color values in design ID: ' .
- $design->id);
- }
+ $this->elementEnd('ul');
+ $this->elementEnd('fieldset');
- $this->elementEnd('ul');
- $this->elementEnd('fieldset');
+ $this->submit('defaults', _('Use defaults'), 'submit form_action-default',
+ 'defaults', _('Restore default designs'));
- $this->element('input', array('id' => 'settings_design_reset',
+ $this->element('input', array('id' => 'settings_design_reset',
'type' => 'reset',
'value' => 'Reset',
'class' => 'submit form_action-primary',
@@ -271,8 +272,8 @@ class DesignSettingsAction extends AccountSettingsAction
if ($this->arg('save')) {
$this->saveDesign();
- } else if ($this->arg('reset')) {
- $this->resetDesign();
+ } else if ($this->arg('defaults')) {
+ $this->restoreDefaults();
} else {
$this->showForm(_('Unexpected form submission.'));
}
@@ -316,7 +317,7 @@ class DesignSettingsAction extends AccountSettingsAction
}
/**
- * Get a default user design
+ * Get a default design
*
* @return Design design
*/
@@ -358,6 +359,12 @@ class DesignSettingsAction extends AccountSettingsAction
return $design;
}
+ /**
+ * Save the background image, if any, and set its disposition
+ *
+ * @return nothing
+ */
+
function saveBackgroundImage($design) {
// Now that we have a Design ID we can add a file to the design.
@@ -403,4 +410,35 @@ class DesignSettingsAction extends AccountSettingsAction
}
}
+ /**
+ * Restore the user or group design to system defaults
+ *
+ * @return nothing
+ */
+
+ function restoreDefaults()
+ {
+ $design = $this->getWorkingDesign();
+ $default = $this->defaultDesign();
+ $original = clone($design);
+
+ $design->backgroundcolor = $default->backgroundcolor;
+ $design->contentcolor = $default->contentcolor;
+ $design->sidebarcolor = $default->sidebarcolor;
+ $design->textcolor = $default->textcolor;
+ $design->linkcolor = $default->linkcolor;
+
+ $design->setDisposition(false, true, false);
+
+ $result = $design->update($original);
+
+ if ($result === false) {
+ common_log_db_error($design, 'UPDATE', __FILE__);
+ $this->showForm(_('Couldn\'t update your design.'));
+ return;
+ }
+
+ $this->showForm(_('Design defaults restored.'), true);
+ }
+
}
diff --git a/theme/base/css/display.css b/theme/base/css/display.css
index dd89f3543..d68523020 100644
--- a/theme/base/css/display.css
+++ b/theme/base/css/display.css
@@ -206,6 +206,10 @@ border-radius:4px;
padding:0 7px;
}
+.form_settings input.form_action-default {
+margin-right:11px;
+}
+.form_settings input.form_action-default,
.form_settings input.form_action-primary {
padding:0;
}