/** * 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); }
/** * Enable components for the scheme by passing a valid policy object * * @param ICE_Policy $policy * @param string $ini_file_name * @return boolean */ public function enable_component(ICE_Policy $policy) { // loop through entire theme stack BOTTOM UP and try to load options foreach ($this->theme_stack(false) as $theme) { // path to ini file $ini_file = $this->theme_config_file($theme, $policy->get_handle()); // load the option config if it exists if (ICE_Files::cache($ini_file)->is_readable()) { // skip loaded files if ($this->config_files_loaded->contains($ini_file)) { continue; } // try to load ini file if ($policy->registry()->load_config_file($ini_file, $theme)) { // push onto loaded stack $this->config_files_loaded->push($ini_file); } } } // finalize policy $policy->finalize(); return true; }
/** * 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; }