Example #1
1
 /**
  * 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('page')) {
         $page = Controller::get_var('page');
         $this->assign('page', isset($page) ? $page : 1);
     }
     $copyright = Options::get('simplerer__copyright_notice');
     if ($copyright == null) {
         $copyright = '© Copyright ' . date('Y') . '. All Rights Reserved.';
     } else {
         $copyright = str_replace('%year', date('Y'), $copyright);
     }
     $this->assign('copyright', $copyright);
     parent::add_template_vars();
 }
Example #2
1
	public function action_admin_footer( $theme ) 
	{
		if ( Controller::get_var( 'page' ) == 'publish' ) {
			$size = Options::get( 'flickrsilo__flickr_size' );
			switch ( $size ) {
				case '_s':
					$vsizex = 75;
					break;
				case '_t':
					$vsizex = 100;
					break;
				case '_m':
					$vsizex = 240;
					break;
				case '':
					$vsizex = 500;
					break;
				case '_b':
					$vsizex = 1024;
					break;
				case '_o':
					$vsizex = 400;
					break;
			}
			$vsizey = intval( $vsizex/4*3 );

			// Translation strings for used in embedding Javascript.  This is quite messy, but it leads to cleaner code than doing it inline.
			$embed_photo = _t( 'embed_photo' );
			$embed_video = _t( 'embed_video' );
			$thumbnail = _t( 'thumbnail' );
			$title = _t( 'Open in new window' );

			echo <<< FLICKR
			<script type="text/javascript">
				habari.media.output.flickr = {
					{$embed_photo}: function(fileindex, fileobj) {
						habari.editor.insertSelection('<a href="' + fileobj.flickr_url + '"><img alt="' + fileobj.title + '" src="' + fileobj.url + '"></a>');
					}
				}
				habari.media.output.flickrvideo = {
					{$embed_video}: function(fileindex, fileobj) {
						habari.editor.insertSelection('<object type="application/x-shockwave-flash" width="{$vsizex}" height="{$vsizey}" data="http://www.flickr.com/apps/video/stewart.swf?v=49235" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="intl_lang=en-us&amp;photo_secret=' + fileobj.secret + '&amp;photo_id=' + fileobj.id + '&amp;show_info_box=true"></param> <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=49235"></param> <param name="bgcolor" value="#000000"></param> <param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=49235" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=' + fileobj.secret + '&amp;photo_id=' + fileobj.id + '&amp;flickr_show_info_box=true" height="{$vsizey}" width="{$vsizex}"></embed></object>');
					},
					{$thumbnail}: function(fileindex, fileobj) {
						habari.editor.insertSelection('<a href="' + fileobj.flickr_url + '"><img alt="' + fileobj.title + '" src="' + fileobj.url + '"></a>');
					}
				}
				habari.media.preview.flickr = function(fileindex, fileobj) {
					var stats = '';
					return '<div class="mediatitle"><a href="' + fileobj.flickr_url + '" class="medialink" onclick="$(this).attr(\'target\',\'_blank\');" title="{$title}">media</a>' + fileobj.title + '</div><img src="' + fileobj.thumbnail_url + '"><div class="mediastats"> ' + stats + '</div>';
				}
				habari.media.preview.flickrvideo = function(fileindex, fileobj) {
					var stats = '';
					return '<div class="mediatitle"><a href="' + fileobj.flickr_url + '" class="medialink" onclick="$(this).attr(\'target\',\'_blank\');"title="{$title}" >media</a>' + fileobj.title + '</div><img src="' + fileobj.thumbnail_url + '"><div class="mediastats"> ' + stats + '</div>';
				}
			</script>
FLICKR;
		}
	}
Example #3
1
 /**
  * Display the plugin administration page
  */
 public function get_plugins()
 {
     $all_plugins = Plugins::list_all();
     $active_plugins = Plugins::get_active();
     $sort_active_plugins = array();
     $sort_inactive_plugins = array();
     foreach ($all_plugins as $file) {
         $plugin = array();
         $plugin_id = Plugins::id_from_file($file);
         $plugin['plugin_id'] = $plugin_id;
         $plugin['file'] = $file;
         $error = '';
         $providing = array();
         if (Utils::php_check_file_syntax($file, $error)) {
             $plugin['debug'] = false;
             $plugin['info'] = Plugins::load_info($file);
             if (array_key_exists($plugin_id, $active_plugins)) {
                 $plugin['verb'] = _t('Deactivate');
                 $pluginobj = $active_plugins[$plugin_id];
                 $plugin['active'] = true;
                 $plugin_actions = array();
                 $plugin_actions = Plugins::filter('plugin_config', $plugin_actions, $plugin_id);
                 $plugin['actions'] = array();
                 foreach ($plugin_actions as $plugin_action => $plugin_action_caption) {
                     if (is_numeric($plugin_action)) {
                         $plugin_action = $plugin_action_caption;
                     }
                     $action = array('caption' => $plugin_action_caption, 'action' => $plugin_action);
                     $urlparams = array('page' => 'plugins', 'configure' => $plugin_id);
                     $action['url'] = URL::get('admin', $urlparams);
                     if ($action['caption'] == _t('?')) {
                         if (isset($_GET['configaction'])) {
                             $urlparams['configaction'] = $_GET['configaction'];
                         }
                         if ($_GET['help'] != $plugin_action) {
                             $urlparams['help'] = $plugin_action;
                         }
                         $action['url'] = URL::get('admin', $urlparams);
                         $plugin['help'] = $action;
                     } else {
                         if (isset($_GET['help'])) {
                             $urlparams['help'] = $_GET['help'];
                         }
                         $urlparams['configaction'] = $plugin_action;
                         $action['url'] = URL::get('admin', $urlparams);
                         $plugin['actions'][$plugin_action] = $action;
                     }
                 }
                 $plugin['actions']['deactivate'] = array('url' => URL::get('admin', 'page=plugin_toggle&plugin_id=' . $plugin['plugin_id'] . '&action=deactivate'), 'caption' => _t('Deactivate'), 'action' => 'Deactivate');
                 if (isset($plugin['info']->provides)) {
                     foreach ($plugin['info']->provides->feature as $feature) {
                         $providing[(string) $feature] = $feature;
                     }
                 }
             } else {
                 // instantiate this plugin
                 // in order to get its info()
                 $plugin['active'] = false;
                 $plugin['verb'] = _t('Activate');
                 $plugin['actions'] = array('activate' => array('url' => URL::get('admin', 'page=plugin_toggle&plugin_id=' . $plugin['plugin_id'] . '&action=activate'), 'caption' => _t('Activate'), 'action' => 'activate'));
                 if (isset($plugin['info']->help)) {
                     if (isset($_GET['configaction'])) {
                         $urlparams['configaction'] = $_GET['configaction'];
                     }
                     if ($_GET['help'] != '_help') {
                         $urlparams['help'] = '_help';
                     }
                     $action['caption'] = _t('?');
                     $action['action'] = '_help';
                     $urlparams = array('page' => 'plugins', 'configure' => $plugin_id);
                     $action['url'] = URL::get('admin', $urlparams);
                     $plugin['help'] = $action;
                 }
             }
         } else {
             $plugin['debug'] = true;
             $plugin['error'] = $error;
             $plugin['active'] = false;
         }
         if (isset($this->handler_vars['configure']) && $this->handler_vars['configure'] == $plugin['plugin_id']) {
             if (isset($plugin['help']) && Controller::get_var('configaction') == $plugin['help']['action']) {
                 $this->theme->config_plugin_caption = _t('Help');
             } else {
                 if (isset($plugin['actions'][Controller::get_var('configaction')])) {
                     $this->theme->config_plugin_caption = $plugin['actions'][Controller::get_var('configaction')]['caption'];
                 } else {
                     $this->theme->config_plugin_caption = Controller::get_var('configaction');
                 }
             }
             unset($plugin['actions'][Controller::get_var('configaction')]);
             $this->theme->config_plugin = $plugin;
         } else {
             if ($plugin['active']) {
                 $sort_active_plugins[$plugin_id] = $plugin;
             } else {
                 $sort_inactive_plugins[$plugin_id] = $plugin;
             }
         }
     }
     // Get the features that the current theme provides
     $themeinfo = Themes::get_active_data();
     if (isset($themeinfo['info']->provides)) {
         foreach ($themeinfo['info']->provides->feature as $feature) {
             $providing[(string) $feature] = $feature;
         }
     }
     foreach ($sort_inactive_plugins as $plugin_id => $plugin) {
         if (isset($plugin['info']->requires)) {
             foreach ($plugin['info']->requires->feature as $feature) {
                 if (!isset($providing[(string) $feature])) {
                     if (!isset($sort_inactive_plugins[$plugin_id]['missing'])) {
                         $sort_inactive_plugins[$plugin_id]['missing'] = array();
                     }
                     $sort_inactive_plugins[$plugin_id]['missing'][(string) $feature] = isset($feature['url']) ? $feature['url'] : '';
                     unset($sort_inactive_plugins[$plugin_id]['actions']['activate']);
                 }
             }
         }
     }
     //$this->theme->plugins = array_merge($sort_active_plugins, $sort_inactive_plugins);
     $this->theme->assign('configaction', Controller::get_var('configaction'));
     $this->theme->assign('helpaction', Controller::get_var('help'));
     $this->theme->assign('configure', Controller::get_var('configure'));
     $this->theme->active_plugins = $sort_active_plugins;
     $this->theme->inactive_plugins = $sort_inactive_plugins;
     $this->theme->plugin_loader = Plugins::filter('plugin_loader', '', $this->theme);
     $this->display('plugins');
 }
Example #4
0
 public function add_template_vars()
 {
     //Theme Options
     $this->assign('header_text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.');
     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()->loggedin);
     }
     /*		if( !$this->template_engine->assigned( 'page' ) ) {
     			$this->assign('page', isset( $page ) ? $page : 1 );
     		}*/
     if (!$this->template_engine->assigned('all_tags')) {
         // List of all the tags
         $tags = Tags::get();
         $this->assign('all_tags', $tags);
     }
     //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)));
     parent::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);
 }
Example #5
0
 public function theme_title($theme)
 {
     $title = '';
     $hv = count($this->handler_vars) != 0 ? $this->handler_vars : Controller::get_handler()->handler_vars;
     $stitle = Options::get('title');
     if ($this->request->display_entries_by_date && count($hv) > 0) {
         $date = '';
         $date .= isset($hv['year']) ? $hv['year'] : '';
         $date .= isset($hv['month']) ? '-' . $hv['month'] : '';
         $date .= isset($hv['day']) ? '-' . $hv['day'] : '';
         $title = $date . ' - ' . $stitle;
     } elseif ($this->request->display_entries_by_tag && isset($hv['tag'])) {
         $title = $theme->tag . ' - ' . $stitle;
     } elseif (($this->request->display_entry || $this->request->display_page) && isset($this->posts)) {
         $title = strip_tags($this->posts->title) . ' - ' . $stitle;
     } elseif ($this->request->display_search) {
         // Set title to the search criteria, or to EMPTY if there were none.
         $q = Controller::get_var('criteria');
         $title = $q != '' ? htmlspecialchars($q) . ' - ' . $stitle . _t(' Search', 'sp') : sprintf(_t('Empty %1$s Search', 'sp'), $stitle);
     } else {
         $title = $stitle;
     }
     if ($this->page > 1) {
         $title .= _t(' &rsaquo; Page ') . $this->page;
     }
     return $title;
 }
Example #6
0
 /**
  * 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();
 }
Example #7
0
 /**
  * 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();
 }
Example #8
0
 /**
  * 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();
 }
 public function action_form_publish($form, $post)
 {
     $selector = $form->append('wrapper', 'type_selector');
     $selector->class = 'container';
     // Utils::debug( 'bob' );
     if (Controller::get_var('to_type') != NULL && $post->content_type != Controller::get_var('to_type')) {
         /* set type */
         $post->content_type = Post::type(Controller::get_var('to_type'));
         $post->update();
         Utils::redirect(URL::get('admin', 'page=publish&id=' . $post->id));
         // Refresh view
     }
     foreach (Post::list_active_post_types() as $type) {
         if ($type != 0) {
             if ($post->id == 0) {
                 $url = URL::get('admin', 'page=publish&content_type=' . Post::type_name($type));
             } else {
                 $url = URL::get('admin', 'page=publish&to_type=' . Post::type_name($type) . '&id=' . $post->id);
             }
             $html = '<a href="' . $url . '"';
             if (Post::type_name($type) == $post->content_type || $type == $post->content_type) {
                 $html .= ' class="active"';
             }
             $html .= '>' . Post::type_name($type) . '</a>';
             $selector->append('static', 'type_selector_' . $type, $html);
         }
     }
     $selector->move_before($selector, $form);
     return $form;
 }
Example #10
0
 /**
  * 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')));
 }
 /**
  * Filters the hadminstrip via Plugin API to add the edit menu item.
  *
  * @param array $menu The hadminstrip array
  * @return array The modified hadminstrip array
  */
 public function filter_hadminstrip($menu)
 {
     if (Controller::get_var('slug')) {
         $menu['write'] = array('Edit', URL::get('admin', 'page=publish&slug=' . Controller::get_var('slug')));
     }
     return $menu;
 }
 /**
  * Respond to post requests on the admin_cctypes template
  *
  * @param AdminHandler $handler The admin handler object
  * @param Theme $theme The admin theme object
  */
 function action_admin_theme_post_admin_cctypes($handler, $theme)
 {
     $action = Controller::get_var('cct_action');
     switch ($action) {
         case 'addtype':
             Post::add_new_type($_POST['newtype']);
             $typeid = Post::type($_POST['newtype']);
             $handled = Options::get('cctypes_types');
             if (!is_array($handled)) {
                 $handled = array();
             }
             $handled[$typeid] = $typeid;
             array_unique($handled);
             Options::set('cctypes_types', $handled);
             Session::notice(_t('Added post type "' . $_POST['newtype'] . '".'));
             break;
         case 'deletetype':
             $typename = Post::type_name($_POST['deltype']);
             Post::deactivate_post_type($_POST['deltype']);
             $handled = Options::get('cctypes_types');
             if (isset($handled[$_POST['deltype']])) {
                 unset($handled[$_POST['deltype']]);
             }
             Options::set('cctypes_types', $handled);
             Session::notice(_t('Deactivated post type "' . $typename . '".'));
     }
     Utils::redirect();
 }
	/**
	 * Filters the habminbar via Plugin API to add the edit menu item.
	 *
	 * @param array $menu The Habminbar array
	 * @return array The modified Habminbar array
	 */
	public function filter_habminbar( $menu )
	{
		if ( Controller::get_var('slug') ) {
			$post = Post::get('slug=' . Controller::get_var('slug'));
			$menu['write']= array( 'Edit', URL::get( 'admin', 'page=publish&id=' . $post->id ) );
		}
		return $menu;
	}
