/** * Return all classes an an array * * @param string $suffixes,... * @return array */ protected function get_classes($suffixes = array()) { if ($this->classes->locked() == false) { throw new Exception('Getting classes before locking is not allowed'); } // any suffixes? if (count($suffixes)) { // loop all classes foreach ($this->classes as $key => $class) { // reached suffix offset? if ($key >= $this->class_suffix_offset) { // yep, suffix on this one $classes[] = $class . $this->suffix($suffixes); } else { // nope, no suffix $classes[] = $class; } } // return suffixed classes return $classes; } else { // return classes as is return $this->classes->to_array(); } }
/** * Render a unique item element id based on depth * * @param string $string */ protected function render_item_id($string = null) { if (null !== $string) { $this->__id_stack__->push($string); print $this->element()->id($this->__id_stack__->to_array()); } else { $this->__id_stack__->pop(); } }
/** * 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; }
/** * Remove filename from the cache * * @param string $filename * @return ICE_File|null The removed fstat object, null if no such filename exists. */ public function remove($filename) { return parent::remove($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; }
/** * Returns all of this asset's sections as an array * * @return array */ public final function get_sections() { return $this->sections->to_array(); }
/** * 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; }
/** */ public function get_unit() { $map = new ICE_Map(); foreach ($this->properties as $property) { $style_value = $property->get_value(); if ($style_value instanceof ICE_Style_Unitable) { $map->add($property->name, $style_value->unit()); } } return $map; }
/** * Remove a data key from the registry (for all themes) * * @param string $name * @return mixed */ public function remove($name) { // wipe cache for this item unset($this->__lookup_cache__[$name]); // call parent to remove return parent::remove($name); }
/** * Export all variables * * @param boolen $object Set to true to return as an object */ public function export_variables($object = false) { // skip if no variables if (!$this->variables->count()) { return null; } // formatted variable statements $vars = array(); // add each variable foreach ($this->variables->to_array() as $name => $value) { // format the var switch (true) { case is_numeric($value): $vars[$name] = $value; break; case is_bool($value): $vars[$name] = $value ? 'true' : 'false'; break; case is_null($value): $vars[$name] = 'null'; break; case is_string($value): $vars[$name] = sprintf("'%s'", $value); break; case is_array($value): $vars[$name] = sprintf("['%s']", implode("','", $value)); break; } } // assignment operator $operator = $object ? ':' : '='; // formatted var expressions $vars_f = array(); // loop all vars and format them foreach ($vars as $var_name => $var_val) { // object properties must be quoted if ($object) { $var_name = sprintf("'%s'", $var_name); } // push onto array array_push($vars_f, $var_name . $operator . $var_val); } // return complete expression if ($object) { return sprintf('{%s}', implode(',', $vars_f)); } else { return sprintf('var %s;', implode(',', $vars_f)); } }
/** * 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); } }