[ 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: listcontent.php 3837 2007-03-23 01:44:59Z dittmann $ 20 21 $CMS_ADMIN_PAGE=1; 22 23 require_once ("../include.php"); 24 25 check_login(); 26 $userid = get_userid(); 27 28 include_once ("../lib/classes/class.admintheme.inc.php"); 29 30 require_once(dirname(dirname(__FILE__)) . '/lib/xajax/xajax.inc.php'); 31 $xajax = new xajax(); 32 $xajax->registerFunction('content_list_ajax'); 33 $xajax->registerFunction('content_setactive'); 34 $xajax->registerFunction('content_setinactive'); 35 $xajax->registerFunction('content_setdefault'); 36 $xajax->registerFunction('content_expandall'); 37 $xajax->registerFunction('content_collapseall'); 38 $xajax->registerFunction('content_toggleexpand'); 39 $xajax->registerFunction('content_move'); 40 $xajax->registerFunction('content_delete'); 41 $xajax->registerFunction('reorder_display_list'); 42 $xajax->registerFunction('reorder_process'); 43 44 $xajax->processRequests(); 45 $headtext = $xajax->getJavascript($config['root_url'] . '/lib/xajax')."\n"; 46 47 include_once ("header.php"); 48 49 //echo '<a onclick="xajax_reorder_display_list();">Test</a>'; 50 51 function content_list_ajax() 52 { 53 $objResponse = new xajaxResponse(); 54 $objResponse->addClear("contentlist", "innerHTML"); 55 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 56 return $objResponse->getXML(); 57 } 58 59 function check_modify_all($userid) 60 { 61 return check_permission($userid, 'Modify Any Page'); 62 } 63 64 function setdefault($contentid) 65 { 66 global $gCms; 67 $userid = get_userid(); 68 69 $result = false; 70 71 if (check_modify_all($userid)) 72 { 73 $hierManager =& $gCms->GetHierarchyManager(); 74 $node = &$hierManager->getNodeById($contentid); 75 if (isset($node)) 76 { 77 $value =& $node->getContent(); 78 if (isset($value)) 79 { 80 if (!$value->Active()) 81 { 82 #Modify the object inline 83 $value->SetActive(true); 84 $value->Save(); 85 } 86 } 87 } 88 89 $db = &$gCms->GetDb(); 90 $query = "SELECT content_id FROM ".cms_db_prefix()."content WHERE default_content=1"; 91 $old_id = $db->GetOne($query); 92 if (isset($old_id)) 93 { 94 $node = &$hierManager->getNodeById($old_id); 95 if (isset($node)) 96 { 97 $value =& $node->getContent(); 98 if (isset($value)) 99 { 100 $value->SetDefaultContent(false); 101 $value->Save(); 102 } 103 } 104 } 105 106 $node = &$hierManager->getNodeById($contentid); 107 if (isset($node)) 108 { 109 $value =& $node->getContent(); 110 if (isset($value)) 111 { 112 $value->SetDefaultContent(true); 113 $value->Save(); 114 } 115 } 116 117 $result = true; 118 global $gCms; 119 $contentops =& $gCms->GetContentOperations(); 120 $contentops->ClearCache(); 121 } 122 return $result; 123 } 124 125 function content_setdefault($contentid) 126 { 127 $objResponse = new xajaxResponse(); 128 129 setdefault($contentid); 130 131 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 132 $objResponse->addScript("new Effect.Highlight('tr_$contentid', { duration: 2.0 });"); 133 return $objResponse->getXML(); 134 } 135 136 function content_setactive($contentid) 137 { 138 $objResponse = new xajaxResponse(); 139 140 setactive($contentid); 141 142 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 143 $objResponse->addScript("new Effect.Highlight('tr_$contentid', { duration: 2.0 });"); 144 return $objResponse->getXML(); 145 } 146 147 function content_setinactive($contentid) 148 { 149 $objResponse = new xajaxResponse(); 150 151 setactive($contentid, false); 152 153 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 154 $objResponse->addScript("new Effect.Highlight('tr_$contentid', { duration: 2.0 });"); 155 return $objResponse->getXML(); 156 } 157 158 function content_expandall() 159 { 160 $objResponse = new xajaxResponse(); 161 162 expandall(); 163 164 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 165 return $objResponse->getXML(); 166 } 167 168 function content_collapseall() 169 { 170 $objResponse = new xajaxResponse(); 171 172 collapseall(); 173 174 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 175 return $objResponse->getXML(); 176 } 177 178 function expandall() 179 { 180 $userid = get_userid(); 181 global $gCms; 182 $contentops =& $gCms->GetContentOperations(); 183 $all = $contentops->GetAllContent(false); 184 $cs = ''; 185 foreach ($all as $thisitem) 186 { 187 if ($thisitem->HasChildren()) 188 { 189 $cs .= $thisitem->Id().'=1.'; 190 } 191 } 192 set_preference($userid, 'collapse', $cs); 193 } 194 195 function collapseall() 196 { 197 $userid = get_userid(); 198 set_preference($userid, 'collapse', ''); 199 } 200 201 function content_toggleexpand($contentid, $collapse) 202 { 203 $objResponse = new xajaxResponse(); 204 205 toggleexpand($contentid, $collapse=='true'?true:false); 206 207 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 208 $objResponse->addScript("new Effect.Highlight('tr_$contentid', { duration: 2.0 });"); 209 return $objResponse->getXML(); 210 } 211 212 function content_delete($contentid) 213 { 214 $objResponse = new xajaxResponse(); 215 216 deletecontent($contentid); 217 218 $objResponse->addScript("new Effect.Fade('tr_$contentid', { afterFinish:function() { xajax_content_list_ajax(); } });"); 219 return $objResponse->getXML(); 220 } 221 222 function toggleexpand($contentid, $collapse = false) 223 { 224 $userid = get_userid(); 225 $openedArray=array(); 226 if (get_preference($userid, 'collapse', '') != '') 227 { 228 $tmp = explode('.',get_preference($userid, 'collapse')); 229 foreach ($tmp as $thisCol) 230 { 231 $colind = substr($thisCol,0,strpos($thisCol,'=')); 232 $openedArray[$colind] = 1; 233 } 234 } 235 if ($collapse) 236 { 237 $openedArray[$contentid] = 0; 238 } 239 else 240 { 241 $openedArray[$contentid] = 1; 242 } 243 $cs = ''; 244 foreach ($openedArray as $key=>$val) 245 { 246 if ($val == 1) 247 { 248 $cs .= $key.'=1.'; 249 } 250 } 251 set_preference($userid, 'collapse', $cs); 252 } 253 254 function setactive($contentid, $active = true) 255 { 256 global $gCms; 257 $userid = get_userid(); 258 259 $hierManager =& $gCms->GetHierarchyManager(); 260 261 // to activate a page, you must be admin, owner, or additional author 262 $permission = (check_modify_all($userid) || 263 check_ownership($userid, $contentid) || 264 check_authorship($userid, $contentid) || 265 check_permission($userid, 'Modify Page Structure') 266 ); 267 268 if($permission) 269 { 270 $node = &$hierManager->getNodeById($contentid); 271 $value =& $node->getContent(); 272 $value->SetActive($active); 273 $value->Save(); 274 global $gCms; 275 $contentops =& $gCms->GetContentOperations(); 276 $contentops->ClearCache(); 277 } 278 } 279 280 function content_move($contentid, $parentid, $direction) 281 { 282 $objResponse = new xajaxResponse(); 283 284 movecontent($contentid, $parentid, $direction); 285 286 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 287 $objResponse->addScript("new Effect.Highlight('tr_$contentid', { duration: 2.0 });"); 288 return $objResponse->getXML(); 289 } 290 291 function movecontent($contentid, $parentid, $direction = 'down') 292 { 293 global $gCms; 294 $db =& $gCms->GetDb(); 295 $userid = get_userid(); 296 297 if (check_modify_all($userid) || check_permission($userid, 'Modify Page Structure')) 298 { 299 $order = 1; 300 301 #Grab necessary info for fixing the item_order 302 $query = "SELECT item_order FROM ".cms_db_prefix()."content WHERE content_id = ?"; 303 $result = $db->Execute($query, array($contentid)); 304 $row = $result->FetchRow(); 305 if (isset($row["item_order"])) 306 { 307 $order = $row["item_order"]; 308 } 309 310 $time = $db->DBTimeStamp(time()); 311 if ($direction == "down") 312 { 313 $query = 'UPDATE '.cms_db_prefix().'content SET item_order = (item_order - 1), modified_date = '.$time.' WHERE item_order = ? AND parent_id = ?'; 314 #echo $query, $order + 1, $parent_id; 315 $db->Execute($query, array($order + 1, $parentid)); 316 $query = 'UPDATE '.cms_db_prefix().'content SET item_order = (item_order + 1), modified_date = '.$time.' WHERE content_id = ? AND parent_id = ?'; 317 #echo $query, $content_id, $parent_id; 318 $db->Execute($query, array($contentid, $parentid)); 319 } 320 else if ($direction == "up") 321 { 322 $query = 'UPDATE '.cms_db_prefix().'content SET item_order = (item_order + 1), modified_date = '.$time.' WHERE item_order = ? AND parent_id = ?'; 323 #echo $query; 324 $db->Execute($query, array($order - 1, $parentid)); 325 $query = 'UPDATE '.cms_db_prefix().'content SET item_order = (item_order - 1), modified_date = '.$time.' WHERE content_id = ? AND parent_id = ?'; 326 #echo $query; 327 $db->Execute($query, array($contentid, $parentid)); 328 } 329 330 global $gCms; 331 $contentops =& $gCms->GetContentOperations(); 332 $contentops->SetAllHierarchyPositions(); 333 $contentops->ClearCache(); 334 } 335 } 336 337 function deletecontent($contentid) 338 { 339 $userid = get_userid(); 340 $access = check_permission($userid, 'Remove Pages') || check_permission($userid, 'Modify Page Structure'); 341 342 global $gCms; 343 $hierManager =& $gCms->GetHierarchyManager(); 344 345 if ($access) 346 { 347 $node = &$hierManager->getNodeById($contentid); 348 if ($node) 349 { 350 $contentobj =& $node->getContent(); 351 $childcount = 0; 352 $parentid = -1; 353 if (isset($node->parentNode)) 354 { 355 $parent =& $node->parentNode; 356 if (isset($parent)) 357 { 358 $parentContent =& $parent->getContent(); 359 if (isset($parentContent)) 360 { 361 $parentid = $parentContent->Id(); 362 $childcount = $parent->getChildrenCount(); 363 } 364 } 365 } 366 367 if ($contentobj) 368 { 369 $title = $contentobj->Name(); 370 371 #Check for children 372 if ($contentobj->HasChildren()) 373 { 374 $_GET['error'] = 'errorchildcontent'; 375 } 376 377 #Check for default 378 if ($contentobj->DefaultContent()) 379 { 380 $_GET['error'] = 'errordefaultpage'; 381 } 382 383 $title = $contentobj->Name(); 384 $contentobj->Delete(); 385 386 $contentops =& $gCms->GetContentOperations(); 387 $contentops->SetAllHierarchyPositions(); 388 389 #See if this is the last child... if so, remove 390 #the expand for it 391 if ($childcount == 1 && $parentid > -1) 392 { 393 toggleexpand($parentid, true); 394 } 395 396 #Do the same with this page as well 397 toggleexpand($contentid, true); 398 399 audit($contentid, $title, 'Deleted Content'); 400 401 $contentops->ClearCache(); 402 403 $_GET['message'] = 'contentdeleted'; 404 } 405 } 406 } 407 } 408 409 function show_h(&$root, &$sortableLists, &$listArray, &$output) 410 { 411 $content = &$root->getContent(); 412 413 global $gCms; 414 $contentops =& $gCms->GetContentOperations(); 415 416 $output .= '<li id="item_'.$content->mId.'">'."\n"; 417 $output .= '('.$contentops->CreateFriendlyHierarchyPosition($content->mHierarchy).') '.$content->mName; 418 419 if ($root->getChildrenCount()>0) 420 { 421 $sortableLists->addList('parent'.$content->mId,'parent'.$content->mId.'ListOrder'); 422 $listArray[$content->mId] = 'parent'.$content->mId.'ListOrder'; 423 $output .= '<ul id="parent'.$content->mId.'" class="sortableList">'."\n"; 424 425 $children = &$root->getChildren(); 426 foreach ($children as $child) 427 { 428 show_h($child, $sortableLists, $listArray, $output); 429 } 430 $output .= "</ul>\n"; 431 } 432 else 433 { 434 $output .= "</li>\n"; 435 } 436 } 437 438 function reorder_display_list() 439 { 440 $objResponse = new xajaxResponse(); 441 global $gCms; 442 $config =& $gCms->GetConfig(); 443 444 $userid = get_userid(); 445 446 $path = cms_join_path(dirname(dirname(__FILE__)), 'lib', 'sllists', 'SLLists.class.php'); 447 require($path); 448 449 $sortableLists = new SLLists($config["root_url"].'/lib/scriptaculous'); 450 451 $hierManager =& $gCms->GetHierarchyManager(); 452 $hierarchy = &$hierManager->getRootNode(); 453 454 $listArray = array(); 455 $output = ''; 456 457 $sortableLists->addList('parent0','parent0ListOrder'); 458 $listArray[0] = 'parent0ListOrder'; 459 $output .= '<ul id="parent0" class="sortableList">'."\n"; 460 461 foreach ($hierarchy->getChildren() as $child) 462 { 463 show_h($child, $sortableLists, $listArray, $output); 464 } 465 466 $output .= '</ul>'; 467 468 ob_start(); 469 //$sortableLists->printTopJS(); 470 $sortableLists->printForm($_SERVER['PHP_SELF'], 'POST', lang('submit'), 'button', 'sortableListForm', lang('cancel'), $output); 471 $contents = ob_get_contents(); 472 ob_end_clean(); 473 474 ob_start(); 475 $sortableLists->printBottomJs(); 476 $script = ob_get_contents(); 477 ob_end_clean(); 478 479 $objResponse->addAssign("contentlist", "innerHTML", $contents); 480 $objResponse->addScript($script); 481 482 return $objResponse->getXML(); 483 } 484 485 function reorder_process($get) 486 { 487 $userid = get_userid(); 488 $objResponse = new xajaxResponse(); 489 490 if (check_modify_all($userid)) 491 { 492 global $gCms; 493 $config =& $gCms->GetConfig(); 494 $db =& $gCms->GetDb(); 495 $contentops =& $gCms->GetContentOperations(); 496 $hm = $contentops->GetAllContentAsHierarchy(false); 497 $hierarchy = &$hm->getRootNode(); 498 499 require(cms_join_path(dirname(dirname(__FILE__)), 'lib', 'sllists','SLLists.class.php')); 500 $sortableLists = new SLLists( $config["root_url"].'/lib/scriptaculous'); 501 502 $listArray = array(); 503 $output = ''; 504 505 $sortableLists->addList('parent0','parent0ListOrder'); 506 $listArray[0] = 'parent0ListOrder'; 507 $output .= '<ul id="parent0" class="sortableList">'."\n"; 508 509 foreach ($hierarchy->getChildren() as $child) 510 { 511 show_h($child, $sortableLists, $listArray, $output); 512 } 513 514 $output .= '</ul>'; 515 516 $order_changed = FALSE; 517 foreach ($listArray AS $parent_id => $order) 518 { 519 $orderArray = SLLists::getOrderArray($get[$order], 'parent'.$parent_id); 520 foreach($orderArray as $item) 521 { 522 $node =& $hm->sureGetNodeById($item['element']); 523 if ($node != NULL) 524 { 525 $one =& $node->getContent(); 526 // Only update if order has changed. 527 if ($one->ItemOrder() != $item['order']) 528 { 529 $order_changed = TRUE; 530 $query = 'UPDATE '.cms_db_prefix().'content SET item_order = ? WHERE content_id = ?'; 531 $db->Execute($query, array($item['order'], $item['element'])); 532 } 533 } 534 } 535 } 536 if (TRUE == $order_changed) { 537 global $gCms; 538 $contentops =& $gCms->GetContentOperations(); 539 $contentops->SetAllHierarchyPositions(); 540 $contentops->ClearCache(); 541 } 542 } 543 544 $objResponse->addAssign("contentlist", "innerHTML", display_content_list()); 545 return $objResponse->getXML(); 546 } 547 548 function check_children(&$root, &$mypages, &$userid) 549 { 550 $result = false; 551 $content =& $root->getContent(); 552 if (isset($content)) 553 { 554 $result = in_array($content->Id(), $mypages, false); 555 if (!$result) 556 { 557 $children =& $root->getChildren(); 558 foreach ($children as $child) 559 { 560 $result = check_children($child, $mypages, $userid); 561 if ($result) 562 break; 563 } 564 } 565 } 566 return $result; 567 } 568 569 function display_hierarchy(&$root, &$userid, $modifyall, &$templates, &$users, &$menupos, &$openedArray, &$pagelist, &$image_true, &$image_set_false, &$image_set_true, &$upImg, &$downImg, &$viewImg, &$editImg, &$deleteImg, &$expandImg, &$contractImg, &$mypages, &$page) 570 { 571 global $currow; 572 global $config; 573 global $page; 574 global $indent; 575 576 $one =& $root->getContent(); 577 $children =& $root->getChildren(); 578 $thelist = ''; 579 580 if (!(isset($one) && $one != NULL)) 581 { 582 return; 583 } 584 585 if (!array_key_exists($one->TemplateId(), $templates)) 586 { 587 global $gCms; 588 $templateops =& $gCms->GetTemplateOperations(); 589 $templates[$one->TemplateId()] = $templateops->LoadTemplateById($one->TemplateId()); 590 } 591 592 if (!array_key_exists($one->Owner(), $users)) 593 { 594 global $gCms; 595 $userops =& $gCms->GetUserOperations(); 596 $users[$one->Owner()] =& $userops->LoadUserById($one->Owner()); 597 } 598 599 $display = 'none'; 600 601 if (check_modify_all($userid) || check_ownership($userid, $one->Id()) || quick_check_authorship($one->Id(), $mypages)) 602 { 603 $display = 'edit'; 604 } 605 else if (check_children($root, $mypages, $userid)) 606 { 607 $display = 'view'; 608 } 609 else if (check_permission($userid, 'Modify Page Structure')) 610 { 611 $display = 'structure'; 612 } 613 614 if ($display != 'none') 615 { 616 $thelist .= "<tr id=\"tr_".$one->Id()."\" class=\"$currow\" onmouseover=\"this.className='".$currow.'hover'."';\" onmouseout=\"this.className='".$currow."';\">\n"; 617 $thelist .= "<td>"; 618 if ($root->hasChildren()) 619 { 620 if (!in_array($one->Id(),$openedArray)) 621 { 622 $thelist .= "<a href=\"listcontent.php?content_id=".$one->Id()."&col=0&page=".$page."\" onclick=\"xajax_content_toggleexpand(".$one->Id().", 'false'); return false;\">"; 623 $thelist .= $expandImg; 624 $thelist .= "</a>"; 625 } 626 else 627 { 628 $thelist .= "<a href=\"listcontent.php?content_id=".$one->Id()."&col=1&page=".$page."\" onclick=\"xajax_content_toggleexpand(".$one->Id().", 'true'); return false;\">"; 629 $thelist .= $contractImg; 630 $thelist .= "</a>"; 631 } 632 } 633 $thelist .= "</td><td>"; 634 /* 635 if (check_modify_all($userid)) 636 { 637 $pos = strrpos($one->Hierarchy(), '.'); 638 if ($pos != false) 639 { 640 $thelist .= substr($one->Hierarchy(), 0, $pos)."\n"; 641 } 642 643 $thelist .= '<input type="text" name="order-'. $one->Id().'" value="'.$one->ItemOrder().'" class="order" /> '."\n"; 644 } 645 else 646 { 647 */ 648 $thelist .= $one->Hierarchy(); 649 //} 650 $thelist .= "</td>\n"; 651 $thelist .= "<td>"; 652 653 if ($indent) 654 { 655 for ($i=0;$i < $root->getLevel();$i++) 656 { 657 $thelist .= "- "; 658 } 659 } ## if indent 660 661 if ($display == 'edit') 662 $thelist .= '<a href="editcontent.php?content_id='.$one->mId.'&page='.$page.'" title="'. htmlspecialchars($one->mName.' ('.$one->mAlias) .')">'.$one->mMenuText.'</a></td>'. "\n"; 663 else 664 $thelist .= $one->Name()."</td>\n"; 665 666 667 if (isset($templates[$one->TemplateId()]->name) && $templates[$one->TemplateId()]->name) 668 { 669 $thelist .= "<td><a href=\"edittemplate.php?template_id=".$one->TemplateId()."&from=content\">".$templates[$one->TemplateId()]->name."</a></td>\n"; 670 } 671 else 672 { 673 $thelist .= "<td> </td>\n"; 674 } 675 676 $thelist .= "<td>".$one->FriendlyName()."</td>\n"; 677 678 if ($one->Owner() > -1) 679 { 680 $thelist .= "<td>".$users[$one->Owner()]->username."</td>\n"; 681 } 682 else 683 { 684 $thelist .= "<td> </td>\n"; 685 } 686 if (check_permission($userid, 'Modify Page Structure')) 687 { 688 if ($display == 'edit' || $display == 'structure') 689 { 690 if($one->Active()) 691 { 692 $thelist .= "<td class=\"pagepos\">".($one->DefaultContent()?$image_true:"<a href=\"listcontent.php?setinactive=".$one->Id()."\" onclick=\"xajax_content_setinactive(".$one->Id().");return false;\">".$image_set_false."</a>")."</td>\n"; 693 } 694 else 695 { 696 $thelist .= "<td class=\"pagepos\"><a href=\"listcontent.php?setactive=".$one->Id()."\" onclick=\"xajax_content_setactive(".$one->Id().");return false;\">".$image_set_true."</a></td>\n"; 697 } 698 } 699 else 700 { 701 $thelist .= "<td> </td>\n"; 702 } 703 } 704 if (check_modify_all($userid)) 705 { 706 if ($one->IsDefaultPossible() && ($display == 'edit' || $display == 'structure')) 707 { 708 $thelist .= "<td class=\"pagepos\">".($one->DefaultContent()?$image_true:"<a href=\"listcontent.php?makedefault=".$one->Id()."\" onclick=\"if(confirm('".lang("confirmdefault")."')) xajax_content_setdefault(".$one->Id().");return false;\">".$image_set_true."</a>")."</td>\n"; 709 } 710 else 711 { 712 $thelist .= "<td> </td>"; 713 } 714 } 715 716 // code for move up is simple 717 if (check_permission($userid, 'Modify Page Structure')) 718 { 719 $thelist .= "<td class=\"move\">"; 720 //$parentNode = &$root->getParentNode(); 721 //if ($parentNode!=null) 722 //{ 723 $sameLevel = $root->getSiblingCount(); 724 if ($sameLevel>1) 725 { 726 if (($one->ItemOrder() - 1)==0) #first 727 { 728 $thelist .= "<a onclick=\"xajax_content_move(".$one->Id().", ".$one->ParentId().", 'down'); return false;\" href=\"listcontent.php?direction=down&content_id=".$one->Id()."&parent_id=".$one->ParentId()."&page=".$page."\">"; 729 $thelist .= $downImg; 730 $thelist .= "</a>"; 731 } 732 else if (($one->ItemOrder() - 1) == $sameLevel-1) #last 733 { 734 $thelist .= " <a class=\"move_up\" onclick=\"xajax_content_move(".$one->Id().", ".$one->ParentId().", 'up'); return false;\" href=\"listcontent.php?direction=up&content_id=".$one->Id()."&parent_id=".$one->ParentId()."&page=".$page."\">"; 735 $thelist .= $upImg; 736 $thelist .= "</a>"; 737 } 738 else #middle 739 { 740 $thelist .= "<a onclick=\"xajax_content_move(".$one->Id().", ".$one->ParentId().", 'down'); return false;\" href=\"listcontent.php?direction=down&content_id=".$one->Id()."&parent_id=".$one->ParentId()."&page=".$page."\">"; 741 $thelist .= $downImg; 742 $thelist .= "</a> <a onclick=\"xajax_content_move(".$one->Id().", ".$one->ParentId().", 'up'); return false;\" href=\"listcontent.php?direction=up&content_id=".$one->Id()."&parent_id=".$one->ParentId()."&page=".$page."\">"; 743 $thelist .= $upImg; 744 $thelist .= "</a>"; 745 } 746 } 747 //} 748 $thelist .= "</td>"; 749 $thelist .= '<td class="invisible" style="text-align: center;"><input type="text" name="order-'. $one->Id().'" value="'.$one->ItemOrder().'" class="order" /> '."</td>\n"; 750 } 751 // end of move code 752 753 $url = $one->GetURL(); 754 if ($url != '' && $url != '#') 755 { 756 $thelist .= "<td class=\"pagepos\"><a href=\"".$one->GetURL()."\" rel=\"external\">"; 757 $thelist .= $viewImg; 758 $thelist .= "</a></td>\n"; 759 } 760 else 761 { 762 $thelist .= '<td> </td>' . "\n"; 763 } 764 765 if ($display == 'edit' || $display == 'structure') 766 { 767 if ($display == 'edit') 768 { 769 $thelist .= "<td class=\"pagepos\"><a href=\"editcontent.php?content_id=".$one->Id()."\">"; 770 $thelist .= $editImg; 771 $thelist .= "</a></td>\n"; 772 } 773 if ($one->DefaultContent() != true) 774 { 775 //if ($one->ChildCount() == 0 && !in_array($one->Id(),$openedArray)) 776 //var_dump($one->ChildCount()); 777 if ($root->getChildrenCount() == 0 && (check_permission($userid, 'Modify Page Structure') || check_permission($userid, 'Remove Pages'))) 778 { 779 $thelist .= "<td class=\"pagepos\"><a href=\"listcontent.php?deletecontent=".$one->Id()."\" onclick=\"if (confirm('".lang('deleteconfirm')."')) xajax_content_delete(".$one->Id()."); return false;\">"; 780 $thelist .= $deleteImg; 781 $thelist .= "</a></td>\n"; 782 } 783 else 784 { 785 $thelist .= '<td> </td>' . "\n"; 786 } 787 if (check_permission($userid, 'Modify Page Structure')) 788 { 789 $thelist .= '<td class="checkbox"><input type="checkbox" name="multicontent-'.$one->Id().'" /></td>'; 790 } 791 } 792 else 793 { 794 $thelist .= '<td> </td>' . "\n"; 795 } 796 $thelist .= "</tr>\n"; 797 } 798 else 799 { 800 $thelist .= '<td> </td><td> </td><td> </td></tr>' . "\n"; 801 } 802 ($currow == "row1"?$currow="row2":$currow="row1"); 803 } 804 805 $pagelist[] = &$thelist; 806 807 $indent = get_preference($userid, 'indent', true); 808 809 if (in_array($one->Id(),$openedArray)) 810 { 811 foreach ($children as $child) 812 { 813 display_hierarchy($child, $userid, $modifyall, $templates, $users, $menupos, $openedArray, $pagelist, $image_true, $image_set_false, $image_set_true, $upImg, $downImg, $viewImg, $editImg, $deleteImg, $expandImg, $contractImg, $mypages, $page); 814 } 815 } 816 } // function display_hierarchy 817 818 function display_content_list($themeObject = null) 819 { 820 global $gCms; 821 822 check_login(); 823 $userid = get_userid(); 824 825 $mypages = author_pages($userid); 826 827 $page = 1; 828 if (isset($_GET['page'])) 829 $page = $_GET['page']; 830 //$limit = get_preference($userid, 'paging', 0); 831 $limit = 0; //Took out pagination 832 833 $thelist = ''; 834 $count = 0; 835 836 $currow = "row1"; 837 838 if ($themeObject == null) 839 $themeObject =& AdminTheme::GetThemeObject(); 840 841 // construct true/false button images 842 $image_true = $themeObject->DisplayImage('icons/system/true.gif', lang('true'),'','','systemicon'); 843 $image_set_false = $themeObject->DisplayImage('icons/system/true.gif', lang('setfalse'),'','','systemicon'); 844 $image_set_true = $themeObject->DisplayImage('icons/system/false.gif', lang('settrue'),'','','systemicon'); 845 $expandImg = $themeObject->DisplayImage('icons/system/expand.gif', lang('expand'),'','','systemicon'); 846 $contractImg = $themeObject->DisplayImage('icons/system/contract.gif', lang('contract'),'','','systemicon'); 847 $downImg = $themeObject->DisplayImage('icons/system/arrow-d.gif', lang('down'),'','','systemicon'); 848 $upImg = $themeObject->DisplayImage('icons/system/arrow-u.gif', lang('up'),'','','systemicon'); 849 $viewImg = $themeObject->DisplayImage('icons/system/view.gif', lang('view'),'','','systemicon'); 850 $editImg = $themeObject->DisplayImage('icons/system/edit.gif', lang('edit'),'','','systemicon'); 851 $deleteImg = $themeObject->DisplayImage('icons/system/delete.gif', lang('delete'),'','','systemicon'); 852 853 $counter = 0; 854 855 #Setup array so we don't load more templates than we need to 856 $templates = array(); 857 858 #Ditto with users 859 $users = array(); 860 861 $menupos = array(); 862 863 $openedArray=array(); 864 if (get_preference($userid, 'collapse', '') != '') 865 { 866 $tmp = explode('.',get_preference($userid, 'collapse')); 867 foreach ($tmp as $thisCol) 868 { 869 $colind = substr($thisCol,0,strpos($thisCol,'=')); 870 if ($colind!="") 871 $openedArray[] = $colind; 872 } 873 } 874 875 //if (check_modify_all($userid)) 876 //$hierManager = &ContentManager::GetAllContentAsHierarchy(false,$openedArray); 877 //else 878 $hierManager =& $gCms->GetHierarchyManager(); 879 880 $hierarchy = &$hierManager->getRootNode(); 881 882 if ($hierarchy->hasChildren()) 883 { 884 $pagelist = array(); 885 foreach ($hierarchy->getChildren() as $child) 886 { 887 display_hierarchy($child, $userid, check_modify_all($userid), $templates, $users, $menupos, $openedArray, $pagelist, $image_true, $image_set_false, $image_set_true, $upImg, $downImg, $viewImg, $editImg, $deleteImg, $expandImg, $contractImg, $mypages, $page); 888 } 889 #display_hierarchy($hierarchy, $userid, check_modify_all($userid), $templates, $users, $menupos, $openedArray, $pagelist, $image_true, $image_set_false, $image_set_true, $upImg, $downImg, $viewImg, $editImg, $deleteImg, $expandImg, $contractImg, $mypages, $page); 890 foreach ($pagelist as $item) 891 { 892 $thelist.=$item; 893 } 894 895 $thelist .= '<tr class="invisible"><td> </td><td> </td><td> </td> 896 <td> </td><td> </td><td> </td><td> </td><td> </td> 897 <td> </td><td><input type="submit" name="reorderpages" value="'.lang('reorderpages').'" /></td><td> </td><td> </td><td> </td><td> </td></tr>'; 898 899 $thelist .= '</tbody>'; 900 $thelist .= "</table>\n"; 901 } 902 903 $headoflist = ''; 904 905 $headoflist .= '<div class="pageoverflow">'; 906 if (check_permission($userid, 'Add Pages')) 907 { 908 $headoflist .= '<p class="pageoptions"><a href="addcontent.php" class="pageoptions">'; 909 $headoflist .= $themeObject->DisplayImage('icons/system/newobject.gif', lang('addcontent'),'','','systemicon').'</a>'; 910 $headoflist .= ' <a class="pageoptions" href="addcontent.php">'.lang("addcontent").'</a></p>'; 911 } 912 if (check_permission($userid, 'Add Pages') || check_modify_all($userid) || check_permission($userid, 'Modify Page Structure')) 913 { 914 if (check_permission($userid, 'Modify Page Structure')) { 915 if (check_modify_all($userid) || check_permission($userid, 'Modify Page Structure')) 916 { 917 $headoflist .= ' <a href="listcontent.php?error=jsdisabled" class="pageoptions" onclick="xajax_reorder_display_list();return false;">'; 918 $headoflist .= $themeObject->DisplayImage('icons/system/reorder.gif', lang('reorderpages'),'','','systemicon').'</a>'; 919 $headoflist .= ' <a href="listcontent.php?error=jsdisabled" class="pageoptions" onclick="xajax_reorder_display_list();return false;">'.lang('reorderpages').'</a>'; 920 } 921 $headoflist .='</p>'; 922 } 923 } 924 $headoflist .='</div>'; 925 $headoflist .= '<form action="multicontent.php" method="post">'; 926 $headoflist .= '<table cellspacing="0" class="pagetable">'."\n"; 927 $headoflist .= '<thead>'; 928 $headoflist .= "<tr>\n"; 929 $headoflist .= "<th> </th>"; 930 $headoflist .= "<th> </th>"; 931 $headoflist .= "<th class=\"pagew25\">".lang('title')."</th>\n"; 932 $headoflist .= "<th>".lang('template')."</th>\n"; 933 $headoflist .= "<th>".lang('type')."</th>\n"; 934 $headoflist .= "<th>".lang('owner')."</th>\n"; 935 if (check_permission($userid, 'Modify Page Structure')) 936 { 937 $headoflist .= "<th class=\"pagepos\">".lang('active')."</th>\n"; 938 } 939 if (check_modify_all($userid)) 940 { 941 $headoflist .= "<th class=\"pagepos\">".lang('default')."</th>\n"; 942 } 943 if (check_modify_all($userid) && check_permission($userid, 'Modify Page Structure')) 944 { 945 $headoflist .= "<th class=\"move\">".lang('move')."</th>\n"; 946 $headoflist .= "<th class=\"pagepos invisible\">".lang('order')."</th>\n"; 947 } 948 $headoflist .= "<th class=\"pageicon\"> </th>\n"; 949 $headoflist .= "<th class=\"pageicon\"> </th>\n"; 950 $headoflist .= "<th class=\"pageicon\"> </th>\n"; 951 if (check_permission($userid, 'Modify Page Structure')) 952 { 953 $headoflist .= "<th class=\"checkbox\"> </th>\n"; 954 } 955 $headoflist .= "</tr>\n"; 956 $headoflist .= '</thead>'; 957 $headoflist .= '<tbody>'; 958 ob_start(); 959 if (check_permission($userid, 'Modify Page Structure')) 960 { 961 ?> 962 <div class="pageoptions" style="margin-right: 3%;" > 963 <div style="margin-top: 0; float: right; text-align: right"> 964 <?php echo lang('selecteditems'); ?>: <select name="multiaction"> 965 <option value="delete"><?php echo lang('delete') ?></option> 966 <option value="active"><?php echo lang('active') ?></option> 967 <option value="inactive"><?php echo lang('inactive') ?></option> 968 </select> 969 <input type="submit" value="<?php echo lang('submit') ?>" /> 970 <span style="margin-left: 10px;"> 971 <a href="javascript:selectall();"><?php echo lang('selectall'); ?></a> 972 </span> 973 </div> 974 </div> 975 <?php 976 } 977 ?> 978 <div style="float: left;"> 979 <?php 980 if (check_permission($userid, 'Add Pages')) 981 { 982 ?> 983 <a href="addcontent.php" class="pageoptions"> 984 <?php 985 echo $themeObject->DisplayImage('icons/system/newobject.gif', lang('addcontent'),'','','systemicon').'</a>'; 986 echo ' <a class="pageoptions" href="addcontent.php">'.lang("addcontent"); 987 ?> 988 </a> 989 <?php 990 } 991 ?> 992 <a style="margin-left: 10px;" href="listcontent.php?expandall=1" onclick="xajax_content_expandall(); return false;"> 993 <?php 994 echo $themeObject->DisplayImage('icons/system/expandall.gif', lang('expandall'),'','','systemicon').'</a>'; 995 echo ' <a class="pageoptions" href="listcontent.php?expandall=1" onclick="xajax_content_expandall(); return false;">'.lang("expandall"); 996 ?> 997 </a> 998 <a href="listcontent.php?collapseall=1" onclick="xajax_content_collapseall(); return false;"> 999 <?php 1000 echo $themeObject->DisplayImage('icons/system/contractall.gif', lang('contractall'),'','','systemicon').'</a>'; 1001 echo ' <a class="pageoptions" href="listcontent.php?collapseall=1" onclick="xajax_content_collapseall(); return false;">'.lang("contractall").'</a>'; 1002 if (check_modify_all($userid) && check_permission($userid, 'Modify Page Structure')) 1003 { 1004 $image_reorder = $themeObject->DisplayImage('icons/system/reorder.gif', lang('reorderpages'),'','','systemicon'); 1005 echo ' <a class="pageoptions" href="listcontent.php?error=jsdisabled" onclick="xajax_reorder_display_list();return false;">'.$image_reorder.'</a> <a class="pageoptions" href="listcontent.php?error=jsdisabled" onclick="xajax_reorder_display_list();return false;">'.lang('reorderpages').'</a>'; 1006 } 1007 ?> 1008 </div> 1009 1010 <br /> 1011 1012 <div class="clearb"></div> 1013 <?php 1014 $footer = ob_get_contents(); 1015 ob_end_clean(); 1016 1017 return $headoflist . $thelist . $footer .'</form></div>'; 1018 } 1019 1020 echo $themeObject->ShowMessage('', 'message'); 1021 echo $themeObject->ShowErrors('' ,'error'); 1022 ?> 1023 <div class="pagecontainer"> 1024 <?php 1025 1026 $hierManager =& $gCms->GetHierarchyManager(); 1027 1028 if (isset($_GET["makedefault"])) 1029 { 1030 setdefault($_GET['makedefault']); 1031 redirect('listcontent.php'); 1032 } 1033 1034 // check if we're activating a page 1035 if (isset($_GET["setactive"])) 1036 { 1037 setactive($_GET["setactive"]); 1038 } 1039 1040 // perhaps we're deactivating a page instead? 1041 if (isset($_GET["setinactive"])) 1042 { 1043 setactive($_GET["setinactive"], false); 1044 } 1045 1046 if (isset($_GET['expandall'])) 1047 { 1048 expandall(); 1049 } 1050 1051 if (isset($_GET['collapseall'])) 1052 { 1053 collapseall(); 1054 } 1055 1056 if (isset($_GET['deletecontent'])) 1057 { 1058 deletecontent($_GET['deletecontent']); 1059 redirect('listcontent.php'); 1060 } 1061 1062 if (isset($_GET['direction'])) 1063 { 1064 movecontent($_GET['content_id'], $_GET['parent_id'], $_GET['direction']); 1065 } 1066 1067 if (isset($_GET['col']) && isset($_GET['content_id'])) 1068 { 1069 toggleexpand($_GET['content_id'], $_GET['col']=='1'?true:false); 1070 } 1071 1072 echo '<div class="pageoverflow">'; 1073 echo $themeObject->ShowHeader('currentpages').'</div>'; 1074 echo '<div id="contentlist">'.display_content_list($themeObject).'</div>'; 1075 1076 ?> 1077 1078 <p class="pageback"><a class="pageback" href="<?php echo $themeObject->BackUrl(); ?>">« <?php echo lang('back')?></a></p> 1079 <script type="text/javascript"> 1080 //<![CDATA[ 1081 function selectall() 1082 { 1083 checkboxes = document.getElementsByTagName("input"); 1084 for (i=0; i<checkboxes.length ; i++) 1085 { 1086 if (checkboxes[i].type == "checkbox") checkboxes[i].checked=true; 1087 } 1088 } 1089 //]]> 1090 </script> 1091 <?php 1092 1093 include_once ("footer.php"); 1094 1095 # vim:ts=4 sw=4 noet 1096 ?>
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 |