[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004-6 by Ted Kulp (ted@cmsmadesimple.org) 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$ 20 21 /** 22 * Class for doing stylesheet related functions. Maybe of the Group object functions are just wrappers around these. 23 * 24 * @since 0.11 25 * @package CMS 26 */ 27 28 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.stylesheet.inc.php'); 29 30 class StylesheetOperations 31 { 32 function & LoadStylesheets() 33 { 34 global $gCms; 35 $db = &$gCms->GetDb(); 36 37 $result = array(); 38 39 $query = "SELECT css_id, css_name, css_text, media_type, modified_date FROM ".cms_db_prefix()."css ORDER BY css_id"; 40 $dbresult = $db->Execute($query); 41 42 while ($dbresult && $row = $dbresult->FetchRow()) 43 { 44 $onestylesheet = new Stylesheet(); 45 $onestylesheet->id = $row['css_id']; 46 $onestylesheet->name = $row['css_name']; 47 $onestylesheet->value = $row['css_text']; 48 $onestylesheet->media_type = $row['media_type']; 49 $onestylesheet->modified_date = $db->UnixTimeStamp($row['modified_date']); 50 $result[] = $onestylesheet; 51 } 52 return $result; 53 } 54 55 56 function AssociateStylesheetToTemplate( $stylesheetid, $templateid ) 57 { 58 global $gCms; 59 $db = &$gCms->GetDb(); 60 61 $time = $db->DBTimeStamp(time()); 62 $query = 'INSERT INTO '.cms_db_prefix().'css_assoc VALUES (?,?,?,'.$time.','.$time.')'; 63 $dbresult = $db->Execute( $query, array( $templateid, 64 $stylesheetid, 65 'template')); 66 return ($dbresult != false); 67 } 68 69 70 function GetTemplateAssociatedStylesheets($templateid) 71 { 72 $result = false; 73 74 global $gCms; 75 $db = &$gCms->GetDb(); 76 77 $query = 'SELECT assoc_css_id FROM '.cms_db_prefix().'css_assoc WHERE 78 assoc_type = ? AND assoc_to_id = ?'; 79 $dbresult = $db->Execute($query, array('template', $templateid)); 80 81 $result = array(); 82 while ($dbresult && $row = $dbresult->FetchRow()) 83 { 84 $result[] = $row['assoc_css_id']; 85 } 86 87 return $result; 88 } 89 90 91 function & LoadStylesheetByID($id) 92 { 93 $result = false; 94 95 global $gCms; 96 $db = &$gCms->GetDb(); 97 $cache = &$gCms->StylesheetCache; 98 99 if (isset($cache[$id])) 100 { 101 return $cache[$id]; 102 } 103 104 $query = "SELECT css_id, css_name, css_text, media_type FROM ".cms_db_prefix()."css WHERE css_id = ?"; 105 $dbresult = $db->Execute($query, array($id)); 106 107 while ($dbresult && $row = $dbresult->FetchRow()) 108 { 109 $onestylesheet = new Stylesheet(); 110 $onestylesheet->id = $row['css_id']; 111 $onestylesheet->name = $row['css_name']; 112 $onestylesheet->value = $row['css_text']; 113 $onestylesheet->media_type = $row['media_type']; 114 $result =& $onestylesheet; 115 116 if (!isset($cache[$onestylesheet->id])) 117 { 118 $cache[$onestylesheet->id] =& $onestylesheet; 119 } 120 } 121 122 return $result; 123 } 124 125 function InsertStylesheet($stylesheet) 126 { 127 $result = -1; 128 129 global $gCms; 130 $db = &$gCms->GetDb(); 131 132 $new_stylesheet_id = $db->GenID(cms_db_prefix()."css_seq"); 133 $time = $db->DBTimeStamp(time()); 134 $query = "INSERT INTO ".cms_db_prefix()."css (css_id, css_name, css_text, media_type, create_date, modified_date) VALUES (?,?,?,?,".$time.",".$time.")"; 135 $dbresult = $db->Execute($query, array($new_stylesheet_id, $stylesheet->name, $stylesheet->value, $stylesheet->media_type)); 136 if ($dbresult !== false) 137 { 138 $result = $new_stylesheet_id; 139 } 140 141 return $result; 142 } 143 144 function UpdateStylesheet($stylesheet) 145 { 146 $result = false; 147 148 global $gCms; 149 $db = &$gCms->GetDb(); 150 151 $time = $db->DBTimeStamp(time()); 152 $query = "UPDATE ".cms_db_prefix()."css SET css_name = ?,css_text = ?, media_type = ?, modified_date = ".$time." WHERE css_id = ?"; 153 $dbresult = $db->Execute($query, array($stylesheet->name, $stylesheet->value, $stylesheet->media_type, $stylesheet->id)); 154 if ($dbresult !== false) 155 { 156 $result = true; 157 } 158 159 return $result; 160 } 161 162 function DeleteStylesheetByID($id) 163 { 164 $result = false; 165 166 global $gCms; 167 $db = &$gCms->GetDb(); 168 169 $query = "DELETE FROM ".cms_db_prefix()."css_assoc where assoc_css_id = ?"; 170 $dbresult = $db->Execute($query, array($id)); 171 172 $query = "DELETE FROM ".cms_db_prefix()."css where css_id = ?"; 173 $dbresult = $db->Execute($query, array($id)); 174 175 if ($dbresult !== false) 176 { 177 $result = true; 178 } 179 180 return $result; 181 } 182 183 function CheckExistingStylesheetName($name) 184 { 185 $result = false; 186 187 global $gCms; 188 $db = &$gCms->GetDb(); 189 190 $query = "SELECT css_id from ".cms_db_prefix()."css WHERE css_name = ?"; 191 $dbresult = $db->Execute($query,array($name)); 192 193 if ($dbresult && $dbresult->RecordCount() > 0) 194 { 195 $result = true; 196 } 197 198 return $result; 199 } 200 } 201 202 ?>
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 |