force = false; while ($option = array_shift($argv)) switch ($option) { case 'force': $this->force = true; break; default: $this->usage(); exit(-1); } } /** * Print command usage information. */ function usage() { echo "CSS Compilation tool\n" . "Use this tool to compile CSS into a single file.\n\n" . "Usage: {$this->scriptName}\n"; } /** * Execute the build CSS command. */ function execute() { // Load the LESS compiler class. require_once('lib/pkp/lib/lessphp/lessc.inc.php'); // Flush if necessary if ($this->force) unlink(APPLICATION_STYLES_DIR . '/' . APPLICATION_CSS_WRAPPER); // Perform the compile. try { // KLUDGE pending fix of https://github.com/leafo/lessphp/issues#issue/66 // Once this issue is fixed, revisit paths and go back to using // lessc::ccompile to parse & compile. $less = new lessc(APPLICATION_STYLES_DIR . '/' . APPLICATION_LESS_WRAPPER); $less->importDir = './'; file_put_contents( APPLICATION_STYLES_DIR . '/' . APPLICATION_CSS_WRAPPER, $less->parse() ); } catch (exception $ex) { echo "ERROR: " . $ex->getMessage() . "\n"; exit(-1); } exit(0); } } $tool = new buildCss(isset($argv) ? $argv : array()); $tool->execute(); ?>