[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/view/blogview.class.php" ); 4 5 define( "MAIN_TEMPLATE", "main" ); 6 7 /** 8 * @private 9 * \ingroup View 10 * 11 * Main default view that simply shows all the posts in the database 12 * of a blog 13 */ 14 class DefaultView extends BlogView 15 { 16 17 /** 18 * Initializes the parent class 19 */ 20 function DefaultView( $blogInfo, $data = Array()) 21 { 22 $this->BlogView( $blogInfo, MAIN_TEMPLATE, SMARTY_VIEW_CACHE_CHECK, $data ); 23 } 24 25 /** 26 * Takes all the posts and determines if we have to add the "show more" after 27 * show_more_threshold words have been counted. If so, clicking on the link 28 * will show the whole post using the ViewArticle action. 29 * 30 * @param maxWords The amount of words we tollerate before showing the link. 31 * @return nothing. 32 */ 33 function _addShowMoreLink() 34 { 35 $posts = $this->_params->getValue( 'posts' ); 36 37 //lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" ); 38 //$textFilter = new TextFilter(); 39 $modifPosts = Array(); 40 $rg = $this->_blogInfo->getBlogRequestGenerator(); 41 foreach( $posts as $post ) { 42 if( $post->hasExtendedText()) { 43 $result = $post->getIntroText(); 44 $showMoreText = $this->_locale->tr( 'read_more' ); 45 $showMoreLink = " <a class=\"showMoreLink\" href=\"".$rg->postPermalink($post)."\">".$showMoreText."</a>"; 46 $post->setText( $result. $showMoreLink ); 47 } 48 49 array_push( $modifPosts, $post ); 50 } 51 52 $this->_params->setValue( 'posts', $modifPosts ); 53 } 54 55 /** 56 * Provides a meaningful page title. The format here will depend on whether we're browsing the main 57 * blog page, or a page from the archives or a category page 58 * 59 * @return a page title 60 */ 61 function getPageTitle() 62 { 63 $title = $this->_blogInfo->getBlog(); 64 if(($date = $this->getValue( "date" ))) { 65 $title .= " | ".$this->_locale->formatDate( $date, "%B %Y" ); 66 } 67 elseif(( $category = $this->getValue( "category" ))) { 68 $title .= " | ".$category->getName(); 69 } 70 71 return( $title ); 72 } 73 74 /** 75 * This view shows a list of the posts for the blog. 76 * 77 * The blog we are going to show is determined by: 78 * 1) blogId parameter in the $_REQUEST 79 * 2) blogId parameter in the session 80 * 3) default_blog_id parameter from the configuration file 81 */ 82 function render() 83 { 84 // load the contents into the template context 85 $blogSettings = $this->_blogInfo->getSettings(); 86 87 // we have to keep in mind that the things below only need to be done 88 // in case that the view is not cached, otherwise we will get a warning message 89 // because there are no posts to process! (the action will not load any data if the 90 // view is cached) 91 if( !$this->isCached()) { 92 // check if we have to cut the posts to a determined amount of words and 93 // then show the "show more" link... 94 //if( $blogSettings->getValue( 'show_more_enabled' ) == true && !$this->isCached()) { 95 if( $blogSettings->getValue( 'show_more_enabled' ) == true ) { 96 $this->_addShowMoreLink(); 97 } 98 } 99 100 parent::render(); 101 } 102 } 103 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |