/** * Plugin to get a variable from the theme * * This function returns the corresponding value set on the theme * * Available parameters: * - name: Name of the variable * - default: If set, the default value to return if the variable is not set * - assign: If set, the results are assigned to the corresponding variable instead of printed out * * Example * {themegetvar name='themepath'} * {themegetvar name='scriptpath' assign='scriptpath'} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string The colour definition. */ function smarty_function_themegetvar($params, Zikula_View $view) { $assign = isset($params['assign']) ? $params['assign'] : null; $default = isset($params['default']) ? $params['default'] : null; $name = isset($params['name']) ? $params['name'] : null; if (!$name) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('themegetvar', 'name'))); return false; } $result = ThemeUtil::getVar($name, $default); if ($assign) { $view->assign($assign, $result); } else { return $result; } }
private function addBootstrapCss($basePath) { $overrideBootstrapPath = ''; if (!\System::isInstalling()) { $overrideBootstrapPath = \ThemeUtil::getVar('bootstrapPath', ''); // allows for theme override of bootstrap css path } if (empty($overrideBootstrapPath)) { $bootstrapFontAwesomePath = $this->params['zikula.stylesheet.bootstrap-font-awesome.path']; $this->cssAssetBag->add(["{$basePath}/{$bootstrapFontAwesomePath}" => 0]); } if (!empty($overrideBootstrapPath)) { $fontAwesomePath = $this->params['zikula.stylesheet.fontawesome.min.path']; $this->cssAssetBag->add(["{$basePath}/{$overrideBootstrapPath}" => 0, "{$basePath}/{$fontAwesomePath}" => 1]); } }
/** * Procedure for managinig stylesheets. * * @param array $stylesheets List of demanded stylesheets. * @param array $themeinfo array of info on current theme * @param boolean $isAdminController * * @return array List of stylesheets */ public static function prepareStylesheets($stylesheets, $themeinfo = array(), $isAdminController = false) { if (ThemeUtil::getVar('noCoreCss', false)) { $initStyle = null; } else { $initStyle = array('style/core.css'); } // Add generic stylesheet as the first stylesheet. $event = new \Zikula\Core\Event\GenericEvent('stylesheet', array(), $initStyle); $coreStyle = EventUtil::getManager()->dispatch('pageutil.addvar_filter', $event)->getData(); if (!is_array($stylesheets)) { $stylesheets = array(); } // Add legacy stylesheet if (System::isLegacyMode('1.4.0')) { array_unshift($stylesheets, 'style/legacy.css'); } // Add core stylesheet array_unshift($stylesheets, $coreStyle[0]); // is theme a 1.4.0 type bundle? $theme = null; if (!empty($themeinfo)) { $theme = ThemeUtil::getTheme($themeinfo['name']); } // Add bootstrap stylesheet only for 1.4.x type themes or if an admin controller is in use if (isset($theme) || $isAdminController) { $overrideBootstrapPath = ThemeUtil::getVar('bootstrapPath', ''); // allows for theme override of bootstrap css path if (empty($overrideBootstrapPath)) { $bootstrapFontAwesomePath = ServiceUtil::getManager()->getParameter('zikula.stylesheet.bootstrap-font-awesome.path'); array_unshift($stylesheets, $bootstrapFontAwesomePath); } // Add font-awesome if (!empty($overrideBootstrapPath)) { $fontAwesomePath = ServiceUtil::getManager()->getParameter('zikula.stylesheet.fontawesome.min.path'); array_unshift($stylesheets, $fontAwesomePath); } $stylesheets = array_unique(array_values($stylesheets)); } $iehack = '<!--[if IE]><link rel="stylesheet" type="text/css" href="style/core_iehacks.css" media="print,projection,screen" /><![endif]-->'; PageUtil::addVar('header', $iehack); return $stylesheets; }
/** * Remoes all problematic template vars assigned by Zikula_View. * * @param array $vars Variables. * * @return array */ protected function removeZikulaViewVars($vars) { unset($vars['zikula_view']); // results in endless loop $themeVars = array_keys(\ThemeUtil::getVar()); foreach ($themeVars as $var) { unset($vars[$var]); } return $vars; }
/** * return a theme variable * * @return mixed theme variable value */ function pnThemeGetVar($name = null, $default = null) { LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array('pnThemeGetVar()', 'ThemeUtil::getVar()')), E_USER_DEPRECATED); return ThemeUtil::getVar($name, $default); }
/** * Procedure for managinig stylesheets. * * @param array $stylesheets List of demanded stylesheets. * * @return array List of stylesheets */ public static function prepareStylesheets($stylesheets) { if (ThemeUtil::getVar('noCoreCss', false)) { $initStyle = null; } else { $initStyle = array('style/core.css'); } // Add generic stylesheet as the first stylesheet. $event = new Zikula_Event('pageutil.addvar_filter', 'stylesheet', array(), $initStyle); $coreStyle = EventUtil::getManager()->notify($event)->getData(); if (is_array($stylesheets)) { array_unshift($stylesheets, $coreStyle[0]); } else { $stylesheets = array($coreStyle[0]); } $stylesheets = array_unique(array_values($stylesheets)); $iehack = '<!--[if IE]><link rel="stylesheet" type="text/css" href="style/core_iehacks.css" media="print,projection,screen" /><![endif]-->'; PageUtil::addVar('header', $iehack); return $stylesheets; }