| [ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 3 # CMS - CMS Made Simple 4 # (c)2004 by Ted Kulp (tedkulp@users.sf.net) 5 # This project's homepage is: http://cmsmadesimple.org 6 # 7 # This program is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # This program is distributed in the hope that it will be useful, 13 # BUT withOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write to the Free Software 18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 # 20 #$Id$ 21 22 /** 23 * Class for static methods related to content 24 * 25 * @since 0.8 26 * @package CMS 27 */ 28 29 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.content.inc.php'); 30 31 class ContentOperations 32 { 33 function LoadContentType($type) 34 { 35 $type = strtolower($type); 36 37 global $gCms; 38 $contenttypes =& $gCms->contenttypes; 39 40 if (isset($contenttypes[$type])) 41 { 42 $placeholder =& $contenttypes[$type]; 43 if ($placeholder->loaded == false) 44 { 45 include_once($placeholder->filename); 46 $placeholder->loaded = true; 47 } 48 return true; 49 } 50 return false; 51 } 52 53 function &CreateNewContent($type) 54 { 55 $type = strtolower($type); 56 57 $result = NULL; 58 59 if (ContentOperations::LoadContentType($type)) 60 { 61 $result =& new $type; 62 } 63 64 return $result; 65 } 66 67 /** 68 * Determine proper type of object, load it and return it 69 */ 70 function &LoadContentFromId($id,$loadprops=true) 71 { 72 $result = FALSE; 73 74 global $gCms; 75 $db = &$gCms->GetDb(); 76 77 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_id = ?"; 78 $row = &$db->GetRow($query, array($id)); 79 if ($row) 80 { 81 #Make sure the type exists. If so, instantiate and load 82 if (in_array($row['type'], array_keys(ContentOperations::ListContentTypes()))) 83 { 84 $classtype = strtolower($row['type']); 85 $contentobj =& ContentOperations::CreateNewContent($classtype); 86 if ($contentobj) 87 { 88 $contentobj->LoadFromData($row, FALSE); 89 } 90 return $contentobj; 91 } 92 else 93 { 94 return $result; 95 } 96 } 97 else 98 { 99 return $result; 100 } 101 } 102 103 function &LoadContentFromAlias($alias, $only_active = false) 104 { 105 global $gCms; 106 $db = &$gCms->GetDb(); 107 108 $row = ''; 109 110 if (is_numeric($alias) && strpos($alias,'.') === FALSE && strpos($alias,',') === FALSE) //Fix for postgres 111 { 112 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_id = ?"; 113 if ($only_active == true) 114 { 115 $query .= " AND active = 1"; 116 } 117 $row = &$db->GetRow($query, array($alias)); 118 } 119 else 120 { 121 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_alias = ?"; 122 if ($only_active == true) 123 { 124 $query .= " AND active = 1"; 125 } 126 $row = &$db->GetRow($query, array($alias)); 127 } 128 129 if ($row) 130 { 131 #Make sure the type exists. If so, instantiate and load 132 if (in_array($row['type'], array_keys(ContentOperations::ListContentTypes()))) 133 { 134 $classtype = strtolower($row['type']); 135 $contentobj =& ContentOperations::CreateNewContent($classtype); 136 $contentobj->LoadFromData($row, TRUE); 137 return $contentobj; 138 } 139 else 140 { 141 return FALSE; 142 } 143 } 144 else 145 { 146 return FALSE; 147 } 148 } 149 150 /** 151 * Load the content of the object from a list of ID 152 * Private method. 153 * @param $ids array of element ids 154 * @param $loadProperties whether to load or not the properties 155 * 156 * @returns array of content objects (empty if not found) 157 */ 158 /*private*/ function &LoadMultipleFromId($ids, $loadProperties = false) 159 { 160 global $gCms, $config, $sql_queries, $debug_errors; 161 $cpt = count($ids); 162 $contents=array(); 163 if ($cpt==0) 164 { 165 return $contents; 166 } 167 $db = &$gCms->GetDb(); 168 $id_list = '('; 169 for ($i=0;$i<$cpt;$i++) 170 { 171 $id_list .= $ids[$i]; 172 if ($i<$cpt-1) 173 { 174 $id_list .= ','; 175 } 176 } 177 $id_list .= ')'; 178 if ($id_list=='()') 179 { 180 return $contents; 181 } 182 $result = false; 183 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_id IN $id_list"; 184 $rows =& $db->Execute($query); 185 186 if ($rows) 187 { 188 while (isset($rows) && $row = &$rows->FetchRow()) 189 { 190 if (in_array($row['type'], array_keys(ContentOperations::ListContentTypes()))) 191 { 192 $classtype = strtolower($row['type']); 193 $contentobj =& ContentOperations::CreateNewContent($classtype); 194 $contentobj->LoadFromData($row,false); 195 $contents[]=$contentobj; 196 $result = true; 197 } 198 } 199 $rows->Close(); 200 } 201 if (!$result) 202 { 203 if (true == $config["debug"]) 204 { 205 # :TODO: Translate the error message 206 $debug_errors .= "<p>Could not retrieve content from db</p>\n"; 207 } 208 } 209 210 if ($result && $loadProperties) 211 { 212 foreach ($contents as $content) 213 { 214 if ($content->mPropertiesLoaded == false) 215 { 216 debug_buffer("load from id is loading properties"); 217 $content->mProperties->Load($content->mId); 218 $content->mPropertiesLoaded = true; 219 } 220 221 if (NULL == $content->mProperties) 222 { 223 $result = false; 224 225 # debug mode 226 if (true == $config["debug"]) 227 { 228 # :TODO: Translate the error message 229 $debug_errors .= "<p>Could not load properties for content</p>\n"; 230 } 231 } 232 } 233 } 234 235 foreach ($contents as $content) 236 { 237 $content->Load(); 238 } 239 240 return $contents; 241 } 242 243 /** 244 * Load the content of the object from a list of aliases 245 * Private method. 246 * @param $ids array of element ids 247 * Private method 248 * 249 * @param $alis the alias of the element 250 * @param $loadProperties whether to load or not the properties 251 * 252 * @returns array of content objects (empty if not found) 253 */ 254 /*private*/function &LoadMultipleFromAlias($ids, $loadProperties = false) 255 { 256 global $gCms, $config, $sql_queries, $debug_errors; 257 $cpt = count($ids); 258 $contents=array(); 259 if ($cpt == 0) 260 { 261 return $contents; 262 } 263 $db = &$gCms->GetDb(); 264 $id_list = '('; 265 for ($i=0; $i<$cpt; $i++) 266 { 267 $id_list .= "'".$ids[$i]."'"; 268 if ($i<$cpt-1) 269 { 270 $id_list .= ','; 271 } 272 } 273 $id_list .= ')'; 274 if ($id_list == '()') 275 { 276 return $contents; 277 } 278 $result = false; 279 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_alias IN $id_list"; 280 $rows =& $db->Execute($query); 281 282 while (isset($rows) && $row=&$rows->FetchRow()) 283 { 284 #Make sure the type exists. If so, instantiate and load 285 if (in_array($row['type'], array_keys(ContentOperations::ListContentTypes()))) 286 { 287 $classtype = strtolower($row['type']); 288 $contentobj =& ContentOperations::CreateNewContent($classtype); 289 $contentobj->LoadFromData($row,false); 290 $contents[] =& $contentobj; 291 $result = true; 292 } 293 } 294 295 if ($rows) $rows->Close(); 296 297 if (!$result) 298 { 299 if (true == $config["debug"]) 300 { 301 # :TODO: Translate the error message 302 $debug_errors .= "<p>Could not retrieve content from db</p>\n"; 303 } 304 } 305 306 if ($result && $loadProperties) 307 { 308 foreach ($contents as $content) 309 { 310 if ($content->mPropertiesLoaded == false) 311 { 312 debug_buffer("load from id is loading properties"); 313 $content->mProperties->Load($content->mId); 314 $content->mPropertiesLoaded = true; 315 } 316 317 if (NULL == $content->mProperties) 318 { 319 $result = false; 320 321 # debug mode 322 if (true == $config["debug"]) 323 { 324 # :TODO: Translate the error message 325 $debug_errors .= "<p>Could not load properties for content</p>\n"; 326 } 327 } 328 } 329 } 330 foreach ($contents as $content) 331 { 332 $content->Load(); 333 } 334 return $contents; 335 } 336 337 338 /** 339 * Display content 340 */ 341 function DisplayContent($content) 342 { 343 //This should be straight forward, since the content will pretty much determine how it is displayed 344 $content->Show(); 345 } 346 347 /** 348 * Determine if content should be loaded from cache 349 */ 350 function IsCached($id) 351 { 352 } 353 354 function & GetDefaultContent() 355 { 356 global $gCms; 357 $db =& $gCms->GetDb(); 358 359 $result = -1; 360 361 $query = "SELECT content_id FROM ".cms_db_prefix()."content WHERE default_content = 1"; 362 $row = &$db->GetRow($query); 363 if ($row) 364 { 365 $result = $row['content_id']; 366 } 367 else 368 { 369 #Just get something... 370 $query = "SELECT content_id FROM ".cms_db_prefix()."content"; 371 $row = &$db->GetRow($query); 372 if ($row) 373 { 374 $result = $row['content_id']; 375 } 376 } 377 378 return $result; 379 } 380 381 /** 382 * Returns a hash of valid content types (classes that extend ContentBase) 383 * The key is the name of the class that would be saved into the dabase. The 384 * value would be the text returned by the type's FriendlyName() method. 385 */ 386 function &ListContentTypes() 387 { 388 global $gCms; 389 $contenttypes =& $gCms->contenttypes; 390 391 if (isset($gCms->variables['contenttypes'])) 392 { 393 $variables =& $gCms->variables; 394 return $variables['contenttypes']; 395 } 396 397 $result = array(); 398 399 reset($contenttypes); 400 while (list($key) = each($contenttypes)) 401 { 402 $value =& $contenttypes[$key]; 403 $result[] = $value->type; 404 } 405 406 $variables =& $gCms->variables; 407 $variables['contenttypes'] =& $result; 408 409 return $result; 410 } 411 412 /** 413 * Updates the hierarchy position of one item 414 */ 415 function SetHierarchyPosition($contentid) 416 { 417 global $gCms; 418 $db =& $gCms->GetDb(); 419 420 $current_hierarchy_position = ''; 421 $current_id_hierarchy_position = ''; 422 $current_hierarchy_path = ''; 423 $current_parent_id = $contentid; 424 $count = 0; 425 426 while ($current_parent_id > -1) 427 { 428 $query = "SELECT item_order, parent_id, content_alias FROM ".cms_db_prefix()."content WHERE content_id = ?"; 429 $row = &$db->GetRow($query, array($current_parent_id)); 430 if ($row) 431 { 432 $current_hierarchy_position = str_pad($row['item_order'], 5, '0', STR_PAD_LEFT) . "." . $current_hierarchy_position; 433 $current_id_hierarchy_position = $current_parent_id . '.' . $current_id_hierarchy_position; 434 $current_hierarchy_path = $row['content_alias'] . '/' . $current_hierarchy_path; 435 $current_parent_id = $row['parent_id']; 436 $count++; 437 } 438 else 439 { 440 $current_parent_id = -1; 441 } 442 } 443 444 if (strlen($current_hierarchy_position) > 0) 445 { 446 $current_hierarchy_position = substr($current_hierarchy_position, 0, strlen($current_hierarchy_position) - 1); 447 } 448 if (strlen($current_id_hierarchy_position) > 0) 449 { 450 $current_id_hierarchy_position = substr($current_id_hierarchy_position, 0, strlen($current_id_hierarchy_position) - 1); 451 } 452 if (strlen($current_hierarchy_path) > 0) 453 { 454 $current_hierarchy_path = substr($current_hierarchy_path, 0, strlen($current_hierarchy_path) - 1); 455 } 456 457 $query = "SELECT prop_name FROM ".cms_db_prefix()."content_props WHERE content_id = ?"; 458 $prop_name_array = $db->GetCol($query, array($contentid)); 459 460 debug_buffer(array($current_hierarchy_position, $current_id_hierarchy_position, implode(',', $prop_name_array), $contentid)); 461 462 $query = "UPDATE ".cms_db_prefix()."content SET hierarchy = ?, id_hierarchy = ?, hierarchy_path = ?, prop_names = ? WHERE content_id = ?"; 463 $db->Execute($query, array($current_hierarchy_position, $current_id_hierarchy_position, $current_hierarchy_path, implode(',', $prop_name_array), $contentid)); 464 } 465 466 /** 467 * Updates the hierarchy position of all items 468 */ 469 function SetAllHierarchyPositions() 470 { 471 global $gCms; 472 $db = $gCms->GetDb(); 473 474 $query = "SELECT content_id FROM ".cms_db_prefix()."content"; 475 $dbresult = &$db->Execute($query); 476 477 while ($dbresult && !$dbresult->EOF) 478 { 479 ContentOperations::SetHierarchyPosition($dbresult->fields['content_id']); 480 $dbresult->MoveNext(); 481 } 482 483 if ($dbresult) $dbresult->Close(); 484 } 485 486 function &GetAllContentAsHierarchy($loadprops, $onlyexpanded=null) 487 { 488 debug_buffer('', 'starting tree'); 489 490 require_once(dirname(dirname(__FILE__)).'/Tree/Tree.php'); 491 492 $nodes = array(); 493 global $gCms; 494 $db = &$gCms->GetDb(); 495 496 $cachefilename = TMP_CACHE_LOCATION . '/contentcache.php'; 497 $usecache = true; 498 if (isset($onlyexpanded) || isset($CMS_ADMIN_PAGE)) 499 { 500 #$usecache = false; 501 } 502 503 $loadedcache = false; 504 505 if ($usecache) 506 { 507 if (isset($gCms->variables['pageinfo']) && file_exists($cachefilename)) 508 { 509 $pageinfo =& $gCms->variables['pageinfo']; 510 //debug_buffer('content cache file exists... file: ' . filemtime($cachefilename) . ' content:' . $pageinfo->content_last_modified_date); 511 if (isset($pageinfo->content_last_modified_date) && $pageinfo->content_last_modified_date < filemtime($cachefilename)) 512 { 513 debug_buffer('file needs loading'); 514 515 $handle = fopen($cachefilename, "r"); 516 $data = fread($handle, filesize($cachefilename)); 517 fclose($handle); 518 519 $tree = unserialize(substr($data, 16)); 520 521 #$variables =& $gCms->variables; 522 #$variables['contentcache'] =& $tree; 523 if (strtolower(get_class($tree)) == 'tree') 524 { 525 $loadedcache = true; 526 } 527 else 528 { 529 $loadedcache = false; 530 } 531 } 532 } 533 } 534 535 if (!$loadedcache) 536 { 537 $query = "SELECT id_hierarchy FROM ".cms_db_prefix()."content ORDER BY hierarchy"; 538 $dbresult =& $db->Execute($query); 539 540 if ($dbresult && $dbresult->RecordCount() > 0) 541 { 542 while ($row = $dbresult->FetchRow()) 543 { 544 $nodes[] = $row['id_hierarchy']; 545 } 546 } 547 548 $tree = &new Tree(); 549 debug_buffer('', 'Start Loading Children into Tree'); 550 $tree = &Tree::createFromList($nodes, '.'); 551 debug_buffer('', 'End Loading Children into Tree'); 552 } 553 554 if (!$loadedcache && $usecache) 555 { 556 debug_buffer("Serializing..."); 557 $handle = fopen($cachefilename, "w"); 558 fwrite($handle, '<?php return; ?>'.serialize($tree)); 559 fclose($handle); 560 } 561 562 ContentOperations::LoadChildrenIntoTree(-1, $tree); 563 564 debug_buffer('', 'ending tree'); 565 566 return $tree; 567 } 568 569 function LoadChildrenIntoTree($id, &$tree, $loadprops = false) 570 { 571 global $gCms; 572 $db = &$gCms->GetDb(); 573 574 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE parent_id = ".$id." ORDER BY hierarchy"; 575 $dbresult =& $db->Execute($query); 576 577 if ($dbresult && $dbresult->RecordCount() > 0) 578 { 579 while ($row = $dbresult->FetchRow()) 580 { 581 #Make sure the type exists. If so, instantiate and load 582 if (in_array($row['type'], array_keys(ContentOperations::ListContentTypes()))) 583 { 584 $contentobj =& ContentOperations::CreateNewContent($row['type']); 585 if ($contentobj) 586 { 587 $contentobj->LoadFromData($row, $loadprops); 588 $contentcache =& $tree->content; 589 $id = $row['content_id']; 590 $contentcache[$id] =& $contentobj; 591 } 592 } 593 } 594 } 595 596 if ($dbresult) $dbresult->Close(); 597 } 598 599 /** 600 * Sets the default content as id 601 */ 602 function SetDefaultContent($id) { 603 global $gCms; 604 $db = &$gCms->GetDb(); 605 $query = "SELECT content_id FROM ".cms_db_prefix()."content WHERE default_content=1"; 606 $old_id = $db->GetOne($query); 607 if (isset($old_id)) 608 { 609 $one = new Content(); 610 $one->LoadFromId($old_id); 611 $one->SetDefaultContent(false); 612 debug_buffer('save from ' . __LINE__); 613 $one->Save(); 614 } 615 $one = new Content(); 616 $one->LoadFromId($id); 617 $one->SetDefaultContent(true); 618 debug_buffer('save from ' . __LINE__); 619 $one->Save(); 620 } 621 622 function &GetAllContent($loadprops=true) 623 { 624 debug_buffer('get all content...'); 625 626 global $gCms; 627 628 $contentcache = array(); 629 630 $db = &$gCms->GetDb(); 631 $query = "SELECT * FROM ".cms_db_prefix()."content ORDER BY hierarchy"; 632 $dbresult = &$db->Execute($query); 633 634 $map = array(); 635 $count = 0; 636 637 while ($dbresult && !$dbresult->EOF) 638 { 639 #Make sure the type exists. If so, instantiate and load 640 if (in_array($dbresult->fields['type'], array_keys(ContentOperations::ListContentTypes()))) 641 { 642 $contentobj =& ContentOperations::CreateNewContent($dbresult->fields['type']); 643 if (isset($contentobj)) 644 { 645 $contentobj->LoadFromData($dbresult->FetchRow(), false); 646 $map[$contentobj->Id()] = $count; 647 $contentcache[] = $contentobj; 648 $count++; 649 } 650 else 651 { 652 $dbresult->MoveNext(); 653 } 654 } 655 else 656 { 657 $dbresult->MoveNext(); 658 } 659 } 660 661 if ($dbresult) $dbresult->Close(); 662 663 for ($i=0;$i<$count;$i++) 664 { 665 if ($contentcache[$i]->ParentId() != -1 && isset($map[$contentcache[$i]->ParentId()])) 666 { 667 $contentcache[$map[$contentcache[$i]->ParentId()]]->mChildCount++; 668 } 669 } 670 671 return $contentcache; 672 } 673 674 function CreateHierarchyDropdown($current = '', $parent = '', $name = 'parent_id') 675 { 676 $result = ''; 677 678 $allcontent =& ContentOperations::GetAllContent(); 679 680 if ($allcontent !== FALSE && count($allcontent) > 0) 681 { 682 $result .= '<select name="'.$name.'">'; 683 $result .= '<option value="-1">None</option>'; 684 685 $curhierarchy = ''; 686 687 foreach ($allcontent as $one) 688 { 689 if ($one->Id() == $current) 690 { 691 #Grab hierarchy just in case we need to check children 692 #(which will always be after) 693 $curhierarchy = $one->Hierarchy(); 694 695 #Then jump out. We don't want ourselves in the list. 696 continue; 697 } 698 #If it's a child of the current, we don't want to show it as it 699 #could cause a deadlock. 700 if ($curhierarchy != '' && strstr($one->Hierarchy() . '.', $curhierarchy . '.') == $one->Hierarchy() . '.') 701 { 702 continue; 703 } 704 #Don't include content types that do not want children either... 705 if ($one->WantsChildren() == true) 706 { 707 $result .= '<option value="'.$one->Id().'"'; 708 709 #Select current parent if it exists 710 if ($one->Id() == $parent) 711 { 712 $result .= ' selected="selected"'; 713 } 714 715 $result .= '>'.$one->Hierarchy().'. - '.$one->Name().'</option>'; 716 } 717 } 718 719 $result .= '</select>'; 720 } 721 722 return $result; 723 } 724 725 726 // function to get the id of the default page 727 function GetDefaultPageID() 728 { 729 global $gCms; 730 $db = &$gCms->GetDb(); 731 732 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE default_content = 1"; 733 $row = &$db->GetRow($query); 734 if (!$row) 735 { 736 return false; 737 } 738 return $row['content_id']; 739 } 740 741 742 // function to map an alias to a page id 743 // returns false if nothing cound be found. 744 function GetPageIDFromAlias( $alias ) 745 { 746 global $gCms; 747 $db = &$gCms->GetDb(); 748 749 if (is_numeric($alias) && strpos($alias,'.') == FALSE && strpos($alias,',') == FALSE) 750 { 751 return $alias; 752 } 753 754 $params = array($alias); 755 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_alias = ?"; 756 $row = $db->GetRow($query, $params); 757 758 if (!$row) 759 { 760 return false; 761 } 762 763 return $row['content_id']; 764 } 765 766 function GetPageIDFromHierarchy($position) 767 { 768 global $gCms; 769 $db = &$gCms->GetDb(); 770 771 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE hierarchy = ?"; 772 $row = $db->GetRow($query, array(ContentOperations::CreateUnfriendlyHierarchyPosition($position))); 773 774 if (!$row) 775 { 776 return false; 777 } 778 return $row['content_id']; 779 } 780 781 782 // function to map an alias to a page id 783 // returns false if nothing cound be found. 784 function GetPageAliasFromID( $id ) 785 { 786 global $gCms; 787 $db = &$gCms->GetDb(); 788 789 if (!is_numeric($id) && strpos($id,'.') == TRUE && strpos($id,',') == TRUE) 790 { 791 return $id; 792 } 793 794 $params = array($id); 795 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_id = ?"; 796 $row = $db->GetRow($query, $params); 797 798 if ( !$row ) 799 { 800 return false; 801 } 802 return $row['content_alias']; 803 } 804 805 function CheckAliasError($alias, $content_id = -1) 806 { 807 global $gCms; 808 $db = &$gCms->GetDb(); 809 810 $error = FALSE; 811 812 if (preg_match('/^\d+$/', $alias)) 813 { 814 $error = lang('aliasnotaninteger'); 815 } 816 else if (!preg_match('/^[\-\_\w]+$/', $alias)) 817 { 818 $error = lang('aliasmustbelettersandnumbers'); 819 } 820 else 821 { 822 $params = array($alias); 823 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_alias = ?"; 824 if ($content_id > -1) 825 { 826 $query .= " AND content_id != ?"; 827 $params[] = $content_id; 828 } 829 $row = &$db->GetRow($query, $params); 830 831 if ($row) 832 { 833 $error = lang('aliasalreadyused'); 834 } 835 } 836 837 return $error; 838 } 839 840 function ClearCache() 841 { 842 global $gCms; 843 $smarty =& $gCms->GetSmarty(); 844 845 $smarty->clear_all_cache(); 846 $smarty->clear_compiled_tpl(); 847 848 if (is_file(TMP_CACHE_LOCATION . '/contentcache.php')) 849 { 850 unlink(TMP_CACHE_LOCATION . '/contentcache.php'); 851 } 852 } 853 854 function CreateFriendlyHierarchyPosition($position) 855 { 856 #Change padded numbers back into user-friendly values 857 $tmp = ''; 858 $levels = split('\.', $position); 859 foreach ($levels as $onelevel) 860 { 861 $tmp .= ltrim($onelevel, '0') . '.'; 862 } 863 $tmp = rtrim($tmp, '.'); 864 return $tmp; 865 } 866 867 function CreateUnfriendlyHierarchyPosition($position) 868 { 869 #Change user-friendly values into padded numbers 870 $tmp = ''; 871 $levels = split('\.', $position); 872 foreach ($levels as $onelevel) 873 { 874 $tmp .= str_pad($onelevel, 5, '0', STR_PAD_LEFT) . '.'; 875 } 876 $tmp = rtrim($tmp, '.'); 877 return $tmp; 878 } 879 880 } 881 882 class ContentManager extends ContentOperations 883 { 884 } 885 886 ?>
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 |