本文整理汇总了PHP中Stack::get_sorted_stack方法的典型用法代码示例。如果您正苦于以下问题:PHP Stack::get_sorted_stack方法的具体用法?PHP Stack::get_sorted_stack怎么用?PHP Stack::get_sorted_stack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack::get_sorted_stack方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_stack_order
function test_stack_order()
{
Stack::add( 'test_stack', 'a', 'a' );
Stack::add( 'test_stack', 'b after(a)', 'b', 'a' );
$sorted = Stack::get_sorted_stack('test_stack');
$this->assert_equal( implode(', ', $sorted), 'a, b after(a)' );
Stack::add( 'test_stack', 'c after(b,d,f)', 'c', array('b','d','f') );
$sorted = Stack::get_sorted_stack('test_stack');
$this->assert_equal( implode(', ', $sorted), 'a, b after(a), c after(b,d,f)' );
Stack::add( 'test_stack', 'd after(b)', 'd', 'b' );
$sorted = Stack::get_sorted_stack('test_stack');
$this->assert_equal( implode(', ', $sorted), 'a, b after(a), d after(b), c after(b,d,f)' );
Stack::add( 'test_stack', 'e after(b)', 'e', 'b' );
$sorted = Stack::get_sorted_stack('test_stack');
$this->assert_equal( implode(', ', $sorted), 'a, b after(a), d after(b), c after(b,d,f), e after(b)' );
Stack::add( 'test_stack', 'f after(b)', 'f', 'b' );
$sorted = Stack::get_sorted_stack('test_stack');
$this->assert_equal( implode(', ', $sorted), 'a, b after(a), d after(b), f after(b), e after(b), c after(b,d,f)' );
Stack::add( 'test_stack', 'g after(e)', 'g', 'e');
$sorted = Stack::get_sorted_stack('test_stack');
$this->output(implode(', ', $sorted));
$this->assert_equal( implode(', ', $sorted), 'a, b after(a), d after(b), f after(b), c after(b,d,f), e after(b), g after(e)' );
}
示例2: 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');
}
}
示例3: 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'));
}
}
}
示例4: test_stack_duplicate_names
function test_stack_duplicate_names()
{
Stack::add('test_dupe_names', 'http://example.com/dupedep.js', 'dupedep');
Stack::add('test_dupe_names', 'http://example.com/dupe1.js', 'dupe', 'dupedep');
Stack::add('test_dupe_names', 'http://example.com/dupe2.js', 'dupe', 'dupedep');
$sorted = Stack::get_sorted_stack('test_dupe_names');
$this->output(implode(', ', $sorted));
$this->assert_equal(implode(', ', $sorted), 'http://example.com/dupedep.js, http://example.com/dupe2.js');
}