/** * Inject static code/markup * * @return string */ public function export() { // the code that will be returned $code = null; // handle callbacks if ($this->has_callbacks()) { // loop em foreach ($this->callbacks as $callback) { // execute callback with myself as only argument call_user_func($callback, $this); } } // have any files? if ($this->files_export->count()) { // loop through all files foreach ($this->files_export as $file) { // resolve file path if (path_is_absolute($file)) { // its absolute already, which is good $filename = $file; } else { // relative path, need to locate it $filename = $this->component()->locate_file($file); } // only import each file once! if (self::$files_imported->contains($filename)) { // already imported that one continue; } else { // push it on to imported stack self::$files_imported->push($filename); } // inject helpful comment ;) //$code .= '/*+++ import source: ' . $filename . ' */' . PHP_EOL; // make sure file actually exists if (ICE_Files::cache($filename)->is_readable()) { // get entire contents of file $code .= $this->get_file_contents($filename) . PHP_EOL; // success //$code .= '/*--- import complete! */' . PHP_EOL . PHP_EOL; } else { //$code .= '/*!!! import failed! */' . PHP_EOL . PHP_EOL; } } } // handle strings if ($this->has_strings()) { //$code .= '/*--- importing strings */' . PHP_EOL; $code .= implode(PHP_EOL, $this->strings->to_array()) . str_repeat(PHP_EOL, 2); //$code .= '/*!!! importing strings complete */' . PHP_EOL; } // all done return $code; }
/** * Register a style with data from a config map * * @param string $handle * @param string $config_map */ private function register_style($handle, $config_map) { if ($this->styles_ignore->contains($handle)) { return; } $deps = array(); foreach ($config_map->item_at(self::TRIGGER_DEPS)->to_array() as $dep) { if ($this->styles->contains($dep) || nxt_style_is($dep, 'registered')) { array_push($deps, $dep); } } // reg it nxt_register_style($handle, $config_map->item_at(self::TRIGGER_PATH), $deps); }
/** * Generate javascript markup for this script's dynamic code * * @return string */ public function export() { // the markup that will be returned $code = parent::export(); // render rules if ($this->logic->count()) { // begin script generation $code .= sprintf('/*+++ begin script: %s */', $this->token) . PHP_EOL; // loop all logic objects foreach ($this->logic->to_array() as $logic) { // append output of logic export $code .= $logic->export(); } // end script generation $code .= sprintf('/*+++ end script: %s */', $this->token) . PHP_EOL . PHP_EOL; } // all done return $code; }
/** * Return theme stack as an array * * @param boolean $top_down * @return array */ public function theme_stack($top_down = true) { // is there anything in the stack yet? if ($this->themes->count() === 0) { // not good. throw an exception here so we don't have to // act paranoid and check the result of every call to this. throw new Exception('You are trying to get the theme stack before it has been loaded'); } // top down? if (true === $top_down) { // empty cache? if (null === $this->theme_stack_topdown) { // populate cache $this->theme_stack_topdown = $this->themes->to_array(true); } // return reversed array return $this->theme_stack_topdown; } else { // return array as is return $this->themes->to_array(); } }
/** * Add a path to check. Later items are check first. * * @param string $path * @return boolean */ public final function add_path($path) { if (!$this->paths->contains($path)) { $this->paths->push($path); return true; } // already exists return false; }
/** * Push an exportable object onto the stack * * @param ICE_Exportable $obj * @return ICE_Stack */ public function push(ICE_Exportable $obj) { // not allowed if callback is set if ($this->callback) { throw new Exception('Adding exportable objects not allowed when a callback is set'); } // push object on to stack $this->stack->push($obj); // handle recursive objects if ($obj instanceof ICE_Recursable) { // loop children foreach ($obj->get_children() as $name => $child) { // push to child $this->child($name)->push($child); } } return $this; }