/** * 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('/')); }
/** * @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; }
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'); }
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; }
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')); }
/** * 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'); }
/** * 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')); } }
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; }
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')); } }
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); }
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)); } } } }
/** * Constructor * * @param string $template */ public function __construct($name, $template = NULL, $base_uri = NULL) { parent::__construct($name); cogear()->menu->register($name, $this); $template && ($this->template = $template); $this->base_uri = rtrim(parse_url($base_uri ? $base_uri : Url::link(), PHP_URL_PATH), '/') . '/'; }
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); }
/** * register a class for startup * @param string $classname * @param bool $useDI */ public static function add($classname, $useDI = false) { if (is_array(self::$startup) && is_array(self::$DIstartup)) { if ($useDI) { self::$DIstartup[] = $classname; } else { self::$startup[] = $classname; } } else { if ($useDI) { self::$DIstartup->push($classname); } else { self::$startup->push($classname); } } }
/** * @return Stack */ public static function GetInstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
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; }
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)' ); }
public function expression($str) { $input = new Stack(); $output = new Stack(); foreach ($this->tokenizer->tokenize($str) as $token) { $part = Dictionary::fromString($token); $part->isOperator() ? $input->push($part) : $output->push($part); } while ($operator = $input->pop()) { $output->push($operator); } // Ran out of time, this'll only work with addition $op = $output->pop(); $val = $op->operate($output); return $val; }
public function setPermissionObject(Area $a) { $ax = $a; if ($a->isGlobalArea()) { $cx = Stack::getByName($a->getAreaHandle()); $a = Area::get($cx, STACKS_AREA_NAME); } $this->permissionObject = $a; // if the area overrides the collection permissions explicitly (with a one on the override column) we check if ($a->overrideCollectionPermissions()) { $this->permissionObjectToCheck = $a; } else { if ($a->getAreaCollectionInheritID() > 0) { // in theory we're supposed to be inheriting some permissions from an area with the same handle, // set on the collection id specified above (inheritid). however, if someone's come along and // reverted that area to the page's permissions, there won't be any permissions, and we // won't see anything. so we have to check $areac = Page::getByID($a->getAreaCollectionInheritID()); $inheritArea = Area::get($areac, $a->getAreaHandlE()); if (is_object($inheritArea) && $inheritArea->overrideCollectionPermissions()) { // okay, so that area is still around, still has set permissions on it. So we // pass our current area to our grouplist, userinfolist objects, knowing that they will // smartly inherit the correct items. $this->permissionObjectToCheck = $inheritArea; } } if (!$this->permissionObjectToCheck) { $this->permissionObjectToCheck = $a->getAreaCollectionObject(); } } }
/** * Actually add the required javascript to the publish page * @param Theme $theme The admin theme instance **/ public function action_admin_header($theme) { if( $theme->page == 'publish' ) { Stack::add( 'admin_header_javascript', 'multicomplete' ); Stack::add( 'admin_header_javascript', 'tags_auto' ); } }
public function __construct() { parent::__construct(); $request = $this->request; $arHandle = $request->query->get('arHandle'); $bID = $request->query->get('bID'); $a = \Area::get($this->page, $arHandle); if (!is_object($a)) { throw new \Exception('Invalid Area'); } $this->area = $a; if (!$a->isGlobalArea()) { $b = \Block::getByID($bID, $this->page, $a); $this->set('isGlobalArea', false); } else { $stack = \Stack::getByName($arHandle); $sc = ConcretePage::getByID($stack->getCollectionID(), 'RECENT'); $b = \Block::getByID($bID, $sc, STACKS_AREA_NAME); $b->setBlockAreaObject($a); // set the original area object $this->set('isGlobalArea', true); } $this->block = $b; $this->permissions = new \Permissions($b); $this->set('bp', $this->permissions); $this->set('b', $b); }
/** * Add the tracking code to the template_header_javascript Stack. * * @todo determine if there is a better action to use * @return null */ public function action_init_theme_any($theme) { $code = $this->tracking_code(); if ($code != null) { Stack::add('template_header_javascript', $code, 'googleanalytics'); } }
/** * Add additional template variables to the template output. * * You can assign additional output values in the template here, instead of * having the PHP execute directly in the template. The advantage is that * you would easily be able to switch between template types (RawPHP/Smarty) * without having to port code from one to the other. * * You could use this area to provide "recent comments" data to the template, * for instance. * * Note that the variables added here should possibly *always* be added, * especially 'user'. * * Also, this function gets executed *after* regular data is assigned to the * template. So the values here, unless checked, will overwrite any existing * values. */ public function add_template_vars ( ) { parent::add_template_vars(); $this->home_tab = 'Blog'; $this->show_author = false; $this->add_template( 'k2_text', dirname( __FILE__ ) . '/formcontrol_text.php' ); if ( !isset( $this->pages ) ) { $this->pages = Posts::get( array( 'content_type' => 'page', 'status' => 'published', 'nolimit' => true ) ); } if ( User::identify()->loggedin ) { Stack::add( 'template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery' ); } if ( ( $this->request->display_entry || $this->request->display_page ) && isset( $this->post ) && $this->post->title != '' ) { $this->page_title = $this->post->title . ' - ' . Options::get('title'); } else { $this->page_title = Options::get('title'); } }
private function pushIfNotNull($direction, BinaryTree $n) { $next = $n->{$direction}(); if ($next !== null) { $this->stack->push($next); } }
public function action_admin_header($theme) { if ($theme->page == 'configure_block' && $_GET['inline'] == 1) { Plugins::act('add_jwysiwyg_admin'); Stack::add('admin_stylesheet', array('#block_admin { display: none; } textarea { height: 250px; width: 540px; }', 'screen')); } }
/** * Load assets and add the CSS ones to the header on the template_stylesheet action hook. * @return void */ public function action_template_header_10() { $assets = $this->load_assets(); foreach ($assets['less'] as $less) { Stack::add('template_stylesheet', array($less, 'screen,projection,print', array('rel' => 'stylesheet/less'))); } Stack::add('template_footer_javascript', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', 'jquery'); }
public function action_init_theme() { Stack::add('template_stylesheet', array(URL::get_from_filesystem(__FILE__) . '/magicarchives.css', 'screen'), 'magicarchives'); Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery'); Stack::add('template_header_javascript', URL::get_from_filesystem(__FILE__) . '/magicarchives.js', 'magicarchives', array('jquery', 'ajax_manager')); Stack::add('template_header_javascript', URL::get_from_filesystem(__FILE__) . '/ajax_manager.js', 'ajax_manager', 'jquery'); Stack::add('template_header_javascript', 'magicArchives.endpoint=\'' . URL::get('ajax', array('context' => 'archive_posts')) . '\'', 'magicurl', 'magicarchives'); }
public function remove_template() { Post::deactivate_post_type('poll'); $this->remove_template('widget', dirname(__FILE__) . '/widget.php'); Stack::remove('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery'); Stack::remove('template_stylesheet', array(URL::get_from_filesystem(__FILE__) . '/widget.css', 'screen'), 'pollwigitcss'); $this->remove_template('poll.single', dirname(__FILE__) . '/poll.single.php'); }
public function action_template_header($theme) { // Add the stylesheets to the stack for output Stack::add('template_stylesheet', array(Site::get_url('theme') . '/style.css', 'screen')); Stack::add('template_stylesheet', array(Site::get_url('theme') . '/print.css', 'print')); Stack::add('template_header_javascript', 'jquery'); Stack::add('template_header_javascript', Site::get_url('them') . '/menu.js', 'select-menu', array('jquery')); }
/** * Add the required javascript to the publish page * @param Theme $theme The admin theme instance **/ public function action_admin_header($theme) { if ($theme->page == 'publish') { Stack::add('admin_header_javascript', $this->get_url(true) . 'tagtray.js', 'tagtray', 'jquery'); Stack::add('admin_footer_javascript', 'resetTags();', 'tagtray', 'tagtray'); Stack::add('admin_stylesheet', $this->get_url(true) . 'tagtray.css', 'tagtray'); } }