| [ PHPXref.com ] | [ Generated: Sun Jul 20 17:01:00 2008 ] | [ CMS Made Simple 0.12.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
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: editcontent.php 2660 2006-03-16 01:58:16Z wishy $ 20 21 $CMS_ADMIN_PAGE=1; 22 23 require_once ("../include.php"); 24 25 check_login(); 26 27 if (isset($_POST["cancel"])) 28 { 29 redirect("listcontent.php"); 30 } 31 32 $error = FALSE; 33 34 $content_id = ""; 35 if (isset($_POST["content_id"])) $content_id = $_POST["content_id"]; 36 else if (isset($_GET["content_id"])) $content_id = $_GET["content_id"]; 37 38 $pagelist_id = "1"; 39 if (isset($_POST["page"])) $pagelist_id = $_POST["page"]; 40 else if (isset($_GET["page"])) $pagelist_id = $_GET["page"]; 41 42 $preview = false; 43 if (isset($_POST["previewbutton"])) $preview = true; 44 45 $submit = false; 46 if (isset($_POST["submitbutton"])) $submit = true; 47 48 $apply = false; 49 if (isset($_POST["applybutton"])) $apply = true; 50 51 if ($preview || $apply) 52 { 53 $CMS_EXCLUDE_FROM_RECENT=1; 54 } 55 56 #Get a list of content types and pick a default if necessary 57 $existingtypes = ContentManager::ListContentTypes(); 58 $content_type = ""; 59 if (isset($_POST["content_type"])) 60 { 61 $content_type = $_POST["content_type"]; 62 } 63 else 64 { 65 if (isset($existingtypes) && count($existingtypes) > 0) 66 { 67 $content_type = 'content'; 68 } 69 else 70 { 71 $error = "<p>No content types loaded!</p>"; 72 } 73 } 74 75 $contentobj = ""; 76 if (isset($_POST["serialized_content"])) 77 { 78 $contentobj = UnserializeObject($_POST["serialized_content"]); 79 if (strtolower(get_class($contentobj)) != strtolower($content_type)) 80 { 81 #Fill up the existing object with values in form 82 #Create new object 83 #Copy important fields to new object 84 #Put new object on top of old on 85 86 $contentobj->FillParams($_POST); 87 $newcontenttype = strtolower($content_type); 88 $tmpobj = new $newcontenttype; 89 $tmpobj->SetId($contentobj->Id()); 90 $tmpobj->SetName($contentobj->Name()); 91 $tmpobj->SetMenuText($contentobj->MenuText()); 92 $tmpobj->SetTemplateId($contentobj->TemplateId()); 93 $tmpobj->SetParentId($contentobj->ParentId()); 94 $tmpobj->SetOldParentId($contentobj->OldParentId()); 95 $tmpobj->SetAlias($contentobj->Alias()); 96 $tmpobj->SetOwner($contentobj->Owner()); 97 $tmpobj->SetActive($contentobj->Active()); 98 $tmpobj->SetItemOrder($contentobj->ItemOrder()); 99 $tmpobj->SetOldItemOrder($contentobj->OldItemOrder()); 100 $tmpobj->SetShowInMenu($contentobj->ShowInMenu()); 101 $tmpobj->SetCachable($contentobj->Cachable()); 102 $tmpobj->SetHierarchy($contentobj->Hierarchy()); 103 $tmpobj->SetLastModifiedBy($contentobj->LastModifiedBy()); 104 $tmpobj->SetAdditionalEditors($contentobj->GetAdditionalEditors()); 105 $contentobj = $tmpobj; 106 } 107 } 108 109 #Get current userid and make sure they have permission to add something 110 $userid = get_userid(); 111 $access = check_ownership($userid, $content_id) || check_permission($userid, 'Modify Any Page'); 112 $adminaccess = $access; 113 if (!$access) 114 { 115 $access = check_authorship($userid, $content_id); 116 } 117 118 if ($access) 119 { 120 if ($submit || $apply) 121 { 122 #Fill contentobj with parameters 123 $contentobj->FillParams($_POST); 124 $error = $contentobj->ValidateData(); 125 126 if (isset($_POST["ownerid"])) 127 { 128 $contentobj->SetOwner($_POST["ownerid"]); 129 } 130 131 #Fill Additional Editors (kind of kludgy) 132 if (isset($_POST["additional_editors"])) 133 { 134 $addtarray = array(); 135 foreach ($_POST["additional_editors"] as $addt_user_id) 136 { 137 array_push($addtarray, $addt_user_id); 138 } 139 $contentobj->SetAdditionalEditors($addtarray); 140 } 141 else 142 { 143 $contentobj->SetAdditionalEditors(array()); 144 } 145 146 if ($error === FALSE) 147 { 148 $contentobj->Save(); 149 ContentManager::SetAllHierarchyPositions(); 150 if ($submit) 151 { 152 audit($contentobj->Id(), $contentobj->Name(), 'Edited Content'); 153 redirect("listcontent.php?page=".$pagelist_id); 154 } 155 } 156 } 157 else if ($content_id != -1 && !$preview && strtolower(get_class($contentobj)) != strtolower($content_type)) 158 { 159 $contentobj = ContentManager::LoadContentFromId($content_id); 160 $content_type = $contentobj->Type(); 161 $contentobj->SetLastModifiedBy($userid); 162 } 163 else 164 { 165 #Fill contentobj with parameters 166 $contentobj->FillParams($_POST); 167 if ($preview) 168 { 169 $error = $contentobj->ValidateData(); 170 } 171 172 if (isset($_POST["ownerid"])) 173 { 174 $contentobj->SetOwner($_POST["ownerid"]); 175 } 176 177 $contentobj->SetLastModifiedBy($userid); 178 179 #Fill Additional Editors (kind of kludgy) 180 if (isset($_POST["additional_editors"])) 181 { 182 $addtarray = array(); 183 foreach ($_POST["additional_editors"] as $addt_user_id) 184 { 185 array_push($addtarray, $addt_user_id); 186 } 187 $contentobj->SetAdditionalEditors($addtarray); 188 } 189 else 190 { 191 $contentobj->SetAdditionalEditors(array()); 192 } 193 } 194 } 195 196 if (strlen($contentobj->Name()) > 0) 197 { 198 $CMS_ADMIN_SUBTITLE = $contentobj->Name(); 199 } 200 201 include_once ("header.php"); 202 203 if (!$access) 204 { 205 echo "<div class=\"pageerrorcontainer\"><p class=\"pageerror\">".lang('noaccessto',array(lang('editpage')))."</p></div>"; 206 } 207 else 208 { 209 #Get a list of content_types and build the dropdown to select one 210 $typesdropdown = '<select name="content_type" onchange="document.contentform.submit()" class="standard">'; 211 foreach ($existingtypes as $onetype=>$name) 212 { 213 $typesdropdown .= "<option value=\"$onetype\""; 214 if ($onetype == $content_type) 215 { 216 $typesdropdown .= ' selected="selected"'; 217 } 218 $typesdropdown .= ">".$name."</option>"; 219 } 220 $typesdropdown .= "</select>"; 221 222 if (isset($error) && $error !== FALSE) 223 { 224 echo "<div class=\"pageerrorcontainer\"><ul class=\"pageerror\">"; 225 foreach ($error as $oneerror) 226 { 227 echo '<li>'.$oneerror.'</li>'; 228 } 229 echo "</ul></div>"; 230 } 231 else if ($preview) 232 { 233 $data["content_id"] = $contentobj->Id(); 234 $data["title"] = $contentobj->Name(); 235 $data["menutext"] = $contentobj->MenuText(); 236 $data["content"] = $contentobj->Show(); 237 $data["template_id"] = $contentobj->TemplateId(); 238 $data["hierarchy"] = $contentobj->Hierarchy(); 239 240 $templateobj = TemplateOperations::LoadTemplateById($contentobj->TemplateId()); 241 $data['template'] = $templateobj->content; 242 243 $stylesheetobj = get_stylesheet($contentobj->TemplateId()); 244 $data['encoding'] = $stylesheetobj['encoding']; 245 $data['stylesheet'] = $stylesheetobj['stylesheet']; 246 247 $tmpfname = ''; 248 if (is_writable($config["previews_path"])) 249 { 250 $tmpfname = tempnam($config["previews_path"], "cmspreview"); 251 } 252 else 253 { 254 $tmpfname = tempnam(TMP_CACHE_LOCATION, "cmspreview"); 255 } 256 $handle = fopen($tmpfname, "w"); 257 fwrite($handle, serialize($data)); 258 fclose($handle); 259 260 ?> 261 <div class="pagecontainer"> 262 <p class="pageheader"><?php echo lang('preview')?></p> 263 <iframe name="previewframe" class="preview" src="<?php echo $config["root_url"] ?>/preview.php?tmpfile=<?php echo urlencode(basename($tmpfname))?>"></iframe> 264 </div> 265 <?php 266 267 } 268 269 #$contentarray = $contentobj->EditAsArray(true, 0, $adminaccess); 270 #$contentarray2 = $contentobj->EditAsArray(true, 1, $adminaccess); 271 272 $tabnames = $contentobj->TabNames(); 273 274 ?> 275 276 <div class="pagecontainer"> 277 <p class="pageheader"><?php echo lang('editcontent')?></p> 278 <?php 279 if (count($tabnames) > 0) 280 { 281 ?> 282 <div id="page_tabs"> 283 <?php 284 $count = 0; 285 foreach ($tabnames as $onetab) 286 { 287 ?> 288 <div id="editab<?php echo $count?>"><?php echo $onetab?></div> 289 <?php 290 $count++; 291 } 292 ?> 293 </div> 294 <?php 295 } 296 ?> 297 <div style="clear: both;"></div> 298 <form method="post" action="editcontent.php<?php if (isset($content_id) && isset($pagelist_id)) echo "?content_id=$content_id&page=$pagelist_id";?>" enctype="multipart/form-data" name="contentform" id="contentform"##FORMSUBMITSTUFFGOESHERE##> 299 <input type="hidden" name="serialized_content" value="<?php echo SerializeObject($contentobj); ?>" /> 300 <input type="hidden" name="content_id" value="<?php echo $content_id?>" /> 301 <input type="hidden" name="page" value="<?php echo $pagelist_id; ?>" /> 302 <div id="page_content"> 303 <?php 304 $numberoftabs = count($tabnames); 305 $showtabs = 1; 306 if ($numberoftabs == 0) 307 { 308 $numberoftabs = 1; 309 $showtabs = 0; 310 } 311 for ($currenttab = 0; $currenttab < $numberoftabs; $currenttab++) 312 { 313 if ($showtabs == 1) 314 { 315 ?><div id="editab<?php echo $currenttab ?>_c"><?php 316 } 317 if ($currenttab == 0) 318 { 319 ?> 320 <div class="pageoverflow"> 321 <p class="pagetext"><?php echo lang('contenttype'); ?>:</p> 322 <p class="pageinput"><?php echo $typesdropdown; ?></p> 323 </div> 324 <?php 325 } 326 $contentarray = $contentobj->EditAsArray(false, $currenttab, $adminaccess); 327 for($i=0;$i<count($contentarray);$i++) 328 { 329 ?> 330 <div class="pageoverflow"> 331 <p class="pagetext"><?php echo $contentarray[$i][0]; ?></p> 332 <p class="pageinput"><?php echo $contentarray[$i][1]; ?></p> 333 </div> 334 <?php 335 } 336 ?> 337 <div class="pageoverflow"> 338 <p class="pagetext"> </p> 339 <p class="pageinput"> 340 <?php if (isset($contentobj->mPreview) && $contentobj->mPreview == true) { ?> 341 <input type="submit" name="previewbutton" value="<?php echo lang('preview')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 342 <?php } ?> 343 <input type="submit" name="submitbutton" value="<?php echo lang('submit')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 344 <input type="submit" name="cancel" value="<?php echo lang('cancel')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 345 <input type="submit" name="applybutton" value="<?php echo lang('apply')?>" class="pagebutton" onmouseover="this.className='pagebuttonhover'" onmouseout="this.className='pagebutton'" /> 346 </p> 347 </div> 348 <div style="clear: both;"></div> 349 </div> 350 <?php 351 } 352 ?> 353 </div> 354 </form> 355 </div> 356 357 <?php 358 359 } 360 361 echo '<p class="pageback"><a class="pageback" href="'.$themeObject->BackUrl().'">« '.lang('back').'</a></p>'; 362 363 include_once ("footer.php"); 364 365 # vim:ts=4 sw=4 noet 366 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |