/** * Retrieve Node label with link * * @param Enterprise_Cms_Model_Hierarchy_Node $node * @return string */ protected function _getNodeLabel($node) { if ($this->_node && $this->_node->getId() == $node->getId()) { return $this->_getSpan($node); } return $this->_getLink($node); }
/** * Retrieve Nodes collection array * * @return array */ public function getNodes() { if (!$this->hasData('_nodes')) { // initialize nodes $nodes = $this->_node->setCollectActivePagesOnly(true)->getParentNodeChildren(); $flags = array('previous' => false, 'next' => false); $count = count($nodes); $previous = null; $next = null; $first = null; $last = null; $current = 0; foreach ($nodes as $k => $node) { $node->setPageNumber($k + 1); $node->setIsCurrent(false); if (is_null($first)) { $first = $node; } if ($flags['next']) { $next = $node; $flags['next'] = false; } if ($node->getId() == $this->_node->getId()) { $flags['next'] = true; $flags['previous'] = true; $current = $k; $node->setIsCurrent(true); } if (!$flags['previous']) { $previous = $node; } $last = $node; } $this->setPreviousNode($previous); $this->setFirstNode($first); $this->setLastNode($last); $this->setNextNode($next); $this->setCanShowNext($next !== null); // calculate pages frame range if ($this->getFrame() > 0) { $middleFrame = ceil($this->getFrame() / 2); if ($count > $this->getFrame() && $current < $middleFrame) { $start = 0; } else { $start = $current - $middleFrame + 1; if ($start + 1 + $this->getFrame() > $count) { $start = $count - $this->getFrame(); } } if ($start > 0) { $this->setCanShowFirst(true); } else { $this->setCanShowFirst(false); } $end = $start + $this->getFrame(); if ($end < $count) { $this->setCanShowLast(true); } else { $this->setCanShowLast(false); } } else { $this->setCanShowFirst(false); $this->setCanShowLast(false); $start = 0; $end = $count; } $this->setCanShowPreviousJump(false); $this->setCanShowNextJump(false); if ($start > 1) { $this->setCanShowPreviousJump(true); if ($start - 1 > $this->getJump() * 2) { $jump = $start - $this->getJump(); } else { $jump = ceil(($start - 1) / 2); } $this->setPreviousJump($nodes[$jump]); } if ($count - 1 > $end) { $this->setCanShowNextJump(true); $difference = $count - $end - 1; if ($difference < $this->getJump() * 2) { $jump = $end + ceil($difference / 2) - 1; } else { $jump = $end + $this->getJump() - 1; } $this->setNextJump($nodes[$jump]); } $this->setRangeStart($start); $this->setRangeEnd($end); $this->setData('_nodes', $nodes); } return $this->_getData('_nodes'); }
/** * Checks whether node belongs to currently active node's path * * @param Enterprise_Cms_Model_Hierarchy_Node $cmsNode * @return bool */ protected function _isCmsNodeActive($cmsNode) { $currentNode = Mage::registry('current_cms_hierarchy_node'); if (!$currentNode) { return false; } $nodePathIds = explode('/', $currentNode->getXpath()); return in_array($cmsNode->getId(), $nodePathIds); }
/** * Remove children by root node. * * @param Enterprise_Cms_Model_Hierarchy_Node $object * @return Enterprise_Cms_Model_Resource_Hierarchy_Node */ public function removeTreeChilds($object) { $where = array('parent_node_id = ?' => (int) $object->getId()); $this->_getWriteAdapter()->delete($this->getMainTable(), $where); return $this; }