Example #14
0
 public function theme_route_event_ics($theme, $handler)
 {
     $slug = Controller::get_var('slug');
     $theme->post = Post::get(array('slug' => $slug));
     header('Content-type: text/x-vcalendar; charset=utf-8');
     header('content-disposition: inline; filename=' . $slug . '.ics');
     ob_end_clean();
     $theme->display('eventone.ics');
 }
Example #15
0
 public function filter_admin_access_tokens($require_any, $page, $type)
 {
     if ($page == 'admin') {
         if (Controller::get_var('page') == 'tests') {
             $require_any = array('manage_plugins' => true);
         }
     }
     return $require_any;
 }
Example #16
0
 /**
  * Handles GET requests for a group's page.
  */
 public function get_group()
 {
     $group = UserGroup::get_by_id(Controller::get_var('id'));
     if (null == $group) {
         Utils::redirect(URL::get('display_groups', 'page=groups'));
     } else {
         $tokens = ACL::all_tokens('id');
         $tokens = Plugins::filter('token_list_display', $tokens);
         array_walk($tokens, function (&$value, $key) {
             $value->description = Plugins::filter('token_description_display', $value->name);
             $value->token_group = Plugins::filter('token_group_display', $value->token_group);
         });
         $access_names = ACL::access_names();
         $access_names[] = 'deny';
         $access_display = array();
         foreach ($access_names as $name) {
             $access_display[$name] = Plugins::filter('permission_display', $name);
         }
         $bool_access_display['allow'] = Plugins::filter('permission_display', 'allow');
         $bool_access_display['deny'] = Plugins::filter('permission_display', 'deny');
         // attach access bitmasks to the tokens
         foreach ($tokens as $token) {
             $token->access = ACL::get_group_token_access($group->id, $token->id);
         }
         // separate tokens into groups
         $grouped_tokens = array();
         foreach ($tokens as $token) {
             $grouped_tokens[$token->token_group][$token->token_type ? 'crud' : 'bool'][] = $token;
         }
         $potentials = array();
         $users = Users::get_all();
         $users[] = User::anonymous();
         $members = $group->members;
         $jsusers = array();
         foreach ($users as $user) {
             $jsuser = new \StdClass();
             $jsuser->id = $user->id;
             $jsuser->username = $user->username;
             $jsuser->member = in_array($user->id, $members);
             $jsusers[$user->id] = $jsuser;
         }
         $this->theme->potentials = $potentials;
         $this->theme->users = $users;
         $this->theme->members = $members;
         $js = '$(function(){groupManage.init(' . json_encode($jsusers) . ');});';
         Stack::add('admin_header_javascript', $js, 'groupmanage', 'admin-js');
         $this->theme->access_names = $access_names;
         $this->theme->grouped_tokens = $grouped_tokens;
         $this->theme->access_display = $access_display;
         $this->theme->bool_access_display = $bool_access_display;
         $this->theme->groups = UserGroups::get_all();
         $this->theme->group = $group;
         $this->theme->id = $group->id;
         $this->theme->wsse = Utils::WSSE();
         $this->display('group');
     }
 }
Example #17
0
 /**
  * Handles GET requests for the theme listing
  */
 public function get_themes()
 {
     $all_themes = Themes::get_all_data();
     $available_updates = Options::get('updates_available', array());
     foreach ($all_themes as $name => $theme) {
         // only themes with a guid can be checked for updates
         if (isset($theme['info']->guid)) {
             if (isset($available_updates[(string) $theme['info']->guid])) {
                 // @todo this doesn't use the URL and is therefore worthless
                 $all_themes[$name]['info']->update = $available_updates[(string) $theme['info']->guid]['latest_version'];
             }
         }
     }
     $this->theme->all_themes = $all_themes;
     $this->theme->active_theme = Themes::get_active_data(true);
     $this->theme->active_theme_dir = $this->theme->active_theme['path'];
     // If the active theme is configurable, allow it to configure
     $this->theme->active_theme_name = $this->theme->active_theme['info']->name;
     $this->theme->configurable = Plugins::filter('theme_config', false, $this->active_theme);
     $this->theme->assign('configure', Controller::get_var('configure'));
     $activedata = Themes::get_active_data(true);
     $areas = array();
     if (isset($activedata['info']->areas->area)) {
         foreach ($activedata['info']->areas->area as $area) {
             $areas[] = (string) $area;
         }
     }
     $this->theme->areas = $areas;
     $this->theme->previewed = Themes::get_theme_dir(false);
     $this->theme->blocks = Plugins::filter('block_list', array());
     $this->theme->block_instances = DB::get_results('SELECT b.* FROM {blocks} b ORDER BY b.title ASC', array(), 'Block');
     $blocks_areas_t = DB::get_results('SELECT b.*, ba.scope_id, ba.area, ba.display_order FROM {blocks} b INNER JOIN {blocks_areas} ba ON ba.block_id = b.id ORDER BY ba.scope_id ASC, ba.area ASC, ba.display_order ASC', array());
     $blocks_areas = array();
     foreach ($blocks_areas_t as $block) {
         if (!isset($blocks_areas[$block->scope_id])) {
             $blocks_areas[$block->scope_id] = array();
         }
         $blocks_areas[$block->scope_id][$block->area][$block->display_order] = $block;
     }
     $this->theme->blocks_areas = $blocks_areas;
     $scopes = DB::get_results('SELECT * FROM {scopes} ORDER BY name ASC;');
     $scopes = Plugins::filter('get_scopes', $scopes);
     $this->theme->scopes = $scopes;
     $this->theme->scopeid = 0;
     $this->theme->theme_loader = Plugins::filter('theme_loader', '', $this->theme);
     $this->theme->display('themes');
 }
