[ 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: edithtmlblob.php 3604 2006-12-20 21:47:27Z elijahlofgren $ 20 21 $CMS_ADMIN_PAGE=1; 22 23 require_once ("../include.php"); 24 //require_once("../lib/classes/class.htmlblob.inc.php"); 25 require_once ("../lib/classes/class.template.inc.php"); 26 27 check_login(); 28 29 $error = ""; 30 31 $htmlblob = ""; 32 if (isset($_POST['htmlblob'])) $htmlblob = $_POST['htmlblob']; 33 34 $oldhtmlblob = ""; 35 if (isset($_POST['oldhtmlblob'])) $oldhtmlblob = $_POST['oldhtmlblob']; 36 37 $content = ""; 38 if (isset($_POST['content'])) $content = $_POST['content']; 39 40 $owner_id = ""; 41 if (isset($_POST['owner_id'])) $owner_id = $_POST['owner_id']; 42 43 $htmlblob_id = -1; 44 if (isset($_POST["htmlblob_id"])) $htmlblob_id = $_POST["htmlblob_id"]; 45 else if (isset($_GET["htmlblob_id"])) $htmlblob_id = $_GET["htmlblob_id"]; 46 47 if (isset($_POST["cancel"])) { 48 redirect("listhtmlblobs.php"); 49 return; 50 } 51 52 global $gCms; 53 $gcbops =& $gCms->GetGlobalContentOperations(); 54 55 $userid = get_userid(); 56 $adminaccess = check_permission($userid, 'Modify Global Content Blocks'); 57 $access = check_permission($userid, 'Modify Global Content Blocks') || $gcbops->CheckOwnership($htmlblob_id, $userid) || 58 $gcbops->CheckAuthorship($htmlblob_id, $userid); 59 60 /* 61 $htmlarea_flag = false; 62 $use_javasyntax = false; 63 64 if (get_preference($userid, 'use_wysiwyg') == "1") 65 { 66 $htmlarea_flag = true; 67 $use_javasyntax = false; 68 } 69 else if (get_preference($userid, 'use_javasyntax') == "1") 70 { 71 $use_javasyntax = true; 72 } 73 */ 74 $gcb_wysiwyg = get_preference($userid, 'gcb_wysiwyg', 1); 75 76 if ($access) 77 { 78 if (isset($_POST["edithtmlblob"])) 79 { 80 $validinfo = true; 81 if ($htmlblob == "") 82 { 83 $error .= "<li>".lang('nofieldgiven', array(lang('edithtmlblob')))."</li>"; 84 $validinfo = false; 85 } 86 else if ($htmlblob != $oldhtmlblob && $gcbops->CheckExistingHtmlBlobName($htmlblob)) 87 { 88 $error .= "<li>".lang('blobexists')."</li>"; 89 $validinfo = false; 90 } 91 92 if ($validinfo) 93 { 94 $blobobj =& new GlobalContent(); 95 $blobobj->id = $htmlblob_id; 96 $blobobj->name = $htmlblob; 97 $blobobj->content = $content; 98 $blobobj->owner = $owner_id; 99 100 $blobobj->ClearAuthors(); 101 if (isset($_POST["additional_editors"])) { 102 foreach ($_POST["additional_editors"] as $addt_user_id) { 103 $blobobj->AddAuthor($addt_user_id); 104 } 105 } 106 $blobobj->AddAuthor($userid); 107 108 #Perform the edithtmlblob_pre callback 109 foreach($gCms->modules as $key=>$value) 110 { 111 if ($gCms->modules[$key]['installed'] == true && 112 $gCms->modules[$key]['active'] == true) 113 { 114 $gCms->modules[$key]['object']->EditHtmlBlobPre($blobobj); 115 } 116 } 117 118 Events::SendEvent('Core', 'EditGlobalContentPre', array('global_content' => &$blobobj)); 119 120 $result = $blobobj->save(); 121 122 if ($result) 123 { 124 audit($blobobj->id, $blobobj->name, 'Edited Html Blob'); 125 126 #Clear cache 127 $smarty = new Smarty_CMS($config); 128 $smarty->clear_all_cache(); 129 $smarty->clear_compiled_tpl(); 130 131 #Perform the edithtmlblob_post callback 132 foreach($gCms->modules as $key=>$value) 133 { 134 if ($gCms->modules[$key]['installed'] == true && 135 $gCms->modules[$key]['active'] == true) 136 { 137 $gCms->modules[$key]['object']->EditHtmlBlobPost($blobobj); 138 } 139 } 140 141 Events::SendEvent('Core', 'EditGlobalContentPost', array('global_content' => &$blobobj)); 142 143 if (!isset($_POST['apply'])) { 144 redirect('listhtmlblobs.php'); 145 return; 146 } 147 } 148 else 149 { 150 $error .= "<li>".lang('errorinsertingblob')."</li>"; 151 } 152 } 153 } 154 else if ($htmlblob_id != -1) 155 { 156 $onehtmlblob = $gcbops->LoadHtmlBlobByID($htmlblob_id); 157 $htmlblob = $onehtmlblob->name; 158 $oldhtmlblob = $onehtmlblob->name; 159 $owner_id = $onehtmlblob->owner; 160 $content = $onehtmlblob->content; 161 } 162 } 163 164 if (strlen($htmlblob) > 0) 165 { 166 $CMS_ADMIN_SUBTITLE = $htmlblob; 167 } 168 169 include_once ("header.php"); 170 global $gCms; 171 $db =& $gCms->GetDb(); 172 173 $owners = "<select name=\"owner_id\">"; 174 175 $query = "SELECT user_id, username FROM ".cms_db_prefix()."users ORDER BY username"; 176 $result = $db->Execute($query); 177 178 while($result && $row = $result->FetchRow()) 179 { 180 $owners .= "<option value=\"".$row["user_id"]."\""; 181 if ($row["user_id"] == $owner_id) 182 { 183 $owners .= " selected=\"selected\""; 184 } 185 $owners .= ">".$row["username"]."</option>"; 186 } 187 188 $owners .= "</select>"; 189 190 $addt_users = ""; 191 192 $query = "SELECT user_id, username FROM ".cms_db_prefix()."users WHERE user_id <> ? ORDER BY username"; 193 $result = $db->Execute($query,array($userid)); 194 195 while($result && $row = $result->FetchRow()) 196 { 197 $addt_users .= "<option value=\"".$row["user_id"]."\""; 198 $query = "SELECT * from ".cms_db_prefix()."additional_htmlblob_users WHERE user_id = ".$row["user_id"]." AND htmlblob_id = ?"; 199 $newresult = $db->Execute($query,array($htmlblob_id)); 200 if ($newresult && $newresult->RecordCount() > 0) 201 { 202 $addt_users .= " selected=\"true\""; 203 } 204 $addt_users .= ">".$row["username"]."</option>"; 205 } 206 207 if (!$access) 208 { 209 echo "<div class=\"pageerrorcontainer\"><p class=\"pageerror\">".lang('noaccessto', array(lang('edithtmlblob')))."</p></div>"; 210 } 211 else 212 { 213 if ($error != "") 214 { 215 echo "<div class=\"pageerrorcontainer\"><ul class=\"pageerror\">".$error."</ul></div>"; 216 } 217 ?> 218 219 220 <div class="pagecontainer"> 221 <?php echo $themeObject->ShowHeader('edithtmlblob'); ?> 222 <form method="post" action="edithtmlblob.php"> 223 <div class="pageoverflow"> 224 <p class="pagetext"> </p> 225 <p class="pageinput"> 226 <input type="submit" value="<?php echo lang('submit')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 227 <input type="submit" name="cancel" value="<?php echo lang('cancel')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 228 <input type="submit" name="apply" value="<?php echo lang('apply')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 229 </p> 230 </div> 231 <div class="pageoverflow"> 232 <p class="pagetext"><?php echo lang('name')?>:</p> 233 <p class="pageinput"><input type="text" name="htmlblob" maxlength="255" value="<?php echo $htmlblob?>" class="standard" /></p> 234 </div> 235 <div class="pageoverflow"> 236 <p class="pagetext">*<?php echo lang('content')?>:</p> 237 <p class="pageinput"><?php echo create_textarea($gcb_wysiwyg, $content, 'content', 'wysiwyg', 'content');?></p> 238 </div> 239 <?php if ($adminaccess) { ?> 240 <div class="pageoverflow"> 241 <p class="pagetext"><?php echo lang('owner')?>:</p> 242 <p class="pageinput"><?php echo $owners?></p> 243 </div> 244 <?php } ?> 245 <?php if ($addt_users != '') { ?> 246 <div class="pageoverflow"> 247 <p class="pagetext"><?php echo lang('additionaleditors')?>:</p> 248 <p class="pageinput"><select name="additional_editors[]" multiple="multiple" size="3"><?php echo $addt_users?></select></p> 249 </div> 250 <?php } ?> 251 <div class="pageoverflow"> 252 <p class="pagetext"> </p> 253 <p class="pageinput"> 254 <input type="hidden" name="edithtmlblob" value="true" /> 255 <input type="hidden" name="oldhtmlblob" value="<?php echo $oldhtmlblob; ?>" /> 256 <input type="hidden" name="htmlblob_id" value="<?php echo $htmlblob_id; ?>" /> 257 <input type="submit" value="<?php echo lang('submit')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 258 <?php if (!$adminaccess) { ?> 259 <input type="hidden" name="owner_id" value="<?php echo $owner_id ?>" /> 260 <?php } ?> 261 <input type="submit" name="cancel" value="<?php echo lang('cancel')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 262 <input type="submit" name="apply" value="<?php echo lang('apply')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 263 </p> 264 </div> 265 </form> 266 </div> 267 268 <?php 269 } 270 echo '<p class="pageback"><a class="pageback" href="'.$themeObject->BackUrl().'">« '.lang('back').'</a></p>'; 271 272 include_once ("footer.php"); 273 274 # vim:ts=4 sw=4 noet 275 ?>
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 |