summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-07-30 16:24:04 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-07-30 16:24:04 -0400
commitae81d361374641ce5cd73b353fae613711e145fe (patch)
treecb168e36ac830ee2e4dbe53b82633644e53adf05 /lib
parente9ac70bfa76bf17e60936cf59c4e0ef13efbda82 (diff)
Site-wide design configuration
I added some code so that the site-wide design can be set, using the configuration interface. I also moved the configuration option from $config['site']['design']['background'] to just $config['design']['background'], but the old syntax will still work.
Diffstat (limited to 'lib')
-rw-r--r--lib/action.php28
-rw-r--r--lib/common.php20
-rw-r--r--lib/currentuserdesignaction.php37
-rw-r--r--lib/groupdesignaction.php30
-rw-r--r--lib/ownerdesignaction.php31
5 files changed, 63 insertions, 83 deletions
diff --git a/lib/action.php b/lib/action.php
index 95ee10c64..a5244371a 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -191,6 +191,7 @@ class Action extends HTMLOutputter // lawsuit
function showStylesheets()
{
if (Event::handle('StartShowStyles', array($this))) {
+
if (Event::handle('StartShowLaconicaStyles', array($this))) {
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
@@ -209,6 +210,7 @@ class Action extends HTMLOutputter // lawsuit
'media' => 'print'));
Event::handle('EndShowLaconicaStyles', array($this));
}
+
if (Event::handle('StartShowUAStyles', array($this))) {
$this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
'href="'.theme_path('css/ie.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
@@ -223,6 +225,21 @@ class Action extends HTMLOutputter // lawsuit
'href="'.theme_path('css/ie.css', null).'?version='.LACONICA_VERSION.'" /><![endif]');
Event::handle('EndShowUAStyles', array($this));
}
+
+ if (Event::handle('StartShowDesign', array($this))) {
+
+ $user = common_current_user();
+
+ if (empty($user) || $user->viewdesigns) {
+ $design = $this->getDesign();
+
+ if (!empty($design)) {
+ $design->showCSS($this);
+ }
+ }
+
+ Event::handle('EndShowDesign', array($this));
+ }
Event::handle('EndShowStyles', array($this));
}
}
@@ -1074,4 +1091,15 @@ class Action extends HTMLOutputter // lawsuit
{
return null;
}
+
+ /**
+ * A design for this action
+ *
+ * @return Design a design object to use
+ */
+
+ function getDesign()
+ {
+ return Design::siteDesign();
+ }
}
diff --git a/lib/common.php b/lib/common.php
index 9d7954fa9..b3d301862 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -94,14 +94,6 @@ $config =
array('name' => 'Just another Laconica microblog',
'server' => $_server,
'theme' => 'default',
- 'design' =>
- array('backgroundcolor' => '#CEE1E9',
- 'contentcolor' => '#FFFFFF',
- 'sidebarcolor' => '#C8D1D5',
- 'textcolor' => '#000000',
- 'linkcolor' => '#002E6E',
- 'backgroundimage' => null,
- 'disposition' => 1),
'path' => $_path,
'logfile' => null,
'logo' => null,
@@ -261,6 +253,14 @@ $config =
'sessions' =>
array('handle' => false, // whether to handle sessions ourselves
'debug' => false), // debugging output for sessions
+ 'design' =>
+ array('backgroundcolor' => null, // null -> 'use theme default'
+ 'contentcolor' => null,
+ 'sidebarcolor' => null,
+ 'textcolor' => null,
+ 'linkcolor' => null,
+ 'backgroundimage' => null,
+ 'disposition' => null),
);
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
@@ -277,6 +277,10 @@ $config['db'] =
'quote_identifiers' => false,
'type' => 'mysql' );
+// Backward compatibility
+
+$config['site']['design'] =& $config['design'];
+
if (function_exists('date_default_timezone_set')) {
/* Work internally in UTC */
date_default_timezone_set('UTC');
diff --git a/lib/currentuserdesignaction.php b/lib/currentuserdesignaction.php
index 4c7e15a8b..52516b624 100644
--- a/lib/currentuserdesignaction.php
+++ b/lib/currentuserdesignaction.php
@@ -47,33 +47,10 @@ if (!defined('LACONICA')) {
class CurrentUserDesignAction extends Action
{
-
- /**
- * Show the user's design stylesheet
- *
- * @return nothing
- */
-
- function showStylesheets()
- {
- parent::showStylesheets();
-
- $user = common_current_user();
-
- if (empty($user) || $user->viewdesigns) {
- $design = $this->getDesign();
-
- if (!empty($design)) {
- $design->showCSS($this);
- }
- }
- }
-
/**
* A design for this action
*
- * if the user attribute has been set, returns that user's
- * design.
+ * Returns the design preferences for the current user.
*
* @return Design a design object to use
*/
@@ -82,11 +59,15 @@ class CurrentUserDesignAction extends Action
{
$cur = common_current_user();
- if (empty($cur)) {
- return null;
+ if (!empty($cur)) {
+
+ $design = $cur->getDesign();
+
+ if (!empty($design)) {
+ return $design;
+ }
}
- return $cur->getDesign();
+ return parent::getDesign();
}
-
}
diff --git a/lib/groupdesignaction.php b/lib/groupdesignaction.php
index 58777c283..c7cdff1fe 100644
--- a/lib/groupdesignaction.php
+++ b/lib/groupdesignaction.php
@@ -50,26 +50,6 @@ class GroupDesignAction extends Action {
var $group = null;
/**
- * Show the groups's design stylesheet
- *
- * @return nothing
- */
- function showStylesheets()
- {
- parent::showStylesheets();
-
- $user = common_current_user();
-
- if (empty($user) || $user->viewdesigns) {
- $design = $this->getDesign();
-
- if (!empty($design)) {
- $design->showCSS($this);
- }
- }
- }
-
- /**
* A design for this action
*
* if the group attribute has been set, returns that group's
@@ -80,10 +60,12 @@ class GroupDesignAction extends Action {
function getDesign()
{
- if (empty($this->group)) {
- return null;
+ if (!empty($this->group)) {
+ $design = $this->group->getDesign();
+ if (!empty($design)) {
+ return $design;
+ }
}
-
- return $this->group->getDesign();
+ return parent::getDesign();
}
}
diff --git a/lib/ownerdesignaction.php b/lib/ownerdesignaction.php
index 785b8a93d..b42df926d 100644
--- a/lib/ownerdesignaction.php
+++ b/lib/ownerdesignaction.php
@@ -53,26 +53,6 @@ class OwnerDesignAction extends Action {
var $user = null;
/**
- * Show the owner's design stylesheet
- *
- * @return nothing
- */
- function showStylesheets()
- {
- parent::showStylesheets();
-
- $user = common_current_user();
-
- if (empty($user) || $user->viewdesigns) {
- $design = $this->getDesign();
-
- if (!empty($design)) {
- $design->showCSS($this);
- }
- }
- }
-
- /**
* A design for this action
*
* if the user attribute has been set, returns that user's
@@ -83,10 +63,15 @@ class OwnerDesignAction extends Action {
function getDesign()
{
- if (empty($this->user)) {
- return null;
+ if (!empty($this->user)) {
+
+ $design = $this->user->getDesign();
+
+ if (!empty($design)) {
+ return $design;
+ }
}
- return $this->user->getDesign();
+ return parent::getDesign();
}
}