/** * Initialisation. * Initialises the view, templaters and all other necessary objects for * successfully creating the response. */ protected function initialize() { // Get current node info $this->node = new vBCms_Item_Content($this->node_segment); // Prenotify the node item of info we will require $info_flags = vBCms_Item_Content::INFO_NODE | vBCms_Item_Content::INFO_PARENTS | vBCms_Item_Content::INFO_CONFIG; $this->node->requireInfo($info_flags); if (!$this->node->isValid()) { $this->node = new vBCms_Item_Content( vB::$vbulletin->options['default_page']); vBCms_NavBar::prepareNavBar($this->node); throw (new vB_Exception_404(new vB_Phrase('error', 'page_not_found'))); } // Prepare navbar vBCms_NavBar::prepareNavBar($this->node); }
/** * Validates a parentid. * Checks if the parent exists. * * @param mixed $value - The value to validate * @param mixed $error - The var to assign an error to * @return mixed | bool - The filtered value or boolean false */ protected function validateParent($value, &$error) { $parent = new vBCms_Item_Content($value); if (!$parent->isValid()) { return false; } $this->section = $parent->getSectionId(); return $value; }
/** * Inflate dynamic segments to canonical values. */ public function inflateSegments() { // Ensure we can resolve the value if (!$value = intval($this->value)) { return; } // Inflate section if ('section' == $this->type) { $node = new vBCms_Item_Content($value); if (!$node->isValid()) { return; } if ($this->value != ($segment = $node->getUrlSegment())) { $this->setSegment('value', $segment, true); } return; } // Inflate author if ('author' == $this->type) { // TODO: Need a model for users $result = vB::$vbulletin->db->query_first(" SELECT username FROM " . TABLE_PREFIX . "user WHERE userid = $value AND username != '' "); if ($result) { $this->setSegment('value', vBCms_Item_Content::buildUrlSegment($value, $result['username']), true); } return; } // Inflate category if ('category' == $this->type) { // TODO: Need a model for categories $result = vB::$vbulletin->db->query_first(" SELECT category FROM " . TABLE_PREFIX . "cms_category WHERE categoryid = $value AND category != '' "); if ($result) { $url = vB_Search_Searchtools::stripHtmlTags($record['category']); $segments['value'] .= '-' . str_replace(' ', '-', $url) ; $this->setSegment('value', vBCms_Item_Content::buildUrlSegment($value, $result['category']), true); } } }
/** * Inflate dynamic segments to canonical values. */ public function inflateSegments() { $node = new vBCms_Item_Content($this->node); if (!$node->isValid()) { return; } if ($this->node != ($segment = $node->getUrlSegment())) { $this->setSegment('node', $segment, true); } }
/** * Validates a nodeid. * Checks if the node exists. * * @param mixed $value - The value to validate * @param mixed $error - The var to assign an error to * @return mixed | bool - The filtered value or boolean false */ protected function validateNode($value, &$error) { $node = new vBCms_Item_Content($value); if (!$node->isValid()) { return false; } return $value; }