[ 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 #$Id: copytemplate.php 3362 2006-08-22 09:55:33Z wishy $ 20 21 $CMS_ADMIN_PAGE=1; 22 23 require_once ("../include.php"); 24 require_once ("../lib/classes/class.template.inc.php"); 25 26 check_login(); 27 28 $error = ""; 29 30 $template = ""; 31 if (isset($_POST["template"])) $template = $_POST["template"]; 32 33 $template_id = -1; 34 if (isset($_POST["template_id"])) $template_id = $_POST["template_id"]; 35 else if (isset($_GET["template_id"])) $template_id = $_GET["template_id"]; 36 37 if (isset($_REQUEST["template_name"])) { $template_name = $_REQUEST["template_name"]; } 38 39 if (isset($_POST["cancel"])) 40 { 41 redirect("listtemplates.php"); 42 return; 43 } 44 45 $userid = get_userid(); 46 $access = check_permission($userid, 'Modify Templates'); 47 48 global $gCms; 49 $templateops =& $gCms->GetTemplateOperations(); 50 51 if ($access) 52 { 53 if (isset($_POST["copytemplate"])) 54 { 55 $validinfo = true; 56 if ($template == "") 57 { 58 $error .= "<li>".lang('nofieldgiven',array(lang('name')))."</li>"; 59 $validinfo = false; 60 } 61 else 62 { 63 if ($templateops->CheckExistingTemplateName($template)) 64 { 65 $error .= "<li>".lang('templateexists')."</li>"; 66 $validinfo = false; 67 } 68 } 69 70 if ($validinfo) 71 { 72 $onetemplate = $templateops->LoadTemplateByID($template_id); 73 $onetemplate->id = -1; //Reset id so it will insert a new record 74 $onetemplate->name = $template; //Change name 75 $onetemplate->default = 0; //It can't be default 76 $result = $onetemplate->Save(); 77 78 if ($result) 79 { 80 //Copy attached CSS templates as well... 81 $db = &$gCms->GetDb(); 82 83 $query = "SELECT assoc_css_id, assoc_type, css_name FROM ".cms_db_prefix()."css_assoc, ".cms_db_prefix()."css WHERE assoc_to_id = '$template_id' AND assoc_css_id = css_id"; 84 debug_buffer($query); 85 $result2 = $db->Execute($query); 86 debug_buffer($result2); 87 88 # if any css was found. 89 if ($result2) 90 { 91 while ($row = $result2->FetchRow()) 92 { 93 $query = "INSERT INTO ".cms_db_prefix()."css_assoc (assoc_to_id,assoc_css_id,assoc_type,create_date,modified_date) VALUES ('".$onetemplate->id."','".$row['assoc_css_id']."','".$row['assoc_type']."',".$db->DBTimeStamp(time()).",".$db->DBTimeStamp(time()).")"; 94 debug_buffer($query); 95 $db->Execute($query); 96 } 97 } 98 99 audit($onetemplate->id, $onetemplate->name, 'Copied Template'); 100 redirect("listtemplates.php"); 101 return; 102 } 103 else 104 { 105 $error .= "<li>".lang('errorcopyingtemplate')."</li>"; 106 } 107 } 108 109 } 110 } 111 112 include_once ("header.php"); 113 114 if (!$access) 115 { 116 echo "<div class=\"pageerrorcontainer\"><p class=\"pageerror\">".lang('noaccessto',array(lang('copytemplate')))."</p></div>"; 117 } 118 else 119 { 120 if ($error != "") 121 { 122 echo "<div class=\"pageerrorcontainer\"><ul class=\"pageerror\">".$error."</ul></div>"; 123 } 124 125 ?> 126 127 128 <div class="pagecontainer"> 129 <p class="pageheader"><?php echo lang('copytemplate')?></p> 130 <form method="post" action="copytemplate.php"> 131 <div class="pageoverflow"> 132 <p class="pagetext"><?php echo lang('template'); ?>:</p> 133 <p class="pageinput"><?php echo $template_name; ?></p> 134 </div> 135 <div class="pageoverflow"> 136 <p class="pagetext"><?php echo lang('newtemplatename'); ?>:</p> 137 <p class="pageinput"><input type="text" name="template" maxlength="255" value="<?php echo $template?>"></p> 138 </div> 139 <div class="pageoverflow"> 140 <p class="pagetext"> </p> 141 <p class="pageinput"> 142 <input type="hidden" name="template_id" value="<?php echo $template_id?>" /><input type="hidden" name="copytemplate" value="true" /> 143 <input type="submit" value="<?php echo lang('submit')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 144 <input type="submit" name="cancel" value="<?php echo lang('cancel')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 145 </p> 146 </div> 147 </form> 148 </div> 149 150 <?php 151 152 } 153 154 echo '<p class="pageback"><a class="pageback" href="listtemplates.php">« '.lang('back').'</a></p>'; 155 156 include_once ("footer.php"); 157 158 # vim:ts=4 sw=4 noet 159 ?>
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 |