Example #18
0
 /**
  * Handles GET requests for the theme listing
  */
 public function get_themes()
 {
     $all_themes = Themes::get_all_data();
     $theme_names = Utils::array_map_field($all_themes, 'name');
     $available_updates = Options::get('updates_available', array());
     foreach ($all_themes as $name => $theme) {
         // only themes with a guid can be checked for updates
         if (isset($theme['info']->guid)) {
             if (isset($available_updates[(string) $theme['info']->guid])) {
                 // @todo this doesn't use the URL and is therefore worthless
                 $all_themes[$name]['info']->update = $available_updates[(string) $theme['info']->guid]['latest_version'];
             }
         }
         // If this theme requires a parent to be present and it's not, send an error
         if (isset($theme['info']->parent) && !in_array((string) $theme['info']->parent, $theme_names)) {
             $all_themes[$name]['req_parent'] = $theme['info']->parent;
         }
     }
     $this->theme->all_themes = $all_themes;
     $this->theme->active_theme = Themes::get_active_data(true);
     $this->theme->active_theme_dir = $this->theme->active_theme['path'];
     // If the active theme is configurable, allow it to configure
     $this->theme->active_theme_name = $this->theme->active_theme['info']->name;
     $this->theme->configurable = Plugins::filter('theme_config', false, $this->active_theme);
     $this->theme->assign('configure', Controller::get_var('configure'));
     $this->theme->areas = $this->get_areas(0);
     $this->theme->previewed = Themes::get_theme_dir(false);
     $this->theme->help = isset($this->theme->active_theme['info']->help) ? $this->theme->active_theme['info']->help : false;
     $this->theme->help_active = Controller::get_var('help') == $this->theme->active_theme['dir'];
     $this->prepare_block_list();
     $blocks_areas_t = DB::get_results('SELECT b.*, ba.scope_id, ba.area, ba.display_order FROM {blocks} b INNER JOIN {blocks_areas} ba ON ba.block_id = b.id ORDER BY ba.scope_id ASC, ba.area ASC, ba.display_order ASC', array());
     $blocks_areas = array();
     foreach ($blocks_areas_t as $block) {
         if (!isset($blocks_areas[$block->scope_id])) {
             $blocks_areas[$block->scope_id] = array();
         }
         $blocks_areas[$block->scope_id][$block->area][$block->display_order] = $block;
     }
     $this->theme->blocks_areas = $blocks_areas;
     $scopes = DB::get_results('SELECT * FROM {scopes} ORDER BY name ASC;');
     $scopes = Plugins::filter('get_scopes', $scopes);
     $this->theme->scopes = $scopes;
     $this->theme->scopeid = 0;
     $this->theme->theme_loader = Plugins::filter('theme_loader', '', $this->theme);
     $this->theme->display('themes');
 }
Example #19
0
 /**
  * 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'))));
     }
     //For Asides loop in sidebar.php
     $this->assign('asides', Posts::get(array('tag' => 'aside', 'limit' => 5)));
     //for recent comments loop in sidebar.php
     $this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
     parent::add_template_vars();
     //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)));
 }
 /**
  * Checks if the proper credential has been supplied to access the current post
  **/
 private function is_authorized($post = null, $deny = false)
 {
     $auth = Controller::get_var('sharedraft');
     // if there's no auth key, deny authorization automatically
     if ($auth == null) {
         return false;
     }
     ACL::clear_caches();
     // sadly, caching can't be used with Hisa
     // if someone has an auth token but should be denied, mess them up
     if ($deny == true) {
         // Utils::redirect( Site::get_url() );
         exit;
         return false;
     }
     // we assume the authorization is fine until actually testing the post
     if ($post != null) {
         if ($auth != $this->get_secret_key($post)) {
             return false;
         }
     }
     return true;
 }
Example #21
0
 /**
  * Returns the appropriate alternate feed based on the currently matched rewrite rule.
  *
  * @param mixed $return Incoming return value from other plugins
  * @param Theme $theme The current theme object
  * @return string Link to the appropriate alternate Atom feed
  */
 public function theme_feed_alternate($theme)
 {
     $matched_rule = URL::get_matched_rule();
     if (is_object($matched_rule)) {
         // This is not a 404
         $rulename = $matched_rule->name;
     } else {
         // If this is a 404 and no rewrite rule matched the request
         $rulename = '';
     }
     switch ($rulename) {
         case 'display_entry':
         case 'display_page':
             return URL::get('atom_entry', array('slug' => Controller::get_var('slug')));
             break;
         case 'display_entries_by_tag':
             return URL::get('atom_feed_tag', array('tag' => Controller::get_var('tag')));
             break;
         case 'display_home':
         default:
             return URL::get('atom_feed', array('index' => '1'));
     }
     return '';
 }
 public function action_handler_snapshot_delete($handler_vars)
 {
     if (!User::identify()->can('snapshot', 'delete')) {
         Utils::redirect(URL::get('admin', array('page' => 'unauthorized')));
     }
     $timestamp = Controller::get_var('ts');
     $snapshots = Options::get('exportsnapshot__snapshots', array());
     if (!isset($snapshots[$timestamp])) {
         die('Unknown snapshot!');
     }
     // expire the snapshot in the cache
     Cache::expire('exportsnapshot__' . $timestamp);
     // remove it from the list
     unset($snapshots[$timestamp]);
     // write a log event
     EventLog::log(_t('Export Snapshot deleted!', 'exportsnapshot'), 'info', 'delete', 'ExportSnapshot');
     // save the list
     Options::set('exportsnapshot__snapshots', $snapshots);
     // and redirect back to the dashboard
     Utils::redirect(URL::get('admin'));
 }
Example #23
0
 private function fetch_logs()
 {
     // load all the values for our filter drop-downs
     $dates = $this->fetch_log_dates();
     $users = $this->fetch_log_users();
     $ips = $this->fetch_log_ips();
     extract($this->fetch_log_modules_types());
     // $modules and $types
     $severities = LogEntry::list_severities();
     // parse out the arguments we'll fetch logs for
     // the initial arguments
     $arguments = array('limit' => Controller::get_var('limit', 20), 'offset' => Controller::get_var('offset', 0));
     // filter for the search field
     $search = Controller::get_var('search', '');
     if ($search != '') {
         $arguments['criteria'] = $search;
     }
     // filter by date
     $date = Controller::get_var('date', 'any');
     if ($date != 'any') {
         $d = HabariDateTime::date_create($date);
         // ! means fill any non-specified pieces with default Unix Epoch ones
         $arguments['year'] = $d->format('Y');
         $arguments['month'] = $d->format('m');
     }
     // filter by user
     $user = Controller::get_var('user', 'any');
     if ($user != 'any') {
         $arguments['user_id'] = $user;
     }
     // filter by ip
     $ip = Controller::get_var('address', 'any');
     if ($ip != 'any') {
         $arguments['ip'] = $ip;
     }
     // filter modules and types
     // @todo get events of a specific type in a specific module, instead of either of the two
     // the interface doesn't currently make any link between module and type, so we won't worry about it for now
     $module = Controller::get_var('module', 'any');
     $type = Controller::get_var('type', 'any');
     if ($module != 'any') {
         // we get a slugified key back, get the actual module name
         $arguments['module'] = $modules[$module];
     }
     if ($type != 'any') {
         // we get a slugified key back, get the actual type name
         $arguments['type'] = $types[$type];
     }
     // filter by severity
     $severity = Controller::get_var('severity', 'any');
     if ($severity != 'any') {
         $arguments['severity'] = $severity;
     }
     // get the logs!
     $logs = EventLog::get($arguments);
     // last, but not least, generate the list of years used for the timeline
     $months = EventLog::get(array_merge($arguments, array('month_cts' => true)));
     $years = array();
     foreach ($months as $m) {
         $years[$m->year][] = $m;
     }
     // assign all our theme values in one spot
     // first the filter options
     $this->theme->dates = $dates;
     $this->theme->users = $users;
     $this->theme->addresses = $ips;
     $this->theme->modules = $modules;
     $this->theme->types = $types;
     $this->theme->severities = $severities;
     // next the filter criteria we used
     $this->theme->search = $search;
     $this->theme->date = $date;
     $this->theme->user = $user;
     $this->theme->address = $ip;
     $this->theme->module = $module;
     $this->theme->type = $type;
     $this->theme->severity = $severity;
     $this->theme->logs = $logs;
     $this->theme->years = $years;
     $this->theme->wsse = Utils::WSSE();
     // prepare a WSSE token for any ajax calls
 }
