本文整理汇总了PHP中lessc::checkedCompile方法的典型用法代码示例。如果您正苦于以下问题:PHP lessc::checkedCompile方法的具体用法?PHP lessc::checkedCompile怎么用?PHP lessc::checkedCompile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lessc
的用法示例。
在下文中一共展示了lessc::checkedCompile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Compile LESS
* @param string $in
* @param string $out
*/
public function compile($in, $out)
{
if ($this->cacheDir) {
$this->autoCompileLess($in, $out);
} else {
$this->compiler->checkedCompile($in, $out);
}
}
示例2: shoestrap_phpless
function shoestrap_phpless()
{
$shoestrap_responsive = get_theme_mod('shoestrap_responsive');
if (!class_exists('lessc')) {
require_once TEMPLATEPATH . '/lib/less_compiler/lessc.inc.php';
}
$less = new lessc();
$less->setFormatter("compressed");
if ($shoestrap_responsive == '0') {
$less->checkedCompile(TEMPLATEPATH . '/assets/css/app-fixed.less', TEMPLATEPATH . '/assets/css/app-fixed.css');
} else {
$less->checkedCompile(TEMPLATEPATH . '/assets/css/app-responsive.less', TEMPLATEPATH . '/assets/css/app-responsive.css');
}
}
示例3: compileLess
private function compileLess()
{
$lessc = new lessc();
$lessIndexPath = DIR_TEMPLATE . '/default/stylesheet/less/index.less';
$cssIndexPath = DIR_TEMPLATE . '/default/stylesheet/stylesheet.css';
$lessc->checkedCompile($lessIndexPath, $cssIndexPath);
}
示例4: registerLessFile
public function registerLessFile($url, $media = '')
{
$this->hasScripts = true;
$lessUrl = $url;
$uniqid = md5($lessUrl);
$lessFileName = basename($lessUrl);
$cssFileName = preg_replace('/\\.less$/i', '', $lessFileName) . ".css";
$tempCachePath = Yii::getPathOfAlias('application.runtime.cache') . "/yiiless/{$uniqid}";
@mkdir($tempCachePath, 0777, true);
$cssFilePath = "{$tempCachePath}/{$cssFileName}";
if (preg_match('/^https?\\:\\/\\//', $lessUrl)) {
$lessFilePath = "{$tempCachePath}/{$lessFileName}";
} else {
if (file_exists(Yii::getPathOfAlias('webroot') . "/{$lessUrl}")) {
$lessFilePath = Yii::getPathOfAlias('webroot') . "/{$lessUrl}";
} else {
if (file_exists($lessUrl)) {
$lessFilePath = $lessUrl;
} else {
$lessFilePath = $_SERVER['DOCUMENT_ROOT'] . "/" . $lessUrl;
}
}
}
$lessCompiler = new lessc();
if ($this->cache === false) {
$lessCompiler->compileFile($lessFilePath, $cssFilePath);
} else {
$lessCompiler->checkedCompile($lessFilePath, $cssFilePath);
}
$cssUrl = Yii::app()->getAssetManager()->publish($cssFilePath);
$this->cssFiles[$cssUrl] = $media;
$params = func_get_args();
$this->recordCachingAction('clientScript', 'registerLessFile', $params);
return $this;
}
示例5: applyDefaultTheme
function applyDefaultTheme()
{
$less = new lessc();
try {
$less->checkedCompile("./style/main.less", "./style/style.css");
} catch (exception $e) {
echo $e->getMessage();
}
}
示例6: Core_View_Helper_Css
function Core_View_Helper_Css($files)
{
include_once LIBRARY_PATH . '/Less/lessc.inc.php';
$options = Core_Resource_View::getOptions();
$less = new lessc();
foreach ($files as $key => $file) {
if (substr($file, 0, 1) != '/') {
$filePaths[] = APPLICATION_PATH . '/theme/' . $options['theme'] . '/' . $file;
} else {
$filePaths[] = BASE_PATH . $file;
}
}
if ($options['combineCss']) {
$fileDate = 0;
$cacheFile = '';
foreach ($filePaths as $filePath) {
$fileDate = max(filemtime($filePath), $fileDate);
$cacheFile .= $filePath;
}
$cacheFile = md5($cacheFile) . '.css';
$cacheFilePath = BASE_PATH . '/public/cache/' . $cacheFile;
$cacheFileDate = file_exists($cacheFilePath) ? filemtime($cacheFilePath) : 0;
if ($cacheFileDate < $fileDate) {
$fileContent = '';
$less->setVariables(array('themeUrl' => "'" . BASE_URL . '/app/theme/' . $options['theme'] . "'", 'publicUrl' => "'" . BASE_URL . '/public' . "'"));
foreach ($filePaths as $filePath) {
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
if ($ext == 'less') {
$fileContent .= $less->compileFile($filePath) . PHP_EOL;
} else {
$fileContent .= file_get_contents($filePath) . PHP_EOL;
}
}
file_put_contents($cacheFilePath, $options['minify'] ? Core_Helper_Minify::minifyCss($fileContent) : $fileContent);
}
$fileLinks = array(BASE_URL . '/public/cache/' . $cacheFile);
} else {
foreach ($filePaths as $key => $filePath) {
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
if ($ext == 'less') {
$less->setVariables(array('themeUrl' => "'" . BASE_URL . '/app/theme/' . $options['theme'] . "'"));
$cacheFile = md5($filePath) . '.css';
$cacheFilePath = BASE_PATH . '/public/cache/' . $cacheFile;
$less->checkedCompile($filePath, $cacheFilePath);
$fileLinks[] = BASE_URL . '/public/cache/' . $cacheFile;
} else {
$fileLinks[] = BASE_URL . '/' . trim(str_replace(BASE_PATH, '', $filePath), '/');
}
}
}
foreach ($fileLinks as $link) {
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$link}\" />" . PHP_EOL;
}
}
示例7: test
function test($data)
{
require "scripts/lessc.inc.php";
$less = new lessc();
if (ENVIRONMENT != 'development') {
$less->checkedCompile('content/' . $data . '/style_compilator.less', 'content/cache/' . $data . '_compiled.css');
} else {
$less->compileFile('content/' . $data . '/style_compilator.less', 'content/cache/' . $data . '_compiled.css');
}
echo '<link href="/content/cache/' . $data . '_compiled.css" rel="stylesheet" type="text/css" />';
}
示例8: lessToCss
/**
* Method that compiles LESS to CSS file
* @param (string) Path to LESS file
* @param (bool) If true additional LESS variables from "jm_bootstrap_variables" parameter will be added
* @param (bool) Indicates if we are dealing with a file that belongs to template's core.
* If yes, it means that we should add suffix for CSS file because different template styles may use
* different variables
* @param (bool) When true old version of LessC will be used. Otherwise Less_Parser class.
*/
protected function lessToCss($lessPath, $useVars = true, $coreStyle = true, $legacyCompiler = false)
{
if (class_exists('lessc') == false && $legacyCompiler) {
require_once JMF_FRAMEWORK_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'lessc' . DIRECTORY_SEPARATOR . 'lessc.inc.0.4.0.php';
}
if (class_exists('Less_Parser') == false && !$legacyCompiler) {
require_once JMF_FRAMEWORK_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'less_parser' . DIRECTORY_SEPARATOR . 'Less.php';
}
$developer_mode = $this->params->get('devmode', false) == '1' ? true : false;
$filename = JFile::stripExt(JFile::getName($lessPath));
$style_id = @JFactory::getApplication()->getTemplate(true)->id;
$css_suffix = '';
// A suffix is simply ID of template style, eg. template.10.css
if ($style_id > 0 && $coreStyle) {
$css_suffix = '.' . $style_id;
}
// Establishing path to CSS file
$cssPath = JPath::clean(JMF_TPL_PATH . '/css/' . $filename . $css_suffix . '.css');
// Checking if LESS file exists. If not we should make sure that we're looking in correct directory
if (!JFile::exists($lessPath)) {
$lessPath = JPath::clean(JMF_TPL_PATH . '/less/' . $filename . '.less');
}
// If developer mode is disabled and CSS file is not older than LESS file, we do not have to compile LESS file.
if (JFile::exists($lessPath) && JFile::exists($cssPath)) {
$lessTime = filemtime($lessPath);
$cssTime = filemtime($cssPath);
if ($lessTime <= $cssTime && $developer_mode == false) {
return JMF_TPL_URL . '/css/' . $filename . $css_suffix . '.css';
}
}
// At this point, either we are in developer mode or CSS file does not exist or is older than LESS file.
// But if CSS file does exist, we should delete it
if (JFile::exists($cssPath)) {
JFile::delete($cssPath);
}
try {
if ($legacyCompiler) {
// Initialising LessC compiler
$less = new lessc();
// Additional LESS variables
if ($useVars) {
$variables = $this->params->get('jm_bootstrap_variables', array());
if (!empty($variables)) {
$less->setVariables($variables);
}
}
// Checked Compile - LessC
$less->checkedCompile($lessPath, $cssPath);
} else {
// Less_Parser compiler
$less_parser_options = array('compress' => $this->params->get('cssCompress', '0') == '1' ? true : false, 'relativeUrls' => false, 'sourceMap' => false);
if ($developer_mode) {
//$less_parser_options['compress'] = false;
$less_parser_options['sourceMap'] = true;
$less_parser_options['sourceMapWriteTo'] = JPath::clean(JMF_TPL_PATH . '/css/' . $filename . $css_suffix . '.map');
$less_parser_options['sourceMapURL'] = JUri::base(false) . 'templates/' . JMF_TPL . '/css/' . $filename . $css_suffix . '.map';
}
$less_parser = new Less_Parser($less_parser_options);
// Less_Parser - LESS file
$less_parser->parseFile($lessPath, JMF_TPL_URL . '/css');
// Additional LESS variables
if ($useVars) {
$variables = $this->params->get('jm_bootstrap_variables', array());
if (!empty($variables)) {
// Less_Parser
$less_parser->ModifyVars($variables);
}
}
// Compilation - Less_Parser
if ($css_content = $less_parser->getCss()) {
if (JFile::write($cssPath, $css_content) == false) {
throw new Exception('Cannot save CSS file. Please check your directory permissions.');
}
}
}
} catch (exception $e) {
throw new Exception(JText::sprintf('PLG_SYSTEM_JMFRAMEWORK_LESS_ERROR', $e->getMessage()));
}
// Returning CSS file's URL
return JMF_TPL_URL . '/css/' . $filename . $css_suffix . '.css';
}
示例9: lessc
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>inlogregistratie - tutorialsite</title>
<?php
require_once "./lessphp/lessc.inc.php";
$less = new lessc();
$less->checkedCompile("./css/style.less", "./css/style.css");
?>
<link rel="stylesheet/less" type="text/css" href="css/less-style.less">
<link rel="stylesheet/less" type="text/css" href="css/php-style.php">
<link rel="stylesheet/less" type="text/css" href="css/style.less">
<link rel="stylesheet" type="text/css" href="./jquery/jquery-ui-1.11.4.custom/jquery-ui.css">
<link rel="stylesheet" media="(max-width:800px; )" type="text/css" href="css/style-mobile.css">
<!--
<link rel="stylesheet/less" type="text/css" href="css/less-style.less">
-->
<script src="./less.js-2.5.3/dist/less.js"></script>
<script src="./jquery/jquery-2.1.4.js"></script>
示例10: unset
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$this->language = $doc->language;
$this->direction = $doc->direction;
$sitename = $app->get('sitename');
$tmpl = $this->baseurl . '/templates/' . $this->template;
// STOP INCLUDING GARBAGE IN MY TEMPLATE !!!!
foreach ($doc->_scripts as $script => $value) {
if (preg_match('/media\\/jui/i', $script)) {
unset($doc->_scripts[$script]);
}
}
// Add Stylesheets
require "php/lessc.inc.php";
$less = new lessc();
$less->checkedCompile(dirname(__FILE__) . "/less/site.less", dirname(__FILE__) . "/css/site.css");
$doc->addStyleSheet($this->baseurl . '/templates/' . $this->template . '/css/site.css');
?>
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php
echo $this->language;
?>
"
lang="<?php
echo $this->language;
?>
" dir="<?php
echo $this->direction;
?>
示例11: function
* Remove JS Conflicts
* ==================================================
*/
//UNSET newJCAPTION
if ($this->params->get('removecaptionjs', 0) == 1) {
if (isset($this->_script['text/javascript'])) {
$codejcaption = "jQuery(window).on('load', function() {\r\t\t\t\t\tnew JCaption('img.caption');\r\t\t\t\t});";
// This @ is in order to hide the warning, working in a better solution
@($this->_script['text/javascript'] = preg_replace($codejcaption, '', $this->_script['text/javascript']));
if (empty($this->_script['text/javascript'])) {
unset($this->_script['text/javascript']);
}
}
}
//UNSET SqueezeBox.initialize
if ($this->params->get('removesqueezeboxjs', 0) == 1) {
if (isset($this->_script['text/javascript'])) {
$codejcaption = "jQuery(function(\$) {\r\t\t\tSqueezeBox.initialize({});\r\t\t\tSqueezeBox.assign(\$('a.modal').get(), {\r\t\t\t\tparse: 'rel'\r\t\t\t});\r\t\t})\r\t\t";
// This @ is in order to hide the warning, working in a better solution
@($this->_script['text/javascript'] = preg_replace($codejcaption, '', $this->_script['text/javascript']));
if (empty($this->_script['text/javascript'])) {
unset($this->_script['text/javascript']);
}
}
}
if ($less == 1) {
$less = new lessc();
$less->checkedCompile($_SERVER['DOCUMENT_ROOT'] . $tpath . "/css/custom.less", $_SERVER['DOCUMENT_ROOT'] . $tpath . "/css/custom.css");
}
// force latest IE & chrome frame
$doc->setMetadata('x-ua-compatible', 'IE=edge,chrome=1');
示例12: lessc
/**
* Less CSS
*
* @param mixed $mixed CSS string to process with Less compiler or an array with CSS file's Path and URL.
* @return mixed string or an array with CSS file's Path and URL.
*/
function _lessCss($mixed)
{
require_once BX_DIRECTORY_PATH_PLUGINS . 'lessphp/lessc.inc.php';
$oLess = new lessc();
$oLess->setVariables($this->_oConfigTemplate->aLessConfig);
if (is_array($mixed) && isset($mixed['url']) && isset($mixed['path'])) {
$sPathFile = realpath($mixed['path']);
$aInfoFile = pathinfo($sPathFile);
if (!isset($aInfoFile['extension']) || $aInfoFile['extension'] != 'less') {
return $mixed;
}
$sPathRoot = realpath(BX_DIRECTORY_PATH_ROOT);
$sFile = $this->_sLessCachePrefix . trim(str_replace(array('.' . $aInfoFile['extension'], DIRECTORY_SEPARATOR), array('', '_'), bx_ltrim_str($sPathFile, $sPathRoot)), '_') . '.css';
$oLess->checkedCompile($mixed['path'], $this->_sCachePublicFolderPath . $sFile);
return array('url' => $this->_sCachePublicFolderUrl . $sFile, 'path' => $this->_sCachePublicFolderPath . $sFile);
}
return $oLess->compile($mixed);
}
示例13: header
<?php
// get config file
$config = parse_ini_file('conf/config.ini', TRUE);
// check for ssl
if ($_SERVER['HTTPS'] != "on" && $config['ssl'] == 1) {
$redirect = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header("HTTP/1.1 301 Moved Permanently");
header("Location: {$redirect}");
}
// build css if there is a newer less version
require "classes/less/lessc.inc.php";
$less = new lessc();
$less->setFormatter("compressed");
try {
$less->checkedCompile("css/less/wuza.less", "css/wuza.css");
} catch (exception $e) {
echo '<div class="text-danger bg-danger small-padding">fatal error: ' . $e->getMessage() . '</div>';
}
// allow GZIP Compression
ob_start("ob_gzhandler");
session_start();
// incude classes
include 'classes/controller.php';
include 'classes/model.php';
include 'classes/view.php';
include 'classes/uri.php';
// $_SESSION, $_GET and $_POST - no $_COOKIE but config values
$request = array_merge($_SESSION, $_GET, $_POST, $config);
// add values from fancy url
$url = new URI("wuza");
示例14: compileLess
private function compileLess()
{
$less = new \lessc();
try {
$less->checkedCompile(__DIR__ . "/../resources/less/main.less", __DIR__ . "/../resources/css/main.css");
} catch (\Exception $e) {
$this->render->error(500, $e->getMessage());
}
}
示例15: less
$compress = c::get('less.compress', true);
$kirby = kirby();
$kirby->options['less.handler'] = function ($url, $media = false) use($kirby, $compress) {
if (is_array($url)) {
$less = array();
foreach ($url as $u) {
$less[] = call($kirby->options['less.handler'], $u);
}
return implode(PHP_EOL, $less) . PHP_EOL;
}
// Update folder and file extension
$compiledUrl = str_replace('/less/', '/css/', $url);
$compiledUrl = str_replace('.less', '.css', $compiledUrl);
$root = $kirby->roots()->index() . DS;
// Will throw error if $file does not exist
$less = new lessc();
$less->setFormatter($compress ? 'compressed' : '');
$less->checkedCompile($root . $url, $root . $compiledUrl);
return call(kirby()->option('css.handler') ?: 'css', array($compiledUrl, $media));
};
/**
* Compile less to css and then call css.handler
*
* @param string $url
* @param string $media
* @return string
*/
function less()
{
return call(kirby::instance()->option('less.handler'), func_get_args());
}