/** * Render all items */ public function render_items() { // render scheme stuff $this->render_scheme(ICE_Scheme::instance()->directives()); // render component stuff $this->render_components(ICE_Policy::all()); }
/** */ public function finalize() { // run parent first if (true === parent::finalize()) { // hook in to body class filter add_filter('body_class', array($this, 'add_body_class')); } }
/** * Get policy instance * * @param string $class Return policy instance which is instance of this class * @return ICE_Policy */ public static function instance($class = null) { // init instances map if (!self::$instances instanceof ICE_Map) { self::$instances = new ICE_Map(); } // is this a lookup? if ($class) { foreach (self::$instances as $instance) { if ($instance instanceof $class) { return $instance; } } } else { // create new instance? if (!self::$instances->contains(self::$calling_class)) { self::$instances->add(self::$calling_class, new self::$calling_class()); } // return it return self::$instances->item_at(self::$calling_class); } }
/** * Register all scripts */ public final function register_scripts() { // check if at least one theme defined this dep if ($this->scheme->directives()->has(ICE_Scheme::DIRECTIVE_SCRIPT_DEPS)) { // get dep directives for all themes $script_depends = $this->scheme->directives()->get_map(ICE_Scheme::DIRECTIVE_SCRIPT_DEPS); // create new map so we can write to it $script_depends_w = new ICE_Map($script_depends); // start with empty stacks $dep_stack = new ICE_Stack(); $dep_admin_stack = new ICE_Stack(); // add dynamic script depends for every policy foreach (ICE_Policy::all() as $policy) { // loop through all registered components foreach ($policy->registry()->get_all() as $component) { // push deps onto stacks $component->script()->push_deps($dep_stack); $component->script()->section('admin')->push_deps($dep_admin_stack); } } // add addtl dependancies $dep_map = new ICE_Map(); $dep_map->add('@:dynamic', $dep_stack->to_array()); $dep_map->add('@:dynamic-admin', $dep_admin_stack->to_array()); $directive_deps = new ICE_Init_Directive('@', 'script_depends', $dep_map); $script_depends_w->add('@', $directive_deps, true); // init script depends $this->depends($this->scripts, $script_depends_w); } // init script action triggers $this->triggers($this->scripts, ICE_Scheme::DIRECTIVE_SCRIPT_ACTS, self::TRIGGER_ACTS); // init script condition triggers $this->triggers($this->scripts, ICE_Scheme::DIRECTIVE_SCRIPT_CONDS, self::TRIGGER_CONDS, 'ice_enqueue_scripts'); foreach ($this->scripts as $handle => $config_map) { $this->register_script($handle, $config_map); } }
/** * Enable components for the scheme by passing a valid policy object * * @param ICE_Policy $policy * @param string $ini_file_name * @return boolean */ public function enable_component(ICE_Policy $policy) { // loop through entire theme stack BOTTOM UP and try to load options foreach ($this->theme_stack(false) as $theme) { // path to ini file $ini_file = $this->theme_config_file($theme, $policy->get_handle()); // load the option config if it exists if (ICE_Files::cache($ini_file)->is_readable()) { // skip loaded files if ($this->config_files_loaded->contains($ini_file)) { continue; } // try to load ini file if ($policy->registry()->load_config_file($ini_file, $theme)) { // push onto loaded stack $this->config_files_loaded->push($ini_file); } } } // finalize policy $policy->finalize(); return true; }
/** * Set the section * * @param string $section */ protected function set_section($section) { // lookup the section registry $section_registry = ICE_Policy::instance('ICE_Section_Policy')->registry(); // get section from section registry $section = $section_registry->get($section); // adding options to parent sections is not allowed foreach ($section_registry->get_all() as $section_i) { if ($section->is_parent_of($section_i)) { throw new Exception(sprintf('Cannot add options to section "%s" because it is acting as a parent section', $section->property('name'))); } } $this->section = $section->property('name'); }