本文整理汇总了PHP中Stack类的典型用法代码示例。如果您正苦于以下问题:PHP Stack类的具体用法?PHP Stack怎么用?PHP Stack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Stack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLink
/**
* Get post Uri
*
* @return string
*/
public function getLink($type = 'default', $param = NULL)
{
switch ($type) {
case 'edit':
$uri = new Stack(array('name' => 'post.link.edit'));
$uri->append('post');
$uri->append('edit');
break;
case 'delete':
$uri = new Stack(array('name' => 'post.link.edit'));
$uri->append('post');
$uri->append('delete');
break;
case 'hide':
$uri = new Stack(array('name' => 'post.link.hide'));
$uri->append('post');
$uri->append('hide');
break;
case 'full':
return '<a href="' . $this->getLink() . $param . '">' . $this->name . '</a>';
break;
default:
$uri = new Stack(array('name' => 'post.link'));
$uri->append('post');
}
$uri->append($this->id);
return l('/' . $uri->render('/'));
}
示例2: tokenize
/**
* @param string $string
* @return Stack
*/
public function tokenize($string)
{
$stack = new Stack();
$baseNameSpace = __NAMESPACE__ . '\\Tokens\\Token';
$offset = 0;
while (preg_match($this->tokens, $string, $matches, 0, $offset)) {
$token = $this->getMatchedToken($matches);
$className = $baseNameSpace . $token;
$stack->attach(new $className($matches[$token], $offset, $stack));
$offset += strlen($matches[0]);
}
return $stack;
}
示例3: action_template_header
public function action_template_header($theme)
{
Stack::add('template_header_javascript', Site::get_url('scripts') . "/jquery.js", 'jquery');
Stack::add('template_header_javascript', Site::get_url('theme') . "/js/jquery.bigframe.js", 'jquery.bigframe', 'jquery');
Stack::add('template_header_javascript', Site::get_url('theme') . "/js/jquery.dimensions.js", 'jquery.dimensions', 'jquery');
Stack::add('template_header_javascript', Site::get_url('theme') . "/js/jquery.tooltip.js", 'jquery.tooltip', 'jquery');
}
示例4: Inbox
function Inbox($POD, $count = 20, $offset = 0)
{
$this->POD = $POD;
if (!$this->POD) {
return false;
}
if (!$this->POD->isAuthenticated()) {
return false;
}
// get unread count.
$sql = "SELECT count(1) as count FROM messages WHERE userId=" . $this->POD->currentUser()->get('id') . " and status='new';";
$this->POD->tolog($sql, 2);
$res = mysql_query($sql, $this->POD->DATABASE);
if ($ur = mysql_fetch_assoc($res)) {
$this->UNREAD_COUNT = $ur['count'];
}
mysql_free_result($res);
$conditions = array();
$conditions['userId'] = $this->POD->currentUser()->get('id');
$sort = 'GROUP by targetUserId ORDER BY max(date) DESC';
$tables = 'FROM messages m';
$select = 'SELECT m.targetUserId as id, m.userId as ownerId,m.targetUserId,max(m.date) as latestMessage,(TIME_TO_SEC(TIMEDIFF(NOW(),max(date))) / 60) as minutes';
parent::Stack($POD, 'threads', $conditions, $sort, $count, $offset, $tables, $select);
return $this;
}
示例5: action_admin_header
function action_admin_header()
{
$url = URL::get('auth_ajax', 'context=extendedlog');
$script = <<<SCRIPT
\$(function(){
\tvar initi = itemManage.initItems;
\titemManage.initItems = function(){
\t\tiniti();
\t\t\$('.page-logs .manage .item .less,.page-logs .manage .item .message.minor').hide();
\t\t\$('.page-logs .manage .item .more').show().css({clear: 'both', marginLeft: '40px', fontWeight: 'bold', width: '100%'});
\t\t\$('.page-logs .manage .item').click(function(){
\t\t\t\$('.extendedlog').remove();
\t\t\t\$(this).after('<div class="extendedlog"><div class="textarea" style="white-space:pre;font-family:consolas,courier new,monospace;border:1px solid #999;padding:20px;margin:20px 0px;height:100px;overflow-y:auto;">Loading...</div></div>');
\t\t\t\$('.extendedlog .textarea').resizeable();
\t\t\t\$.post(
\t\t\t\t'{$url}',
\t\t\t\t{
\t\t\t\t\tlog_id: \$('.checkbox input', \$(this)).attr('id').match(/\\[([0-9]+)\\]/)[1]
\t\t\t\t},
\t\t\t\tfunction(result){
\t\t\t\t\t\$('.extendedlog .textarea').html(result)
\t\t\t\t}
\t\t\t);
\t\t});
\t}
});
SCRIPT;
Stack::add('admin_header_javascript', $script, 'extendedlog', array('jquery', 'admin'));
}
示例6: get_dashboard
/**
* Handles get requests for the dashboard
* @todo update check should probably be cron'd and cached, not re-checked every load
*/
public function get_dashboard()
{
// Not sure how best to determine this yet, maybe set an option on install, maybe do this:
$firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
if ($firstpostdate) {
$this->theme->active_time = DateTime::create($firstpostdate);
}
// check to see if we have updates to display
$this->theme->updates = Options::get('updates_available', array());
// collect all the stats we display on the dashboard
$user = User::identify();
$this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'post_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total('approved', false), 'tag_count' => Tags::vocabulary()->count_total(), 'user_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('draft'), 'user_id' => $user->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total('unapproved', false) : Comments::count_by_author(User::identify()->id, Comment::status('unapproved')), 'spam_comment_count' => $user->can('manage_all_comments') ? Comments::count_total('spam', false) : Comments::count_by_author($user->id, Comment::status('spam')), 'user_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => $user->id)));
// check for first run
$u = User::identify();
$uinfo = $u->info;
if (!isset($uinfo->experience_level)) {
$this->theme->first_run = true;
$u->info->experience_level = 'user';
$u->info->commit();
} else {
$this->theme->first_run = false;
}
$this->get_additem_form();
Stack::add('admin_header_javascript', 'dashboard-js');
$this->display('dashboard');
}
示例7: action_admin_header
/**
* Add appropriate CSS to this plugin's configuration form
*/
public function action_admin_header($theme)
{
$vars = Controller::get_handler_vars();
if ($theme->admin_page == 'plugins' && isset($vars['configure']) && $vars['configure'] === $this->plugin_id) {
Stack::add('admin_stylesheet', array($this->get_url() . '/metaseo.css', 'screen'));
}
}
示例8: call
public static function call($hook, $args = null)
{
// Run all registered functions of called hookpoint
$functions = Stack::get("hook:" . $hook);
foreach ($functions as $function) {
if (is_array($function)) {
if (is_string($function[0]) && class_exists($function[0])) {
$instance = new $function[0]();
} else {
$instance = $function[0];
}
if (method_exists($instance, $function[1])) {
$args = $instance->{$function}[1]($args);
} else {
throw new Exception("Hooked method '{$function[1]}' of class '{$function[0]}' for hookpoint '{$hook}' not found!");
}
} else {
if (function_exists($function)) {
$args = $function($args);
} else {
throw new Exception("Hooked function '{$function}' for hookpoint '{$hook}' not found!");
}
}
}
// Return possibly modified arguments
return $args;
}
示例9: view_details
public function view_details($cID, $msg = false) {
$s = Stack::getByID($cID);
if (is_object($s)) {
$blocks = $s->getBlocks('Main');
$view = View::getInstance();
foreach($blocks as $b1) {
$btc = $b1->getInstance();
// now we inject any custom template CSS and JavaScript into the header
if('Controller' != get_class($btc)){
$btc->outputAutoHeaderItems();
}
$btc->runTask('on_page_view', array($view));
}
$this->addHeaderItem('<style type="text/css">' . $s->outputCustomStyleHeaderItems(true) . '</style>');
$this->set('stack', $s);
$this->set('blocks', $blocks);
switch($msg) {
case 'delete_saved':
$this->set('message', t('Delete request saved. You must complete the delete workflow before this stack can be deleted.'));
break;
}
} else {
throw new Exception(t('Invalid stack'));
}
}
示例10: OutputException
public function OutputException()
{
echo '<h1>Error.</h1>';
echo '<p>Stack Trace</p>';
// Show base
$msg = sprintf(err_exception, __CLASS__, $this->code, "<i>" . $this->message . '</i> attempting to run process ' . Stack::Top());
$basearray = array('class' => __CLASS__, 'code' => $this->code, 'message' => $this->message, 'file' => $this->file, 'line' => $this->line);
self::Render('Error Base', $msg, $basearray);
// Show codelines
$codelines = self::GetCodeLines(5);
self::Render('Source', 'From ' . $this->file . ' around line ' . $this->line, implode($codelines, ''));
// Show backtrace
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
if (count($trace) > 1) {
unset($trace[0]);
}
self::Render('Backtrace', null, $trace);
// Show stack
$stack = array();
for ($i = 0; $i < Stack::Count(); $i++) {
$stack[$i] = Stack::Get($i);
}
$msg = 'Stack pointer at position #' . Stack::Pointer() . ' (' . Stack::Top() . ')';
self::Render('Stack', $msg, $stack);
// Show requests
self::Render('Requests', null, $_REQUEST);
}
示例11: on_page_view
public function on_page_view()
{
$stack = Stack::getByID($this->stID);
if (!is_object($stack)) {
return false;
}
$p = new Permissions($stack);
if ($p->canViewPage()) {
$blocks = $stack->getBlocks();
foreach ($blocks as $b) {
$bp = new Permissions($b);
if ($bp->canViewBlock()) {
$btc = $b->getInstance();
if ('Controller' != get_class($btc)) {
$btc->outputAutoHeaderItems();
}
$csr = $b->getBlockCustomStyleRule();
if (is_object($csr)) {
$styleHeader = '#' . $csr->getCustomStyleRuleCSSID(1) . ' {' . $csr->getCustomStyleRuleText() . "} \r\n";
$btc->addHeaderItem("<style type=\"text/css\"> \r\n" . $styleHeader . '</style>', 'VIEW');
}
$btc->runTask('on_page_view', array($view));
}
}
}
}
示例12: __construct
public function __construct()
{
// Enforce time limit, ignore aborts
set_time_limit(2);
ignore_user_abort();
// Load constants
require_once 'system/core/constants.php';
// Set error reporting (debuging mode)
if (debug) {
error_reporting(E_ALL ^ E_DEPRECATED);
}
// Load security
require_once 'system/core/security.php';
// Load dependencies
require_once 'system/core/dependencies.php';
// Session handling
date_default_timezone_set(local_timezone);
session_start();
// Initialize the stack (stack routing)
Stack::Push((isset($_REQUEST[route_key]) and trim($_REQUEST[route_key]) != '') ? $_REQUEST[route_key] : route_home);
// Initialize buffering
ob_start();
// Cycle the processes stack, run all the processors sucessively until the stack is empty.
while (Stack::Ahead() > 0) {
// Pre-init / re-init 'found' flag (in case the stack had multiple items)
$found = false;
// Catch anything that might happen
try {
foreach (route_repos as $rep => $types) {
if (!is_array($types)) {
$types = array($types);
}
foreach ($types as $t) {
$p = $rep . Stack::Top() . $t;
if (is_file($p)) {
$found = true;
// Update the output sequencer
Output::Path(Stack::Path());
if (!(include $p)) {
throw new SystemException(sprintf(err_include500, Stack::Top()));
}
break 2;
}
}
}
if (!$found) {
throw new SystemException(sprintf(err_include404, Stack::Top()));
}
// Processor completed; pop the stack
Stack::Pop();
} catch (Exception $e) {
throw new SystemException($e);
}
}
$this->buffer = ob_get_contents();
ob_end_clean();
// Pass the buffer to the output handler for final render
Output::Flush($this->buffer);
exit(1);
}
示例13: GetInstance
/**
* @return Stack
*/
public static function GetInstance()
{
if (!self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
示例14: filter_theme_call_header
public function filter_theme_call_header($return, $theme)
{
if (User::identify() != FALSE) {
Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery');
}
return $return;
}
示例15: 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)' );
}