theme_name = $theme_name; $this->set_global('theme', $this); $this->set_global('user', user::active()); } public function url($path) { return url::file("themes/{$this->theme_name}/$path"); } public function display($page_name, $view_class="View") { return new $view_class($page_name); } public function admin_menu() { $menu = new Menu(true); core_menu::admin($menu, $this); foreach (module::installed() as $module) { if ($module->name == "core") { continue; } $class = "{$module->name}_menu"; if (method_exists($class, "admin")) { call_user_func_array(array($class, "admin"), array(&$menu, $this)); } } print $menu; } /** * Handle all theme functions that insert module content. */ public function __call($function, $args) { switch ($function) { case "dashboard_blocks": case "sidebar_blocks": $function = "admin_$function"; $blocks = array(); foreach (module::installed() as $module) { $helper_class = "{$module->name}_block"; if (method_exists($helper_class, $function)) { $blocks[] = call_user_func_array( array($helper_class, $function), array_merge(array($this), $args)); } } return implode("\n", $blocks); default: throw new Exception("@todo UNKNOWN_THEME_FUNCTION: $function"); } } }