[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #------------------------------------------------------------------------- 3 # Module: ThemeManager - a module for importing and exporting template 4 # and stylesheet packages. 5 # Version: 1.0.8, Robert Campbell <rob@techcom.dyndns.org> 6 # 7 #------------------------------------------------------------------------- 8 # CMS - CMS Made Simple is (c) 2005 by Ted Kulp (wishy@cmsmadesimple.org) 9 # This project's homepage is: http://www.cmsmadesimple.org 10 # 11 #------------------------------------------------------------------------- 12 # 13 # This program is free software; you can redistribute it and/or modify 14 # it under the terms of the GNU General Public License as published by 15 # the Free Software Foundation; either version 2 of the License, or 16 # (at your option) any later version. 17 # 18 # This program is distributed in the hope that it will be useful, 19 # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 # GNU General Public License for more details. 22 # You should have received a copy of the GNU General Public License 23 # along with this program; if not, write to the Free Software 24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 # Or read it online: http://www.gnu.org/licenses/licenses.html#GPL 26 # 27 #------------------------------------------------------------------------- 28 29 define( "DTD_VERSION", "1.2" ); 30 31 function get_urls($string, $strict=true) { 32 $types = array("href", "src", "url"); 33 while(list(,$type) = each($types)) { 34 $innerT = $strict?'[a-z0-9:?=&@/._-]+?':'.+?'; 35 preg_match_all ("|$type\=([\"'`])(".$innerT.")\\1|i", $string, $matches); 36 $ret[$type] = $matches[2]; 37 } 38 39 return $ret; 40 }; 41 42 #------------------------------------------------------------------------- 43 class ThemeManager extends CMSModule 44 { 45 var $dtd = ' 46 <!DOCTYPE theme [ 47 <!ELEMENT theme (name,dtdversion,template+,stylesheet+,assoc+,reference*,mmtemplate*)> 48 <!ELEMENT name (#PCDATA)> 49 <!ELEMENT dtdversion (#PCDATA)> 50 <!ELEMENT template (tname,tencoding,tdata)> 51 <!ELEMENT tname (#PCDATA)> 52 <!ELEMENT tencoding (#PCDATA)> 53 <!ELEMENT tdata (#PCDATA)> 54 <!ELEMENT stylesheet (cssname,cssmediatype,cssencoding,cssdata)> 55 <!ELEMENT cssname (#PCDATA)> 56 <!ELEMENT cssmediatype (#PCDATA)> 57 <!ELEMENT cssdata (#PCDATA)> 58 <!ELEMENT assoc (assoc_tname,assoc_cssname)> 59 <!ELEMENT assoc_tname (#PCDATA)> 60 <!ELEMENT assoc_cssname (#PCDATA)> 61 <!ELEMENT reference (refname,refencoded,reflocation,refdata)> 62 <!ELEMENT refname (#PCDATA)> 63 <!ELEMENT refencoded (#PCDATA)> 64 <!ELEMENT reflocation (#PCDATA)> 65 <!ELEMENT refdata (#PCDATA)> 66 <!ELEMENT mmtemplate (mmtemplate_name,mmtemplate_data)> 67 <!ELEMENT mmtemplate_name (#PCDATA)> 68 <!ELEMENT mmtemplate_data (#PCDATA)> 69 ]>'; 70 71 /*--------------------------------------------------------- 72 GetName() 73 ---------------------------------------------------------*/ 74 function GetName() 75 { 76 return 'ThemeManager'; 77 } 78 79 80 /*--------------------------------------------------------- 81 GetFriendlyName() 82 ---------------------------------------------------------*/ 83 function GetFriendlyName() 84 { 85 return $this->Lang('friendlyname'); 86 } 87 88 89 /*--------------------------------------------------------- 90 GetVersion() 91 ---------------------------------------------------------*/ 92 function GetVersion() 93 { 94 return '1.0.8'; 95 } 96 97 98 /*--------------------------------------------------------- 99 MinimumCVSVersion() 100 ---------------------------------------------------------*/ 101 function MinimumCMSVersion() 102 { 103 return "1.0.4"; 104 } 105 106 107 /*--------------------------------------------------------- 108 GetHelp() 109 ---------------------------------------------------------*/ 110 function GetHelp() 111 { 112 return $this->Lang('help'); 113 } 114 115 116 /*--------------------------------------------------------- 117 GetAuthor() 118 ---------------------------------------------------------*/ 119 function GetAuthor() 120 { 121 return 'calguy1000'; 122 } 123 124 125 /*--------------------------------------------------------- 126 GetAuthorEmail() 127 This returns a string that is presented in the Module 128 Admin if you click on the "About" link. It helps users 129 of your module get in touch with you to send bug reports, 130 questions, cases of beer, and/or large sums of money. 131 ---------------------------------------------------------*/ 132 function GetAuthorEmail() 133 { 134 return 'calguy1000@hotmail.com'; 135 } 136 137 138 /*--------------------------------------------------------- 139 GetChangeLog() 140 This returns a string that is presented in the module 141 Admin if you click on the About link. It helps users 142 figure out what's changed between releases. 143 See the note on localization at the top of this file. 144 ---------------------------------------------------------*/ 145 function GetChangeLog() 146 { 147 return $this->Lang('changelog'); 148 } 149 150 151 /*--------------------------------------------------------- 152 IsPluginModule() 153 ---------------------------------------------------------*/ 154 function IsPluginModule() 155 { 156 return false; 157 } 158 159 160 /*--------------------------------------------------------- 161 HasAdmin() 162 ---------------------------------------------------------*/ 163 function HasAdmin() 164 { 165 return true; 166 } 167 168 169 /*--------------------------------------------------------- 170 IsAdminOnly() 171 ---------------------------------------------------------*/ 172 function IsAdminOnly() 173 { 174 return true; 175 } 176 177 178 /*--------------------------------------------------------- 179 GetAdminSection() 180 ---------------------------------------------------------*/ 181 function GetAdminSection() 182 { 183 return 'layout'; 184 } 185 186 187 /*--------------------------------------------------------- 188 GetAdminDescription() 189 ---------------------------------------------------------*/ 190 function GetAdminDescription() 191 { 192 return $this->Lang('moddescription'); 193 } 194 195 196 /*--------------------------------------------------------- 197 VisibleToAdminUser() 198 ---------------------------------------------------------*/ 199 function VisibleToAdminUser() 200 { 201 return $this->CheckPermission('Manage Themes') || 202 ($this->CheckPermission('Add Stylesheets') && 203 $this->CheckPermission('Add Templates') && 204 $this->CheckPermission('Add Stylesheet Assoc')); 205 } 206 207 /*--------------------------------------------------------- 208 GetDependencies() 209 ---------------------------------------------------------*/ 210 function GetDependencies() 211 { 212 return array(); 213 } 214 215 216 /*--------------------------------------------------------- 217 Install() 218 ---------------------------------------------------------*/ 219 function Install() 220 { 221 // this module does not have any tables of its own 222 223 // create a permission 224 $this->CreatePermission('Manage Themes', 'Manage Themes'); 225 226 // put mention into the admin log 227 $this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('installed',$this->GetVersion())); 228 } 229 230 231 /*--------------------------------------------------------- 232 InstallPostMessage() 233 ---------------------------------------------------------*/ 234 function InstallPostMessage() 235 { 236 return $this->Lang('postinstall'); 237 } 238 239 240 /*--------------------------------------------------------- 241 Upgrade() 242 ---------------------------------------------------------*/ 243 function Upgrade($oldversion, $newversion) 244 { 245 // nothing to do here, yet 246 247 // put mention into the admin log 248 $this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('upgraded',$this->GetVersion())); 249 } 250 251 252 /*--------------------------------------------------------- 253 Uninstall() 254 ---------------------------------------------------------*/ 255 function Uninstall() 256 { 257 // remove the permissions 258 $this->RemovePermission('Manage Themes'); 259 260 // put mention into the admin log 261 $this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('uninstalled')); 262 } 263 264 265 /*--------------------------------------------------------- 266 DisplayErrorPage($id, $params, $return_id, $message) 267 NOT PART OF THE MODULE API 268 ---------------------------------------------------------*/ 269 function DisplayErrorPage($id, &$params, $returnid, $message='') 270 { 271 $this->smarty->assign('title_error', $this->Lang('error')); 272 if ($message != '') 273 { 274 $this->smarty->assign('message', $message); 275 } 276 277 // Display the populated template 278 echo $this->ProcessTemplate('error.tpl'); 279 } 280 281 282 /*--------------------------------------------------------- 283 _mkdirr( $pathname, $mode ) 284 NOT PART OF THE MODULE API 285 286 Make a directory recursively 287 ---------------------------------------------------------*/ 288 function _mkdirr ($pathname, $mode = 0777) 289 { 290 // Check if directory already exists 291 if (is_dir ($pathname) || empty ($pathname)) 292 { 293 return true; 294 } 295 296 // Ensure a file does not already exist with the same name 297 if (is_file ($pathname)) 298 { 299 // RC: Modification such that this isn't an error 300 return true; 301 } 302 303 // Crawl up the directory tree 304 $next_pathname = 305 substr ($pathname, 0, strrpos ($pathname, DIRECTORY_SEPARATOR)); 306 if ($this->_mkdirr ($next_pathname, $mode)) 307 { 308 if (!file_exists ($pathname)) 309 { 310 return @mkdir ($pathname, $mode); 311 } 312 } 313 314 return false; 315 } 316 317 } 318 319 ?>
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 |