• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List

system/themes/mzingi/theme.php

00001 <?php namespace Habari; ?>
00002 <?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); }
00003 
00010 class MzingiHi extends Theme
00011 {
00012 
00013   public function action_init_theme()
00014   {
00015     // Apply Format::autop() to comment content...
00016     Format::apply( 'autop', 'comment_content_out' );
00017     // Apply Format::tag_and_list() to post tags...
00018     Format::apply( 'tag_and_list', 'post_tags_out' );
00019     // Only uses the <!--more--> tag, with the 'more' as the link to full post
00020     Format::apply_with_hook_params( 'more', 'post_content_out', 'more' );
00021     // Creates an excerpt option. echo $post->content_excerpt;
00022     Format::apply( 'autop', 'post_content_excerpt' );
00023     Format::apply_with_hook_params( 'more', 'post_content_excerpt', 'more',60, 1 );
00024     // Format the calendar like date for home, entry.single and entry.multiple templates
00025     Format::apply( 'format_date', 'post_pubdate_out','<span class="calyear">{Y}</span><br><span class="calday">{j}</span><br><span  class="calmonth">{F}</span>' );
00026     Format::apply( 'nice_date', 'post_pubdate_nice', 'F j, Y' );
00027     Format::apply( 'nice_date', 'comment_date_out', 'M j, Y h:ia' );
00028   }
00029 
00045   public function action_add_template_vars($theme)
00046   {
00047     if ( !isset( $this->pages ) ) {
00048       $this->pages = Posts::get( 'page_list' );
00049     }
00050     //For Asides loop in sidebar.php
00051     $this->asides = Posts::get( array( 'vocabulary' => array( 'tags:term' => 'asides') ) );
00052 
00053     if ( is_object($this->request) && $this->request->display_entries_by_tag ) {
00054       if ( count( $this->include_tag ) && count( $this->exclude_tag ) == 0 ) {
00055         $this->tags_msg = _t( 'Posts tagged with %s', array( Format::tag_and_list( $this->include_tag ) ) );
00056       }
00057       else if ( count( $this->exclude_tag ) && count( $this->include_tag ) == 0 ) {
00058         $this->tags_msg = _t( 'Posts not tagged with %s', array( Format::tag_and_list( $this->exclude_tag ) ) );
00059       }
00060       else {
00061         $this->tags_msg = _t( 'Posts tagged with %s and not with %s', array( Format::tag_and_list( $this->include_tag ), Format::tag_and_list( $this->exclude_tag ) ) );
00062       }
00063     }
00064   }
00065 
00066   public function action_template_header($theme) {
00067     // Add the stylesheet to the stack for output
00068     $this->add_style( array( $this->get_url( 'style.css' ), 'screen' ), 'header', 'style' );
00069 
00070     // Add the extra login form styling on the login page
00071     if( is_object( $this->request ) && $this->request->auth ) {
00072       $this->add_style( array( $this->get_url( 'login.css' ), 'screen' ), 'header', 'login_style', 'style' );
00073     }
00074   }
00075 
00076   public function action_template_footer($theme) {
00077     // Add the extra login form styling on the login page
00078     if( is_object( $this->request ) && $this->request->auth ) {
00079       $this->add_script( $this->get_url( 'login.js' ), 'footer', 'login_js', 'jquery' );
00080     }
00081   }
00082 
00083   public function act_display_home( $user_filters = array() )
00084   {
00085     //To exclude posts with the aside tag from the main content loop
00086     parent::act_display_home( array( 'vocabulary' => array( 'tags:not:term' => 'aside' ) ) );
00087   }
00088 
00089   public function theme_next_post_link( $theme )
00090   {
00091     $next_link = '';
00092     if( isset( $theme->post ) ) {
00093       $next_post = $theme->post->ascend();
00094       if( ( $next_post instanceOf Post ) ) {
00095         $next_link = '<a href="' . $next_post->permalink. '" title="' . $next_post->title .'" >' . '&laquo; ' .$next_post->title . '</a>';
00096       }
00097     }
00098 
00099     return $next_link;
00100   }
00101 
00102   public function theme_prev_post_link( $theme )
00103   {
00104     $prev_link = '';
00105 
00106     if( isset( $theme->post ) ) {
00107     $prev_post = $theme->post->descend();
00108     if( ( $prev_post instanceOf Post) ) {
00109       $prev_link= '<a href="' . $prev_post->permalink. '" title="' . $prev_post->title .'" >' . $prev_post->title . ' &raquo;' . '</a>';
00110     }
00111     }
00112     return $prev_link;
00113   }
00114 
00115   public function theme_feed_site( $theme )
00116   {
00117     return URL::get( 'atom_feed', array( 'index' => '1' ) );
00118   }
00119 
00120   public function theme_prevpage_link( $theme )
00121   {
00122     return parent::theme_prev_page_link( $theme, '&laquo; ' . _t('Newer Posts') );
00123   }
00124 
00125   public function theme_nextpage_link( $theme )
00126   {
00127     return parent::theme_next_page_link( $theme, '&raquo; ' . _t('Older Posts') );
00128   }
00129 
00130   public function theme_prevpage_results( $theme )
00131   {
00132     return parent::theme_prev_page_link( $theme, '&laquo; ' . _t('Newer Results') );
00133   }
00134 
00135   public function theme_nextpage_results( $theme )
00136   {
00137     return parent::theme_next_page_link( $theme, '&raquo; ' . _t('Older Reults') );
00138   }
00139 
00140   public static function theme_pageselector( $theme )
00141   {
00142     return parent::theme_page_selector( $theme, null, array( 'leftSide' => 2, 'rightSide' => 2 ) );
00143   }
00144 
00145   public function theme_comment_form( $theme )
00146   {
00147     return $theme->post->comment_form();
00148   }
00149 
00150   public function theme_search_form( $theme )
00151   {
00152     $form = new FormUI( 'searchform');
00153     $form->set_properties( array( 'action' => Url::get( 'display_search' ), 'method' => 'GET' ) );
00154     $form->append( FormControlText::create( 'criteria' )-> set_properties(
00155       array( 'type'  => 'search', 'id' => 's', 'placeholder' => _t( "Search" )
00156        ))->set_value(
00157         isset( $theme->criteria ) ? htmlentities($theme->criteria, ENT_COMPAT, 'UTF-8') : '' )
00158     );
00159     $form->append( FormControlSubmit::create( 'searchsubmit' )->set_caption( _t( 'Go!' ) ) );
00160     return $form;
00161   }
00162 
00166   public function action_form_comment( FormUI $form ) {
00167     //Create a fieldset for Name, Email and URL before Name
00169     $cf_commenterinfo = $form->insert($form->label_for_cf_commenter, FormControlFieldset::create('cf_commenterinfo')->set_caption( _t( 'About You' ) ) );
00170     //move the Name ( cf_commenter) into the fieldset
00171     $form->move_into($form->label_for_cf_commenter, $cf_commenterinfo );
00172 
00173     //$form->label_for_cf_commenter->set_label( _t( 'Name:' ) . '<span class="required">' . ( Options::get( 'comments_require_id' ) == 1 ? ' *' . _t( 'Required' ) : '' ) . '</span>' );
00174     //move the Email ( cf_email) into the Fieldset
00175     $form->move_into( $form->label_for_cf_email, $cf_commenterinfo );
00176 
00177 //    $label_for_cf_email = $form->label_for_cf_email;
00178 //    $label_for_cf_email->set_label(_t( 'Email Address:' ) . '<span class="required">' . ( Options::get( 'comments_require_id' ) == 1 ? ' *' . _t( 'Required' ) : '' ) . '</span>');
00179     //move the URL into the fieldset
00180     $form->move_into( $form->label_for_cf_url, $cf_commenterinfo );
00181     $form->label_for_cf_url->set_label( _t( 'Web Address:' ) );
00182     //add a disclaimer/message
00183     $cf_commenterinfo->append(FormControlStatic::create('cf_disclaimer')->set_static( _t( '<p><em><small>Email address is not published</small></em></p>' ) ) );
00184     //create a second fieldset for the comment textarea
00185     $cf_contentbox = $form->append(FormControlFieldset::create('cf_contentbox')->set_caption( _t( 'Add to the Discussion' ) ) );
00186     //move the fieldset before the textarea
00187     $form->move_before( $form->cf_contentbox, $form->label_for_cf_content );
00188     //move the textarea into the second fieldset
00189     $form->move_into($form->label_for_cf_content, $cf_contentbox );
00190     $form->label_for_cf_content->set_label( _t( 'Message: (Required)' ) );
00191 
00192     $form->cf_submit->set_caption( _t( 'Submit' ) );
00193   }
00194 
00195   public function action_form_login( $form )
00196   {
00197     $form->set_wrap_each( '<div>%s</div>' );
00198     $form->habari_username->set_properties( array( 'placeholder' => _t( 'User name' ) ) );
00199     $form->habari_password->set_properties( array( 'placeholder' => _t( 'Password' ) ) );
00200   }
00201 }
00202 
00203 ?>

Generated on Sun Aug 4 2013 12:51:43 for Habari by  doxygen 1.7.1