Beispiel #1
0
 /**
  * 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();
     }
 }
Beispiel #2
0
 /**
  * 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();
     }
 }
Beispiel #3
0
 /**
  * One time initialization helper
  *
  * @param string $base_theme
  * @return ICE_Scheme
  */
 public function init($base_theme)
 {
     // do not init same scheme twice
     if ($this->base_theme) {
         return;
     }
     // set base theme
     $this->base_theme = $base_theme;
     // is there at least one compiled themes?
     if ($this->themes_compiled->count() >= 1) {
         // copy all compiled themes
         $compiled = $this->themes_compiled->to_array();
         // use highest ancestor
         $this->root_theme = key($compiled);
     } else {
         // no compiled theme, root is template
         $this->root_theme = get_template();
     }
     // load it
     $this->load();
     // add filters
     $this->add_filters();
     // run theme feature support helper
     $this->feature_support();
     // some scheme initializations must occur after WP theme setup
     add_action('after_setup_theme', array($this, 'init_enqueueing'));
     add_action('after_setup_theme', array($this, 'load_functions'));
     add_action('ice_enqueue_styles', array($this, 'exports_refresh'), 0);
     add_action('ice_enqueue_scripts', array($this, 'exports_refresh'), 0);
     return $this;
 }
Beispiel #4
0
 /**
  * Returns all of this asset's sections as an array
  *
  * @return array
  */
 public final function get_sections()
 {
     return $this->sections->to_array();
 }
Beispiel #5
0
 /**
  * Generate CSS markup for this rule
  *
  * @param array $declarations
  * @return string
  */
 public function export($declarations = null)
 {
     // the markup that will be returned
     $markup = null;
     // declarations passed in?
     if (is_array($declarations)) {
         // merge over existing decs?
         if (is_array($this->declarations)) {
             $declarations = array_merge($this->declarations->to_array(), $declarations);
         }
     } else {
         $declarations = $this->declarations->to_array();
     }
     // open declarations with the selector
     $markup = $this->selector . " {" . PHP_EOL;
     // add each dec
     foreach ($declarations as $property => $value) {
         $markup .= sprintf("\t%s: %s;", $property, $value) . PHP_EOL;
     }
     // close
     $markup .= '}' . PHP_EOL;
     // all done
     return $markup;
 }
Beispiel #6
0
 /**
  * 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));
     }
 }