/** * load_apply * Finds @load lines, includes the files * @param array $lines The lines to prcoess * @return array $new The new lines with the loaded files included */ function load_apply($lines) { global $cssp; $new = array(); foreach ($lines as $line) { if (preg_match('/^[\\s]*@load[\\s]+url\\((.*?)\\)/', $line, $matches)) { if (count($matches) == 2) { $loadfilepath = $matches[1]; // Apply global path constants; foreach ($cssp->global_constants as $g_constant => $g_value) { $loadfilepath = preg_replace('/(\\$_' . $g_constant . ')\\b/', $g_value, $loadfilepath); } $basedir = dirname($loadfilepath); // Load the file if (file_exists($loadfilepath)) { $newlines = file($loadfilepath); $newlines_indention_char = Parser2::get_indention_char($newlines); // Fix the indention of the new lines if ($cssp->indention_char != $newlines_indention_char) { $newlines = load_fix_indention($newlines, $cssp->indention_char, $newlines_indention_char); } // Apply the basedir to $_FILEPATH $newlines = load_fix_filepath($newlines, $basedir); // Apply the loader plugin to the loaded files $newlines = load_apply($newlines); // Import the new lines foreach ($newlines as $imported) { $new[] = $imported; } } else { $cssp->report_error('Loader plugin could not find file ' . $loadfilepath . '.'); } } } else { $new[] = $line; } } return $new; }
/** * set_indention_char * Sets the indention char * @param string $char The whitespace char(s) used for indention * @return void */ public function set_indention_char($char = null) { if (!$char) { $char = Parser2::get_indention_char($this->code); } $this->indention_char = $char; }