grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026setProperties($category); if ($constructor) { $this->_constructor = $constructor; } return true; } return false; } /** * Set the parent of this category * * If the category already has a parent, the link is unset * * @param CategoryNode|null $parent CategoryNode for the parent to be set or null * * @return void * * @since 1.6 */ public function setParent($parent) { if ($parent instanceof CategoryNode || is_null($parent)) { if (!is_null($this->_parent)) { $key = array_search($this, $this->_parent->_children); unset($this->_parent->_children[$key]); } if (!is_null($parent)) { $parent->_children[] = & $this; } $this->_parent = $parent; if ($this->id != 'root') { if ($this->parent_id != 1) { $this->_path = $parent->getPath(); } $this->_path[$this->id] = $this->id . ':' . $this->alias; } if (count($parent->_children) > 1) { end($parent->_children); $this->_leftSibling = prev($parent->_children); $this->_leftSibling->_rightsibling = & $this; } } } /** * Add child to this node * * If the child already has a parent, the link is unset * * @param CategoryNode $child The child to be added. * * @return void * * @since 1.6 */ public function addChild($child) { if ($child instanceof CategoryNode) { $child->setParent($this); } } /** * Remove a specific child * * @param integer $id ID of a category * * @return void * * @since 1.6 */ public function removeChild($id) { $key = array_search($this, $this->_parent->_children); unset($this->_parent->_children[$key]); } /** * Get the children of this node * * @param boolean $recursive False by default * * @return CategoryNode[] The children * * @since 1.6 */ public function &getChildren($recursive = false) { if (!$this->_allChildrenloaded) { $temp = $this->_constructor->get($this->id, true); if ($temp) { $this->_children = $temp->getChildren(); $this->_leftSibling = $temp->getSibling(false); $this->_rightSibling = $temp->getSibling(true); $this->setAllLoaded(); } } if ($recursive) { $items = array(); foreach ($this->_children as $child) { $items[] = $child; $items = array_merge($items, $child->getChildren(true)); } return $items; } return $this->_children; } /** * Get the parent of this node * * @return CategoryNode * * @since 1.6 */ public function getParent() { return $this->_parent; } /** * Test if this node has children * * @return boolean True if there is a child * * @since 1.6 */ public function hasChildren() { return count($this->_children); } /** * Test if this node has a parent * * @return boolean True if there is a parent * * @since 1.6 */ public function hasParent() { return $this->getParent() != null; } /** * Function to set the left or right sibling of a category * * @param CategoryNode $sibling CategoryNode object for the sibling * @param boolean $right If set to false, the sibling is the left one * * @return void * * @since 1.6 */ public function setSibling($sibling, $right = true) { if ($right) { $this->_rightSibling = $sibling; } else { $this->_leftSibling = $sibling; } } /** * Returns the right or left sibling of a category * * @param boolean $right If set to false, returns the left sibling * * @return CategoryNode|null CategoryNode object with the sibling information or null if there is no sibling on that side. * * @since 1.6 */ public function getSibling($right = true) { if (!$this->_allChildrenloaded) { $temp = $this->_constructor->get($this->id, true); $this->_children = $temp->getChildren(); $this->_leftSibling = $temp->getSibling(false); $this->_rightSibling = $temp->getSibling(true); $this->setAllLoaded(); } if ($right) { return $this->_rightSibling; } else { return $this->_leftSibling; } } /** * Returns the category parameters * * @return Registry * * @since 1.6 */ public function getParams() { if (!($this->params instanceof Registry)) { $this->params = new Registry($this->params); } return $this->params; } /** * Returns the category metadata * * @return Registry A Registry object containing the metadata * * @since 1.6 */ public function getMetadata() { if (!($this->metadata instanceof Registry)) { $this->metadata = new Registry($this->metadata); } return $this->metadata; } /** * Returns the category path to the root category * * @return array * * @since 1.6 */ public function getPath() { return $this->_path; } /** * Returns the user that created the category * * @param boolean $modified_user Returns the modified_user when set to true * * @return \JUser A \JUser object containing a userid * * @since 1.6 */ public function getAuthor($modified_user = false) { if ($modified_user) { return \JFactory::getUser($this->modified_user_id); } return \JFactory::getUser($this->created_user_id); } /** * Set to load all children * * @return void * * @since 1.6 */ public function setAllLoaded() { $this->_allChildrenloaded = true; foreach ($this->_children as $child) { $child->setAllLoaded(); } } /** * Returns the number of items. * * @param boolean $recursive If false number of children, if true number of descendants * * @return integer Number of children or descendants * * @since 1.6 */ public function getNumItems($recursive = false) { if ($recursive) { $count = $this->numitems; foreach ($this->getChildren() as $child) { $count = $count + $child->getNumItems(true); } return $count; } return $this->numitems; } }