[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 4 lt_include( PLOG_CLASS_PATH."class/dao/article.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/dao/articlecategory.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/dao/userinfo.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" ); 10 11 /** 12 * @deprecated 13 * @see StringUtils 14 * 15 * \ingroup Template 16 */ 17 class TemplateUtils 18 { 19 20 var $_blogInfo; 21 var $_rg; 22 var $_mode; 23 24 /** 25 * Constructor. We need the blogInfo object to get some information 26 * about the current blog and so on 27 */ 28 function TemplateUtils( $blogInfo ) 29 { 30 31 $this->_blogInfo = $blogInfo; 32 } 33 34 /** 35 * Transforms some characters into their HTML entities 36 * 37 * @param string The string we'd like to translate 38 * @return Returns the translated string. 39 */ 40 function htmlTranslate( $string ) 41 { 42 return htmlspecialchars( $string ); 43 } 44 45 /** 46 * Manually adds the "show more" link in a post. 47 * 48 * @param post The post we are going to cut. 49 * @param maxWords Amount of words we'd like to allow. 50 * @param linkText Text we are going to show. 51 * @return The modified link. 52 */ 53 function addShowMoreLink( $post, $maxWords, $linkText ) 54 { 55 $textFilter = new TextFilter(); 56 $result = $textFilter->cutText( $post->getText(), $maxWords ); 57 $config =& Config::getConfig(); 58 if( $result != $post->getText()) { 59 $rg =& RequestGenerator::getRequestGenerator(); 60 $rg->addParameter( "op", "ViewArticle" ); 61 $rg->addParameter( "articleId", $post->getId()); 62 $rg->addParameter( "blogId", $this->_blogInfo->getId()); 63 $indexPage = $config->getValue( "script_name", "index.php" ); 64 $showMoreLink = " <a href=\"$indexPage".$rg->getRequest()."\">".$linkText."</a>"; 65 $result .= $showMoreLink; 66 } 67 68 return $result; 69 } 70 71 /** 72 * Cuts a string after 'n' characters. 73 * 74 * @param string The string. 75 * @return The string cut to 'n' characters. 76 */ 77 function cutString( $string, $n ) 78 { 79 return substr( $string, 0, $n ); 80 } 81 82 /** 83 * Returns an array with all the links in a string. 84 * 85 * @param string The string 86 * @return An array with the links in the string. 87 */ 88 function getLinks( $string ) 89 { 90 $regexp = "|<a href=\"(.+)\">(.+)</a>|U"; 91 $result = Array(); 92 93 if( preg_match_all( $regexp, $string, $out, PREG_PATTERN_ORDER )) { 94 foreach( $out[1] as $link ) { 95 array_push( $result, $link ); 96 } 97 } 98 99 return $result; 100 } 101 } 102 ?>
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 |
![]() |