function test_stack_item_lambda() { StackItem::register('bar', function () { return 'true'; }); $item = StackItem::get('bar'); $this->assert_equal((string) $item, 'true'); }
function action_template_header($theme) { // Add the HTML5 shiv for IE < 9 Stack::add('template_header_javascript', StackItem::get('html5_shiv')); Stack::add('template_header_javascript', StackItem::get('less-js')); Stack::add('template_header_javascript', '$(function(){$("#masthead").click(function(){location.href=$("#home").attr("href");})})', 'homelink', 'jquery'); Stack::add('template_stylesheet', $theme->get_url('/fonts/new_athena_unicode.css'), 'new_athena_unicode'); Stack::add('template_stylesheet', $theme->get_url('/fonts/ss-standard.css'), 'ss-standard'); //Stack::add('template_stylesheet', $theme->get_url('/css/style.css'), 'style'); Stack::add('template_stylesheet', array($theme->get_url('/less/style.less'), null, array('type' => null, 'rel' => 'stylesheet/less')), 'style'); // Add this line to your config.php to show an error and a notice if (defined('DEBUG_THEME')) { Session::error('This is a <b>sample error</b>'); Session::notice('This is a <b>sample notice</b> for ' . $_SERVER['REQUEST_URI']); } }
/** * Add a value to a stack * @param string $stack_name The name of the stack * @param mixed $value The value to add * @param string $value_name The name of the value to add * @param string $after The name of the stack element to insert this new element after * @return array The stack that was added to **/ public static function add($stack_name, $value, $value_name = null, $after = null) { $stack = self::get_named_stack($stack_name); if ($value_name == null && is_string($value)) { if ($test = StackItem::get($value)) { $value = $test; } } if (!$value instanceof StackItem) { $value_name = $value_name ? $value_name : md5(serialize($value)); $value = StackItem::register($value_name, $value); foreach ((array) $after as $a) { $value->add_dependency($a); } } $stack[$value->name] = $value; self::$stacks[$stack_name] = $stack; return $stack; }