Skip to content
Snippets Groups Projects
Commit 5dcc3b28 authored by Demian Katz's avatar Demian Katz
Browse files

Changed theme configuration to use PHP files instead of .ini files in order to...

Changed theme configuration to use PHP files instead of .ini files in order to allow more flexible helper configuration.
parent 7c6fc238
Branches
Tags
No related merge requests found
...@@ -272,26 +272,18 @@ class Initializer ...@@ -272,26 +272,18 @@ class Initializer
/** /**
* Support method for setUpThemes -- register view helpers. * Support method for setUpThemes -- register view helpers.
* *
* @param string $theme Name of theme * @param array $helpers Helper settings
* @param string $namespace Namespace for view helpers
* @param array $helpers Helpers to register
* *
* @return void * @return void
*/ */
protected function setUpThemeViewHelpers($theme, $namespace, $helpers) protected function setUpThemeViewHelpers($helpers)
{ {
// Ignore null helper array:
if (is_null($helpers)) {
return;
}
// Grab the helper loader from the view manager: // Grab the helper loader from the view manager:
$loader = $this->serviceManager->get('viewmanager')->getHelperManager(); $loader = $this->serviceManager->get('viewmanager')->getHelperManager();
// Register all the helpers: // Register all the helpers:
foreach ($helpers as $helper) { $config = new \Zend\ServiceManager\Config($helpers);
$loader->setInvokableClass(strtolower($helper), "$namespace\\$helper"); $config->configureServiceManager($loader);
}
} }
/** /**
...@@ -310,31 +302,29 @@ class Initializer ...@@ -310,31 +302,29 @@ class Initializer
// Apply the loaded theme settings in reverse for proper inheritance: // Apply the loaded theme settings in reverse for proper inheritance:
foreach ($themes as $key=>$currentThemeInfo) { foreach ($themes as $key=>$currentThemeInfo) {
if ($helperNS = $currentThemeInfo->get('helper_namespace')) { if (isset($currentThemeInfo['helpers'])) {
$this->setUpThemeViewHelpers( $this->setUpThemeViewHelpers($currentThemeInfo['helpers']);
$key, $helperNS, $currentThemeInfo->get('helpers_to_register')
);
} }
// Add template path: // Add template path:
$templatePathStack[] = $this->baseDir . "/$key/templates"; $templatePathStack[] = $this->baseDir . "/$key/templates";
// Add CSS and JS dependencies: // Add CSS and JS dependencies:
if ($css = $currentThemeInfo->get('css')) { if (isset($currentThemeInfo['css'])) {
$resources->addCss($css); $resources->addCss($currentThemeInfo['css']);
} }
if ($js = $currentThemeInfo->get('js')) { if (isset($currentThemeInfo['js'])) {
$resources->addJs($js); $resources->addJs($currentThemeInfo['js']);
} }
// Select encoding: // Select encoding:
if ($encoding = $currentThemeInfo->get('encoding')) { if (isset($currentThemeInfo['encoding'])) {
$resources->setEncoding($encoding); $resources->setEncoding($currentThemeInfo['encoding']);
} }
// Select favicon: // Select favicon:
if ($favicon = $currentThemeInfo->get('favicon')) { if (isset($currentThemeInfo['favicon'])) {
$resources->setFavicon($favicon); $resources->setFavicon($currentThemeInfo['favicon']);
} }
} }
......
...@@ -97,7 +97,7 @@ class Tools ...@@ -97,7 +97,7 @@ class Tools
*/ */
protected function getThemeConfig($theme) protected function getThemeConfig($theme)
{ {
return $this->baseDir . "/$theme/theme.ini"; return $this->baseDir . "/$theme/theme.config.php";
} }
/** /**
...@@ -145,11 +145,9 @@ class Tools ...@@ -145,11 +145,9 @@ class Tools
$this->allThemeInfo = array(); $this->allThemeInfo = array();
$currentTheme = $this->getTheme(); $currentTheme = $this->getTheme();
do { do {
$iniReader = new \Zend\Config\Reader\Ini(); $this->allThemeInfo[$currentTheme]
$this->allThemeInfo[$currentTheme] = new \Zend\Config\Config( = include $this->getThemeConfig($currentTheme);
$iniReader->fromFile($this->getThemeConfig($currentTheme)) $currentTheme = $this->allThemeInfo[$currentTheme]['extends'];
);
$currentTheme = $this->allThemeInfo[$currentTheme]->extends;
} while ($currentTheme); } while ($currentTheme);
} }
...@@ -183,7 +181,7 @@ class Tools ...@@ -183,7 +181,7 @@ class Tools
return $returnFile ? $file : $currentTheme; return $returnFile ? $file : $currentTheme;
} }
} }
$currentTheme = $allThemeInfo[$currentTheme]->extends; $currentTheme = $allThemeInfo[$currentTheme]['extends'];
} }
return null; return null;
......
<?php
return array(
'extends' => 'root',
'css' => array(
'blueprint/screen.css:screen, projection',
'blueprint/print.css:print',
'blueprint/ie.css:screen, projection:lt IE 8',
'jquery-ui/css/smoothness/jquery-ui.css',
'styles.css:screen, projection',
'print.css:print',
'ie.css:screen, projection:lt IE 8',
),
'js' => array(
'jquery.min.js',
'jquery.form.js',
'jquery.metadata.js',
'jquery.validate.min.js',
'jquery-ui/js/jquery-ui.js',
'lightbox.js',
'common.js',
),
'favicon' => 'vufind-favicon.ico',
'helpers' => array(
'invokables' => array(
'layoutclass' => 'VuFind\Theme\Blueprint\Helper\LayoutClass',
'search' => 'VuFind\Theme\Blueprint\Helper\Search',
)
)
);
\ No newline at end of file
extends = root
css[] = "blueprint/screen.css:screen, projection"
css[] = "blueprint/print.css:print"
css[] = "blueprint/ie.css:screen, projection:lt IE 8"
css[] = "jquery-ui/css/smoothness/jquery-ui.css"
css[] = "styles.css:screen, projection"
css[] = "print.css:print"
css[] = "ie.css:screen, projection:lt IE 8"
js[] = "jquery.min.js"
js[] = "jquery.form.js"
js[] = "jquery.metadata.js"
js[] = "jquery.validate.min.js"
js[] = "jquery-ui/js/jquery-ui.js"
js[] = "lightbox.js"
js[] = "common.js"
favicon = "vufind-favicon.ico"
helper_namespace = "VuFind\Theme\Blueprint\Helper"
helpers_to_register[] = "LayoutClass"
helpers_to_register[] = "Search"
\ No newline at end of file
<?php
return array(
'extends' => 'root',
'css' => array(
'jquery.mobile-1.0rc2.min.css',
'styles.css',
'formats.css',
),
'js' => array(
'jquery-1.6.4.min.js',
'common.js',
'jquery.mobile-1.0rc2.min.js',
'jquery.cookie.js',
'cart_cookie.js',
'cart.js',
'scripts.js',
),
'favicon' => 'vufind-favicon.ico',
'helpers' => array(
'invokables' => array(
'mobilemenu' => 'VuFind\Theme\jQueryMobile\Helper\MobileMenu'
)
),
);
\ No newline at end of file
extends = root
css[] = "jquery.mobile-1.0rc2.min.css"
css[] = "styles.css"
css[] = "formats.css"
js[] = "jquery-1.6.4.min.js"
js[] = "common.js"
js[] = "jquery.mobile-1.0rc2.min.js"
js[] = "jquery.cookie.js"
js[] = "cart_cookie.js"
js[] = "cart.js"
js[] = "scripts.js"
favicon = "vufind-favicon.ico"
helper_namespace = "VuFind\Theme\jQueryMobile\Helper"
helpers_to_register[] = "MobileMenu"
\ No newline at end of file
<?php
return array(
'extends' => false,
'helpers' => array(
'invokables' => array(
'addellipsis' => 'VuFind\Theme\Root\Helper\AddEllipsis',
'addthis' => 'VuFind\Theme\Root\Helper\AddThis',
'auth' => 'VuFind\Theme\Root\Helper\Auth',
'authornotes' => 'VuFind\Theme\Root\Helper\AuthorNotes',
'browse' => 'VuFind\Theme\Root\Helper\Browse',
'cart' => 'VuFind\Theme\Root\Helper\Cart',
'citation' => 'VuFind\Theme\Root\Helper\Citation',
'context' => 'VuFind\Theme\Root\Helper\Context',
'currentpath' => 'VuFind\Theme\Root\Helper\CurrentPath',
'datetime' => 'VuFind\Theme\Root\Helper\DateTime',
'displaylanguageoption' => 'VuFind\Theme\Root\Helper\DisplayLanguageOption',
'excerpt' => 'VuFind\Theme\Root\Helper\Excerpt',
'flashmessages' => 'VuFind\Theme\Root\Helper\Flashmessages',
'getlastsearchlink' => 'VuFind\Theme\Root\Helper\GetLastSearchLink',
'headlink' => 'VuFind\Theme\Root\Helper\HeadLink',
'headscript' => 'VuFind\Theme\Root\Helper\HeadScript',
'headthemeresources' => 'VuFind\Theme\Root\Helper\HeadThemeResources',
'highlight' => 'VuFind\Theme\Root\Helper\Highlight',
'ils' => 'VuFind\Theme\Root\Helper\Ils',
'imagelink' => 'VuFind\Theme\Root\Helper\ImageLink',
'inlinescript' => 'VuFind\Theme\Root\Helper\InlineScript',
'jqueryvalidation' => 'VuFind\Theme\Root\Helper\JqueryValidation',
'mobileurl' => 'VuFind\Theme\Root\Helper\MobileUrl',
'openurl' => 'VuFind\Theme\Root\Helper\OpenUrl',
'printms' => 'VuFind\Theme\Root\Helper\Printms',
'proxyurl' => 'VuFind\Theme\Root\Helper\ProxyUrl',
'recommend' => 'VuFind\Theme\Root\Helper\Recommend',
'record' => 'VuFind\Theme\Root\Helper\Record',
'recordlink' => 'VuFind\Theme\Root\Helper\RecordLink',
'related' => 'VuFind\Theme\Root\Helper\Related',
'renderarray' => 'VuFind\Theme\Root\Helper\RenderArray',
'resultfeed' => 'VuFind\Theme\Root\Helper\ResultFeed',
'reviews' => 'VuFind\Theme\Root\Helper\Reviews',
'searchoptions' => 'VuFind\Theme\Root\Helper\SearchOptions',
'safemoneyformat' => 'VuFind\Theme\Root\Helper\SafeMoneyFormat',
'sortfacetlist' => 'VuFind\Theme\Root\Helper\SortFacetList',
'summon' => 'VuFind\Theme\Root\Helper\Summon',
'syndeticsplus' => 'VuFind\Theme\Root\Helper\SyndeticsPlus',
'systememail' => 'VuFind\Theme\Root\Helper\SystemEmail',
'transesc' => 'VuFind\Theme\Root\Helper\TransEsc',
'translate' => 'VuFind\Theme\Root\Helper\Translate',
'truncate' => 'VuFind\Theme\Root\Helper\Truncate',
'userlist' => 'VuFind\Theme\Root\Helper\UserList',
'videoclips' => 'VuFind\Theme\Root\Helper\VideoClips',
)
),
);
extends = false
helper_namespace = "VuFind\Theme\Root\Helper"
helpers_to_register[] = "AddEllipsis"
helpers_to_register[] = "AddThis"
helpers_to_register[] = "Auth"
helpers_to_register[] = "AuthorNotes"
helpers_to_register[] = "Browse"
helpers_to_register[] = "Cart"
helpers_to_register[] = "Citation"
helpers_to_register[] = "Context"
helpers_to_register[] = "CurrentPath"
helpers_to_register[] = "DateTime"
helpers_to_register[] = "DisplayLanguageOption"
helpers_to_register[] = "Excerpt"
helpers_to_register[] = "Flashmessages"
helpers_to_register[] = "GetLastSearchLink"
helpers_to_register[] = "HeadLink"
helpers_to_register[] = "HeadScript"
helpers_to_register[] = "HeadThemeResources"
helpers_to_register[] = "Highlight"
helpers_to_register[] = "Ils"
helpers_to_register[] = "ImageLink"
helpers_to_register[] = "InlineScript"
helpers_to_register[] = "JqueryValidation"
helpers_to_register[] = "MobileUrl"
helpers_to_register[] = "OpenUrl"
helpers_to_register[] = "Printms"
helpers_to_register[] = "ProxyUrl"
helpers_to_register[] = "Recommend"
helpers_to_register[] = "Record"
helpers_to_register[] = "RecordLink"
helpers_to_register[] = "Related"
helpers_to_register[] = "RenderArray"
helpers_to_register[] = "ResultFeed"
helpers_to_register[] = "Reviews"
helpers_to_register[] = "SearchOptions"
helpers_to_register[] = "SafeMoneyFormat"
helpers_to_register[] = "SortFacetList"
helpers_to_register[] = "Summon"
helpers_to_register[] = "SyndeticsPlus"
helpers_to_register[] = "SystemEmail"
helpers_to_register[] = "TransEsc"
helpers_to_register[] = "Translate"
helpers_to_register[] = "Truncate"
helpers_to_register[] = "UserList"
helpers_to_register[] = "VideoClips"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment