Exemple #1
0
	/**
	 * Fetches the standard page view for a widget.
	 *
	 * @param bool $skip_errors					- If using a collection, omit widgets that throw errors
	 * @return vBCms_View_Widget				- The resolved view, or array of views
	 */
	public function getPageView()
	{
		$this->assertWidget();

		// Create view
		$config = $this->widget->getConfig();
		if (!isset($config['template_name']) OR ($config['template_name'] == '') )
		{
			$config['template_name'] = 'vbcms_widget_staticbb_page';
		}

		// Create view
		$view = new vBCms_View_Widget($config['template_name']);
		$view->class = $this->widget->getClass();
		$view->title = $this->widget->getTitle();
		$view->description = $this->widget->getDescription();

		$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
		$view->static_html = $bbcode_parser->do_parse($config['html'], false, true, true, true, true);
		$view->widget_title = $this->widget->getTitle();

		return $view;
	}
Exemple #2
0
	public function getPageTitle()
	{
		if (!$this->pagelist)
		{
			$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());

			$bbcode_parser->setOutputPage($this->parameters['page']);
			$this->pagelist = $bbcode_parser->getPageTitles();
		}

		if ((count($this->pagelist) > 1)  AND isset($this->pagelist[$this->parameters['page']]))
		{
			return $this->content->getHtmlTitle() . '--' . $this->pagelist[$this->parameters['page']];
		}
		return $this->content->getHtmlTitle();

	}
	/**
	 * This function composes and executes the SQL query to generate the
	 * blog data.
	 *
	 * @return	array
	 */
	private function getComments()
	{
		require_once DIR . "/includes/functions_user.php";

		if (!isset($this->config['days']) OR (! intval($this->config['days'])) )
		{
			$this->config['days'] = 7;
		}

		if (!isset($this->config['count']) OR (! intval($this->config['count'])) )
		{
			$this->config['count'] = 10;
		}

		if (!isset($this->config['messagemaxchars']) OR (! intval($this->config['messagemaxchars'])) )
		{
			$this->config['messagemaxchars'] = 200;
		}

		//handle authors
		$useridsql = empty($this->config['postuserid']) ? '' : " AND(blog.userid IN (" .
			implode(',', array_keys($this->config['postuserid']))
			. "))";

		$useridsql .= empty($this->config['commentuserid']) ? '' : " AND(blog_text.userid IN (" .
			implode(',', array_keys($this->config['commentuserid']))
			. "))";

		//categories
		if (empty($this->config['categories']))
		{
			$catjoin = '';
			$categorysql = '';
		}
		else
		{
			$catjoin = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid)";
			$categorysql = " AND cu.blogcategoryid IN (" . implode(',', array_keys($this->config['categories'])) . ")";
		}

		//and tags
		if (empty($this->config['taglist']))
		{
			$tagjoin = '';
			$tagsql = '';
		}
		else
		{
			$tagjoin = "LEFT JOIN " . TABLE_PREFIX . "tagcontent AS tc ON (tc.contentid = blog.blogid AND
				tc.contenttypeid= " . vb_Types::instance()->getContentTypeID("vBBlog_BlogEntry") . ")";
			$tagsql = " AND tc.tagid IN (" . implode(',', array_keys($this->config['taglist'])) . ")";
		}

		$datecutoffsql = "AND (blog.dateline > " . (TIMENOW - (86400 * $this->config['days']) ).  ")" ;

		require_once(DIR . '/includes/blog_functions_shared.php');

		prepare_blog_category_permissions(vB::$vbulletin->userinfo);

		if (!(vB::$vbulletin->userinfo['permissions']['vbblog_general_permissions'] & vB::$vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers']))
		{
			$sql_and[] = "blog.userid = " . vB::$vbulletin->userinfo['userid'];
		}

		$state = array('visible');
		if (can_moderate_blog('canmoderateentries'))
		{
			$state[] = 'moderation';
		}

		$sql_and[] = "blog.state IN('" . implode("', '", $state) . "')";
		$sql_and[] = "blog.dateline <= " . TIMENOW;
		$sql_and[] = "blog.pending = 0";

		$sql_join = array();
		$sql_or = array();
		if (!can_moderate_blog())
		{
			if (vB::$vbulletin->userinfo['userid'])
			{
				$sql_or[] = "blog.userid = " . vB::$vbulletin->userinfo['userid'];
				$sql_or[] = "(options_ignore & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignored.relationid IS NOT NULL)";
				$sql_or[] = "(options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL)";
				$sql_or[] = "(options_member & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddy.relationid IS NULL) AND (options_ignore & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR ignored.relationid IS NULL))";
				$sql_and[] = "(" . implode(" OR ", $sql_or) . ")";

				$sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = blog.userid AND buddy.relationid = " . vB::$vbulletin->userinfo['userid'] . " AND buddy.type = 'buddy')";
				$sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = blog.userid AND ignored.relationid = " . vB::$vbulletin->userinfo['userid'] . " AND ignored.type = 'ignore')";

				$sql_and[] = "
					(blog.userid = " . vB::$vbulletin->userinfo['userid'] . "
						OR
					~blog.options & " . vB::$vbulletin->bf_misc_vbblogoptions['private'] . "
						OR
					(options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL))";
			}
			else
			{
				$sql_and[] = "options_guest & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
				$sql_and[] = "~blog.options & " . vB::$vbulletin->bf_misc_vbblogoptions['private'];

			}
		}

		$globalignore = '';
		if (trim(vB::$vbulletin->options['globalignore']) != '')
		{
			require_once(DIR . '/includes/functions_bigthree.php');
			if ($Coventry = fetch_coventry('string'))
			{
				$globalignore = "AND blog.userid NOT IN ($Coventry) ";
			}
		}

		$sql = "SELECT blog.blogid, blog.comments_visible as replycount, blog.title, blog.lastcomment, blog.lastcommenter, blog.postedby_userid, blog.postedby_username, blog.dateline,
			blog_text.blogtextid, blog_text.pagetext AS message, blog.ratingnum, blog.ratingtotal, blog.rating, blog.views, blog.postedby_userid AS userid, blog.postedby_username AS username,
			blog_user.title as blogtitle, blog_user.description as blogdescription, blog.trackback_visible,
			user.*
			" . (vB::$vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "
			FROM " . TABLE_PREFIX . "blog AS blog
			INNER JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON ((blog_text.blogid = blog.blogid) AND (blog_text.blogtextid <> blog.firstblogtextid))
			INNER JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog_user.bloguserid = blog.userid)
			LEFT JOIN " . TABLE_PREFIX . "user AS user ON (blog_text.userid = user.userid) " .
            implode("\r\n\t ", $sql_join) . "
			$catjoin
			$tagjoin
			" . (vB::$vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "
			WHERE 1=1
			$useridsql
			$categorysql
			$tagsql
			$datecutoffsql
			$globalignore
			AND " . implode("\r\n\tAND ", $sql_and) . "
			ORDER BY blog_text.dateline DESC
			LIMIT 0," . $this->config['count'] ;

		$results = vB::$db->query_read($sql);
		$array = array();
		$parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
		while ($blogcomment = vB::$db->fetch_array($results))
		{
			$blogcomment['title'] = fetch_trimmed_title($blogcomment['title'], $this->config['blogentries_titlemaxchars']);

			$urlinfo = array('blogid' => $blogcomment['blogid'], 'blog_title' => $blogcomment['title']);
			$blogcomment['url'] = fetch_seo_url('entry', $urlinfo, array('bt' => $blogcomment['blogtextid']))
				. "#comment" . $blogcomment['blogtextid'] ;

			$blogcomment['blogtitle'] = $blogcomment['blogtitle'] ? $blogcomment['blogtitle'] : $blogcomment['username'];

			$blogcomment['date'] = vbdate(vB::$vbulletin->options['dateformat'], $blogcomment['dateline'], true);
			$blogcomment['time'] = vbdate(vB::$vbulletin->options['timeformat'], $blogcomment['dateline']);

			$thread['lastpostdate'] = vbdate(vB::$vbulletin->options['dateformat'], $thread['lastcomment'], true);
			$thread['lastposttime'] = vbdate(vB::$vbulletin->options['timeformat'], $thread['lastcomment']);

			$blogcomment['message'] = $this->getSummary($blogcomment['message'], $this->config['messagemaxchars']);

			//get the avatar
			if (vB::$vbulletin->options['avatarenabled'])
			{
				$blogcomment['avatar'] = fetch_avatar_url($blogcomment['userid']);
			}
			else
			{
				$blogcomment['avatar'] = 0;
			}

			$blogcomment['tags'] = array();
			$array[$blogcomment['blogtextid']] = $blogcomment;
		}

		//let's get the tags;
		if (!empty($array))
		{
			$sql = "SELECT tag.tagid, tc.contentid, tag.tagtext
			FROM " . TABLE_PREFIX . "tagcontent AS tc INNER JOIN " .	TABLE_PREFIX .
			"tag AS tag ON tag.tagid = tc.tagid
				 WHERE tc.contentid IN (" . implode(',', array_keys($array)) . ") AND
				tc.contenttypeid= " . vb_Types::instance()->getContentTypeID("vBBlog_BlogEntry") ;
			if ($rst = vB::$db->query_read($sql))
			{
				while ($record = vB::$db->fetch_array($rst))
				{
					$array[$record['contentid']]['tags'][$record['tagid']] = $record['tagtext'];
				}
			}
		}
		return $array;

	}
