public function controller_header($args) { if (empty($this->shown["header"])) { // Only allow header once per page $this->shown["header"] = true; $agents = array('mac', 'windows', 'linux', 'unix', 'android', 'ios', 'ipad', 'iphone', 'ipod', 'mobile', 'webkit', 'chrome', 'firefox', 'msie', 'opera', 'safari'); $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); $classes = ''; for ($i = 1; $i <= count($agents); $i++) { if (strpos($useragent, $agents[$i])) { $classes .= ' ' . $agents[$i]; } } $args["classes"] = $classes; $args["agent"] = $useragent; $dependencies = ConfigManager::get("dependencies.load"); if (!empty($dependencies)) { foreach ($dependencies as $dependency) { if (!empty($dependency["enabled"])) { $dependency_args = array(); foreach ($dependency["args"] as $dependency_name => $dependency_arg) { $dependency_args[$dependency_name] = $dependency_arg; } DependencyManager::add($dependency_args); } } } $args["native"] = any(ConfigManager::get("native"), array("enabled" => false)); return $this->GetTemplate("./header.tpl", $args); } return ""; }
function smarty_block_config($params, $content, &$smarty) { global $webapp; static $initialized = false; if (empty($params->skipcobrand)) { // FIXME - this should also apply to page_component's getCobrandContent() somehow... $cfgmgr = ConfigManager::singleton(); if (!$initialized) { $heirarchy = $cfgmgr->GetConfigHeirarchy("cobrand." . $webapp->cobrand); foreach (array_reverse($heirarchy) as $cfgname) { // Walk heirarchy from bottom up if (preg_match("/^cobrand\\.(.*)\$/", $cfgname, $m) || $cfgname == "base") { // FIXME - most general-purpose would be to use the cobrand key as imagedir (s/\./\//g?) $cobrandname = $cfgname == "base" ? $cfgname : $m[1]; if (!empty($cobrandname)) { DependencyManager::add(array("type" => "component", "name" => "cobrands." . $cobrandname, "priority" => 4)); //DependencyManager::add(array("type"=>"component", "name"=>"cobrands.".$cobrandname."-fixes", "priority"=>4)); } } } $initialized = true; } } return trim($content); }
function Init($args, $locations) { foreach ($args as $k => $v) { $this->{$k} = $v; } if (!empty($args["name"]) && !empty($args["component"]) && !isset(self::$templates[$args["name"]])) { self::$templates[$args["name"]] = ComponentManager::fetch($args["component"], $args["componentargs"]); DependencyManager::add(array("type" => "component", "name" => "tplmgr.tplmgr", "priority" => 2)); } }
/** * Smarty {dependency} plugin * * Type: function<br> * Name: dependency<br> * Purpose: Register a dependency to be printed in the header * * @author James Baicoianu * @param array * @param Smarty * @return string|null if the assign parameter is passed, Smarty assigns the * result to a template variable */ function smarty_function_dependency($args, &$smarty) { DependencyManager::add($args); }