/** * Returns a <style> tag with the content of all the stylesheets included inline * * @param $styles * If not empty, this associative array contains styles which will be * included at the end of the generated <style> tag. * @param string $slot_name * Optional. If provided, returns only the stylesheets added while filling this slot. * * @return string * the style tags and their contents inline */ static function stylesheetsInline($styles = array(), $slot_name = null) { $styles = self::stylesInline($slot_name, false); if (empty($styles) and empty(self::$stylesheets)) { return ''; } $return = "<style type='text/css'>\n"; if (!empty(self::$stylesheets)) { foreach (self::$stylesheets as $stylesheet) { $href = ''; $media = 'screen, print'; $type = 'text/css'; extract($stylesheet, EXTR_IF_EXISTS); $ob = new Pie_OutputBuffer(); if (Pie_Valid::url($href)) { try { include $href; } catch (Exception $e) { } } else { list($href, $filename) = Pie_Html::themedUrlAndFilename($href); try { Pie::includeFile($filename); } catch (Exception $e) { } } $stylesheet = "\n/* Included inline from {$href} */\n" . $ob->getClean(); $return .= "{$stylesheet}\n"; } } $return .= "/* Included inline from Pie_Response::stylesInline() */\n"; $return .= $styles; $return .= "\n</style>"; return $return; }
/** * Loads the configuration and plugins in the right order */ static function configure() { Pie_Config::load('config/pie.json'); // Get the app config, but don't load it yet $app_p = new Pie_Parameters(); $app_p->load('config/app.json'); $app_p->load('local/app.json'); // Load all the plugin config files first $paths = explode(PS, get_include_path()); $plugins = $app_p->get('pie', 'plugins', array()); foreach ($plugins as $plugin) { $plugin_path = Pie::realPath('plugins' . DS . $plugin); if (!$plugin_path) { throw new Pie_Exception_MissingPlugin(compact('plugin')); } Pie_Config::load($plugin_path . DS . 'config' . DS . 'plugin.json'); array_splice($paths, 1, 0, array($plugin_path)); $PLUGIN = strtoupper($plugin); if (!defined($PLUGIN . '_PLUGIN_DIR')) { define($PLUGIN . '_PLUGIN_DIR', $plugin_path); } if (!defined($PLUGIN . '_PLUGIN_CONFIG_DIR')) { define($PLUGIN . '_PLUGIN_CONFIG_DIR', $plugin_path . DS . 'config'); } if (!defined($PLUGIN . '_PLUGIN_CLASSES_DIR')) { define($PLUGIN . '_PLUGIN_CLASSES_DIR', $plugin_path . DS . 'classes'); } if (!defined($PLUGIN . '_PLUGIN_FILES_DIR')) { define($PLUGIN . '_PLUGIN_FILES_DIR', $plugin_path . DS . 'files'); } if (!defined($PLUGIN . '_PLUGIN_HANDLERS_DIR')) { define($PLUGIN . '_PLUGIN_HANDLERS_DIR', $plugin_path . DS . 'handlers'); } if (!defined($PLUGIN . '_PLUGIN_PLUGINS_DIR')) { define($PLUGIN . '_PLUGIN_PLUGINS_DIR', $plugin_path . DS . 'plugins'); } if (!defined($PLUGIN . '_PLUGIN_SCRIPTS_DIR')) { define($PLUGIN . '_PLUGIN_SCRIPTS_DIR', $plugin_path . DS . 'scripts'); } if (!defined($PLUGIN . '_PLUGIN_TESTS_DIR')) { define($PLUGIN . '_PLUGIN_TESTS_DIR', $plugin_path . DS . 'tests'); } if (!defined($PLUGIN . '_PLUGIN_WEB_DIR')) { define($PLUGIN . '_PLUGIN_WEB_DIR', $plugin_path . DS . 'web'); } } set_include_path(implode(PS, $paths)); // Now, we can merge in our app's config Pie_Config::merge($app_p); // Now, load any other files we were supposed to load $config_files = Pie_Config::get('pie', 'configFiles', array()); foreach ($config_files as $cf) { Pie_Config::load($cf); } $script_files = Pie_Config::get('pie', 'scriptFiles', array()); foreach ($script_files as $cf) { Pie::includeFile($cf); } }