/** * Imports all of the mixins in the mixins folder automatically. All comments * are stripped from these included mixins. * * @return void */ public static function import_process() { $folder = Scaffold::$config['Mixins']['auto_include']; if ($folder === false) { return; } foreach (Scaffold::list_files($folder, true) as $file) { if (is_dir($file)) { continue; } Scaffold::$css->string .= Scaffold::$css->remove_comments(file_get_contents($file)); } }
/** * Sets the initial variables, checks if we need to process the css * and then sends whichever file to the browser. * * @return void */ public static function setup($config) { /** * Choose whether to show or hide errors */ if (SCAFFOLD_PRODUCTION === false) { ini_set('display_errors', true); error_reporting(E_ALL & ~E_STRICT); } else { ini_set('display_errors', false); error_reporting(0); } /** * Define contstants for system paths for easier access. */ if (!defined('SCAFFOLD_SYSPATH') && !defined('SCAFFOLD_DOCROOT')) { define('SCAFFOLD_SYSPATH', self::fix_path($config['system'])); define('SCAFFOLD_DOCROOT', $config['document_root']); define('SCAFFOLD_URLPATH', str_replace(SCAFFOLD_DOCROOT, '', SCAFFOLD_SYSPATH)); } /** * Add include paths for finding files */ Scaffold::add_include_path(SCAFFOLD_SYSPATH, SCAFFOLD_DOCROOT); /** * Tell the cache where to save files and for how long to keep them for */ Scaffold_Cache::setup(Scaffold::fix_path($config['cache']), $config['cache_lifetime']); /** * The level at which logged messages will halt processing and be thrown as errors */ self::$error_threshold = $config['error_threshold']; /** * Disabling flags allows for quicker processing */ if ($config['disable_flags'] === true) { self::$flags = false; } /** * Tell the log where to save it's files. Set it to automatically save the log on exit */ if ($config['enable_log'] === true) { // START - Modified by Webligo Developments if ($config['log_path']) { Scaffold_Log::log_directory($config['log_path']); } else { Scaffold_Log::log_directory(SCAFFOLD_SYSPATH . 'logs'); } // END - Modified by Webligo Developments //Scaffold_Log::log_directory(SCAFFOLD_SYSPATH.'logs'); Scaffold_Event::add('system.shutdown', array('Scaffold_Log', 'save')); } /** * Load each of the modules */ foreach (Scaffold::list_files(SCAFFOLD_SYSPATH . 'modules') as $module) { $name = basename($module); $module_config = SCAFFOLD_SYSPATH . 'config/' . $name . '.php'; if (file_exists($module_config)) { unset($config); include $module_config; self::$config[$name] = $config; } self::add_include_path($module); if ($controller = Scaffold::find_file($name . '.php', false, true)) { require_once $controller; self::$modules[$name] = new $name(); } } /** * Module Initialization Hook * This hook allows modules to load libraries and create events * before any processing is done at all. */ self::hook('initialize'); /** * Create the shutdown event */ Scaffold_Event::add('system.shutdown', array('Scaffold', 'shutdown')); }
/** * Loads each of the property functions and parses them. * * @param $name The location of the extension files * @param $function The CSS function to call to look for instances of it in the CSS * @param $split_params Explode the params before sending them off to the user function * @return $css string */ public static function load_extensions($location, $function, $split_params = false) { $files = Scaffold::list_files($location, true); foreach ($files as $path) { if (is_dir($path)) { continue; } /** * If the functions or properties ARE unique, they will * be parsed as such. If not, properties or functions that * are found to be exactly the same will be merged. */ $unique = false; /** * The name of the property that can be used in Scaffold CSS */ # Webligo PHP5.1 compat $extension_name = substr(basename($path), 0, strrpos(basename($path), '.')); #$extension_name = pathinfo($path, PATHINFO_FILENAME); /** * Include the function we'll use as a callback */ if (!isset(self::$extensions[$extension_name])) { include_once $path; } else { $unique = self::$extensions[$extension_name]['unique']; } /** * The name of the function we'll call for this property */ $callback = 'Scaffold_' . str_replace('-', '_', $extension_name); /** * Save this extension */ self::$extensions[$extension_name] = array('unique' => $unique, 'path' => $path, 'callback' => $callback, 'function' => $function, 'split_params' => $split_params); /** * Find an replace them */ if ($found = Scaffold::$css->{$function}($extension_name)) { // Make the list unique or not $originals = $unique === false ? array_unique($found[0]) : $found[0]; // Loop through each found instance foreach ($originals as $key => $value) { // Explode the params to send them as function params or as a single param if ($split_params === true) { $result = call_user_func_array($callback, explode(',', $found[2][$key])); } else { $result = call_user_func($callback, $found[2][$key]); } // Run the user callback if ($result === false) { Scaffold::error('Invalid Extension Syntax - <strong>' . $originals[$key] . '</strong>'); } elseif ($unique === true) { $pos = strpos(Scaffold::$css->string, $originals[$key]); if ($pos !== false) { Scaffold::$css->string = substr_replace(Scaffold::$css->string, $result, $pos, strlen($originals[$key])); } } else { Scaffold::$css->string = str_replace($originals[$key], $result, Scaffold::$css->string); } } } } }