Example #24
0
 public function more($content, $post)
 {
     $more_text = 'Read the rest &#8594;';
     $max_paragraphs = 1;
     $showmore = false;
     $matches = preg_split('/<!--\\s*more\\s*-->/is', $content, 2, PREG_SPLIT_NO_EMPTY);
     if (count($matches) > 1) {
         $summary = $matches[0];
         $remainder = $matches[1];
         if (trim($remainder) != '') {
             $showmore = true;
         }
     } else {
         $ht = new HtmlTokenizer($content, false);
         $set = $ht->parse();
         $stack = array();
         $para = 0;
         $token = $set->current();
         $summary = new HTMLTokenSet(false);
         $remainder = new HTMLTokenSet(false);
         $set->rewind();
         for ($token = $set->current(); $set->valid(); $token = $set->next()) {
             if ($token['type'] == HTMLTokenizer::NODE_TYPE_ELEMENT_OPEN) {
                 $stack[$token['name']] = $token['name'];
             }
             if ($para < $max_paragraphs) {
                 $summary[] = $token;
             }
             if ($para >= $max_paragraphs) {
                 $remainder[] = $token;
                 $showmore = true;
             }
             if ($token['type'] == HTMLTokenizer::NODE_TYPE_ELEMENT_CLOSE) {
                 if (isset($stack[$token['name']])) {
                     while (end($stack) != $token['name']) {
                         array_pop($stack);
                     }
                     array_pop($stack);
                 }
                 if (count($stack) == 0) {
                     $para++;
                 }
             }
         }
     }
     if ($post->slug == Controller::get_var('slug')) {
         $content = $summary . '<div id="more" class="moreanchor">' . 'Continues here &#8594;' . '</div>' . $remainder;
     } elseif ($showmore == true) {
         $content = $summary . '<p class="more"><a href="' . $post->permalink . '#more">' . $more_text . '</a></p>';
     } else {
         $content = $summary . $remainder;
     }
     return $content;
 }
 /**
  * Initiate tracking on display
  */
 function action_add_template_vars($theme)
 {
     static $set = false;
     if ($set == true || !is_object($theme->matched_rule) || $theme->matched_rule->action != 'display_post' || $theme->post->content_type != Post::type('link')) {
         return;
     }
     $post = $theme->post;
     $type = Traffum::TYPE_VIEW_NORMAL;
     if (Controller::get_var('refer') != null && Controller::get_var('refer') == 'atom') {
         $type = Traffum::TYPE_VIEW_ATOM;
     }
     Traffum::create(array('post_id' => $post->id, 'type' => $type));
     $set = true;
 }
Example #26
0
    public function action_admin_header($theme)
    {
        if (Controller::get_var('page') == 'publish') {
            $header = <<<HEADER
habari.media.output.viddler = {display: function(index, fileobj) {
\thabari.editor.insertSelection( ''+
\t\t'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="370" id="viddler_' + fileobj.basename + '">' +
\t\t'<param name="movie" value="http://www.viddler.com/player/' + fileobj.basename + '/" />' +
\t\t'<param name="allowScriptAccess" value="always" />' +
\t\t'<param name="allowFullScreen" value="true" />' +
\t\t'<embed src="http://www.viddler.com/player/' + fileobj.basename + '/" width="437" height="370" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" ></embed>' +
\t\t'</object>'
\t);
}}
HEADER;
            Stack::add('admin_header_javascript', $header, 'viddlerinline', array('viddlerjs', 'media', 'jquery'));
        }
    }
