[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 function smarty_cms_function_recently_updated($params, &$smarty) 20 { 21 if(empty($params['number'])) 22 { 23 $number = 10; 24 } 25 else 26 { 27 $number = $params['number']; 28 } 29 30 if(empty($params['leadin'])) 31 { 32 $leadin = "Modified: "; 33 } 34 else 35 { 36 $leadin = $params['leadin']; 37 } 38 39 if(empty($params['showtitle'])) 40 { 41 $showtitle='true'; 42 } 43 else 44 { 45 $showtitle = $params['showtitle']; 46 } 47 48 $dateformat = isset($params['dateformat']) ? $params['dateformat'] : "d.m.y h:m" ; 49 $css_class = isset($params['css_class']) ? $params['css_class'] : "" ; 50 51 if (isset($params['css_class'])){ 52 $output = '<div class="'.$css_class.'"><ul>'; 53 } 54 else { 55 $output = '<ul>'; 56 } 57 58 global $gCms; 59 $hm =& $gCms->GetHierarchyManager(); 60 $db = &$gCms->db; 61 // Get list of most recently updated pages excluding the home page 62 $q = "SELECT * FROM ".cms_db_prefix()."content WHERE (type='content' OR type='link') 63 AND default_content != 1 AND active = 1 AND show_in_menu = 1 64 ORDER BY modified_date DESC LIMIT ".$number; 65 $dbresult = $db->Execute( $q ); 66 if( !$dbresult ) 67 { 68 echo 'DB error: '. $db->ErrorMsg()."<br/>"; 69 } 70 while ($dbresult && $updated_page = $dbresult->FetchRow()) 71 { 72 $curnode =& $hm->getNodeById($updated_page['content_id']); 73 $curcontent =& $curnode->GetContent(); 74 $output .= '<li>'; 75 $output .= '<a href="'.$curcontent->GetURL().'">'.$updated_page['content_name'].'</a>'; 76 if ((FALSE == empty($updated_page['titleattribute'])) && ($showtitle=='true')) 77 { 78 $output .= '<br />'; 79 $output .= $updated_page['titleattribute']; 80 } 81 $output .= '<br />'; 82 83 $output .= $leadin; 84 $output .= date($dateformat,strtotime($updated_page['modified_date'])); 85 $output .= '</li>'; 86 } 87 88 $output .= '</ul>'; 89 if (isset($params['css_class'])){ 90 $output .= '</div>'; 91 } 92 93 return $output; 94 } 95 96 function smarty_cms_help_function_recently_updated() { 97 ?> 98 <h3>What does this do?</h3> 99 <p>Outputs a list of recently updated pages.</p> 100 <h3>How do I use it?</h3> 101 <p>Just insert the tag into your template/page like: <code>{recently_updated}</code></p> 102 <h3>What parameters does it take?</h3> 103 <ul> 104 <li><p><em>(optional)</em> number='10' - Number of updated pages to show.</p><p>Example: <pre>{recently_updated number='15'}</pre></p></li> 105 <li><p><em>(optional)</em> leadin='Last changed' - Text to show left of the modified date.</p><p>Example: <pre>{recently_updated leadin='Last Changed'}</pre></p></li> 106 <li><p><em>(optional)</em> showtitle='true' - Shows the titleattribute if it exists as well (true|false).</p><p>Example: <pre>{recently_updated showtitle='true'}</pre></p></li> 107 <li><p><em>(optional)</em> css_class='some_name' - Warp a div tag with this class around the list.</p><p>Example: <pre>{recently_updated css_class='some_name'}</pre></p></li> 108 <li><p><em>(optional)</em> dateformat='d.m.y h:m' - default is d.m.y h:m , use the format you whish (php -date- format)</p><p>Example: <pre>{recently_updated dateformat='D M j G:i:s T Y'}</pre></p></li> 109 </ul> 110 <p>or combined:</p> 111 <pre>{recently_updated number='15' showtitle='false' leadin='Last Change: ' css_class='my_changes' dateformat='D M j G:i:s T Y'}</pre> 112 <?php 113 } 114 115 function smarty_cms_about_function_recently_updated() { 116 ?> 117 <p>Author: Olaf Noehring <http://www.team-noehring.de></p> 118 <p>Version: 1.1</p> 119 <p>Author: Elijah Lofgren <elijahlofgren@elijahlofgren.com></p> 120 <p>Version: 1.0</p> 121 <p> 122 Change History:<br/> 123 1.1: added new parameters: <br /> <leadin>. The contents of leadin will be shown left of the modified date. Default is <Modified:><br /> 124 $showtitle='true' - if true, the titleattribute of the page will be shown if it exists (true|false)<br /> 125 css_class<br /> 126 dateformat - default is d.m.y h:m , use the format you whish (php format) <br /> 127 128 </p> 129 <?php 130 } 131 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |