Example #1
0
	/**
	 * Populates a view with the expected info from a content item.
	 *
	 * @param vB_View $view
	 * @param int $viewtype
	 */
	protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE)
	{
		parent::populateViewContent($view, $viewtype);

		$view->node = $this->content->getNodeId();
		$view->type = new vB_Phrase('global', 'content');

		if (vB::$vbulletin->userinfo['userid'])
		{
			$view->published = $this->content->isPublished();
		}
		else
		{
			$view->published = true;
		}

		$view->page_url = $this->getPageUrl();
		//Let's pass an url for editing.
		$view->edit_url = $this->getEditUrl();

		if ($date = $this->content->getPublishDate())
		{
			$view->publishdate = $date;
		}

		$view->publish_phrase = new vB_Phrase('vbcms', 'page_not_published');

		// Get comments
		if ((self::VIEW_PAGE == $viewtype) AND (vB::$vbulletin->options['vbcmsforumid'] > 0) AND $this->content->isPublished() AND !$this->isSection())
		{
			try
			{
				$thread = $this->getAssociatedThread();
				$view->show_comments = ($thread AND $thread->can_view(new vB_Legacy_CurrentUser()));

				if ($view->show_comments)
				{
					$postids = $this->getCommentPosts($thread);
					require_once DIR . '/includes/functions_forumdisplay.php' ;
					$view->thread = process_thread_array($thread->get_record());
				}
			}
			catch (Exception $e)
			{
				if (vB::$vbulletin->config['debug'])
				{
					throw ($e);
				}
			}
		}


		// Check if the user has voted
		$check = true;
		if (vB::$vbulletin->userinfo['userid'])
		{
			$row = vB::$db->query_first("SELECT vote FROM " . TABLE_PREFIX . "cms_rate WHERE userid = " . vB::$vbulletin->userinfo['userid'] . " AND nodeid = " . $view->node);
			if ($row[0])
			{
				$check = false;
			}
		}
		$rated = intval(fetch_bbarray_cookie('cms_rate', $view->node));

		// voted already
		if ($row[0] OR $rated)
		{
			$rate_index = $rated;
			if ($row[0])
			{
				$rate_index = $row[0];
			}
			$view->voteselected["$rate_index"] = 'selected="selected"';
			$view->votechecked["$rate_index"] = 'checked="checked"';
		}
		else
		{
			$view->voteselected[0] = 'selected="selected"';
			$view->votechecked[0] = 'checked="checked"';
		}

		$view->showratenode =
		(
			(
				$check
			OR
				(!$rated AND !vB::$vbulletin->userinfo['userid'])
			)
			OR
				vB::$vbulletin->options['votechange']
		);

		// Get ratings
		if ($this->content->getRatingNum() >= vB::$vbulletin->options['showvotes'])
		{
			$view->ratingtotal = $this->content->getRatingTotal();
			$view->ratingnum = $this->content->getRatingNum();
			$view->ratingavg = vb_number_format($view->ratingtotal / $view->ratingnum, 2);
			$view->rating = intval(round($view->ratingtotal / $view->ratingnum));
			$view->showrating = true;
		}
		else
		{
			$view->showrating = false;
		}
		vB_Cache::instance()->event(vBCms_NavBar::getCacheEventId($this->content->getNodeId()));


	}
Example #2
0
	/**
	 * Gets the full controller class name for a contenttype.
	 *
	 * @param $contenttypeid					- An identifier for the contenttypeid
	 * @param $contentid						- An optional contentid
	 *
	 * @return string
	 */
	public function getContentTypeController($contenttypeid, $contentid = false)
	{
		if (!($id = $this->getContentTypeID($contenttypeid)))
		{
			throw (new vB_Exception_Warning('Trying to get contenttype controller class from invalid contenttype \'' . htmlspecialchars(print_r($contenttypeid, 1)) . '\''));
		}

		return vB_Content::create($this->getContentTypePackage($id), $this->getContentTypeClass($id), $contentid);
	}