Beispiel #1
0
 /**
  * Add a class to the class list
  *
  * @param string $class
  * @return ICE_Element
  */
 public function add_class($class)
 {
     if (is_array($class)) {
         $class = implode('-', $class);
     }
     $this->classes->add(null, $class);
     return $this;
 }
Beispiel #2
0
 /**
  * Register a component
  *
  * @param ICE_Component $component
  * @return boolean
  */
 protected final function register(ICE_Component $component)
 {
     // has the component already been registered?
     if (!$this->components->contains($component->name)) {
         // register it
         $this->components->add($component->name, $component);
     }
     return true;
 }
Beispiel #3
0
 /**
  * Add a section to the asset
  * 
  * @param string $name
  * @return ICE_Asset 
  */
 public final function add_section($name)
 {
     // get class of this object
     $class = get_class($this);
     // new "sub asset"
     $asset = new $class($this->component);
     // add new "sub asset" of same class
     $this->sections->add($name, $asset);
     return $this;
 }
 /**
  * Add a filename to the cache
  *
  * @param string $filename
  * @param boolean $force If true, overwrite existing data
  * @return ICE_File The fstat instance for the filename
  */
 public function add($filename, $force = false)
 {
     // get the hash
     $hash = $this->hash($filename);
     // hash exists?
     if ($force || !parent::contains($hash)) {
         // add it
         parent::add($hash, new ICE_File($filename));
     }
     return parent::item_at($hash);
 }
Beispiel #5
0
 /**
  * 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;
 }
Beispiel #6
0
 /**
  * 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);
     }
 }
Beispiel #8
0
 /**
  * This is a singleton
  */
 private function __construct()
 {
     // initialize themes map
     $this->themes = new ICE_Stack();
     $this->themes_compiled = new ICE_Map();
     $this->directives = new ICE_Init_Directive_Registry();
     $this->config_files_loaded = new ICE_Stack();
     // handle compiled themes
     if (defined('ICE_THEMES_COMPILED') && ICE_THEMES_COMPILED !== null) {
         // split at comma
         foreach (explode(',', ICE_THEMES_COMPILED) as $theme) {
             // push on to compiled themes map
             $this->themes_compiled->add($theme, $theme);
         }
     }
     // set up exports
     $this->exports = new ICE_Export_Manager();
     $this->exports->add('styles', new ICE_Component_Style_Export('dynamic', 'css'));
     $this->exports->add('scripts', new ICE_Component_Script_Export('dynamic', 'js'));
 }
Beispiel #9
0
 /**
  * Load an extension file
  *
  * @param string $ext
  * @return string Name of class that was loaded
  */
 public final function load_ext($ext)
 {
     // get class parts
     $class_parts = array_filter(explode(self::PATH_DELIM, $ext));
     // files must have at least two parts
     if (count($class_parts) < 2) {
         throw new Exception('The extension path is empty or incomplete.');
     }
     // determine class name
     $class_name = $class_parts;
     $class_name[0] = rtrim($class_name[0], 's');
     $class_name = ICE_Files::file_to_class($class_name, ICE_EXT_PREFIX);
     // if class already exists, just return it
     if (class_exists($class_name)) {
         // already loaded, woot
         return $class_name;
     }
     // try to locate file
     $path = $this->locate_file($ext, 'class.php');
     // did we find a file?
     if ($path) {
         // load it
         require_once $path;
     } else {
         // not good
         throw new Exception(sprintf('The extension "%s" was not found.', $ext));
     }
     // did the file we just loaded define the class we were expecting?
     if (class_exists($class_name)) {
         // update loaded map
         $this->loaded->add($class_name, $class_parts);
         // return class name
         return $class_name;
     } else {
         throw new Exception(sprintf('The class "%s" does not exist', $class_name));
     }
 }
Beispiel #10
0
 /**
  */
 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;
 }
Beispiel #11
0
 /**
  * Add a variable
  *
  * @param string $name
  * @param mixed $value
  * @param boolean $nulls
  */
 public function add_variable($name, $value, $nulls = false)
 {
     if (!is_null($value) || $nulls) {
         $this->variables->add($name, $value);
     }
 }
Beispiel #12
0
 /**
  * Add an export instance to be managed
  *
  * @param string $handle
  * @param ICE_Export $export
  * @return ICE_Export
  */
 public function add($handle, ICE_Export $export)
 {
     if ($this->exports->contains($handle)) {
         throw new Exception(sprintf('The "%s" handle has already been registered'), $handle);
     } else {
         $this->exports->add($handle, $export);
     }
     return $this->exports->item_at($handle);
 }
Beispiel #13
0
    /**
     * Render values of one directive for each scheme in stack
     *
     * @param ICE_Map $directive_map
     */
    protected function render_directive(ICE_Map $directive_map)
    {
        // get the theme stack from the scheme
        $stack = ICE_Scheme::instance()->theme_stack();
        $map_last = null;
        // open list
        ?>
		<ul><?php 
        foreach ($stack as $theme) {
            if ($directive_map->contains($theme)) {
                $directive = $directive_map->item_at($theme);
                $map_child = new ICE_Map();
                $map_child->add($directive->get_name(), $directive->get_value());
                // render item
                ?>
				<li id="<?php 
                $this->render_item_id($theme);
                ?>
" class="jstree-open">
					<a><?php 
                print $theme;
                ?>
</a>
					<?php 
                $this->render_value_map($map_child, $map_last);
                ?>
				</li><?php 
                $map_last = $map_child;
                $this->render_item_id();
            } else {
                $map_last = null;
            }
        }
        ?>
		</ul><?php 
    }