コード例 #1
0
ファイル: controller.php プロジェクト: hungnv0789/vhtm
	/**
	 * 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);
	}
コード例 #2
0
ファイル: node.php プロジェクト: hungnv0789/vhtm
	/**
	 * 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;
	}
コード例 #3
0
ファイル: list.php プロジェクト: hungnv0789/vhtm
	/**
	 * 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);
			}
		}
	}
コード例 #4
0
ファイル: content.php プロジェクト: hungnv0789/vhtm
	/**
	 * 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);
		}
	}
コード例 #5
0
ファイル: rate.php プロジェクト: hungnv0789/vhtm
	/**
	 * 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;
	}