| [ 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: class.content.inc.php 3392 2006-08-25 09:52:10Z wishy $ 21 22 /** 23 * Generic content class. 24 * 25 * As for some treatment we don't need the extra properties of the content 26 * we load them only when required. However, each function which makes use 27 * of extra properties should first test if the properties object exist. 28 * 29 * @since 0.8 30 * @package CMS 31 */ 32 33 class ContentBase 34 { 35 /** 36 * The unique ID identifier of the element 37 * Integer 38 */ 39 var $mId; 40 41 /** 42 * The name of the element (like a filename) 43 * String 44 */ 45 var $mName; 46 47 /** 48 * The type of content (page, url, etc..) 49 * String 50 */ 51 var $mType; 52 53 /** 54 * The owner of the content 55 * Integer 56 */ 57 var $mOwner; 58 59 /** 60 * The properties part of the content. This is an object of the good type. 61 * It should contain all treatments specific to this type of content 62 */ 63 var $mProperties; 64 65 var $mPropertiesLoaded; 66 67 /** 68 * The ID of the parent, 0 if none 69 * Integer 70 */ 71 var $mParentId; 72 73 /** 74 * The old parent id... only used on update 75 */ 76 var $mOldParentId; 77 78 /** 79 * This is used too often to not be part of the base class 80 */ 81 var $mTemplateId; 82 83 /** 84 * The item order of the content in his level 85 * Integer 86 */ 87 var $mItemOrder; 88 89 /** 90 * The old item order... only used on update 91 */ 92 var $mOldItemOrder; 93 94 /** 95 * The metadata (head tags) fir this content 96 */ 97 var $mMetadata; 98 99 var $mTitleAttribute; 100 var $mAccessKey; 101 var $mTabIndex; 102 103 /** 104 * The full hierarchy of the content 105 * String of the form : 1.4.3 106 */ 107 var $mHierarchy; 108 109 /** 110 * The full hierarchy of the content ids 111 * String of the form : 1.4.3 112 */ 113 var $mIdHierarchy; 114 115 /** 116 * The full path through the hierarchy 117 * String of the form : parent/parent/child 118 */ 119 var $mHierarchyPath; 120 121 /** 122 * What should be displayed in a menu 123 */ 124 var $mMenuText; 125 126 /** 127 * Is the content active ? 128 * Integer : 0 / 1 129 */ 130 var $mActive; 131 132 /** 133 * Alias of the content 134 */ 135 var $mAlias; 136 137 var $mOldAlias; 138 139 /** 140 * Cachable? 141 */ 142 var $mCachable; 143 144 /** 145 * Does this content have a preview function? 146 */ 147 var $mPreview; 148 149 /** 150 * Should it show up in the menu? 151 */ 152 var $mShowInMenu; 153 154 /** 155 * Is this page the default? 156 */ 157 var $mDefaultContent; 158 159 /** 160 * What type of markup is ths? HTML is the default 161 */ 162 var $mMarkup; 163 164 /** 165 * Last user to modify this content 166 */ 167 var $mLastModifiedBy; 168 169 /** 170 * Creation date 171 * Date 172 */ 173 var $mCreationDate; 174 175 /** 176 * Modification date 177 * Date 178 */ 179 var $mModifiedDate; 180 181 var $mAdditionalEditors; 182 183 var $mReadyForEdit; 184 /************************************************************************/ 185 /* Constructor related */ 186 /************************************************************************/ 187 188 /** 189 * Generic constructor. Runs the SetInitialValues fuction. 190 */ 191 function ContentBase() 192 { 193 $this->SetInitialValues(); 194 $this->SetProperties(); 195 $this->mPropertiesLoaded = false; 196 $this->mReadyForEdit = false; 197 } 198 199 /** 200 * Sets object to some sane initial values 201 */ 202 function SetInitialValues() 203 { 204 $this->mId = -1 ; 205 $this->mName = "" ; 206 $this->mAlias = "" ; 207 $this->mOldAlias = "" ; 208 $this->mType = strtolower(get_class($this)) ; 209 $this->mOwner = -1 ; 210 $this->mProperties = new ContentProperties(); 211 $this->mParentId = -1 ; 212 $this->mOldParentId = -1 ; 213 $this->mTemplateId = -1 ; 214 $this->mItemOrder = -1 ; 215 $this->mOldItemOrder = -1 ; 216 $this->mLastModifiedBy = -1 ; 217 $this->mHierarchy = "" ; 218 $this->mIdHierarchy = "" ; 219 $this->mHierarchyPath = "" ; 220 $this->mMetadata = "" ; 221 $this->mTitleAttribute = "" ; 222 $this->mAccessKey = "" ; 223 $this->mTabIndex = "" ; 224 $this->mActive = false ; 225 $this->mDefaultContent = false ; 226 $this->mShowInMenu = false ; 227 $this->mCachable = true; 228 $this->mMenuText = "" ; 229 $this->mCreationDate = "" ; 230 $this->mModifiedDate = "" ; 231 $this->mPreview = false ; 232 $this->mMarkup = 'html' ; 233 $this->mChildCount = 0; 234 $this->mPropertiesLoaded = false; 235 } 236 237 /** 238 * Subclasses should override this to set their property types using a lot 239 * of mProperties.Add statements 240 */ 241 function SetProperties() 242 { 243 } 244 245 246 /************************************************************************/ 247 /* Functions giving access to needed elements of the content */ 248 /************************************************************************/ 249 250 /** 251 * Returns the ID 252 */ 253 function Id() 254 { 255 return $this->mId; 256 } 257 258 function SetId($id) 259 { 260 $this->DoReadyForEdit(); 261 $this->mId = $id; 262 } 263 264 /** 265 * Returns a friendly name for this content type 266 */ 267 function FriendlyName() 268 { 269 return ''; 270 } 271 272 /** 273 * Returns the Name 274 */ 275 function Name() 276 { 277 return $this->mName; 278 } 279 280 function SetName($name) 281 { 282 $this->DoReadyForEdit(); 283 $this->mName = $name; 284 } 285 286 /** 287 * Returns the Alias 288 */ 289 function Alias() 290 { 291 return $this->mAlias; 292 } 293 294 /** 295 * Returns the Type 296 */ 297 function Type() 298 { 299 return strtolower($this->mType); 300 } 301 302 function SetType($type) 303 { 304 $this->DoReadyForEdit(); 305 $this->mType = strtolower($type); 306 } 307 308 /** 309 * Returns the Owner 310 */ 311 function Owner() 312 { 313 return $this->mOwner; 314 } 315 316 function SetOwner($owner) 317 { 318 $this->DoReadyForEdit(); 319 $this->mOwner = $owner; 320 } 321 322 /** 323 * Returns the Metadata 324 */ 325 function Metadata() 326 { 327 return $this->mMetadata; 328 } 329 330 function SetMetadata($metadata) 331 { 332 $this->DoReadyForEdit(); 333 $this->mMetadata = $metadata; 334 } 335 336 function TabIndex() 337 { 338 return $this->mTabIndex; 339 } 340 341 function SetTabIndex($tabindex) 342 { 343 $this->DoReadyForEdit(); 344 $this->mTabIndex = $tabindex; 345 } 346 347 function TitleAttribute() 348 { 349 return $this->mTitleAttribute; 350 } 351 352 function GetCreationDate() 353 { 354 return $this->mCreationDate; 355 } 356 357 function GetModifiedDate() 358 { 359 return $this->mModifiedDate; 360 } 361 362 function SetTitleAttribute($titleattribute) 363 { 364 $this->DoReadyForEdit(); 365 $this->mTitleAttribute = $titleattribute; 366 } 367 368 function AccessKey() 369 { 370 return $this->mAccessKey; 371 } 372 373 function SetAccessKey($accesskey) 374 { 375 $this->DoReadyForEdit(); 376 $this->mAccessKey = $accesskey; 377 } 378 379 /** 380 * Returns the ParentId 381 */ 382 function ParentId() 383 { 384 return $this->mParentId; 385 } 386 387 function SetParentId($parentid) 388 { 389 $this->DoReadyForEdit(); 390 $this->mParentId = $parentid; 391 } 392 393 function OldParentId() 394 { 395 return $this->mOldParentId; 396 } 397 398 function SetOldParentId($parentid) 399 { 400 $this->DoReadyForEdit(); 401 $this->mOldParentId = $parentid; 402 } 403 404 function TemplateId() 405 { 406 return $this->mTemplateId; 407 } 408 409 function SetTemplateId($templateid) 410 { 411 $this->DoReadyForEdit(); 412 $this->mTemplateId = $templateid; 413 } 414 415 /** 416 * Returns the ItemOrder 417 */ 418 function ItemOrder() 419 { 420 return $this->mItemOrder; 421 } 422 423 function SetItemOrder($itemorder) 424 { 425 $this->DoReadyForEdit(); 426 $this->mItemOrder = $itemorder; 427 } 428 429 function OldItemOrder() 430 { 431 return $this->mOldItemOrder; 432 } 433 434 function SetOldItemOrder($itemorder) 435 { 436 $this->DoReadyForEdit(); 437 $this->mOldItemOrder = $itemorder; 438 } 439 440 /** 441 * Returns the Hierarchy 442 */ 443 function Hierarchy() 444 { 445 global $gCms; 446 $contentops =& $gCms->GetContentOperations(); 447 return $contentops->CreateFriendlyHierarchyPosition($this->mHierarchy); 448 } 449 450 function SetHierarchy($hierarchy) 451 { 452 $this->DoReadyForEdit(); 453 $this->mHierarchy = $hierarchy; 454 } 455 456 /** 457 * Returns the Hierarchy 458 */ 459 function IdHierarchy() 460 { 461 return $this->mIdHierarchy; 462 } 463 464 function SetIdHierarchy($idhierarchy) 465 { 466 $this->DoReadyForEdit(); 467 $this->mIdHierarchy = $idhierarchy; 468 } 469 470 /** 471 * Returns the Hierarchy 472 */ 473 function HierarchyPath() 474 { 475 return $this->mHierarchyPath; 476 } 477 478 function SetHierarchyPath($hierarchypath) 479 { 480 $this->DoReadyForEdit(); 481 $this->mHierarchyPath = $hierarchypath; 482 } 483 484 /** 485 * Returns the Active state 486 */ 487 function Active() 488 { 489 return $this->mActive; 490 } 491 492 function SetActive($active) 493 { 494 $this->DoReadyForEdit(); 495 $this->mActive = $active; 496 } 497 498 /** 499 * Returns whether it should show in the menu 500 */ 501 function ShowInMenu() 502 { 503 return $this->mShowInMenu; 504 } 505 506 function SetShowInMenu($showinmenu) 507 { 508 $this->DoReadyForEdit(); 509 $this->mShowInMenu = $showinmenu; 510 } 511 512 /** 513 * Returns if the page is the default 514 */ 515 function DefaultContent() 516 { 517 return $this->mDefaultContent; 518 } 519 520 function SetDefaultContent($defaultcontent) 521 { 522 $this->DoReadyForEdit(); 523 $this->mDefaultContent = $defaultcontent; 524 } 525 526 function Cachable() 527 { 528 return $this->mCachable; 529 } 530 531 function SetCachable($cachable) 532 { 533 $this->DoReadyForEdit(); 534 $this->mCachable = $cachable; 535 } 536 537 function Markup() 538 { 539 return $this->mMarkup; 540 } 541 542 function SetMarkup($markup) 543 { 544 $this->DoReadyForEdit(); 545 $this->mMarkup = $markup; 546 } 547 548 function LastModifiedBy() 549 { 550 return $this->mLastModifiedBy; 551 } 552 553 function SetLastModifiedBy($lastmodifiedby) 554 { 555 $this->DoReadyForEdit(); 556 $this->mLastModifiedBy = $lastmodifiedby; 557 } 558 559 function SetAlias($alias) 560 { 561 $this->DoReadyForEdit(); 562 global $gCms; 563 $config =& $gCms->GetConfig(); 564 565 $tolower = false; 566 567 if ($alias == '' && $config['auto_alias_content'] == true) 568 { 569 $alias = trim($this->mMenuText); 570 if ($alias == '') 571 { 572 $alias = trim($this->mName); 573 } 574 575 $tolower = true; 576 $alias = munge_string_to_url($alias, $tolower); 577 // Make sure auto-generated new alias is not already in use on a different page, if it does, add "-2" to the alias 578 global $gCms; 579 $contentops =& $gCms->GetContentOperations(); 580 $error = $contentops->CheckAliasError($alias); 581 if ($error !== FALSE) 582 { 583 if (FALSE == empty($alias)) 584 { 585 $alias_num_add = 2; 586 // If a '-2' version of the alias already exists 587 // Check the '-3' version etc. 588 while ($contentops->CheckAliasError($alias.'-'.$alias_num_add) !== FALSE) 589 { 590 $alias_num_add++; 591 } 592 $alias .= '-'.$alias_num_add; 593 } 594 else 595 { 596 $alias = ''; 597 } 598 } 599 } 600 601 $this->mAlias = munge_string_to_url($alias, $tolower); 602 } 603 604 /** 605 * Returns the menu text for this content 606 */ 607 function MenuText() 608 { 609 return $this->mMenuText; 610 } 611 612 function SetMenuText($menutext) 613 { 614 $this->DoReadyForEdit(); 615 $this->mMenuText = $menutext; 616 } 617 618 /** 619 * Returns number of immediate child-content items of this content 620 */ 621 function ChildCount() 622 { 623 return $this->mChildCount; 624 } 625 626 /** 627 * Returns the properties 628 */ 629 function Properties() 630 { 631 debug_buffer('properties called'); 632 if ($this->mPropertiesLoaded == false) 633 { 634 $this->mProperties->Load($this->mId); 635 $this->mPropertiesLoaded = true; 636 } 637 return $this->mProperties; 638 } 639 640 function HasProperty($name) 641 { 642 return $this->mProperties->HasProperty($name); 643 } 644 645 function GetPropertyValue($name) 646 { 647 if ($this->mProperties->HasProperty($name)) 648 { 649 if ($this->mPropertiesLoaded == false) 650 { 651 $this->mProperties->Load($this->mId); 652 $this->mPropertiesLoaded = true; 653 } 654 return $this->mProperties->GetValue($name); 655 } 656 return ''; 657 } 658 659 function SetPropertyValue($name, $value) 660 { 661 debug_buffer('setpropertyvalue called'); 662 $this->DoReadyForEdit(); 663 if ($this->mPropertiesLoaded == false) 664 { 665 $this->mProperties->Load($this->mId); 666 $this->mPropertiesLoaded = true; 667 } 668 $this->mProperties->SetValue($name, $value); 669 } 670 671 /** 672 * Function content types to use to say whether or not they should show 673 * up in lists where parents of content are set. This will default to true, 674 * but should be used in cases like Separator where you don't want it to 675 * have any children. 676 * 677 * @since 0.11 678 */ 679 function WantsChildren() 680 { 681 return true; 682 } 683 684 function GetAdditionalContentBlocks() 685 { 686 } 687 688 /** 689 * Should this link be used in various places where a link is the only 690 * useful output? (Like next/previous links in cms_selflink, for example) 691 */ 692 function HasUsableLink() 693 { 694 return true; 695 } 696 697 /************************************************************************/ 698 /* The rest */ 699 /************************************************************************/ 700 701 /** 702 * This is a callback function to handle any things that might need to be done before content is 703 * edited. 704 */ 705 function ReadyForEdit() 706 { 707 } 708 709 function DoReadyForEdit() 710 { 711 if ($this->mReadyForEdit == false) 712 { 713 $this->ReadyForEdit(); 714 $this->mReadyForEdit = true; 715 } 716 } 717 718 /** 719 * Load the content of the object from an ID 720 * 721 * @param $id the ID of the element 722 * @param $loadProperties whether to load or not the properties 723 * 724 * @returns bool If it fails, the object comes back to initial values and returns FALSE 725 * If everything goes well, it returns TRUE 726 */ 727 function LoadFromId($id, $loadProperties = false) 728 { 729 global $gCms, $config, $sql_queries, $debug_errors; 730 $db = &$gCms->GetDb(); 731 732 $result = false; 733 734 if (-1 < $id) 735 { 736 $query = "SELECT * FROM ".cms_db_prefix()."content WHERE content_id = ?"; 737 $row =& $db->Execute($query, array($id)); 738 739 if ($row && !$row->EOF) 740 { 741 $this->mId = $row->fields["content_id"]; 742 $this->mName = $row->fields["content_name"]; 743 $this->mAlias = $row->fields["content_alias"]; 744 $this->mOldAlias = $row->fields["content_alias"]; 745 $this->mType = strtolower($row->fields["type"]); 746 $this->mOwner = $row->fields["owner_id"]; 747 #$this->mProperties = new ContentProperties(); 748 $this->mParentId = $row->fields["parent_id"]; 749 $this->mOldParentId = $row->fields["parent_id"]; 750 $this->mTemplateId = $row->fields["template_id"]; 751 $this->mItemOrder = $row->fields["item_order"]; 752 $this->mOldItemOrder = $row->fields["item_order"]; 753 $this->mMetadata = $row->fields['metadata']; 754 $this->mHierarchy = $row->fields["hierarchy"]; 755 $this->mIdHierarchy = $row->fields["id_hierarchy"]; 756 $this->mHierarchyPath = $row->fields["hierarchy_path"]; 757 $this->mProperties->mPropertyNames = explode(',',$row->fields["prop_names"]); 758 $this->mMenuText = $row->fields['menu_text']; 759 $this->mMarkup = $row->fields['markup']; 760 $this->mTitleAttribute = $row->fields['titleattribute']; 761 $this->mAccessKey = $row->fields['accesskey']; 762 $this->mTabIndex = $row->fields['tabindex']; 763 $this->mActive = ($row->fields["active"] == 1 ? true : false); 764 $this->mDefaultContent = ($row->fields["default_content"] == 1 ? true : false); 765 $this->mShowInMenu = ($row->fields["show_in_menu"] == 1 ? true : false); 766 $this->mCachable = ($row->fields["cachable"] == 1 ? true : false); 767 $this->mLastModifiedBy = $row->fields["last_modified_by"]; 768 $this->mCreationDate = $row->fields["create_date"]; 769 $this->mModifiedDate = $row->fields["modified_date"]; 770 771 $result = true; 772 } 773 else 774 { 775 if (true == $config["debug"]) 776 { 777 # :TODO: Translate the error message 778 $debug_errors .= "<p>Could not retrieve content from db</p>\n"; 779 } 780 } 781 782 if ($row) $row->Close(); 783 784 if ($result && $loadProperties) 785 { 786 if ($this->mPropertiesLoaded == false) 787 { 788 debug_buffer("load from id is loading properties"); 789 $this->mProperties->Load($this->mId); 790 $this->mPropertiesLoaded = true; 791 } 792 793 if (NULL == $this->mProperties) 794 { 795 $result = false; 796 797 # debug mode 798 if (true == $config["debug"]) 799 { 800 # :TODO: Translate the error message 801 $debug_errors .= "<p>Could not load properties for content</p>\n"; 802 } 803 } 804 } 805 806 if (false == $result) 807 { 808 $this->SetInitialValues(); 809 } 810 } 811 else 812 { 813 # debug mode 814 if ($config["debug"] == true) 815 { 816 # :TODO: Translate the error message 817 $debug_errors .= "<p>The id wasn't valid : $id</p>\n"; 818 } 819 } 820 821 $this->Load(); 822 823 return $result; 824 } 825 826 /** 827 * Load the content of the object from an array 828 * 829 * There is no check on the data provided, because this is the job of 830 * ValidateData 831 * 832 * @returns bool If it fails, the object comes back to initial values and returns FALSE 833 * If everything goes well, it returns TRUE 834 */ 835 function LoadFromData($data, $loadProperties = false) 836 { 837 global $config, $debug_errors; 838 839 $result = true; 840 841 $this->mId = $data["content_id"]; 842 $this->mName = $data["content_name"]; 843 $this->mAlias = $data["content_alias"]; 844 $this->mOldAlias = $data["content_alias"]; 845 $this->mType = strtolower($data["type"]); 846 $this->mOwner = $data["owner_id"]; 847 #$this->mProperties = new ContentProperties(); 848 $this->mParentId = $data["parent_id"]; 849 $this->mOldParentId = $data["parent_id"]; 850 $this->mTemplateId = $data["template_id"]; 851 $this->mItemOrder = $data["item_order"]; 852 $this->mOldItemOrder = $data["item_order"]; 853 $this->mMetadata = $data['metadata']; 854 $this->mHierarchy = $data["hierarchy"]; 855 $this->mIdHierarchy = $data["id_hierarchy"]; 856 $this->mHierarchyPath = $data["hierarchy_path"]; 857 $this->mProperties->mPropertyNames = explode(',',$data["prop_names"]); 858 $this->mMenuText = $data['menu_text']; 859 $this->mMarkup = $data['markup']; 860 $this->mTitleAttribute = $data['titleattribute']; 861 $this->mAccessKey = $data['accesskey']; 862 $this->mTabIndex = $data['tabindex']; 863 $this->mDefaultContent = ($data["default_content"] == 1 ? true : false); 864 $this->mActive = ($data["active"] == 1 ? true : false); 865 $this->mShowInMenu = ($data["show_in_menu"] == 1 ? true : false); 866 $this->mCachable = ($data["cachable"] == 1 ? true : false); 867 $this->mLastModifiedBy = $data["last_modified_by"]; 868 $this->mCreationDate = $data["create_date"]; 869 $this->mModifiedDate = $data["modified_date"]; 870 871 if ($loadProperties == true) 872 { 873 #$this->mProperties = ContentManager::LoadPropertiesFromData(strtolower($this->mType), $data); 874 if ($this->mPropertiesLoaded == false) 875 { 876 debug_buffer("load from data is loading properties"); 877 $this->mProperties->Load($this->mId); 878 $this->mPropertiesLoaded = true; 879 } 880 881 if (NULL == $this->mProperties) 882 { 883 $result = false; 884 885 # debug mode 886 if (true == $config["debug"]) 887 { 888 # :TODO: Translate the error message 889 $debug_errors .= "<p>Could not load properties for content</p>\n"; 890 } 891 } 892 } 893 894 if (false == $result) 895 { 896 $this->SetInitialValues(); 897 } 898 899 $this->Load(); 900 901 return $result; 902 } 903 904 /** 905 * Callback function for content types to use to preload content or other things if necessary. This 906 * is called right after the properties are loaded. 907 */ 908 function Load() 909 { 910 } 911 912 /** 913 * Save or update the content 914 */ 915 # :TODO: This function should return something 916 function Save() 917 { 918 global $gCms; 919 foreach($gCms->modules as $key=>$value) 920 { 921 if ($gCms->modules[$key]['installed'] == true && 922 $gCms->modules[$key]['active'] == true) 923 { 924 $gCms->modules[$key]['object']->ContentEditPre($this); 925 } 926 } 927 928 Events::SendEvent('Core', 'ContentEditPre', array('content' => &$this)); 929 930 if ($this->mPropertiesLoaded == false) 931 { 932 debug_buffer('save is loading properties'); 933 $this->mProperties->Load($this->mId); 934 $this->mPropertiesLoaded = true; 935 } 936 937 if (-1 < $this->mId) 938 { 939 $this->Update(); 940 } 941 else 942 { 943 $this->Insert(); 944 } 945 946 foreach($gCms->modules as $key=>$value) 947 { 948 if ($gCms->modules[$key]['installed'] == true && 949 $gCms->modules[$key]['active'] == true) 950 { 951 $gCms->modules[$key]['object']->ContentEditPost($this); 952 } 953 } 954 955 Events::SendEvent('Core', 'ContentEditPost', array('content' => &$this)); 956 } 957 958 /** 959 * Update the content 960 * We can notice, that only a few things are updated 961 * We do not care about hierarchy for example. This is because hierarchy, 962 * order or parents management is the job of the content manager. 963 * Remember that a content is like a file, and a file don't know where it is 964 * on the disk, it only knows its own content. It's the same here. 965 */ 966 # :TODO: This function should return something 967 function Update() 968 { 969 global $gCms, $config, $sql_queries, $debug_errors; 970 $db = &$gCms->GetDb(); 971 972 $result = false; 973 974 #Figure out the item_order (if necessary) 975 if ($this->mItemOrder < 1) 976 { 977 $query = "SELECT ".$db->IfNull('max(item_order)','0')." as new_order FROM ".cms_db_prefix()."content WHERE parent_id = ?"; 978 $row = &$db->GetRow($query,array($this->mParentId)); 979 980 if ($row) 981 { 982 if ($row['new_order'] < 1) 983 { 984 $this->mItemOrder = 1; 985 } 986 else 987 { 988 $this->mItemOrder = $row['new_order'] + 1; 989 } 990 } 991 } 992 993 $this->mModifiedDate = trim($db->DBTimeStamp(time()), "'"); 994 995 $query = "UPDATE ".cms_db_prefix()."content SET content_name = ?, owner_id = ?, type = ?, template_id = ?, parent_id = ?, active = ?, default_content = ?, show_in_menu = ?, cachable = ?, menu_text = ?, content_alias = ?, metadata = ?, titleattribute = ?, accesskey = ?, tabindex = ?, modified_date = ?, item_order = ?, markup = ?, last_modified_by = ? WHERE content_id = ?"; 996 $dbresult = $db->Execute($query, array( 997 $this->mName, 998 $this->mOwner, 999 strtolower($this->mType), 1000 $this->mTemplateId, 1001 $this->mParentId, 1002 ($this->mActive == true ? 1 : 0), 1003 ($this->mDefaultContent == true ? 1 : 0), 1004 ($this->mShowInMenu == true ? 1 : 0), 1005 ($this->mCachable == true ? 1 : 0), 1006 $this->mMenuText, 1007 $this->mAlias, 1008 $this->mMetadata, 1009 $this->mTitleAttribute, 1010 $this->mAccessKey, 1011 $this->mTabIndex, 1012 $this->mModifiedDate, 1013 $this->mItemOrder, 1014 $this->mMarkup, 1015 $this->mLastModifiedBy, 1016 $this->mId 1017 )); 1018 1019 if (!$dbresult) 1020 { 1021 if (true == $config["debug"]) 1022 { 1023 # :TODO: Translate the error message 1024 $debug_errors .= "<p>Error updating content</p>\n"; 1025 } 1026 } 1027 1028 if ($this->mOldParentId != $this->mParentId) 1029 { 1030 #Fix the item_order if necessary 1031 $query = "UPDATE ".cms_db_prefix()."content SET item_order = item_order - 1 WHERE parent_id = ? AND item_order > ?"; 1032 $result = $db->Execute($query, array($this->mOldParentId,$this->mOldItemOrder)); 1033 1034 $this->mOldParentId = $this->mParentId; 1035 $this->mOldItemOrder = $this->mItemOrder; 1036 } 1037 1038 if (isset($this->mAdditionalEditors)) 1039 { 1040 $query = "DELETE FROM ".cms_db_prefix()."additional_users WHERE content_id = ?"; 1041 $db->Execute($query, array($this->Id())); 1042 1043 foreach ($this->mAdditionalEditors as $oneeditor) 1044 { 1045 $new_addt_id = $db->GenID(cms_db_prefix()."additional_users_seq"); 1046 $query = "INSERT INTO ".cms_db_prefix()."additional_users (additional_users_id, user_id, content_id) VALUES (?,?,?)"; 1047 $db->Execute($query, array($new_addt_id, $oneeditor, $this->Id())); 1048 } 1049 } 1050 1051 if (NULL != $this->mProperties) 1052 { 1053 # :TODO: There might be some error checking there 1054 debug_buffer('save from ' . __LINE__); 1055 $this->mProperties->Save($this->mId); 1056 } 1057 else 1058 { 1059 if (true == $config["debug"]) 1060 { 1061 # :TODO: Translate the error message 1062 $debug_errors .= "<p>Error updating : the content has no properties</p>\n"; 1063 } 1064 } 1065 } 1066 1067 /** 1068 * Insert the content in the db 1069 */ 1070 # :TODO: This function should return something 1071 # :TODO: Take care bout hierarchy here, it has no value ! 1072 # :TODO: Figure out proper item_order 1073 function Insert() 1074 { 1075 global $gCms, $config, $sql_queries, $debug_errors; 1076 $db = &$gCms->GetDb(); 1077 1078 $result = false; 1079 1080 #Figure out the item_order 1081 if ($this->mItemOrder < 1) 1082 { 1083 $query = "SELECT max(item_order) as new_order FROM ".cms_db_prefix()."content WHERE parent_id = ?"; 1084 $row = &$db->Getrow($query, array($this->mParentId)); 1085 1086 if ($row) 1087 { 1088 if ($row['new_order'] < 1) 1089 { 1090 $this->mItemOrder = 1; 1091 } 1092 else 1093 { 1094 $this->mItemOrder = $row['new_order'] + 1; 1095 } 1096 } 1097 } 1098 1099 $newid = $db->GenID(cms_db_prefix()."content_seq"); 1100 $this->mId = $newid; 1101 1102 $this->mModifiedDate = $this->mCreationDate = trim($db->DBTimeStamp(time()), "'"); 1103 1104 $query = "INSERT INTO ".$config["db_prefix"]."content (content_id, content_name, content_alias, type, owner_id, parent_id, template_id, item_order, hierarchy, id_hierarchy, active, default_content, show_in_menu, cachable, menu_text, markup, metadata, titleattribute, accesskey, tabindex, last_modified_by, create_date, modified_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; 1105 1106 $dbresult = $db->Execute($query, array( 1107 $newid, 1108 $this->mName, 1109 $this->mAlias, 1110 strtolower($this->mType), 1111 $this->mOwner, 1112 $this->mParentId, 1113 $this->mTemplateId, 1114 $this->mItemOrder, 1115 $this->mHierarchy, 1116 $this->mIdHierarchy, 1117 ($this->mActive == true ? 1 : 0), 1118 ($this->mDefaultContent == true ? 1 : 0), 1119 ($this->mShowInMenu == true ? 1 : 0), 1120 ($this->mCachable == true ? 1 : 0), 1121 $this->mMenuText, 1122 $this->mMarkup, 1123 $this->mMetadata, 1124 $this->mTitleAttribute, 1125 $this->mAccessKey, 1126 $this->mTabIndex, 1127 $this->mLastModifiedBy, 1128 $this->mModifiedDate, 1129 $this->mCreationDate 1130 )); 1131 1132 if (! $dbresult) 1133 { 1134 if ($config["debug"] == true) 1135 { 1136 # :TODO: Translate the error message 1137 $debug_errors .= "<p>Error inserting content</p>\n"; 1138 } 1139 } 1140 1141 if (NULL != $this->mProperties) 1142 { 1143 # :TODO: There might be some error checking there 1144 debug_buffer('save from ' . __LINE__); 1145 $this->mProperties->Save($newid); 1146 } 1147 else 1148 { 1149 if (true == $config["debug"]) 1150 { 1151 # :TODO: Translate the error message 1152 $debug_errors .= "<p>Error inserting : the content has no properties</p>\n"; 1153 } 1154 } 1155 if (isset($this->mAdditionalEditors)) 1156 { 1157 foreach ($this->mAdditionalEditors as $oneeditor) 1158 { 1159 $new_addt_id = $db->GenID(cms_db_prefix()."additional_users_seq"); 1160 $query = "INSERT INTO ".cms_db_prefix()."additional_users (additional_users_id, user_id, content_id) VALUES (?,?,?)"; 1161 $db->Execute($query, array($new_addt_id, $oneeditor, $this->Id())); 1162 } 1163 } 1164 } 1165 1166 /** 1167 * Test if the array given contains valid data for the object 1168 * This function is used to check that no compulsory argument 1169 * has been forgotten by the user 1170 * 1171 * We do not check the Id because there can be no Id (new content) 1172 * That's up to Save to check this. 1173 * 1174 * @returns FALSE if data is ok, and an array of invalid parameters else 1175 */ 1176 function ValidateData() 1177 { 1178 return FALSE; 1179 } 1180 1181 /** 1182 * Delete the content 1183 */ 1184 # :TODO: This function should return something 1185 function Delete() 1186 { 1187 global $gCms, $config, $sql_queries, $debug_errors; 1188 1189 foreach($gCms->modules as $key=>$value) 1190 { 1191 if ($gCms->modules[$key]['installed'] == true && 1192 $gCms->modules[$key]['active'] == true) 1193 { 1194 $gCms->modules[$key]['object']->ContentDeletePre($this); 1195 } 1196 } 1197 1198 Events::SendEvent('Core', 'ContentDeletePre', array('content' => &$this)); 1199 1200 $db = &$gCms->GetDb(); 1201 1202 $result = false; 1203 1204 if (-1 > $this->mId) 1205 { 1206 if (true == $config["debug"]) 1207 { 1208 # :TODO: Translate the error message 1209 $debug_errors .= "<p>Could not delete content : invalid Id</p>\n"; 1210 } 1211 } 1212 else 1213 { 1214 $query = "DELETE FROM ".cms_db_prefix()."content WHERE content_id = ?"; 1215 $dbresult = $db->Execute($query, array($this->mId)); 1216 1217 if (! $dbresult) 1218 { 1219 if (true == $config["debug"]) 1220 { 1221 # :TODO: Translate the error message 1222 $debug_errors .= "<p>Error deleting content</p>\n"; 1223 } 1224 } 1225 1226 #Fix the item_order if necessary 1227 $query = "UPDATE ".cms_db_prefix()."content SET item_order = item_order - 1 WHERE parent_id = ? AND item_order > ?"; 1228 $result = $db->Execute($query,array($this->ParentId(),$this->ItemOrder())); 1229 1230 #Remove the cross references 1231 remove_cross_references($this->mId, 'content'); 1232 1233 $cachefilename = TMP_CACHE_LOCATION . '/contentcache.php'; 1234 @unlink($cachefilename); 1235 1236 if (NULL != $this->mProperties) 1237 { 1238 # :TODO: There might be some error checking there 1239 $this->mProperties->Delete($this->mId); 1240 } 1241 else 1242 { 1243 if (true == $config["debug"]) 1244 { 1245 # :TODO: Translate the error message 1246 $debug_errors .= "<p>Error deleting : the content has no properties</p>\n"; 1247 } 1248 } 1249 } 1250 1251 foreach($gCms->modules as $key=>$value) 1252 { 1253 if ($gCms->modules[$key]['installed'] == true && 1254 $gCms->modules[$key]['active'] == true) 1255 { 1256 $gCms->modules[$key]['object']->ContentDeletePost($this); 1257 } 1258 } 1259 1260 Events::SendEvent('Core', 'ContentDeletePost', array('content' => &$this)); 1261 } 1262 1263 /** 1264 * Function for the subclass to parse out data for it's parameters (usually from $_POST) 1265 */ 1266 function FillParams($params) 1267 { 1268 } 1269 1270 /** 1271 * Function for content types to override to set their proper generated URL 1272 */ 1273 function GetURL($rewrite = true) 1274 { 1275 global $gCms; 1276 $config = &$gCms->GetConfig(); 1277 $url = ""; 1278 $alias = ($this->mAlias != ''?$this->mAlias:$this->mId); 1279 if ($config["assume_mod_rewrite"] && $rewrite == true) 1280 { 1281 if ($config['use_hierarchy'] == true) 1282 { 1283 $url = $config['root_url']. '/' . $this->HierarchyPath() . (isset($config['page_extension'])?$config['page_extension']:'.html'); 1284 } 1285 else 1286 { 1287 $url = $config['root_url']. '/' . $alias . (isset($config['page_extension'])?$config['page_extension']:'.html'); 1288 } 1289 } 1290 else 1291 { 1292 if (isset($_SERVER['PHP_SELF']) && $config['internal_pretty_urls'] == true) 1293 { 1294 if ($config['use_hierarchy'] == true) 1295 { 1296 $url = $config['root_url'] . '/index.php/' . $this->HierarchyPath() . (isset($config['page_extension'])?$config['page_extension']:'.html'); 1297 } 1298 else 1299 { 1300 $url = $config['root_url'] . '/index.php/' . $alias . (isset($config['page_extension'])?$config['page_extension']:'.html'); 1301 } 1302 } 1303 else 1304 { 1305 $url = $config['root_url'] . '/index.php?' . $config['query_var'] . '=' . $alias; 1306 } 1307 } 1308 return $url; 1309 } 1310 1311 /* 1312 function MakeHierarchyURL($ext='') 1313 { 1314 global $gCms; 1315 $hm =& $gCms->GetHierarchyManager(); 1316 1317 $path = '/' . $this->Alias(); 1318 1319 $node =& $hm->getNodeById($this->ParentId()); 1320 if(isset($node)) 1321 { 1322 $content =& $node->GetContent(); 1323 if (isset($content)) 1324 { 1325 $path = '/' . $content->HierarchyPath(); 1326 } 1327 } 1328 1329 $result = $path; 1330 1331 if ($ext != '') 1332 $result = $path . $ext; 1333 1334 return $result; 1335 } 1336 */ 1337 1338 /** 1339 * Show the content 1340 */ 1341 function Show($param = '') 1342 { 1343 # :TODO: 1344 return "<tr><td>Show Not Defined</td></tr>"; 1345 } 1346 1347 /** 1348 * allow the content module to handle custom tags. Typically used for parameters in {content} tags 1349 */ 1350 function ContentPreRender($tpl_source) 1351 { 1352 return $tpl_source; 1353 } 1354 1355 /** 1356 * Returns a list of tab names that should be used when adding or editing this type of content 1357 */ 1358 function GetTabDefinitions() 1359 { 1360 return array(); 1361 } 1362 1363 /** 1364 * Returns the tab names used in the add and edit content page. If it's an empty array, then 1365 * the tabs won't show at all. 1366 */ 1367 function TabNames() 1368 { 1369 return array(); 1370 } 1371 1372 /** 1373 * Show the Alternate Edit interface 1374 */ 1375 function EditAsArray($adding = false, $tab = 0, $showadmin = false) 1376 { 1377 # :TODO: 1378 return array(array('Error','Edit Not Defined!')); 1379 } 1380 1381 /** 1382 * Show the Edit interface 1383 */ 1384 function Edit($adding = false, $tab = 0, $showadmin = false) 1385 { 1386 $text = ''; 1387 $val = $this->EditAsArray($adding, $tab, $showadmin); 1388 foreach ($val as $thisRow) 1389 { 1390 $text .= '<tr><th>'.$thisRow[0].'</th><td>'.$thisRow[1].'</td></tr>'; 1391 $text .= "\n"; 1392 } 1393 return $text; 1394 } 1395 1396 /** 1397 * Show the Advanced Edit interface 1398 */ 1399 function AdvancedEdit($adding = false) 1400 { 1401 # :TODO: 1402 return "<tr><td>Advanced Edit Not Defined</td></tr>"; 1403 } 1404 1405 /** 1406 * Show Help 1407 */ 1408 function Help() 1409 { 1410 # :TODO: 1411 return "<tr><td>Help Not Defined</td></tr>"; 1412 } 1413 1414 /** 1415 * Does this have children? 1416 */ 1417 function HasChildren() 1418 { 1419 global $gCms, $config, $sql_queries, $debug_errors; 1420 $db = &$gCms->GetDb(); 1421 1422 $result = false; 1423 1424 $query = "SELECT content_id FROM ".cms_db_prefix()."content WHERE parent_id = ?"; 1425 $row = &$db->GetRow($query, array($this->mId)); 1426 1427 if ($row) 1428 { 1429 $result = true; 1430 } 1431 1432 return $result; 1433 } 1434 1435 function GetAdditionalEditors() 1436 { 1437 if (!isset($this->mAdditionalEditors)) 1438 { 1439 global $gCms; 1440 $db = &$gCms->GetDb(); 1441 1442 $this->mAdditionalEditors = array(); 1443 1444 $query = "SELECT user_id FROM ".cms_db_prefix()."additional_users WHERE content_id = ?"; 1445 $dbresult = &$db->Execute($query,array($this->mId)); 1446 1447 while ($dbresult && !$dbresult->EOF) 1448 { 1449 $this->mAdditionalEditors[] = $dbresult->fields['user_id']; 1450 $dbresult->MoveNext(); 1451 } 1452 1453 if ($dbresult) $dbresult->Close(); 1454 } 1455 return $this->mAdditionalEditors; 1456 } 1457 1458 function SetAdditionalEditors($editorarray) 1459 { 1460 $this->mAdditionalEditors = $editorarray; 1461 } 1462 1463 function ShowAdditionalEditors() 1464 { 1465 $ret = array(); 1466 1467 $ret[] = lang('additionaleditors'); 1468 $text = '<select name="additional_editors[]" multiple="multiple" size="5">'; 1469 1470 global $gCms; 1471 $userops =& $gCms->GetUserOperations(); 1472 $allusers =& $userops->LoadUsers(); 1473 $addteditors = $this->GetAdditionalEditors(); 1474 foreach ($allusers as $oneuser) 1475 { 1476 if ($oneuser->id != $this->Owner()) 1477 { 1478 $text .= '<option value="'.$oneuser->id.'"'; 1479 if (in_array($oneuser->id, $addteditors)) 1480 { 1481 $text .= ' selected="selected"'; 1482 } 1483 $text .= '>'.$oneuser->username.'</option>'; 1484 } 1485 } 1486 1487 $text .= '</select>'; 1488 $ret[] = $text; 1489 return $ret; 1490 } 1491 1492 function IsDefaultPossible() 1493 { 1494 return FALSE; 1495 } 1496 } 1497 1498 /** 1499 * Class to represent content properties. These are pretty much 1500 * separate beings that get used by a content object instance. 1501 * 1502 * @since 0.8 1503 * @package CMS 1504 */ 1505 class ContentProperties 1506 { 1507 var $mPropertyNames; 1508 var $mPropertyTypes; 1509 var $mPropertyValues; 1510 1511 /** 1512 * The (content type specific) allowed properties of the content. 1513 */ 1514 var $mAllowedPropertyNames; 1515 1516 /** 1517 * Generic constructor. Runs the SetInitialValues fuction. 1518 */ 1519 function ContentProperties() 1520 { 1521 $this->SetInitialValues(); 1522 $this->SetAllowedPropertyNames(NULL); 1523 } 1524 1525 /** 1526 * Sets object to some sane initial values 1527 */ 1528 function SetInitialValues() 1529 { 1530 $this->mPropertyNames = array(); 1531 $this->mPropertyTypes = array(); 1532 $this->mPropertyValues = array(); 1533 } 1534 1535 function HasProperty($name) 1536 { 1537 #debug_buffer($this->mPropertyNames); 1538 if (!isset($this->mPropertyNames)) 1539 $this->mPropertyNames = array(); 1540 return in_array($name, $this->mPropertyNames); 1541 } 1542 1543 function Add($type, $name, $defaultvalue='') 1544 { 1545 //Handle names separately 1546 if (!in_array($name, $this->mPropertyNames)) 1547 { 1548 $this->mPropertyNames[] = $name; 1549 } 1550 if (!array_key_exists($name, $this->mPropertyValues)) 1551 { 1552 $this->mPropertyTypes[$name] = $type; 1553 $this->mPropertyValues[$name] = $defaultvalue; 1554 } 1555 } 1556 1557 function GetValue($name) 1558 { 1559 if (in_array($name, $this->mPropertyNames)) 1560 { 1561 if (count($this->mPropertyValues) > 0) 1562 { 1563 if (array_key_exists($name, $this->mPropertyValues)) 1564 { 1565 return $this->mPropertyValues[$name]; 1566 } 1567 } 1568 } 1569 } 1570 1571 function SetValue($name, $value) 1572 { 1573 if (count($this->mPropertyValues) > 0) 1574 { 1575 if (in_array($name, $this->mPropertyNames)) 1576 { 1577 $this->mPropertyValues[$name] = $value; 1578 } 1579 } 1580 } 1581 1582 function Load($content_id) 1583 { 1584 debug_buffer('load properties called'); 1585 if (count($this->mPropertyNames) > 0) 1586 { 1587 global $gCms, $config, $sql_queries, $debug_errors; 1588 $db = &$gCms->GetDb(); 1589 1590 $query = "SELECT * FROM ".cms_db_prefix()."content_props WHERE content_id = ?"; 1591 $dbresult = &$db->Execute($query, array($content_id)); 1592 1593 while ($dbresult && !$dbresult->EOF) 1594 { 1595 $prop_name = $dbresult->fields['prop_name']; 1596 // if ($this->GetAllowedPropertyNames() == NULL || in_array($prop_name, $this->GetAllowedPropertyNames())) 1597 // { 1598 if (!in_array($prop_name, $this->mPropertyNames)) 1599 { 1600 $this->mPropertyNames[] = $prop_name; 1601 } 1602 $this->mPropertyTypes[$prop_name] = $dbresult->fields['type']; 1603 $this->mPropertyValues[$prop_name] = $dbresult->fields['content']; 1604 // } 1605 $dbresult->MoveNext(); 1606 } 1607 1608 if ($dbresult) $dbresult->Close(); 1609 } 1610 } 1611 1612 function Save($content_id) 1613 { 1614 if (count($this->mPropertyValues) > 0) 1615 { 1616 global $gCms, $config, $sql_queries, $debug_errors; 1617 1618 $db =& $gCms->GetDb(); 1619 $concat = ''; 1620 $timestamp = $db->DBTimeStamp(time()); 1621 1622 $insquery = " 1623 INSERT INTO ".cms_db_prefix()."content_props 1624 ( 1625 content_id, 1626 type, 1627 prop_name, 1628 param1, 1629 param2, 1630 param3, 1631 content, 1632 modified_date 1633 ) 1634 VALUES 1635 ( 1636 ?,?,?,'','','',?,$timestamp 1637 ) 1638 "; 1639 1640 foreach ($this->mPropertyValues as $key=>$value) 1641 { 1642 // if ($this->GetAllowedPropertyNames() == NULL || in_array($key, $this->GetAllowedPropertyNames())) 1643 // { 1644 $delquery = "DELETE FROM ".cms_db_prefix()."content_props WHERE content_id = '$content_id' AND prop_name = '$key'"; 1645 $dbresult = $db->Execute($delquery); 1646 1647 $sql_vars = array( 1648 $content_id, 1649 $this->mPropertyTypes[$key], 1650 $key, 1651 $this->mPropertyValues[$key] 1652 ); 1653 $dbresult = $db->Execute($insquery, $sql_vars); 1654 1655 $concat .= $this->mPropertyValues[$key]; 1656 1657 # debug mode 1658 if (true == $config["debug"]) 1659 { 1660 $sql_queries .= "<p>$delquery</p>\n<p>$insquery</p>\n"; 1661 } 1662 1663 if (! $dbresult) 1664 { 1665 if (true == $config["debug"]) 1666 { 1667 # :TODO: Translate the error message 1668 $debug_errors .= "<p>Error updating content property</p>\n"; 1669 } 1670 } 1671 // } 1672 } 1673 1674 if ($concat != '') 1675 { 1676 do_cross_reference($content_id, 'content', $concat); 1677 } 1678 } 1679 } 1680 1681 function Delete($content_id) 1682 { 1683 if (count($this->mPropertyValues) > 0) 1684 { 1685 global $gCms, $config, $sql_queries, $debug_errors; 1686 $db = &$gCms->GetDb(); 1687 1688 $query = "DELETE FROM ".cms_db_prefix()."content_props WHERE content_id = ?"; 1689 $db->Execute($query, array($content_id)); 1690 } 1691 } 1692 1693 /** 1694 * Subclasses should fill this array with strings containing the name of 1695 * the allowed property 1696 * @param array 1697 */ 1698 function SetAllowedPropertyNames($array) 1699 { 1700 $this->mAllowedPropertyNames = $array; 1701 } 1702 1703 /** 1704 * Subclasses should fill this array with strings containing the name of 1705 * the allowed property 1706 * @return array 1707 */ 1708 function GetAllowedPropertyNames() 1709 { 1710 return $this->mAllowedPropertyNames; 1711 } 1712 1713 } // end of class ContentProperties 1714 1715 /** 1716 * Class that module defined content types must extend. 1717 * 1718 * @since 0.9 1719 * @package CMS 1720 */ 1721 class CMSModuleContentType extends ContentBase 1722 { 1723 //What module do I belong to? (needed for things like Lang to work right) 1724 function ModuleName() 1725 { 1726 return ''; 1727 } 1728 1729 function Lang($name, $params=array()) 1730 { 1731 global $gCms; 1732 $cmsmodules = &$gCms->modules; 1733 if (array_key_exists($this->ModuleName(), $cmsmodules)) 1734 { 1735 return $cmsmodules[$this->ModuleName()]['object']->Lang($name, $params); 1736 } 1737 else 1738 { 1739 return 'ModuleName() not defined properly'; 1740 } 1741 } 1742 1743 /* 1744 * Returns the instance of the module this content type belongs to 1745 * 1746 */ 1747 function GetModuleInstance() 1748 { 1749 global $gCms; 1750 $cmsmodules = &$gCms->modules; 1751 if (array_key_exists($this->ModuleName(), $cmsmodules)) 1752 { 1753 return $cmsmodules[$this->ModuleName()]['object']; 1754 } 1755 else 1756 { 1757 return 'ModuleName() not defined properly'; 1758 } 1759 } 1760 } 1761 1762 # vim:ts=4 sw=4 noet 1763 ?>
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 |