/** * Creates a stylesheet link with LESS support * * @param string|array $style filename, or array of filenames to match to array of medias * @param string|array $media media type of stylesheet, or array to match filenames * @param boolean $index include the index_page in the link * @param array $imports compare file date for these too, CSS and LESS in style @import * @return string */ public static function stylesheet($style, $media = false, $index = false, $imports = null) { $style = (array) $style; $imports = (array) $imports; $compiled = array(); // Loop through styles and compile less if necessary foreach ($style as $_style) { // Detect suffix if (substr_compare($_style, '.less', -5, 5, FALSE) === 0) { $_style = substr_replace($_style, '', -5, 5); $less = $_style . '.less'; $css = $_style . '.css'; try { // Check if included files have changed $compile = false; if (!empty($imports)) { foreach ($imports as $import) { if (!is_file($css) || filemtime($import) > filemtime($css)) { $compile = true; break; } } } // Compile LESS if ($compile || !is_file($css) || filemtime($less) > filemtime($css)) { $compiler = new less($less); file_put_contents($css, $compiler->parse()); } $_style = $css; } catch (Exception $e) { Kohana_Log::add('error', __METHOD__ . ': Error compiling LESS file ' . $less . ', ' . $e->getMessage()); continue; } } else { if (strpos($_style, '.css') === false) { // Require suffix to support timestamp cache overrides $_style .= '.css'; } } // Add to compiled, with timestamp $compiled[] = $_style . '?' . filemtime($_style); } return html::link($compiled, 'stylesheet', 'text/css', false, $media, $index); }
"> <head> <meta charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo strip_tags($page_title); echo (!empty($page_title) ? ' | ' : '') . Kohana::config('site.site_name'); ?> </title> <link rel="icon" type="image/png" href="/ui/favicon.png" /> <?php echo html::stylesheet(array('ui/boot.css', 'ui/grid.css', 'ui/typo.css', 'ui/base.css')); ?> <?php echo less::stylesheet($skin, false, false, $skin_imports); ?> <!--[if IE]> <?php echo html::script('http://html5shiv.googlecode.com/svn/trunk/html5.js'); ?> <![endif]--> <script src="http://www.google.com/jsapi?key=<?php echo Kohana::config('site.google_api_key'); ?> "></script> <?php echo html::script(array('http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js', 'js/jquery.tools.min.js')); echo widget::get('head'); ?> </head>
/** * @param array $arguments * @param array $options * @return void */ protected function execute($arguments = array(), $options = array()) { $lessc = new less(); $lessc->compileLessFiles(); }