本文整理汇总了PHP中site::get_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP site::get_dir方法的具体用法?PHP site::get_dir怎么用?PHP site::get_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类site
的用法示例。
在下文中一共展示了site::get_dir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_template_header
public function action_template_header()
{
$modified = Stack::get_sorted_stack('template_header_javascript');
foreach ($modified as $key => $value) {
Stack::remove('template_header_javascript', $key);
}
Stack::add('template_header_javascript', Site::get_url('user') . "/files/minified.js", 'Minified');
if (!Cache::has(self::$cache_name . '_js') || !Cache::has(self::$cache_name . '_css')) {
set_include_path(dirname(__FILE__) . '/min/lib' . PATH_SEPARATOR . get_include_path());
require_once 'Minify/Source.php';
require_once 'Minify/HTML.php';
require_once 'Minify/CSS.php';
require_once 'Minify/HTML.php';
require_once 'Minify.php';
require_once 'Minify/Cache/File.php';
}
if (!Cache::has(self::$cache_name . '_js')) {
$js_stack = array();
foreach ($modified as $js) {
$js_stack[] = Site::get_path('base') . str_replace(Site::get_url('habari') . '/', '', $js);
}
$options = array('files' => $js_stack, 'encodeOutput' => false, 'quiet' => true, 'maxAge' => 86400);
$result = Minify::serve('Files', $options);
file_put_contents(site::get_dir('user') . '/files/minified.js', $result['content']);
Cache::set(self::$cache_name . '_js', 'true');
}
/* CSS */
$modified = Stack::get_sorted_stack('template_stylesheet');
$tmp = array();
foreach ($modified as $key => $value) {
$tmp[] = $value[0];
Stack::remove('template_stylesheet', $key);
}
Stack::add('template_stylesheet', array(Site::get_url('user') . "/files/minified.css", 'screen'), 'style');
if (!Cache::has(self::$cache_name . '_css')) {
$css_stack = array();
foreach ($tmp as $css) {
$css_stack[] = Site::get_path('base') . str_replace(Site::get_url('habari') . '/', '', $css);
}
$options = array('files' => $css_stack, 'encodeOutput' => false, 'quiet' => true, 'maxAge' => 86400);
// handle request
$result = Minify::serve('Files', $options);
file_put_contents(site::get_dir('user') . '/files/minified.css', $result['content']);
Cache::set(self::$cache_name . '_css', 'true');
}
}
示例2: action_template_header
public function action_template_header()
{
//Cache::expire( self::$cache_name . '_js' );
//Cache::expire( self::$cache_name . '_css' );
// try to disable output_compression (may not have an effect)
ini_set('zlib.output_compression', '0');
$modified_js = Stack::get_sorted_stack('template_header_javascript');
foreach ($modified_js as $key => $value) {
Stack::remove('template_header_javascript', $key);
}
Stack::add('template_header_javascript', Site::get_url('user') . '/files/minified.js', 'Minified');
$modified_css = Stack::get_sorted_stack('template_stylesheet');
$css = array();
foreach ($modified_css as $key => $value) {
$css[] = $value[0];
Stack::remove('template_stylesheet', $key);
}
Stack::add('template_stylesheet', array(Site::get_url('user') . "/files/minified.css", 'screen'), 'style');
/*
* If we have the files or the cache havent expired don't create new files.
*/
if (!file_exists(site::get_dir('user') . '/files/minified.css') || !file_exists(site::get_dir('user') . '/files/minified.js') || (!Cache::has(self::$cache_name . '_js') || !Cache::has(self::$cache_name . '_css'))) {
/* Taken from min/index.php */
define('MINIFY_MIN_DIR', dirname(__FILE__) . '/min/');
// load config
require MINIFY_MIN_DIR . '/config.php';
// setup include path
set_include_path($min_libPath . PATH_SEPARATOR . get_include_path());
require 'Minify.php';
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
Minify::setCache(isset($min_cachePath) ? $min_cachePath : '', $min_cacheFileLocking);
if ($min_documentRoot) {
$_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
} elseif (0 === stripos(PHP_OS, 'win')) {
Minify::setDocRoot();
// IIS may need help
}
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
// Using jsmin+ 1.3
$min_serveOptions['minifiers']['application/x-javascript'] = array('JSMinPlus', 'minify');
/* Javascript */
if (!Cache::has(self::$cache_name . '_js') || !file_exists(site::get_dir('user') . '/files/minified.js')) {
$js_stack = array();
foreach ($modified_js as $js) {
$js_stack[] = Site::get_path('base') . str_replace(Site::get_url('habari') . '/', '', $js);
}
$options = array('files' => $js_stack, 'encodeOutput' => false, 'quiet' => true);
$result = Minify::serve('Files', $options);
file_put_contents(site::get_dir('user') . '/files/minified.js', $result['content']);
Cache::set(self::$cache_name . '_js', 'true', Options::get('minification__expire'));
}
/* CSS */
if (!Cache::has(self::$cache_name . '_css') || !file_exists(site::get_dir('user') . '/files/minified.css')) {
$css_stack = array();
foreach ($css as $file) {
$css_stack[] = Site::get_path('base') . str_replace(Site::get_url('habari') . '/', '', $file);
}
$options = array('files' => $css_stack, 'encodeOutput' => false, 'quiet' => true);
// handle request
$result = Minify::serve('Files', $options);
file_put_contents(site::get_dir('user') . '/files/minified.css', $result['content']);
Cache::set(self::$cache_name . '_css', 'true', Options::get('minification__expire'));
}
}
}