/** * Add google service * * @return ICE_Webfont */ public function add_google() { // has service been initialized? if (!$this->services->contains('google')) { // create new instance $google = new ICE_Webfont_Service_Google(); // add to services registry $this->services->add('google', $google); } // return self return $this; }
/** * 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); } }
/** * Load one component given its name and config array * * @param string $name * @param array $config_array * @return boolean */ protected final function load_config_map($name, $config_array) { // normalize name $name = $this->normalize_name($name); // push theme onto config $config_array['theme'] = self::theme_scope(); // check if already registered if ($this->components->contains($name)) { // use that one $component = $this->components->item_at($name); } else { // use factory to create new component $component = $this->policy()->factory()->create($name, $config_array); // register component $this->register($component); } // push configuration $component->config_array($config_array); // post registration if ($component->supported()) { $component->init_registered(); } return true; }
/** * Return true if filename exists in cache * * @param string $filename * @return boolean */ public function contains($filename) { return parent::contains($this->hash($filename)); }
/** * Add dep to an existing style * * This only applies to styles handled by this special enqueuer * * @param string $handle * @param string $dep */ public function style_dep($handle, $dep) { if ($this->styles->contains($dep)) { $this->styles->item_at($handle)->item_at(self::TRIGGER_DEPS)->push($dep); } }
/** * Locate a theme file, giving priority to top themes in the stack * * If first argument is a ICE_Map instance, it is expected to be * a map of theme directives whose values are relative path prefixes. * * @param ICE_Map $prefix_map Optional map of directives which define path prefixes * @param string $file_names,... The file names that make up the RELATIVE path to the theme root * @return string|false */ public function locate_file() { // get all args $file_names = func_get_args(); // no prefix map by default $prefix_map = null; // prefixes map? if (!empty($file_names)) { if ($file_names[0] instanceof ICE_Map) { $prefix_map = array_shift($file_names); } } // still have something? if (empty($file_names)) { return false; } // loop through theme stack foreach ($this->theme_stack() as $theme) { // is theme in current loop compiled? if (true === $this->themes_compiled->contains($theme)) { // yep, skip it continue; } // build path to stackfile $stack_file = $this->theme_dir($theme); // inject prefix? if ($prefix_map && $prefix_map->contains($theme)) { $stack_file .= '/' . $prefix_map->item_at($theme)->get_value(); } // append requested path $stack_file .= '/' . implode('/', $file_names); // does stack file exist? if (ICE_Files::cache($stack_file)->is_readable()) { return $stack_file; } } return false; }
/** * Return information of about loaded extensions * * @param string $class_name the extension's class name * @param boolean $return_array set to true to return an array of the extension name parts * @return boolean|array */ public final function loaded($class_name, $return_array = false) { // is class in loaded map? if ($this->loaded->contains($class_name)) { // yep return array or true return $return_array ? $this->loaded->item_at($class_name) : true; } // class not loaded return false; }
/** * Add URI as a possible value type */ public function add_uri() { if (!$this->valmap->contains(self::KEY_URI)) { $this->valmap->add(self::KEY_URI, new ICE_Style_Value_Uri()); } return $this; }
/** * Get an export instance for handle * * @param string $handle * @return ICE_Export */ public function get($handle) { if ($this->exports->contains($handle)) { return $this->exports->item_at($handle); } else { throw new Exception(sprintf('The "%s" handle is not registered'), $handle); } }
/** * Recursively render a map of values * * @param ICE_Map $map * @param ICE_Map $map_last */ protected function render_value_map(ICE_Map $map, ICE_Map $map_last = null) { // open list ?> <ul><?php foreach ($map as $key => $value) { // inline styles $style_attr = null; // strike through the text? if ($map_last instanceof ICE_Map) { if ($map_last->contains($key)) { // get the value $map_value = $map_last->item_at($key); // strike or not? if ($map_value instanceof ICE_Map) { // map to compare on next loop $map_next = $map_value; } elseif ($map_value !== $value) { // strike it! $style_attr = ' style="text-decoration: line-through;"'; } } } // render item ?> <li id="<?php $this->render_item_id($key); ?> " class="jstree-open"<?php print $style_attr; ?> > <?php if ($value instanceof ICE_Map) { ?> <a>[<?php print $key; ?> ]</a> <?php $this->render_value_map($value, $map_next); ?> <?php } else { ?> <span> <em><?php print $key; ?> </em> = <?php if (is_scalar($value) && null !== $value) { ?> <?php $this->render_value($value); ?> <?php } else { ?> <?php _e('null', infinity_text_domain); ?> <?php } ?> </span> <?php } ?> </li><?php $this->render_item_id(); } // close list ?> </ul><?php }