本文整理汇总了PHP中CSS::load方法的典型用法代码示例。如果您正苦于以下问题:PHP CSS::load方法的具体用法?PHP CSS::load怎么用?PHP CSS::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSS
的用法示例。
在下文中一共展示了CSS::load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_css
function load_css()
{
CSS::load();
}
示例2: setup
/**
* Sets the initial variables, checks if we need to process the css
* and then sends whichever file to the browser.
*
* @return void
* @author Anthony Short
**/
public static function setup($url_params)
{
static $run;
# This function can only be run once
if ($run === TRUE) {
return;
}
# Change into the system directory
chdir(SYSPATH);
# Load the include paths
self::include_paths(TRUE);
# Recache is off by default
$recache = false;
# Set the user agent
self::$user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : '';
# Set timezone
date_default_timezone_set('UTC');
# Define Scaffold error constant
define('E_SCAFFOLD', 42);
# Set error handler
set_error_handler(array('CSScaffold', 'exception_handler'));
# Set exception handler
set_exception_handler(array('CSScaffold', 'exception_handler'));
if (!isset($url_params['request'])) {
throw new Scaffold_Exception('core.no_file_requested');
}
# Get rid of those pesky slashes
$requested_file = trim_slashes($url_params['request']);
# Remove anything about .css - like /typography/
$requested_file = preg_replace('/\\.css(.*)$/', '.css', $requested_file);
# Remove the start of the url if it exists (http://www.example.com)
$requested_file = preg_replace('/https?\\:\\/\\/[^\\/]+/i', '', $requested_file);
# Add our requested file var to the array
$request['file'] = $requested_file;
# Path to the file, relative to the css directory
$request['relative_file'] = ltrim(str_replace(CSSURL, '/', $requested_file), '/');
# Path to the directory containing the file, relative to the css directory
$request['relative_dir'] = pathinfo($request['relative_file'], PATHINFO_DIRNAME);
# Find the server path to the requested file
if (file_exists(DOCROOT . $requested_file)) {
# The request is sent with the absolute path most of the time
$request['path'] = DOCROOT . $requested_file;
} else {
# Otherwise we'll try to find it inside the CSS directory
$request['path'] = self::find_file($request['relative_dir'] . '/', basename($requested_file, '.css'), FALSE, 'css');
}
# If they've put a param in the url, consider it set to 'true'
foreach ($url_params as $key => $value) {
if (!in_array($key, self::$system_url_params)) {
if ($value == "") {
self::config_set('core.options.' . $key, true);
} else {
self::config_set('core.options.' . $key, $value);
}
}
}
# If the file doesn't exist
if (!file_exists($request['path'])) {
throw new Scaffold_Exception("core.doesnt_exist", $request['file']);
}
# or if it's not a css file
if (!is_css($requested_file)) {
throw new Scaffold_Exception("core.not_css", $requested_file);
}
# or if the requested file wasn't from the css directory
if (!substr(pathinfo($request['path'], PATHINFO_DIRNAME), 0, strlen(CSSPATH))) {
throw new Scaffold_Exception("core.outside_css_directory");
}
# Make sure the files/folders are writeable
if (!is_dir(CACHEPATH) || !is_writable(CACHEPATH)) {
throw new Scaffold_Exception("core.missing_cache", CACHEPATH);
}
# Send it off to the config
self::config_set('core.request', $request);
# Get the modified time of the CSS file
self::config_set('core.request.mod_time', filemtime(self::config('core.request.path')));
# Set the recache to true if needed
if (self::config('core.always_recache') or isset($url_params['recache'])) {
$recache = true;
}
# Set it back to false if it's locked
if (self::config('core.cache_lock') === true || IN_PRODUCTION) {
$recache = false;
}
# Load the modules.
self::load_addons(self::$modules, 'modules');
# Load the plugins
$plugins = self::config('core.plugins');
# If the plugin is disabled, remove it.
foreach ($plugins as $key => $value) {
if ($value !== false) {
self::$plugins[] = $key;
}
//.........这里部分代码省略.........
示例3: run
/**
* Sets the initial variables, checks if we need to process the css
* and then sends whichever file to the browser.
*
* @return void
* @author Anthony Short
**/
public static function run($get, $config = array(), $path = array())
{
static $run;
# This function can only be run once
if ($run === TRUE) {
return;
}
# If we want to debug (turn on errors and FirePHP)
if ($config['debug']) {
# Set the error reporting level.
error_reporting(E_ALL & ~E_STRICT);
# Set error handler
set_error_handler(array('CSScaffold', 'exception_handler'));
# Set exception handler
set_exception_handler(array('CSScaffold', 'exception_handler'));
# Turn on FirePHP
FB::setEnabled(true);
} else {
# Turn off errors
error_reporting(0);
FB::setEnabled(false);
}
# The default options
$default_config = array('debug' => false, 'in_production' => false, 'force_recache' => false, 'show_header' => true, 'auto_include_mixins' => true, 'override_import' => false, 'absolute_urls' => false, 'use_css_constants' => false, 'minify_css' => true, 'constants' => array(), 'disabled_plugins' => array());
# Merge them with our set options
$config = array_merge($default_config, $config);
# The default paths
$default_paths = array('document_root' => $_SERVER['DOCUMENT_ROOT'], 'css' => '../', 'system' => 'system', 'cache' => 'cache');
# Merge them with our set options
$path = array_merge($default_paths, $path);
# Set the options and paths in the config
self::config_set('core', $config);
# Set the paths in the config
self::config_set('core.path.docroot', fix_path($path['document_root']));
self::config_set('core.path.system', fix_path($path['system']));
self::config_set('core.path.cache', fix_path($path['cache']));
self::config_set('core.path.css', fix_path($path['css']));
self::config_set('core.url.css', str_replace(self::config('core.path.docroot'), '/', self::config('core.path.css')));
self::config_set('core.url.system', str_replace(self::config('core.path.docroot'), '/', SYSPATH));
# Load the include paths
self::include_paths(TRUE);
# Change into the system directory
chdir(SYSPATH);
# Set the output
if (isset($get['output'])) {
self::config_set('core.output', $get['output']);
}
# Parse the $_GET['request'] and set it in the config
self::config_set('core.request', self::parse_request($get['request']));
# Get the modified time of the CSS file
self::config_set('core.request.mod_time', filemtime(self::config('core.request.path')));
# Tell CSScaffold where to cache and tell if we want to recache
self::cache_set(self::config('core.path.cache'));
# Set it back to false if it's locked
if ($config['in_production'] and file_exists(self::$cached_file)) {
$recache = false;
} elseif ($config['force_recache'] or isset($get['recache']) or self::config('core.cache.mod_time') <= self::config('core.request.mod_time')) {
$recache = true;
self::cache_clear();
}
# Load the modules
self::load_modules($config['disabled_plugins']);
# Work in the same directory as the requested CSS file
chdir(dirname(self::config('core.request.path')));
# Create a new CSS object
CSS::load(self::config('core.request.path'));
# Parse it
if ($recache) {
self::parse_css();
}
# Log to Firebug
FB::group('CSScaffold Settings');
FB::log(self::config('core'));
FB::groupEnd();
# Output it
self::output(CSS::$css);
# Setup is complete, prevent it from being run again
$run = TRUE;
}