From 7229a8daa753ba1ec9d3a16d9fe2b0d281b2a7aa Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 4 Jan 2013 12:44:16 -0500 Subject: [PATCH] Simplified and documented configuration values passed to \VuFind\Theme\Initializer. --- module/VuFind/src/VuFind/Bootstrap.php | 2 +- .../VuFind/src/VuFind/Theme/Initializer.php | 28 +++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/module/VuFind/src/VuFind/Bootstrap.php b/module/VuFind/src/VuFind/Bootstrap.php index c57f69d3629..63b21e44c91 100644 --- a/module/VuFind/src/VuFind/Bootstrap.php +++ b/module/VuFind/src/VuFind/Bootstrap.php @@ -306,7 +306,7 @@ class Bootstrap // Attach remaining theme configuration to the dispatch event at high // priority (TODO: use priority constant once defined by framework): - $config =& $this->config; + $config = $this->config->Site; $callback = function ($event) use ($config) { $theme = new \VuFind\Theme\Initializer($config, $event); $theme->init(); diff --git a/module/VuFind/src/VuFind/Theme/Initializer.php b/module/VuFind/src/VuFind/Theme/Initializer.php index b06a737aa59..032f485508a 100644 --- a/module/VuFind/src/VuFind/Theme/Initializer.php +++ b/module/VuFind/src/VuFind/Theme/Initializer.php @@ -74,7 +74,19 @@ class Initializer /** * Constructor * - * @param Config $config Configuration object + * @param Config $config Configuration object containing these keys: + * <ul> + * <li>theme - the name of the default theme for non-mobile devices</li> + * <li>mobile_theme - the name of the default theme for mobile devices + * (omit to disable mobile support)</li> + * <li>alternate_themes - a comma-separated list of alternate themes that + * can be accessed via the ui GET parameter; each entry is a colon-separated + * parameter-value:theme-name pair.</li> + * <li>selectable_themes - a comma-separated list of themes that may be + * selected through the user interface; each entry is a colon-separated + * name:description pair, where name may be 'standard,' 'mobile,' or one of + * the parameter-values from the alternate_themes array.</li> + * </ul> * @param MvcEvent $event Zend MVC Event object */ public function __construct(Config $config, MvcEvent $event) @@ -181,9 +193,9 @@ class Initializer protected function pickTheme(Request $request) { // Load standard configuration options: - $standardTheme = $this->config->Site->theme; - $mobileTheme = isset($this->config->Site->mobile_theme) - ? $this->config->Site->mobile_theme : false; + $standardTheme = $this->config->theme; + $mobileTheme = isset($this->config->mobile_theme) + ? $this->config->mobile_theme : false; // Find out if the user has a saved preference in the POST, URL or cookies: $selectedUI = $request->getPost()->get( @@ -208,10 +220,10 @@ class Initializer // Do we have a non-standard selection? if ($selectedUI != 'standard' - && isset($this->config->Site->alternate_themes) + && isset($this->config->alternate_themes) ) { // Check the alternate theme settings for a match: - $parts = explode(',', $this->config->Site->alternate_themes); + $parts = explode(',', $this->config->alternate_themes); foreach ($parts as $part) { $subparts = explode(':', $part); if ((trim($subparts[0]) == trim($selectedUI)) @@ -251,8 +263,8 @@ class Initializer protected function getThemeOptions() { $options = array(); - if (isset($this->config->Site->selectable_themes)) { - $parts = explode(',', $this->config->Site->selectable_themes); + if (isset($this->config->selectable_themes)) { + $parts = explode(',', $this->config->selectable_themes); foreach ($parts as $part) { $subparts = explode(':', $part); $name = trim($subparts[0]); -- GitLab