Exemple #4
0
	/** This function prepares the preview text for an article or other bbcode text
	*
	*	@param	string	the text to be parsed
	 *	@param	int		the number of chars to be returned
	 *	@param	bool		can this user use HTML in their content
	 *	@param	str		the html state of the text - on, off, or on_nl2br
	 *
	 *	@return	string
	 * ***/
	public static function makePreviewText($pagetext, $chars, $canUseHtml, $htmlstate = null)
	{
		//We don't want any table content to display when we generate the preview- unless there
		// is nothing else
		$pagetext = trim(preg_replace('/\<(\s*)TABLE(.+)\<\/TABLE\>/is', ' ', $pagetext));
		$tableless_text = trim(preg_replace('/\[TABLE(.+)\[\/TABLE\]/is', ' ', $pagetext));

		if ($tableless_text =='')
		{
			$tableless_text = $pagetext;
		}

		$parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
		$previewtext = $parser->get_preview(
			$tableless_text,
			$chars,
			$canUseHtml,
			true,
			$htmlstate);

		if ($previewtext =='')
		{
			$previewtext = $parser->get_preview(
				$pagetext,
				$chars,
				$canUseHtml,
				true,
				$htmlstate);
		}
		//We tend to get some blank lines that we don't need.
		$previewtext = preg_replace('/^\<br\>$/i', '', $previewtext);
		$previewtext = preg_replace('/^\<br\/\>$/i', '', $previewtext);
		$previewtext = preg_replace('/^\<br \/\>$/i', '', $previewtext);
		return $previewtext;

	}