Example #27
0
	/**
	 * function act_comment_insert_before
	 * This function is executed when the action "comment_insert_before"
	 * is invoked from a Comment object.
	 * The parent class, Plugin, handles registering the action
	 * and hook name using the name of the function to determine
	 * where it will be applied.
	 * You can still register functions as hooks without using
	 * this method, but boy, is it handy.
	 * @param Comment The comment that will be processed before storing it in the database.
	 **/
	function action_comment_insert_before ( $comment )
	{
		// This plugin ignores non-comments
		if ($comment->type != Comment::COMMENT) {
			return;
		}

		$spamcheck = array();

		// <script> is bad, mmmkay?
		$comment->content = InputFilter::filter($comment->content);

		// first, check the commenter's name
		// if it's only digits, then we can discard this comment
		if ( preg_match( "/^\d+$/", $comment->name ) ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('Commenters with numeric names are spammy.');
		}

		// now look at the comment text
		// if it's digits only, discard it
		$textonly = strip_tags( $comment->content );

		if ( preg_match( "/^\d+$/", $textonly ) ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('Comments that are only numeric are spammy.');
		}

		// is the content whitespaces only?
		if ( preg_match( "/\A\s+\z/", $textonly ) ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('Comments that are only whitespace characters are spammy.');
		}

		// is the content the single word "array"?
		if ( 'array' == strtolower( $textonly ) ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('Comments that are only "array" are spammy.');
		}

		// is the content the same as the name?
		if ( strtolower( $textonly ) == strtolower( $comment->name ) ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('Comments that consist of only the commenters name are spammy.');
		}

		// a lot of spam starts with "<strong>some text...</strong>"
		if ( preg_match( "#^<strong>[^.]+\.\.\.</strong>#", $comment->content ) )
		{
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('Comments that start with strong text are spammy.');
		}

		// are there more than 3 URLs posted?  If so, it's almost certainly spam
		if ( preg_match_all( "#https?://#", strtolower( $comment->content ), $matches, PREG_SET_ORDER ) > 3 ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('There is a 3 URL limit in comments.');
		}

		// are there more than 3 URLencoded characters in the content?
		if ( preg_match_all( "/%[0-9a-f]{2}/", strtolower( $comment->content ), $matches, PREG_SET_ORDER ) > 3 ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('There is a 3 URL-encoded character limit in comments.');
		}

		// Was the tcount high enough?
		/* // This only works with special javascript running on comment form
		if ( empty($handlervars['tcount']) || $handlervars['tcount'] < 10 ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('Commenter did not actually type content.');
		}
		*/

		// We don't allow bbcode here, silly
		if ( stripos($comment->content, '[url=') !== false ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('We do not accept BBCode here.');
		}

		// Must have less than half link content
		$nonacontent = strip_tags(preg_replace('/<a.*?<\/a/i', '', $comment->content));
		$text_length = strlen( $textonly );
		if ( strlen($nonacontent) / ( $text_length == 0 ? 1 : $text_length) < 0.5 ) {
			$comment->status = Comment::STATUS_SPAM;
			$spamcheck[] = _t('Too much text that is a link compared to that which is not.');
		}

		// Only do db checks if it's not already spam
		if ($comment->status != Comment::STATUS_SPAM) {
			$spams = DB::get_value('SELECT count(*) FROM ' . DB::table('comments') . ' WHERE status = ? AND ip = ?', array(Comment::STATUS_SPAM, $comment->ip));
			// If you've already got two spams on your IP address, all you ever do is spam
			if ($spams > 1) {
				$comment->status = Comment::STATUS_SPAM;
				$spamcheck[] = sprintf(_t('Too many existing spams from this IP: %s'), $comment->ip);
			}
		}

		// Any commenter that takes longer than the session timeout is automatically moderated
		if (!isset($_SESSION['comments_allowed']) || ! in_array(Controller::get_var('ccode'), $_SESSION['comments_allowed'])) {
			$comment->status = Comment::STATUS_UNAPPROVED;
			$spamcheck[] = _t("The commenter's session timed out.");
		}

		if ( isset($comment->info->spamcheck) && is_array($comment->info->spamcheck)) {
			$comment->info->spamcheck = array_unique(array_merge($comment->info->spamcheck, $spamcheck));
		}
		else {
			$comment->info->spamcheck = $spamcheck;
		}

		// otherwise everything looks good
		// so continue processing the comment
		return;
	}
Example #28
-1
 public function filter_post_content($content, Post $post)
 {
     if ($post->info->password) {
         // if user logged in, show post
         // make sure it's not just the anonymous user!
         $user = User::identify();
         if ($user instanceof User && $user != User::anonymous()) {
             return $content;
         }
         $session = Session::get_set('post_passwords', false);
         $token = Utils::crypt('42' . $post->info->password . $post->id . Options::get('GUID'));
         // if password was submitted verify it
         if (Controller::get_var('post_password') && Controller::get_var('post_password_id') == $post->id) {
             $pass = InputFilter::filter(Controller::get_var('post_password'));
             if (Utils::crypt($pass, $post->info->password)) {
                 Session::add_to_set('post_passwords', $token, $post->id);
                 $session[$post->id] = $token;
             } else {
                 Session::error(_t('That password was incorrect.', 'postpass'));
             }
         }
         // if password is stored in session verify it
         if (isset($session[$post->id]) && $session[$post->id] == $token) {
             return $content;
         } else {
             $theme = Themes::create();
             $theme->post = $post;
             return $theme->fetch('post_password_form');
         }
     } else {
         return $content;
     }
 }
Example #29
-1
 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->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
     $this->assign('recent_posts', Posts::get(array('limit' => 5, 'orderby' => 'pubdate DESC', 'content_type' => 1, 'status' => 2)));
     if ('' != Controller::get_var('tag')) {
         $tag_text = DB::get_value('SELECT tag_text FROM {tags} WHERE tag_slug=?', array(Controller::get_var('tag')));
         $this->assign('tag_text', $tag_text);
     }
     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')) {
         $page = Controller::get_var('page');
         $this->assign('page', isset($page) ? $page : 1);
     }
     parent::add_template_vars();
 }
Example #30
-2
 /**
  * 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', 'Blog');
     //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();
     if (User::identify()->loggedin) {
         Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery');
     }
 }