public function theme_monthly_archives_links_list($theme, $full_names = TRUE, $show_counts = TRUE, $type = 'entry', $status = 'published') { $results = Posts::get(array('content_type' => $type, 'status' => $status, 'month_cts' => 1)); $archives[] = ''; foreach ($results as $result) { // add leading zeros $result->month = str_pad($result->month, 2, 0, STR_PAD_LEFT); // what format do we want to show the month in? if ($full_names) { $display_month = HabariDateTime::date_create()->set_date($result->year, $result->month, 1)->get('F'); } else { $display_month = HabariDateTime::date_create()->set_date($result->year, $result->month, 1)->get('M'); } // do we want to show the count of posts? if ($show_counts) { $count = ' (' . $result->ct . ')'; } else { $count = ''; } $archives[] = '<li>'; $archives[] = '<a href="' . URL::get('display_entries_by_date', array('year' => $result->year, 'month' => $result->month)) . '" title="View entries in ' . $display_month . '/' . $result->year . '">' . $display_month . ' ' . $result->year . ' ' . $count . '</a>'; $archives[] = '</li>'; } $archives[] = ''; return implode("\n", $archives); }
/** * Add some variables to the template output */ public function add_template_vars() { // Use theme options to set values that can be used directly in the templates // Don't check for constant values in the template code itself $this->assign('show_title_image', self::SHOW_TITLE_IMAGE); $this->assign('home_label', self::HOME_LABEL); $this->assign('show_powered', self::SHOW_POWERED); $this->assign('display_login', self::DISPLAY_LOGIN); $this->assign('tags_in_multiple', self::TAGS_IN_MULTIPLE); $this->assign('post_class', 'post' . (!self::SHOW_ENTRY_PAPERCLIP ? ' alt' : '')); $this->assign('page_class', 'post' . (!self::SHOW_PAGE_PAPERCLIP ? ' alt' : '')); $this->assign('show_post_nav', self::SHOW_POST_NAV); $locale = Options::get('locale'); if (file_exists(Site::get_dir('theme', true) . $locale . '.css')) { $this->assign('localized_css', $locale . '.css'); } else { $this->assign('localized_css', false); } if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0); // Add FormUI template placing the input before the label $this->add_template('charcoal_text', dirname(__FILE__) . '/formcontrol_text.php'); parent::add_template_vars(); }
/** * 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'); }
public function add_template_vars() { //TODO: Fully support localization; //theme configuration $this->assign('da_feedtext', $this->options['darkautumn__feedtext']); $this->assign('da_maintenancetitle', $this->options['darkautumn__maintenancetitle']); $this->assign('da_blurbtext', $this->options['darkautumn__blurbtext']); $this->assign('da_sidenotes_tag', $this->options['darkautumn__sidenotestag']); $this->base_url = Site::get_url('habari'); //TODO: use assign instead $this->theme_url = Site::get_url('theme'); //TODO: use assign instead if (!$this->posts) { $this->posts = Posts::get(array('content_type' => 'entry', 'status' => Post::status('published'))); } if (!$this->pages) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } if (!$this->sidenotes) { $this->assign('sidenotes', Posts::get(array('tag' => $this->options['darkautumn__sidenotestag'], 'limit' => 5))); } if (!$this->page) { $this->page = isset($page) ? $page : 1; //TODO: use assign instead } $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0); parent::add_template_vars(); }
/** * 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() { //Theme Options $this->assign('home_tab', 'Home'); //Set to whatever you want your first tab text to be. $this->assign('show_author', false); //Display author in posts if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } if (!$this->template_engine->assigned('page')) { $page = Controller::get_var('page'); $this->assign('page', isset($page) ? $page : 1); } parent::add_template_vars(); //from mzingi //visiting page/2, /3 will offset to the next page of posts in the sidebar $page = Controller::get_var('page'); $pagination = Options::get('pagination'); if ($page == '') { $page = 1; } $this->assign('more_posts', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $pagination * $page, 'limit' => 5))); //from mzingi //for recent comments loop in sidebar.php $this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC'))); }
/** * 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'))); $this->theme->active_time = HabariDateTime::date_create($firstpostdate); // get the active theme, so we can check it // @todo this should be worked into the main Update::check() code for registering beacons $active_theme = Themes::get_active(); $active_theme = $active_theme->name . ':' . $active_theme->version; // 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 $this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, false), 'tag_count' => Tags::vocabulary()->count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id))); $this->fetch_dashboard_modules(); // check for first run $u = User::identify(); if (!isset($u->info->experience_level)) { $this->theme->first_run = true; $u->info->experience_level = 'user'; $u->info->commit(); } else { $this->theme->first_run = false; } $this->display('dashboard'); }
/** * 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() { if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } if (!$this->template_engine->assigned('user')) { $this->assign('user', User::identify()); } if (!$this->template_engine->assigned('tags')) { $this->assign('tags', Tags::get()); } if (!$this->template_engine->assigned('page')) { $this->assign('page', isset($page) ? $page : 1); } if (!$this->template_engine->assigned('feed_alternate')) { $matched_rule = URL::get_matched_rule(); switch ($matched_rule->name) { case 'display_entry': case 'display_page': $feed_alternate = URL::get('atom_entry', array('slug' => Controller::get_var('slug'))); break; case 'display_entries_by_tag': $feed_alternate = URL::get('atom_feed_tag', array('tag' => Controller::get_var('tag'))); break; case 'display_home': default: $feed_alternate = URL::get('atom_feed', array('index' => '1')); } $this->assign('feed_alternate', $feed_alternate); } // Specify pages you want in your navigation here $this->assign('nav_pages', Posts::get(array('content_type' => 'page', 'status' => 'published', 'nolimit' => 1))); parent::add_template_vars(); }
/** * 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() { $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true); $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true); if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } if (!$this->template_engine->assigned('user')) { $this->assign('user', User::identify()); } if (!$this->template_engine->assigned('page')) { $this->assign('page', isset($page) ? $page : 1); } if (!$this->template_engine->assigned('feed_alternate')) { $matched_rule = URL::get_matched_rule(); switch ($matched_rule->name) { case 'display_entry': case 'display_page': $feed_alternate = URL::get('entry', array('slug' => Controller::get_var('slug'))); break; case 'display_entries_by_tag': $feed_alternate = URL::get('tag_collection', array('tag' => Controller::get_var('tag'))); break; case 'index_page': default: $feed_alternate = URL::get('collection', array('index' => '1')); } $this->assign('feed_alternate', $feed_alternate); } parent::add_template_vars(); }
/** * Produce the content for the latest drafts block * @param Block $block The block object * @param Theme $theme The theme that the block will be output with */ public function action_block_content_draft_posts($block, $theme) { $block->recent_posts = Posts::get(array('status' => 'draft', 'limit' => 8, 'user_id' => User::identify()->id)); if (User::identify()->can('manage_entries')) { $block->link = URL::get('admin', array('page' => 'posts', 'status' => Post::status('draft'), 'user_id' => User::identify()->id)); } }
/** * Add some variables to the template output */ public function add_template_vars() { if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } $page = Controller::get_var('page'); $page = isset($page) ? $page : 1; if (!$this->template_engine->assigned('page')) { $this->assign('page', $page); } $this->assign('show_previously', false); $this->assign('show_latest', false); $action = Controller::get_action(); if ($action == 'display_home' || $action == 'display_entries') { $offset = (int) (($page + 1 - 1) * Options::get('pagination')); $this->assign('previously', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $offset, 'limit' => self::PREVIOUSLY_ITEMS))); $this->assign('show_previously', true); } if ($action != 'display_home') { $this->assign('latest', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => 0, 'limit' => self::LATEST_ITEMS))); $this->assign('show_latest', true); } $this->assign('controller_action', $action); parent::add_template_vars(); }
public function SitemapBuild() { //return cached sitemap if exsist if (Cache::has('sitemap')) { $xml = Cache::get('sitemap'); } else { $types = Options::get_group(__CLASS__); //..or generate a new one $xml = '<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="' . $this->get_url() . '/sitemap.xsl"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>'; $xml = new SimpleXMLElement($xml); if (array_key_exists('any', $types) && $types['any'] || empty($types)) { // Retrieve all published content, regardless of the type $content['any'] = Posts::get(array('content_type' => 'any', 'status' => 'published', 'nolimit' => 1)); } else { // Retreive all published content for select content types $content['posts'] = Posts::get(array('content_type' => array_keys($types, 1), 'status' => 'published', 'nolimit' => 1)); } // Add the index page first $url = $xml->addChild('url'); $url_loc = $url->addChild('loc', Site::get_url('habari')); // Generate the `<url>`, `<loc>`, `<lastmod>` markup for each post and page. foreach ($content as $entries) { foreach ($entries as $entry) { $url = $xml->addChild('url'); $url_loc = $url->addChild('loc', $entry->permalink); $url_lastmod = $url->addChild('lastmod', $entry->updated->get('c')); } } $xml = $xml->asXML(); Cache::set('sitemap', $xml); } return $xml; }
public function add_template_vars() { //Theme Options $this->assign('show_author', true); //Display author in posts // How many months should be displayed by the RN Archives plugin $this->assign('rn_archives_months', 2); // Links list $this->assign('links_list', array('Follow me on Twitter' => 'http://twitter.com/sebastianp')); if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } // Fetch the last 5 posts, for displaying in the quickbar if (!$this->template_engine->assigned('latest_posts')) { $this->assign('latest_posts', Posts::get(array('content_type' => 'entry', 'status' => Post::status('published'), 'limit' => 5))); } // Fetch the last 5 comments, for displaying in the quickbar if (!$this->template_engine->assigned('latest_comments')) { $this->assign('latest_comments', Comments::get(array('status' => Comment::STATUS_APPROVED))); } if (!$this->template_engine->assigned('taglist')) { $this->assign('taglist', $this->theme_show_tags()); } // Fetch all the posts if (!$this->template_engine->assigned('archives')) { $this->assign('archives', Posts::get(array('content_type' => 'entry', 'status' => Post::status('published')))); } parent::add_template_vars(); }
public function act_packages() { $packages = Posts::get(array('content_type' => 'plugin', 'nolimit' => true)); $xml = new SimpleXMLElement('<packages/>'); foreach ($packages as $package) { if (!$package->info->guid) { continue; } $package_node = $xml->addChild('package'); $package_node->addChild('description', utf8_encode(Format::summarize(strip_tags($package->content)))); $package_node->addAttribute('guid', $package->info->guid); $package_node->addAttribute('name', $package->title); if ($package->info->author) { $package_node->addAttribute('author', $package->info->author); } if ($package->info->author_url) { $package_node->addAttribute('author_url', $package->info->author_url); } $package_node->addAttribute('type', 'plugin'); $package_node->addAttribute('tags', implode(',', (array) $package->tags)); $versions_node = $package_node->addChild('versions'); foreach ($package->versions as $version) { if ($version->habari_version) { $version_node = $versions_node->addChild('version', $version->description); $version_node->addAttribute('version', $version->version); $version_node->addAttribute('archive_md5', $version->md5); $version_node->addAttribute('archive_url', $version->url); $version_node->addAttribute('habari_version', $version->habari_version); } } } ob_clean(); header('Content-Type: application/xml'); echo $xml->asXml(); }
/** * Populate a block with the popular entries **/ public function action_block_content_popular_posts($block, $theme) { if (!($limit = $block->quantity)) { $limit = 5; } $block->popular_posts = Posts::get(array('content_type' => 'entry', 'has:info' => 'views', 'orderby' => 'CAST(hipi1.value as UNSIGNED) DESC', 'limit' => $limit)); }
/** * Respond to the URL that was created * Determine the post that was supposed to be displayed, and show it in raw * @params array $handlervars An array of values passed in from the URL requested */ function action_plugin_act_plaintext($handlervars) { $activetheme = Themes::create(); $user_filters = array('fetch_fn' => 'get_row', 'limit' => 1); $page_key = array_search('page', $activetheme->valid_filters); unset($activetheme->valid_filters[$page_key]); $user_filters = Plugins::filter('template_user_filters', $user_filters); $user_filters = array_intersect_key($user_filters, array_flip($activetheme->valid_filters)); $where_filters = Controller::get_handler()->handler_vars->filter_keys($activetheme->valid_filters); $where_filters = $where_filters->merge($user_filters); $where_filters = Plugins::filter('template_where_filters', $where_filters); $post = Posts::get($where_filters); $current_url = URL::get(); $created_at = $post->pubdate->get(); header('Content-type: text/plain; charset=utf-8'); echo <<<HERE # {$post->title} By {$post->author->displayname} <{$current_url}> {$created_at} \t {$post->content} HERE; exit; }
/** * Add additional template variables to the template output. * * 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(); if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get('page_list')); } if (!$this->template_engine->assigned('asides')) { //For Asides loop in sidebar.php $this->assign('asides', Posts::get('asides')); } if (!$this->template_engine->assigned('recent_comments')) { //for recent comments loop in sidebar.php $this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC'))); } if (!$this->template_engine->assigned('more_posts')) { //Recent posts in sidebar.php //visiting page/2 will offset to the next page of posts in the footer /3 etc $pagination = Options::get('pagination'); $this->assign('more_posts', Posts::get(array('content_type' => 'entry', 'status' => 'published', 'vocabulary' => array('tags:not:tag' => 'asides'), 'offset' => $pagination * $this->page, 'limit' => 5))); } if (!$this->template_engine->assigned('all_tags')) { // List of all the tags $this->assign('all_tags', Tags::vocabulary()->get_tree()); } if (!$this->template_engine->assigned('all_entries')) { // List of all the entries $this->assign('all_entries', Posts::get(array('content_type' => 'entry', 'status' => 'published', 'nolimit' => 1))); } }
public function act_request() { // @todo limit this to GUIDs POST'd $plugins = Posts::get(array('content_type' => 'addon', 'nolimit' => true, 'status' => Post::status('published'))); $xml = new SimpleXMLElement('<updates></updates>'); foreach ($plugins as $plugin) { // if we don't have any versions, skip this plugin if (empty($plugin->info->versions)) { //continue; } // create the beacon's node $beacon = $xml->addChild('beacon'); $beacon['id'] = $plugin->info->guid; $beacon['name'] = $plugin->title; $beacon['url'] = $plugin->permalink; $beacon['type'] = $plugin->info->type; foreach ($plugin->info->versions as $version) { // @todo limit this to only versions older than the one POST'd $update = $beacon->addChild('update', $version['description']); $update['severity'] = $version['severity']; $update['version'] = $version['version']; $update['habari_version'] = $version['habari_version']; $update['url'] = $version['url']; $update['date'] = HabariDateTime::date_create($version->date)->format('c'); } } // spit out the xml ob_clean(); // clean the output buffer header('Content-type: application/xml'); echo $xml->asXML(); }
public function EmDestaque() { if ($this->get->id) { $this->views->post_id = $this->get->id; $this->views->search_data = Posts::get($this->get->id); } $this->views->data = Posts::em_destaque(); $this->views->display('posts-em-destaque.phtml'); }
protected function module_teardown() { $posts = Posts::get( array('user_id' => $this->user->id )); foreach ( $posts as $post ) { $post->delete(); } $this->user->delete(); unset($this->user); }
/** * Respond to call to $theme->linkoid() in template * * @param string $return The return value to the template function (passed through other potential plugin calls) * @param Theme $theme The theme object * @param string $tag An optional tag to use instead of the one defined in the plugin options. * @return string The return value to the template function */ public function theme_linkoid($theme, $tag = null) { if (!isset($tag)) { $tag = Options::get('linkoid__show'); } $linkoids = Posts::get(array('tag_slug' => $tag, 'limit' => Options::get('linkoid__count'))); $theme->linkoids = $linkoids; return $theme->fetch('linkoid'); }
public function add_template_vars() { //Theme Options $this->assign('show_author', true); //Display author in posts if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } parent::add_template_vars(); }
public static function get_reports($params = array()) { $params['content_type'] = Post::type('report'); $params['nolimit'] = true; if ($params['tag'] != NULL) { $params['vocabulary'] = array('tags:term' => $params['tag']); unset($params['tags']); } return Posts::get($params); }
public function add_template_vars() { $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true); $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true); $this->recent_comments = Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')); $this->recent_posts = Posts::get(array('limit' => 5, 'orderby' => 'pubdate DESC', 'content_type' => Post::type('entry'), 'status' => Post::status('published'))); if (!$this->template_engine->assigned('pages')) { $this->pages = Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)); } parent::add_template_vars(); }
protected function module_teardown() { if ($this->comment instanceof Comment) { $this->comment->delete(); } unset($this->comment); $posts = Posts::get(array('user_id' => $this->user->id)); foreach ($posts as $post) { $post->delete(); } $this->user->delete(); unset($this->user); }
public function action_form_user($form, User $edit_user) { $fieldset = $form->insert('change_password', 'wrapper', 'client_info', 'Client Information'); $fieldset->class = 'container settings'; $fieldset->append('static', 'client_info', '<h2>Client Information</h2>'); $clients = Posts::get(array('content_type' => 'client', 'status' => 'published')); $client_options = array(); foreach ($clients as $client) { $client_options[$client->id] = $client->title; } $fieldset->append(new FormControlSelect('client', $edit_user, 'Client', $client_options, 'optionscontrol_select'))->class[] = 'item clear'; $fieldset->append(new FormControlText('phone', $edit_user, 'Contact Phone', 'optionscontrol_text'))->class[] = 'item clear'; }
public function add_template_vars() { if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } // Comment form $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true); $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true); $this->add_template('formcontrol_submit', dirname(__FILE__) . '/forms/formcontrol_submit.php', true); // Display author $this->assign('show_author', true); parent::add_template_vars(); }
public function action_theme_ui($theme) { $ui = new FormUI(__CLASS__); // Potential Static home page $page = $ui->append('select', 'page', 'criticalhit__home', _t('The page to show for the home page: ', 'staticfront')); $page->options['--none--'] = _t('Show Normal Posts', 'staticfront'); foreach (Posts::get(array('content_type' => Post::type('page'), 'nolimit' => 1)) as $post) { $page->options[$post->slug] = $post->title; } // Save $ui->append('submit', 'save', _t('Save')); $ui->set_option('success_message', _t('Options saved')); $ui->out(); }
/** * Respond to Javascript callbacks * The name of this method is action_ajax_ followed by what you passed to the context parameter above. */ public function action_ajax_instant_search($handler) { // Get the data that was sent $response = $handler->handler_vars['q']; // Wipe anything else that's in the buffer ob_end_clean(); $new_response = Posts::get(array("criteria" => $response)); $final_response = array(); foreach ($new_response as $post) { $final_response[] = array('title' => $post->title, 'content' => $post->content, 'pubdate' => $post->pubdate->format(), 'updated' => $post->updated->format(), 'modified' => $post->modified->format(), 'url' => $post->permalink); } // Send the response echo json_encode($final_response); }
/** * Add various elements for the OpenSearch protocol to work * * @param string $xml XML generated so far by the AtomHandler::get_collection() method * @param array $params Parameters used to fetch results, will be used to find total results and where to start (index) * @return string XML OpenSearch results Atom feed */ public function filter_atom_get_collection($xml, $params) { $criteria = $params['criteria']; $totalResults = Posts::get($params)->count_all(); $startIndex = isset($params['page']) ? $params['page'] : 1; $itemsPerPage = isset($this->handler_vars['count']) ? $this->handler_vars['count'] : Options::get('pagination'); $xml->addChild('opensearch:totalResults', $totalResults); $xml->addChild('opensearch:startIndex', $startIndex); $xml->addChild('opensearch:itemsPerPage', $itemsPerPage); $xml_os_query = $xml->addChild('opensearch:Query'); $xml_os_query->addAttribute('role', 'request'); $xml_os_query->addAttribute('searchTerms', $criteria); $xml_os_query->addAttribute('startPage', 1); return $xml; }
public function action_add_template_vars($theme, $handler_vars) { $items = array(); if (isset($theme->request->display_home) && $theme->request->display_home) { $posts = Posts::get(array('content_type' => Post::type('entry'), 'status' => Post::status('published'), 'nolimit' => true, 'orderby' => 'pubdate ASC')); foreach ($posts as $post) { $item = array(); $item['url'] = $post->permalink; $item['title'] = $post->title; $item['time'] = strtotime($post->pubdate); $items[] = $item; } } $theme->timeline_items = $items; }