Exemple #5
0
	/**
	 * this will create an array of result objects from an array of ids()
	 *
	 * @param array of integer $ids
	 * @return array of objects
	 */
	public static function create_array($ids)
	{
		$contenttypeid = vb_Types::instance()->getContentTypeId('vBCms_Article');
		$rst = vB::$vbulletin->db->query_read($sql = "
			SELECT a.contentid as itemid, a.htmlstate,
				u.username, a.contentid, n.nodeid, u.userid, i.html_title, a.blogid, n.setpublish AS published,
				n.url, n.showtitle, n.showuser, n.showpreviewonly,
				n.showupdated, n.showviewcount, n.settingsforboth,
				a.pagetext, i.title, i.description, n.publishdate, parent.title as parenttitle, i.viewcount,
				n.parentnode as parentid, a.threadid, a.postauthor, a.poststarter, a.blogpostid,
				a.postid, a.post_started, a.post_posted, thread.threadid AS comment_threadid , thread.title AS threadtitle, thread.replycount,
				thread.lastposterid, thread.lastposter, thread.dateline, thread.views, thread.lastpost
			FROM " . TABLE_PREFIX . "cms_article a
				LEFT JOIN " . TABLE_PREFIX . "cms_node n ON n.contentid = a.contentid
  			LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo i ON i.nodeid = n.nodeid
  			LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS parent ON parent.nodeid = n.parentnode
  			LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.threadid = i.associatedthreadid
  			LEFT JOIN " . TABLE_PREFIX . "user u ON u.userid = n.userid
			WHERE a.contentid IN (" . implode(', ', $ids) .") AND n.contenttypeid = " . $contenttypeid
		);

		$id_list = array();
		$items = array();

		if ($rst)
		{
			$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
			$bbcode_parser->setOutputPage(1);
			while ($search_result = vB::$vbulletin->db->fetch_array($rst))
			{
				//If unpublished we hide this.
				if (!($search_result['publishdate'] < TIMENOW))
				{
					continue;
				}
				$item = new vBCms_Search_Result_Article();
				$item->itemid = $search_result['itemid'];
				$categories = array();
				$tags = array();
				$item->contenttypeid = $contenttypeid;
				$search_result['pagetext'] = $bbcode_parser->do_parse($search_result['pagetext'], true);
				$search_result['categories'] = $categories;
				$item->record = $search_result;
				$id_list[$search_result['nodeid']] = $search_result['itemid'];
				$items[$search_result['itemid']] = $item;
			}

			//avoid database error when all cms items are filtered out.
			if (!count($id_list))
			{
				return array();
			}

			$ids = implode(', ', array_keys($id_list));
			$rst1 = vB::$vbulletin->db->query_read(
				"SELECT cat.categoryid, cat.category, nc.nodeid FROM " .
				TABLE_PREFIX . "cms_nodecategory AS nc INNER JOIN " .	TABLE_PREFIX .
				"cms_category AS cat ON nc.categoryid = cat.categoryid WHERE nc.nodeid IN ($ids)"
			);

			if ($rst1)
			{
				$route = new vBCms_Route_List();
				$route->setParameter('action', 'list');

				while($record = vB::$vbulletin->db->fetch_array($rst1))
				{
					$itemid = $id_list[$record['nodeid']];
					$route_info = $record['categoryid'] .
						($record['category'] != '' ? '-' . $record['category'] : '');
					$record['category_url'] = vBCms_Route_List::getUrl(array('type' =>'category',
					 'value' => $route_info , 'page' => 1));
					$items[$itemid]->addCategory($record['categoryid'], $record)  ;
				}
			}

			if ($rst1 = vB::$vbulletin->db->query_read("SELECT tag.tagid, tag.tagtext, node.contentid FROM " .
				TABLE_PREFIX . "cms_node AS node INNER JOIN " .	TABLE_PREFIX .
				"tagcontent AS tc ON (tc.contentid = node.contentid AND  tc.contenttypeid = node.contenttypeid)
				INNER JOIN " .	TABLE_PREFIX .
				"tag AS tag ON tag.tagid = tc.tagid
				 WHERE node.nodeid IN ($ids) " ))
			{
				while($record = vB::$vbulletin->db->fetch_array($rst1))
				{
					$items[$record['contentid']]->addTag($record['tagid'], $record);
			}
			}
			return $items;
		}
		return false;
	}
Exemple #6
0
	private static function getNewBlogs($user)
	{
		global $vbulletin;
		global $vbphrase;
		if (! file_exists(DIR . '/packages/vbblog/search/searchcontroller/newblogentry.php')
			or ! (vB_Search_Core::get_instance()->get_cansearch('vBBlog', 'BlogEntry') ))
		{
			return;
		}
		include_once DIR . '/packages/vbblog/search/searchcontroller/newblogentry.php' ;
		require_once DIR . '/vb/search/core.php' ;
		require_once DIR . '/vb/search/criteria.php' ;
		require_once DIR . '/includes/functions_databuild.php' ;
		//We can use the existing new structures to create this feed. We don't
		// have to, we could do a direct sql query. But this structure is tested
		// and we know it handles permissions properly.
		//First we need a criteria object
		fetch_phrase_group('vbcms');
		$criteria = vB_Search_Core::get_instance()->create_criteria(vB_Search_Core::SEARCH_NEW);
		//Set the count, which may have been passed to us.
		$max_count = 10;

		if ($vbulletin->GPC_exists['count'] AND intval($vbulletin->GPC['count'])
			and intval($vbulletin->GPC['count']) < 21)
		{
			$max_count = intval($vbulletin->GPC['count']);
		}

		//Do we get a user? If so, limit the query.
		if ($vbulletin->GPC_exists['userid'] AND intval($vbulletin->GPC['userid']))
		{
			$criteria->add_userid_filter($vbulletin->GPC['userid'], true);
		}
		else if ($vbulletin->GPC_exists['searchuser'])
		{
			$criteria->add_user_filter($vbulletin->GPC['searchuser'], true);
		}

		//and set the date limit
		if ($vbulletin->GPC_exists['days'] AND intval($vbulletin->GPC['days'] ))
		{
			$datelimit = TIMENOW - ( intval($vbulletin->GPC['days']) * 86400);
		}
		else
		{
			$datelimit = TIMENOW - ( 3 * 86400);
		}
		$criteria->add_newitem_filter($datelimit, null, null);
		$search_controller = new vBBlog_Search_SearchController_NewBlogEntry;
		$results = vB_Search_Results::create_from_cache($user, $criteria, $search_controller);

		if (! $results = vB_Search_Results::create_from_cache($user, $criteria, $search_controller))
		{
			$results = vB_Search_Results::create_from_criteria($user, $criteria, $search_controller);
		}
		$page = $results->get_page(1, $max_count, 1);
		$headers = array(
			'title' => $vbulletin->options['hometitle'] ,
			'link' => $vbulletin->options['bburl'],
			'description' => construct_phrase($vbphrase['recent_blogs_from_x'], $vbulletin->options['hometitle']) ,
			'language' => 'en-us',
			'updated' => date('Y-m-d\TH:i:s', TIMENOW),
			'lastBuildDate' => date('Y-m-d\TH:i:s', TIMENOW)
		);
		$items= array();

		if (count($page))
		{
			$parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
			foreach ($page as $result)
			{
				if ($blog = $result->get_record())
				{
					$items[] = array(
						'title' => $blog['title'],
						'summary' => $parser->get_preview($blog['pagetext'], 800),
						'link' => $vbulletin->options['bburl'] . '/blog.php?blogid='
							. $blog['blogid'],
						'author' => 'noreply@noreply.com-' . $blog['username']);
				}
			}
		}
		return self::makeXml($headers, null, $items);
	}
Exemple #7
0
	/** This function gets the article information based on the defined criteria
	*
	 * @return	array
	 */
	protected function getContent()
	{

		// First, compose the sql
		$sql = "SELECT article.pagetext, article.previewimage, article.imagewidth,
		article.imageheight, article.previewvideo, article.htmlstate, node.url, node.publishdate, node.userid,
		node.setpublish, node.publicpreview, info.title, user.username, node.showuser,
		node.nodeid, node.contenttypeid, thread.replycount FROM "
		. TABLE_PREFIX . "cms_article AS article INNER JOIN "
		. TABLE_PREFIX . "cms_node AS node ON (node.contentid = article.contentid
		AND node.contenttypeid = " . vb_Types::instance()->getContentTypeID("vBCms_Article") .
		") INNER JOIN "	. TABLE_PREFIX . "cms_nodeinfo AS info on info.nodeid = node.nodeid "
		. ( (($this->config['categories'] != '') AND ($this->config['categories'] != '0')) ?
			" INNER JOIN " . TABLE_PREFIX .
		"cms_nodecategory nc ON nc.nodeid = node.nodeid " : '') .	"
		LEFT JOIN "	. TABLE_PREFIX . "user AS user ON user.userid = node.userid
		LEFT JOIN "	. TABLE_PREFIX . "thread AS thread ON thread.threadid = info.associatedthreadid
		WHERE " . vBCMS_Permissions::getPermissionString() ;

		if (($this->config['categories'] != '') AND ($this->config['categories'] != '0') )
		{
			$sql .= "\n AND nc.categoryid IN (" . $this->config['categories'] . ")\n";
		}

		if (($this->config['sections'] != '') AND ($this->config['sections'] != '0'))
		{

			$sql .= "\n AND node.parentnode IN (" . $this->config['sections'] . ")\n";
		}

		if (isset($this->config['days']) AND (intval($this->config['days'])) )
		{
			$sql .= "\n AND node.publishdate > " . (TIMENOW - (86400 * $this->config['days'])) . "\n";
		}

		$sql .= "\n ORDER BY node.publishdate DESC LIMIT " . $this->config['count'];
		$articles = array();

		//Execute
		if ($rst = vB::$db->query_read($sql))
		{
			$current_record = array('contentid' => -1);
			$contenttypeid = vb_Types::instance()->getContentTypeId($this->package . '_' . $this->view_class);
			//now build the results array
			$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin,  vBCms_BBCode_HTML::fetchCmsTags());
			while($article = vB::$db->fetch_array($rst))
			{
				$article['categories'] = array();
				$article['tags'] = array();
				$allow_html = vBCMS_Permissions::canUseHtml($article['nodeid'], $contenttypeid, $article['userid']);
				$pagetext = $bbcode_parser->get_preview(fetch_censored_text($article['pagetext']),
					vB::$vbulletin->options['default_cms_previewlength'], $allow_html);
				$article['previewtext'] = strip_bbcode($pagetext);

				//get the avatar
				if (vB::$vbulletin->options['avatarenabled'])
				{
					$article['avatar'] = fetch_avatar_url($article['userid']);
				}

				$articles[$article['nodeid']]  = $article;
			}

			//Let's get the tags and the categories
			// we can do that with one query each.
			if (count($articles))
			{
				//first let's get categories
				$nodeids = implode(', ', array_keys($articles));
				$sql = "SELECT nc.nodeid, nc.categoryid, category.category FROM " . TABLE_PREFIX . "cms_nodecategory AS nc
				INNER JOIN "	. TABLE_PREFIX . "cms_category AS category ON category.categoryid = nc.categoryid
				WHERE nc.nodeid IN ($nodeids)";
				if ($rst = vB::$db->query_read($sql))
				{
					while ($record = vB::$db->fetch_array($rst))
					{
						$route_info = $record['categoryid'] .
							($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : '');
						$record['route_info'] = $route_info;
						$record['category_url'] = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL();

						$articles[$record['nodeid']]['categories'][$record['categoryid']] = $record;
					}
				}

				//next tags;
				$sql = "SELECT tag.tagid, node.nodeid, tag.tagtext FROM " .
				TABLE_PREFIX . "cms_node AS node INNER JOIN " .	TABLE_PREFIX .
				"tagcontent AS tc ON (tc.contentid = node.contentid AND  tc.contenttypeid = node.contenttypeid)
				INNER JOIN " .	TABLE_PREFIX .
				"tag AS tag ON tag.tagid = tc.tagid
				 WHERE node.nodeid IN ($nodeids) ";
				if ($rst = vB::$db->query_read($sql))
				{
					while ($record = vB::$db->fetch_array($rst))
					{
						$articles[$record['nodeid']]['tags'][$record['tagid']] = $record['tagtext'];
					}
				}
			}
		}
		return $articles;
	}
Exemple #8
0
	public function getRendered($forceload = false)
	{
		$context = new vB_Context($this->package . '_' . $this->class . '_pagetext_' ,
			array( 'nodeid' => $this->nodeid,
			'permissions' => vB::$vbulletin->userinfo['permissions']['cms']));
		$hashkey = strval($context);
		if (!$forceload AND ($rendered = vB_Cache::instance()->read($hashkey, true, true)))
		{
			return $rendered;
		}
		$this->Load(self::INFO_CONTENT);

		$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
		$bbcode_parser->setCanDownload($this->canDownload());
		$pages = array();
		// Articles will generally have an attachment but they should still keep a counter so that this query isn't always running
		require_once(DIR . '/packages/vbattach/attach.php');
		if ($this->canDownload())
		{
			$viewinfo = array();
			$attach = new vB_Attach_Display_Content(vB::$vbulletin, 'vBCms_Article');
			$attachments = $attach->fetch_postattach(0, $this->nodeid);
			$bbcode_parser->attachments = $attachments;
			$bbcode_parser->unsetattach = true;
		}

		$validpage = true;
		$pageno = 1;

		require_once DIR . '/includes/functions.php';
		while($validpage)
		{
			$bbcode_parser->setOutputPage($pageno);

			$pagetext = fetch_censored_text($bbcode_parser->do_parse(
				$this->pagetext,
				vBCMS_Permissions::canUseHtml($this->nodeid, $this->contenttypeid, $this->userid),
				$this->htmlstate
				));

			$validpage = $bbcode_parser->fetchedValidPage();

			if ($pageno == 1)
			{
				$pagelist = $bbcode_parser->getPageTitles();
			}

			if ($validpage)
			{
				$pages[$pageno] = $pagetext;
			}

			$pageno++;
		}
		if ($this->canDownload())
		{
			$attach->process_attachments($viewinfo, $bbcode_parser->attachments, false, false, true, false, true);
		}

		$rendered = array('pages' => $pages, 'attachments' => $bbcode_parser->attachments,
			'viewinfo' => $viewinfo, 'pagelist' => $pagelist);
		vB_Cache::instance()->write($hashkey ,
			$rendered, 1440, array_merge($this->getCacheEvents(), array($this->getContentCacheEvent())));
		//If we updated the page text we need to also update the preview.
		$this->getPreviewText(true);
		return $rendered;
	}