| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Platform 4 * @subpackage Application 5 * 6 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 7 * @license GNU General Public License version 2 or later; see LICENSE 8 */ 9 10 defined('JPATH_PLATFORM') or die; 11 12 /** 13 * JCategories Class. 14 * 15 * @package Joomla.Platform 16 * @subpackage Application 17 * @since 11.1 18 */ 19 class JCategories 20 { 21 /** 22 * Array to hold the object instances 23 * 24 * @var array 25 * @since 11.1 26 */ 27 public static $instances = array(); 28 29 /** 30 * Array of category nodes 31 * 32 * @var mixed 33 * @since 11.1 34 */ 35 protected $nodes; 36 37 /** 38 * Array of category nodes 39 * 40 * @var mixed 41 * @since 11.1 42 * @deprecated use $nodes or declare as private 43 */ 44 protected $_nodes; 45 46 /** 47 * Array of checked categories -- used to save values when _nodes are null 48 * 49 * @var array 50 * @since 11.1 51 */ 52 protected $checkedCategories; 53 54 /** 55 * Array of checked categories -- used to save values when _nodes are null 56 * 57 * @var array 58 * @since 11.1 59 * @deprecated use $checkedCategories or declare as private 60 */ 61 protected $_checkedCategories; 62 63 /** 64 * Name of the extension the categories belong to 65 * 66 * @var string 67 * @since 11.1 68 */ 69 protected $extension = null; 70 71 /** 72 * Name of the extension the categories belong to 73 * 74 * @var string 75 * @since 11.1 76 * @deprecated use $extension or declare as private 77 */ 78 protected $_extension = null; 79 80 /** 81 * Name of the linked content table to get category content count 82 * 83 * @var string 84 * @since 11.1 85 */ 86 protected $table = null; 87 88 /** 89 * Name of the linked content table to get category content count 90 * 91 * @var string 92 * @since 11.1 93 * @deprecated use $table or declare as private 94 */ 95 protected $_table = null; 96 97 /** 98 * Name of the category field 99 * 100 * @var string 101 * @since 11.1 102 */ 103 protected $field = null; 104 105 /** 106 * Name of the category field 107 * 108 * @var string 109 * @since 11.1 110 * @deprecated use $field or declare as private 111 */ 112 protected $_field = null; 113 114 /** 115 * Name of the key field 116 * 117 * @var string 118 * @since 11.1 119 */ 120 protected $key = null; 121 122 /** 123 * Name of the key field 124 * 125 * @var string 126 * @since 11.1 127 * @deprecated use $key or declare as private 128 */ 129 protected $_key = null; 130 131 /** 132 * Name of the items state field 133 * 134 * @var string 135 * @since 11.1 136 */ 137 protected $statefield = null; 138 139 /** 140 * Name of the items state field 141 * 142 * @var string 143 * @since 11.1 144 * @deprecated use $statefield or declare as private 145 */ 146 protected $_statefield = null; 147 148 /** 149 * Array of options 150 * 151 * @var array 152 * @since 11.1 153 */ 154 protected $options = null; 155 156 /** 157 * Array of options 158 * 159 * @var array 160 * @since 11.1 161 * @deprecated use $options or declare as private 162 */ 163 protected $_options = null; 164 165 /** 166 * Class constructor 167 * 168 * @param array $options Array of options 169 * 170 * @since 11.1 171 */ 172 public function __construct($options) 173 { 174 $this->_extension = $options['extension']; 175 $this->_table = $options['table']; 176 $this->_field = (isset($options['field']) && $options['field']) ? $options['field'] : 'catid'; 177 $this->_key = (isset($options['key']) && $options['key']) ? $options['key'] : 'id'; 178 $this->_statefield = (isset($options['statefield'])) ? $options['statefield'] : 'state'; 179 $options['access'] = (isset($options['access'])) ? $options['access'] : 'true'; 180 $options['published'] = (isset($options['published'])) ? $options['published'] : 1; 181 $this->_options = $options; 182 183 return true; 184 } 185 186 /** 187 * Returns a reference to a JCategories object 188 * 189 * @param string $extension Name of the categories extension 190 * @param array $options An array of options 191 * 192 * @return JCategories JCategories object 193 * 194 * @since 11.1 195 */ 196 public static function getInstance($extension, $options = array()) 197 { 198 $hash = md5($extension . serialize($options)); 199 200 if (isset(self::$instances[$hash])) 201 { 202 return self::$instances[$hash]; 203 } 204 205 $parts = explode('.', $extension); 206 $component = 'com_' . strtolower($parts[0]); 207 $section = count($parts) > 1 ? $parts[1] : ''; 208 $classname = ucfirst(substr($component, 4)) . ucfirst($section) . 'Categories'; 209 210 if (!class_exists($classname)) 211 { 212 $path = JPATH_SITE . '/components/' . $component . '/helpers/category.php'; 213 if (is_file($path)) 214 { 215 include_once $path; 216 } 217 else 218 { 219 return false; 220 } 221 } 222 223 self::$instances[$hash] = new $classname($options); 224 225 return self::$instances[$hash]; 226 } 227 228 /** 229 * Loads a specific category and all its children in a JCategoryNode object 230 * 231 * @param mixed $id an optional id integer or equal to 'root' 232 * @param boolean $forceload True to force the _load method to execute 233 * 234 * @return mixed JCategoryNode object or null if $id is not valid 235 * 236 * @since 11.1 237 */ 238 public function get($id = 'root', $forceload = false) 239 { 240 if ($id !== 'root') 241 { 242 $id = (int) $id; 243 244 if ($id == 0) 245 { 246 $id = 'root'; 247 } 248 } 249 250 // If this $id has not been processed yet, execute the _load method 251 if ((!isset($this->_nodes[$id]) && !isset($this->_checkedCategories[$id])) || $forceload) 252 { 253 $this->_load($id); 254 } 255 256 // If we already have a value in _nodes for this $id, then use it. 257 if (isset($this->_nodes[$id])) 258 { 259 return $this->_nodes[$id]; 260 } 261 // If we processed this $id already and it was not valid, then return null. 262 elseif (isset($this->_checkedCategories[$id])) 263 { 264 return null; 265 } 266 267 return false; 268 } 269 270 /** 271 * Load method 272 * 273 * @param integer $id Id of category to load 274 * 275 * @return void 276 * 277 * @since 11.1 278 */ 279 protected function _load($id) 280 { 281 $db = JFactory::getDbo(); 282 $app = JFactory::getApplication(); 283 $user = JFactory::getUser(); 284 $extension = $this->_extension; 285 // Record that has this $id has been checked 286 $this->_checkedCategories[$id] = true; 287 288 $query = $db->getQuery(true); 289 290 // Right join with c for category 291 $query->select('c.*'); 292 $case_when = ' CASE WHEN '; 293 $case_when .= $query->charLength('c.alias'); 294 $case_when .= ' THEN '; 295 $c_id = $query->castAsChar('c.id'); 296 $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':'); 297 $case_when .= ' ELSE '; 298 $case_when .= $c_id . ' END as slug'; 299 $query->select($case_when); 300 301 $query->from('#__categories as c'); 302 $query->where('(c.extension=' . $db->Quote($extension) . ' OR c.extension=' . $db->Quote('system') . ')'); 303 304 if ($this->_options['access']) 305 { 306 $query->where('c.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')'); 307 } 308 309 if ($this->_options['published'] == 1) 310 { 311 $query->where('c.published = 1'); 312 } 313 314 $query->order('c.lft'); 315 316 // s for selected id 317 if ($id != 'root') 318 { 319 // Get the selected category 320 $query->where('s.id=' . (int) $id); 321 if ($app->isSite() && $app->getLanguageFilter()) 322 { 323 $query->leftJoin('#__categories AS s ON (s.lft < c.lft AND s.rgt > c.rgt AND c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')) OR (s.lft >= c.lft AND s.rgt <= c.rgt)'); 324 } 325 else 326 { 327 $query->leftJoin('#__categories AS s ON (s.lft <= c.lft AND s.rgt >= c.rgt) OR (s.lft > c.lft AND s.rgt < c.rgt)'); 328 } 329 } 330 else 331 { 332 if ($app->isSite() && $app->getLanguageFilter()) 333 { 334 $query->where('c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); 335 } 336 } 337 338 $subQuery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ' . 339 'ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = ' . $db->quote($extension) . 340 ' AND parent.published != 1 GROUP BY cat.id) '; 341 $query->leftJoin($subQuery . 'AS badcats ON badcats.id = c.id'); 342 $query->where('badcats.id is null'); 343 344 // i for item 345 if (isset($this->_options['countItems']) && $this->_options['countItems'] == 1) 346 { 347 if ($this->_options['published'] == 1) 348 { 349 $query->leftJoin( 350 $db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id AND i.' . $this->_statefield . ' = 1' 351 ); 352 } 353 else 354 { 355 $query->leftJoin($db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id'); 356 } 357 358 $query->select('COUNT(i.' . $db->quoteName($this->_key) . ') AS numitems'); 359 } 360 361 // Group by 362 $query->group('c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time, 363 c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level, 364 c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id, 365 c.path, c.published, c.rgt, c.title, c.modified_user_id'); 366 367 // Get the results 368 $db->setQuery($query); 369 $results = $db->loadObjectList('id'); 370 $childrenLoaded = false; 371 372 if (count($results)) 373 { 374 // Foreach categories 375 foreach ($results as $result) 376 { 377 // Deal with root category 378 if ($result->id == 1) 379 { 380 $result->id = 'root'; 381 } 382 383 // Deal with parent_id 384 if ($result->parent_id == 1) 385 { 386 $result->parent_id = 'root'; 387 } 388 389 // Create the node 390 if (!isset($this->_nodes[$result->id])) 391 { 392 // Create the JCategoryNode and add to _nodes 393 $this->_nodes[$result->id] = new JCategoryNode($result, $this); 394 395 // If this is not root and if the current node's parent is in the list or the current node parent is 0 396 if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id == 1)) 397 { 398 // Compute relationship between node and its parent - set the parent in the _nodes field 399 $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]); 400 } 401 402 // If the node's parent id is not in the _nodes list and the node is not root (doesn't have parent_id == 0), 403 // then remove the node from the list 404 if (!(isset($this->_nodes[$result->parent_id]) || $result->parent_id == 0)) 405 { 406 unset($this->_nodes[$result->id]); 407 continue; 408 } 409 410 if ($result->id == $id || $childrenLoaded) 411 { 412 $this->_nodes[$result->id]->setAllLoaded(); 413 $childrenLoaded = true; 414 } 415 } 416 elseif ($result->id == $id || $childrenLoaded) 417 { 418 // Create the JCategoryNode 419 $this->_nodes[$result->id] = new JCategoryNode($result, $this); 420 421 if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id)) 422 { 423 // Compute relationship between node and its parent 424 $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]); 425 } 426 427 if (!isset($this->_nodes[$result->parent_id])) 428 { 429 unset($this->_nodes[$result->id]); 430 continue; 431 } 432 433 if ($result->id == $id || $childrenLoaded) 434 { 435 $this->_nodes[$result->id]->setAllLoaded(); 436 $childrenLoaded = true; 437 } 438 439 } 440 } 441 } 442 else 443 { 444 $this->_nodes[$id] = null; 445 } 446 } 447 } 448 449 /** 450 * Helper class to load Categorytree 451 * 452 * @package Joomla.Platform 453 * @subpackage Application 454 * @since 11.1 455 */ 456 class JCategoryNode extends JObject 457 { 458 459 /** 460 * Primary key 461 * 462 * @var integer 463 * @since 11.1 464 */ 465 public $id = null; 466 467 /** 468 * The id of the category in the asset table 469 * 470 * @var integer 471 * @since 11.1 472 */ 473 public $asset_id = null; 474 475 /** 476 * The id of the parent of category in the asset table, 0 for category root 477 * 478 * @var integer 479 * @since 11.1 480 */ 481 public $parent_id = null; 482 483 /** 484 * The lft value for this category in the category tree 485 * 486 * @var integer 487 * @since 11.1 488 */ 489 public $lft = null; 490 491 /** 492 * The rgt value for this category in the category tree 493 * 494 * @var integer 495 * @since 11.1 496 */ 497 public $rgt = null; 498 499 /** 500 * The depth of this category's position in the category tree 501 * 502 * @var integer 503 * @since 11.1 504 */ 505 public $level = null; 506 507 /** 508 * The extension this category is associated with 509 * 510 * @var integer 511 * @since 11.1 512 */ 513 public $extension = null; 514 515 /** 516 * The menu title for the category (a short name) 517 * 518 * @var string 519 * @since 11.1 520 */ 521 public $title = null; 522 523 /** 524 * The the alias for the category 525 * 526 * @var string 527 * @since 11.1 528 */ 529 public $alias = null; 530 531 /** 532 * Description of the category. 533 * 534 * @var string 535 * @since 11.1 536 */ 537 public $description = null; 538 539 /** 540 * The publication status of the category 541 * 542 * @var boolean 543 * @since 11.1 544 */ 545 public $published = null; 546 547 /** 548 * Whether the category is or is not checked out 549 * 550 * @var boolean 551 * @since 11.1 552 */ 553 public $checked_out = 0; 554 555 /** 556 * The time at which the category was checked out 557 * 558 * @var time 559 * @since 11.1 560 */ 561 public $checked_out_time = 0; 562 563 /** 564 * Access level for the category 565 * 566 * @var integer 567 * @since 11.1 568 */ 569 public $access = null; 570 571 /** 572 * JSON string of parameters 573 * 574 * @var string 575 * @since 11.1 576 */ 577 public $params = null; 578 579 /** 580 * Metadata description 581 * 582 * @var string 583 * @since 11.1 584 */ 585 public $metadesc = null; 586 587 /** 588 * Key words for meta data 589 * 590 * @var string 591 * @since 11.1 592 */ 593 public $metakey = null; 594 595 /** 596 * JSON string of other meta data 597 * 598 * @var string 599 * @since 11.1 600 */ 601 public $metadata = null; 602 603 public $created_user_id = null; 604 605 /** 606 * The time at which the category was created 607 * 608 * @var time 609 * @since 11.1 610 */ 611 public $created_time = null; 612 613 public $modified_user_id = null; 614 615 /** 616 * The time at which the category was modified 617 * 618 * @var time 619 * @since 11.1 620 */ 621 public $modified_time = null; 622 623 /** 624 * Nmber of times the category has been viewed 625 * 626 * @var integer 627 * @since 11.1 628 */ 629 public $hits = null; 630 631 /** 632 * The language for the category in xx-XX format 633 * 634 * @var time 635 * @since 11.1 636 */ 637 public $language = null; 638 639 /** 640 * Number of items in this category or descendants of this category 641 * 642 * @var integer 643 * @since 11.1 644 */ 645 public $numitems = null; 646 647 /** 648 * Number of children items 649 * 650 * @var 651 * @since 11.1 652 */ 653 public $childrennumitems = null; 654 655 /** 656 * Slug fo the category (used in URL) 657 * 658 * @var string 659 * @since 11.1 660 */ 661 public $slug = null; 662 663 /** 664 * Array of assets 665 * 666 * @var array 667 * @since 11.1 668 */ 669 public $assets = null; 670 671 /** 672 * Parent Category object 673 * 674 * @var object 675 * @since 11.1 676 */ 677 protected $parent = null; 678 679 /** 680 * Parent Category object 681 * 682 * @var object 683 * @since 11.1 684 * @deprecated use $parent or declare as private 685 */ 686 protected $_parent = null; 687 688 /** 689 * @var Array of Children 690 * @since 11.1 691 */ 692 protected $children = array(); 693 694 /** 695 * @var Array of Children 696 * @since 11.1 697 * @deprecated use $children or declare as private 698 */ 699 protected $_children = array(); 700 701 /** 702 * Path from root to this category 703 * 704 * @var array 705 * @since 11.1 706 */ 707 protected $path = array(); 708 709 /** 710 * Path from root to this category 711 * 712 * @var array 713 * @since 11.1 714 * @deprecated use $path or declare as private 715 */ 716 protected $_path = array(); 717 718 /** 719 * Category left of this one 720 * 721 * @var integer 722 * @since 11.1 723 */ 724 protected $leftSibling = null; 725 726 /** 727 * Category left of this one 728 * 729 * @var integer 730 * @since 11.1 731 * @deprecated use $leftSibling or declare as private 732 */ 733 protected $_leftSibling = null; 734 735 /** 736 * Category right of this one 737 * 738 * @var 739 * @since 11.1 740 */ 741 protected $rightSibling = null; 742 743 /** 744 * Category right of this one 745 * 746 * @var 747 * @since 11.1 748 * @deprecated use $rightSibling or declare as private 749 */ 750 protected $_rightSibling = null; 751 752 /** 753 * true if all children have been loaded 754 * 755 * @var boolean 756 * @since 11.1 757 */ 758 protected $allChildrenloaded = false; 759 760 /** 761 * true if all children have been loaded 762 * 763 * @var boolean 764 * @since 11.1 765 * @deprecated use $allChildrenloaded or declare as private 766 */ 767 protected $_allChildrenloaded = false; 768 769 /** 770 * Constructor of this tree 771 * 772 * @var 773 * @since 11.1 774 */ 775 protected $constructor = null; 776 777 /** 778 * Constructor of this tree 779 * 780 * @var 781 * @since 11.1 782 * @deprecated use $constructor or declare as private 783 */ 784 protected $_constructor = null; 785 786 /** 787 * Class constructor 788 * 789 * @param array $category The category data. 790 * @param JCategoryNode &$constructor The tree constructor. 791 * 792 * @since 11.1 793 */ 794 public function __construct($category = null, &$constructor = null) 795 { 796 if ($category) 797 { 798 $this->setProperties($category); 799 if ($constructor) 800 { 801 $this->_constructor = &$constructor; 802 } 803 804 return true; 805 } 806 807 return false; 808 } 809 810 /** 811 * Set the parent of this category 812 * 813 * If the category already has a parent, the link is unset 814 * 815 * @param mixed &$parent JCategoryNode for the parent to be set or null 816 * 817 * @return void 818 * 819 * @since 11.1 820 */ 821 public function setParent(&$parent) 822 { 823 if ($parent instanceof JCategoryNode || is_null($parent)) 824 { 825 if (!is_null($this->_parent)) 826 { 827 $key = array_search($this, $this->_parent->_children); 828 unset($this->_parent->_children[$key]); 829 } 830 831 if (!is_null($parent)) 832 { 833 $parent->_children[] = & $this; 834 } 835 836 $this->_parent = & $parent; 837 838 if ($this->id != 'root') 839 { 840 if ($this->parent_id != 1) 841 { 842 $this->_path = $parent->getPath(); 843 } 844 $this->_path[] = $this->id . ':' . $this->alias; 845 } 846 847 if (count($parent->_children) > 1) 848 { 849 end($parent->_children); 850 $this->_leftSibling = prev($parent->_children); 851 $this->_leftSibling->_rightsibling = &$this; 852 } 853 } 854 } 855 856 /** 857 * Add child to this node 858 * 859 * If the child already has a parent, the link is unset 860 * 861 * @param JNode &$child The child to be added. 862 * 863 * @return void 864 * 865 * @since 11.1 866 */ 867 public function addChild(&$child) 868 { 869 if ($child instanceof JCategoryNode) 870 { 871 $child->setParent($this); 872 } 873 } 874 875 /** 876 * Remove a specific child 877 * 878 * @param integer $id ID of a category 879 * 880 * @return void 881 * 882 * @since 11.1 883 */ 884 public function removeChild($id) 885 { 886 $key = array_search($this, $this->_parent->_children); 887 unset($this->_parent->_children[$key]); 888 } 889 890 /** 891 * Get the children of this node 892 * 893 * @param boolean $recursive False by default 894 * 895 * @return array The children 896 * 897 * @since 11.1 898 */ 899 public function &getChildren($recursive = false) 900 { 901 if (!$this->_allChildrenloaded) 902 { 903 $temp = $this->_constructor->get($this->id, true); 904 if ($temp) 905 { 906 $this->_children = $temp->getChildren(); 907 $this->_leftSibling = $temp->getSibling(false); 908 $this->_rightSibling = $temp->getSibling(true); 909 $this->setAllLoaded(); 910 } 911 } 912 913 if ($recursive) 914 { 915 $items = array(); 916 foreach ($this->_children as $child) 917 { 918 $items[] = $child; 919 $items = array_merge($items, $child->getChildren(true)); 920 } 921 return $items; 922 } 923 924 return $this->_children; 925 } 926 927 /** 928 * Get the parent of this node 929 * 930 * @return mixed JNode or null 931 * 932 * @since 11.1 933 */ 934 public function &getParent() 935 { 936 return $this->_parent; 937 } 938 939 /** 940 * Test if this node has children 941 * 942 * @return boolean True if there is a child 943 * 944 * @since 11.1 945 */ 946 public function hasChildren() 947 { 948 return count($this->_children); 949 } 950 951 /** 952 * Test if this node has a parent 953 * 954 * @return boolean True if there is a parent 955 * 956 * @since 11.1 957 */ 958 public function hasParent() 959 { 960 return $this->getParent() != null; 961 } 962 963 /** 964 * Function to set the left or right sibling of a category 965 * 966 * @param object $sibling JCategoryNode object for the sibling 967 * @param boolean $right If set to false, the sibling is the left one 968 * 969 * @return void 970 * 971 * @since 11.1 972 */ 973 public function setSibling($sibling, $right = true) 974 { 975 if ($right) 976 { 977 $this->_rightSibling = $sibling; 978 } 979 else 980 { 981 $this->_leftSibling = $sibling; 982 } 983 } 984 985 /** 986 * Returns the right or left sibling of a category 987 * 988 * @param boolean $right If set to false, returns the left sibling 989 * 990 * @return mixed JCategoryNode object with the sibling information or 991 * NULL if there is no sibling on that side. 992 * 993 * @since 11.1 994 */ 995 public function getSibling($right = true) 996 { 997 if (!$this->_allChildrenloaded) 998 { 999 $temp = $this->_constructor->get($this->id, true); 1000 $this->_children = $temp->getChildren(); 1001 $this->_leftSibling = $temp->getSibling(false); 1002 $this->_rightSibling = $temp->getSibling(true); 1003 $this->setAllLoaded(); 1004 } 1005 1006 if ($right) 1007 { 1008 return $this->_rightSibling; 1009 } 1010 else 1011 { 1012 return $this->_leftSibling; 1013 } 1014 } 1015 1016 /** 1017 * Returns the category parameters 1018 * 1019 * @return JRegistry 1020 * 1021 * @since 11.1 1022 */ 1023 public function getParams() 1024 { 1025 if (!($this->params instanceof JRegistry)) 1026 { 1027 $temp = new JRegistry; 1028 $temp->loadString($this->params); 1029 $this->params = $temp; 1030 } 1031 1032 return $this->params; 1033 } 1034 1035 /** 1036 * Returns the category metadata 1037 * 1038 * @return JRegistry A JRegistry object containing the metadata 1039 * 1040 * @since 11.1 1041 */ 1042 public function getMetadata() 1043 { 1044 if (!($this->metadata instanceof JRegistry)) 1045 { 1046 $temp = new JRegistry; 1047 $temp->loadString($this->metadata); 1048 $this->metadata = $temp; 1049 } 1050 1051 return $this->metadata; 1052 } 1053 1054 /** 1055 * Returns the category path to the root category 1056 * 1057 * @return array 1058 * 1059 * @since 11.1 1060 */ 1061 public function getPath() 1062 { 1063 return $this->_path; 1064 } 1065 1066 /** 1067 * Returns the user that created the category 1068 * 1069 * @param boolean $modified_user Returns the modified_user when set to true 1070 * 1071 * @return JUser A JUser object containing a userid 1072 * 1073 * @since 11.1 1074 */ 1075 public function getAuthor($modified_user = false) 1076 { 1077 if ($modified_user) 1078 { 1079 return JFactory::getUser($this->modified_user_id); 1080 } 1081 1082 return JFactory::getUser($this->created_user_id); 1083 } 1084 1085 /** 1086 * Set to load all children 1087 * 1088 * @return void 1089 * 1090 * @since 11.1 1091 */ 1092 public function setAllLoaded() 1093 { 1094 $this->_allChildrenloaded = true; 1095 foreach ($this->_children as $child) 1096 { 1097 $child->setAllLoaded(); 1098 } 1099 } 1100 1101 /** 1102 * Returns the number of items. 1103 * 1104 * @param boolean $recursive If false number of children, if true number of descendants 1105 * 1106 * @return integer Number of children or descendants 1107 * 1108 * @since 11.1 1109 */ 1110 public function getNumItems($recursive = false) 1111 { 1112 if ($recursive) 1113 { 1114 $count = $this->numitems; 1115 1116 foreach ($this->getChildren() as $child) 1117 { 1118 $count = $count + $child->getNumItems(true); 1119 } 1120 1121 return $count; 1122 } 1123 1124 return $this->numitems; 1125 } 1126 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |