[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (tedkulp@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.org 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 #$Id: class.pageinfo.inc.php 3560 2006-12-08 17:45:30Z calguy1000 $ 20 21 /** 22 * Page Info -- Represents a "page" which consists of different variables virtually 23 * composited together. 24 * 25 * @since 0.11 26 * @package CMS 27 */ 28 class PageInfo 29 { 30 var $content_id; 31 var $content_title; 32 var $content_alias; 33 var $content_menutext; 34 var $content_titleattribute; 35 var $content_hierarchy; 36 var $content_id_hierarchy; 37 var $content_type; 38 var $content_props; 39 var $content_metadata; 40 var $content_modified_date; 41 var $content_created_date; 42 var $content_last_modified_date; 43 var $content_last_modified_by_id; 44 var $template_id; 45 var $template_encoding; 46 var $template_modified_date; 47 var $cachable; 48 49 function PageInfo() 50 { 51 $this->SetInitialValues(); 52 } 53 54 function SetInitialValues() 55 { 56 $this->content_id = -1; 57 $this->content_title = ''; 58 $this->content_alias = ''; 59 $this->content_menutext = ''; 60 $this->content_titleattribute = ''; 61 $this->content_hierarchy = ''; 62 $this->content_metadata = ''; 63 $this->content_id_hierarchy = ''; 64 $this->content_modified_date = -1; 65 $this->content_created_date = -1; 66 $this->content_last_modified_date = -1; 67 $this->content_last_modified_by_id = -1; 68 $this->content_props = array(); 69 $this->template_id = -1; 70 $this->template_modified_date = -1; 71 $this->template_encoding = ''; 72 $this->cachable = false; 73 74 global $gCms; 75 $db = &$gCms->GetDb(); 76 77 $query = 'SELECT MAX(modified_date) AS thedate FROM '.cms_db_prefix().'content c'; 78 $row = $db->GetRow($query); 79 80 if ($row) 81 { 82 $this->content_last_modified_date = $db->UnixTimeStamp($row['thedate']); 83 } 84 } 85 } 86 87 /** 88 * Class for doing template related functions. Many of the Template object functions are just wrappers around these. 89 * 90 * @since 0.6 91 * @package CMS 92 */ 93 class PageInfoOperations 94 { 95 function LoadPageInfoByContentAlias($alias) 96 { 97 $result = false; 98 99 global $gCms; 100 $db = &$gCms->GetDb(); 101 102 $row = ''; 103 104 if (is_numeric($alias) && strpos($alias, '.') === FALSE && strpos($alias, ',') === FALSE) //Fix for postgres 105 { 106 $query = "SELECT c.content_id, c.content_name, c.content_alias, c.menu_text, c.titleattribute, c.hierarchy, c.metadata, c.id_hierarchy, c.prop_names, c.create_date AS c_create_date, c.modified_date AS c_date, c.cachable, c.last_modified_by, t.template_id, t.encoding, t.modified_date AS t_date FROM ".cms_db_prefix()."templates t INNER JOIN ".cms_db_prefix()."content c ON c.template_id = t.template_id WHERE (c.content_alias = ? OR c.content_id = ?) AND c.active = 1"; 107 $row = &$db->GetRow($query, array($alias, $alias)); 108 } 109 else 110 { 111 $query = "SELECT c.content_id, c.content_name, c.content_alias, c.menu_text, c.titleattribute, c.hierarchy, c.metadata, c.id_hierarchy, c.prop_names, c.create_date AS c_create_date, c.modified_date AS c_date, c.cachable, c.last_modified_by,t.template_id, t.encoding, t.modified_date AS t_date FROM ".cms_db_prefix()."templates t INNER JOIN ".cms_db_prefix()."content c ON c.template_id = t.template_id WHERE c.content_alias = ? AND c.active = 1"; 112 $row = &$db->GetRow($query, array($alias)); 113 } 114 115 if ($row) 116 { 117 $onepageinfo = new PageInfo(); 118 $onepageinfo->content_id = $row['content_id']; 119 $onepageinfo->content_title = $row['content_name']; 120 $onepageinfo->content_alias = $row['content_alias']; 121 $onepageinfo->content_menutext = $row['menu_text']; 122 $onepageinfo->content_titleattribute = $row['titleattribute']; 123 $onepageinfo->content_hierarchy = $row['hierarchy']; 124 $onepageinfo->content_id_hierarchy = $row['id_hierarchy']; 125 $onepageinfo->content_metadata = $row['metadata']; 126 $onepageinfo->content_created_date = $db->UnixTimeStamp($row['c_create_date']); 127 $onepageinfo->content_modified_date = $db->UnixTimeStamp($row['c_date']); 128 $onepageinfo->content_last_modified_by_id = $row['last_modified_by']; 129 $onepageinfo->content_props = explode(',', $row['prop_names']); 130 $onepageinfo->template_id = $row['template_id']; 131 $onepageinfo->template_encoding = $row['encoding']; 132 $onepageinfo->cachable = ($row['cachable'] == 1?true:false); 133 $onepageinfo->template_modified_date = $db->UnixTimeStamp($row['t_date']); 134 if( !$onepageinfo->cachable ) 135 { 136 // calguy1000 - if the page is not cachable, don't cache 137 // the template either. This trick forces smarty to 138 // refresh the template cache. 139 $onepageinfo->template_modified_date = time(); 140 } 141 $result = $onepageinfo; 142 } 143 else 144 { 145 #Page isn't found. Should we setup an alternate page? 146 #if (get_site_preference('custom404template') > 0 && get_site_preference('enablecustom404') == "1") 147 if (get_site_preference('enablecustom404') == "1") 148 { 149 $onepageinfo = new PageInfo(); 150 $onepageinfo->cachable = false; 151 if (get_site_preference('custom404template') > 0) 152 $onepageinfo->template_id = get_site_preference('custom404template'); 153 else 154 $onepageinfo->template_id = 'notemplate'; 155 $onepageinfo->template_modified_date = time(); 156 $result = $onepageinfo; 157 } 158 } 159 160 return $result; 161 } 162 } 163 164 # vim:ts=4 sw=4 noet 165 ?>
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 |