Пример #1
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');

		if ($rst = vB::$vbulletin->db->query_read("SELECT a.contentid as itemid,
		u.username, a.contentid, n.nodeid, u.userid, i.html_title,
		a.pagetext, i.title, i.description, n.publishdate
		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 . "user u ON u.userid = n.userid
		WHERE a.contentid IN (" . implode(', ', $ids) .
			") AND n.contenttypeid = " . $contenttypeid))
		{
			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'];
				$item->contenttypeid = $contenttypeid;
				$item->record = $search_result;
				$items[$search_result['itemid']] = $item;
			}
			return $items;
		}
		return false;
	}
Пример #2
0
	protected function prepareFields()
	{
		$this->set('contenttypeid', vb_Types::instance()->getContentTypeID("vBCms_Section"));

		if ($this->set_fields['nodeid'])
		{
			$this->item_id = $this->set_fields['nodeid'];
		}
		parent::prepareFields();
	}
Пример #3
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();

		if (! isset($vbulletin->userinfo['permissions']['cms']))
		{
			vBCMS_Permissions::getUserPerms();
		}
		// Create view
		$config = $this->widget->getConfig();
		if (!isset($config['template_name']) OR ($config['template_name'] == '') )
		{
			$config['template_name'] = 'vbcms_widget_sectionnav_page';
		}

		$canviewlist = implode(', ', vB::$vbulletin->userinfo['permissions']['cms']['viewonly']);
		$caneditlist = implode(', ', vB::$vbulletin->userinfo['permissions']['cms']['canedit']);
		$for_node = intval($this->content->getContentTypeId()) == intval(vb_Types::instance()->getContentTypeID("vBCms_Section")) ?
			$this->content->getNodeId() : $this->content->getParentId();
		// Create view
		$view = new vBCms_View_Widget($config['template_name']);
		if ( $link_nodes = vB_Cache::instance()->read($cache_key = $this->getHash($this->widget->getId(), $for_node), false, true))
		{
			$links_before = $link_nodes['links_before'];
			$links_above = $link_nodes['links_above'];
			$links_sibling = $link_nodes['links_sibling'];
			$links_children = $link_nodes['links_children'];
			$links_after = $link_nodes['links_after'];
			$myself = $link_nodes['myself'];
		}
		else
		{
			//If we're on a section, we show for this nodeid. If we're on
			// on a leaf-type node we show for the parent

			$section_possibles = vBCms_ContentManager::getSections();
			$my_left = $this->content->getNodeLeft();
			$my_right = $this->content->getNodeRight();
			$my_parent = $this->content->getParentId();
			$my_nodeid = $this->content->getNodeId();
			$my_title = '';

			$links_above = array();
			$links_before = array();
			$links_above = array();
			$links_sibling = array();
			$links_after = array();
			$links_children = array();
			$top_level = array();

			if (! isset(vB::$vbulletin->userinfo['permissions']['cms']) )
			{
				vBCMS_Permissions::getUserPerms();
			}
			$route = new vBCms_Route_Content();
			$route->setParameter('action', 'view');

			$homeid = $sections[0]['nodeid'];
			//Now let's scan the array;
			$indent = 0;
			$i = 1;
			$noderight = 0;
			//Let's remove items we're not supposed to see.
			$sections= array();
			foreach ($section_possibles as $key => $section)
			{
				if (/** This user has permissions to view this record **/
					( in_array($section['permissionsfrom'], vB::$vbulletin->userinfo['permissions']['cms']['canedit'])
					OR (in_array($section['permissionsfrom'],vB::$vbulletin->userinfo['permissions']['cms']['canview'] )
					AND $section['setpublish'] == '1' AND $section['publishdate'] < TIMENOW ))
					AND /** This user also has rights to the parents **/
					($section['noderight'] > $noderight))
				{
					$sections[] = $section;
				}
				else
				{
					//So the children will be skipped
					$noderight = $section['noderight'];
				}
			}

			//First the sections ahead of us
			while($i < count($sections) AND $my_left > $sections[$i]['nodeleft'])
			{
				$route->node = $sections[$i]['nodeid'] . (strlen($sections[$i]['url']) ? '-' . $sections[$i]['url'] : '' );

				//see if it's a top-level
				if ($sections[$i]['parentnode'] == $homeid)
				{
					$links_before[] =  array('title' => $sections[$i]['title'],
					'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0);
				}//is it a sibling?
				else if ($my_parent == $sections[$i]['parentnode'])
				{
					$links_sibling[] =  array('title' => $sections[$i]['title'],
						 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0);
				}

				$i++;
			}

			//Now our parentage and children
			while($i < count($sections)  AND $my_right > $sections[$i]['nodeleft'])
			{
				$route->node = $sections[$i]['nodeid'] . (strlen($sections[$i]['url']) ? '-' . $sections[$i]['url'] : '' );
				if ($my_nodeid == $sections[$i]['parentnode'])
				{
					$links_children[] =  array('title' => $sections[$i]['title'],
						 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => ($indent) * 10);
				}
				else if ($my_nodeid == $sections[$i]['nodeid'])
				{
					$myself =  array('title' => $sections[$i]['title'],
						 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => $indent * 10);
			}
				else
			{
					$links_above[] =  array('title' => $sections[$i]['title'],
						 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => $indent * 10);
					$my_title = $sections[$i]['title'];
					$indent++;

				}
				$i++;
			}

			//Now the afters
			while ($i < count($sections))
			{
				$route->node = $sections[$i]['nodeid'] . (strlen($sections[$i]['url']) ? '-' . $sections[$i]['url'] : '' );

				if ($sections[$i]['parentnode'] == $homeid)
				{
					$links_after[] =  array('title' => $sections[$i]['title'],
					'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0);
				}
				else if ($my_parent == $sections[$i]['parentnode'])
				{
					$links_sibling[] =  array('title' => $sections[$i]['title'],
						 'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0);
				}
				$i++;
			}

			foreach($links_sibling as $key => $value)
			{
				$links_sibling[$key]['indent'] = $indent * 10;
			}

			$route->node = $sections[1]['nodeid'] . (strlen($sections[1]['url']) ? '-' . $sections[1]['url'] : '' );
			//We have the pieces, now let's string them together;
			//Top level first

			$links_before = array_merge(array(array('title' => $sections[0]['title'],
					'sectionurl' => $route->getCurrentUrl(array('node' =>$route->node, 'action' => 'view')), 'indent' => 0)), $links_before);
			//Now write to the cache
			vB_Cache::instance()->write($cache_key,
				   array('links_before' => $links_before, 'links_above' => $links_above,
				   'links_sibling' => $links_sibling , 'links_after' => $links_after,
				   'links_children' => $links_children, 'myself' => $myself ), $this->cache_ttl,
					array('section_nav_' . $for_node, 'sections_updated'));
		}

		//The first record is the root

		$view->links_before = $links_before;
		$view->links_above = $links_above;
		$view->links_sibling = $links_sibling;
		$view->links_children = $links_children;
		$view->links_after = $links_after;
		$view->myself = $myself;
		$view->widget_title = $this->widget->getTitle();

		return $view;
	}
Пример #4
0
	public static function construct_section_chooser_options($topname = null)
	{
		require_once(DIR . '/includes/class_bootstrap_framework.php');
		require_once(DIR . '/packages/vbcms/contentmanager.php');
		vB_Bootstrap_Framework::init();

		$selectoptions = array();

		if ($topname)
		{
			$selectoptions['-1'] = $topname;
		}

		// get category options
		$nodelist = vBCms_ContentManager::getNodes(1,
				array('contenttypeid' => 'node2.contenttypeid = ' . vb_Types::instance()->getContentTypeID("vBCms_Section")));


		foreach ($nodelist as $section)
		{
			$selectoptions[$section['nodeid']] = str_replace('&gt;', '>', $section['parent']) . $section['leaf'];
		}

		return $selectoptions;
	}
Пример #5
0
	/**
	 * 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;

	}
Пример #6
0
	/**
	 * Fetches a rich page view of the specified content item.
	 * This method can accept parameters from the client code which are usually
	 * derived from user input.  Parameters are passed as an array in the order that
	 * they were received.  Parameters do not normally have assoc keys.
	 *
	 * Note: Parameters are always passed raw, so ensure that validation and
	 * escaping is performed where required.
	 *
	 * Skip permissions should allow content to be rendered regardless of the
	 * current user's permissions.
	 *
	 * Child classes will inevitably override this with wildly different
	 * implementations.
	 *
	 * @param array mixed $parameters			- Request parameters
	 * @param bool $skip_permissions			- Whether to skip can view permission checking
	 * @return vB_View | bool					- Returns a view or false
	 */
	public function getInlineEditBodyView($parameters = false)
	{
		global $vbphrase;
		require_once DIR . '/includes/functions.php';
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');
		$this->editing = true;

		//confirm that the user has edit rights

		if (!$this->content->canPublish())
		{
			return new vB_Phrase('cpcms', 'no_edit_permissions');
		}

		if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode')
		{
			$this->checkSaveData($view);
			unset($_REQUEST['do']);
		}

		$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC  &
			vBCms_Item_Content::INFO_CONFIG & vBCms_Item_Content::INFO_NODE &
			vBCms_Item_Content::INFO_NAVIGATION & vBCms_Item_Content::INFO_PARENTS);
		$this->content->isValid();
		$config = $this->content->getConfig();

		//See if we're deleting
		if ($_REQUEST['do'] == 'delete')
		{

			//We can't delete if there is content below
			if ($record = vB::$vbulletin->db->query_first("SELECT nodeid FROM " . TABLE_PREFIX .
				"cms_node WHERE parentnode = " . $this->content->getNodeId() . " limit 1")
				and intval($record['nodeid']))
			{
				return new vB_Phrase('cpcms', 'cannot_delete_with_subnodes');
			}
			$dm = $this->content->getDM();
			$dm->delete();
			$events = $this->getCleanCacheEvents();
			vB_Cache::instance()->event($events);
			vB_Cache::instance()->cleanNow();
			return new vB_Phrase('cpcms', 'section_deleted');
		}
		vB::$vbulletin->input->clean_array_gpc('r', array(
		'sortby' => vB_Input::TYPE_STR,
		'dir' => vB_Input::TYPE_STR,
		'page' => vB_Input::TYPE_INT,
		'item_count' => vB_Input::TYPE_INT,
		'per_page' => TYPE_INT,
		'simple_paging' => TYPE_INT,
		'page' => TYPE_INT
			));

		// Load the content item
		if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE)))
		{
			throw (new vB_Exception_404());
		}

		// Create view
		$view = $this->createView('inline', self::VIEW_PAGE);

		// Add the content to the view
		parent::populateViewContent($view, self::VIEW_PAGE);

		$this->config = $this->getConfig();

		$view->formid = 'cms_content_data';
		$view->title = $this->content->getTitle();
		$view->html_title = $this->content->getHtmlTitle();
		$view->url = $this->content->getUrl();
		$view->contentfrom = $this->config['contentfrom'];
		$view->editshowchildren = $this->content->getEditShowchildren() ? 1 : 0;
		$view->layout_select = vBCms_ContentManager::getLayoutSelect($this->content->getLayoutSetting(), $this->getParentId());
		$view->style_select = vBCms_ContentManager::getStyleSelect($this->content->getStyleSetting()) ;
		$view->display_order_select = vBCms_ContentManager::getSectionPrioritySelect($this->config['section_priority']) ;
		$view->content_layout_select = $tmp = vBCms_ContentManager::getContentLayoutSelect($this->config['content_layout']);
		$view->simple_paging = $this->config['simple_paging'];
		$view->per_page = $this->config['items_perhomepage'];
		$view->nodeid = $this->content->getNodeId();
		$view->dateformat = vB::$vbulletin->options['dateformat'] . " " . vB::$vbulletin->options['timeformat'];

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

		$aggregate = new vBCms_Collection_Content_Section();
		switch(vB::$vbulletin->GPC['sortby'])
		{
			case 'title' :
				$aggregate->setSortBy('ORDER BY title ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'setpublish' :
				$aggregate->setSortBy('ORDER BY setpublish ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'displayorder' :
				$aggregate->setSortBy('ORDER BY displayorder ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'username' :
				$aggregate->setSortBy('ORDER BY username ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'publishdate' :
				$aggregate->setSortBy('ORDER BY publishdate ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'pageviews' :
				$aggregate->setSortBy('ORDER BY viewcount ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'replycount':
				$aggregate->setSortBy('ORDER BY replycount ' . vB::$vbulletin->GPC['dir']);
				;
				break;
			case 'section':
				$aggregate->setSortBy('ORDER BY parenttitle ' . vB::$vbulletin->GPC['dir']);
				;
				break;
			default:
		$aggregate->setOrderBy(1);
			;
		} // switch

		//See if we need to hide the children
		$filter_node = $this->content->getEditShowchildren();
		if (!$filter_node)
		{
			$aggregate->setFilterNodeExact($this->content->getNodeId());
		}
		else
		{
			$aggregate->filterNode($this->content->getNodeId());
		}
		$nodes = array();
		$sequence = 0;
		$candelete = 1;


		if (vB::$vbulletin->GPC_exists['perpage'] AND intval(vB::$vbulletin->GPC['perpage']))
		{
			$perpage = vB::$vbulletin->GPC['perpage'];
		}
		else
		{
			$perpage = vBCms_ContentManager::getPerPage(new vB_Legacy_CurrentUser());
		}

		$current_page = (vB::$vbulletin->GPC_exists['page'] AND intval(vB::$vbulletin->GPC['page']) ) ?
			vB::$vbulletin->GPC['page'] : 1;
		$aggregate->paginate();
		$aggregate->paginateQuantity($perpage);
		$aggregate->paginatePage($current_page);

		foreach ($aggregate as $id => $content_node)
		{
			$candelete = 0;

			if ($content_node->getContentTypeid() != vb_Types::instance()->getContentTypeID("vBCms_Section") )
			{
				$sequence++;
				$nodes[] = array('sequence' => $sequence,
				'class' => $content_node->getClass(),
				'title' => $content_node->getTitle(),
				'html_title' => $content_node->getHtmlTitle(),
				'nodeid' => $content_node->getNodeid(),
				'prev_checked' =>	($content_node->getPublicPreview() ? " checked=\"checked\" " : ''),
				'publicpreview' => $content_node->publicpreview,
				'parenttitle' => $content_node->getParentTitle(),
				'published_select' => vBCms_ContentManager::getPublishedSelect($content_node->getSetPublish(), $content_node->getPublishDate()),
				'order_select' =>  vBCms_ContentManager::getOrderSelect($content_node->getDisplayOrder($this->content->getNodeId()),
					$this->content->getNodeId()),
				'author' => $content_node->getUsername(),
				'pub_date' =>  (intval($content_node->getPublishDate()) ? vbdate(vB::$vbulletin->options['dateformat'], $content_node->getPublishDate()) : '') ,
				'viewcount' => $content_node->getViewCount(),
				'view_url' => vBCms_Route_Content::getURL(array('node' => $content_node->getUrlSegment())),
				'replycount' => $content_node->getReplyCount());
			}
		}

		if (vB::$vbulletin->GPC_exists['item_count'])
		{
				$item_count = vB::$vbulletin->GPC['item_count'];
		}
		else
		{
			$aggregate->filterNoSections(1);
			$item_count = $aggregate->getCount();
		}

		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'));
		$view->view_url = vBCms_Route_Content::getURL($segments);
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
		$view->submit_url = vBCms_Route_Content::getURL($segments);
		$base_url = $view->submit_url;
		$base_url .=  strpos($base_url, '?') ? '&amp;' : '?';

		$view->record_count = count($aggregate);
		$view->item_count = $item_count;

		$pagination = construct_page_nav($current_page, $perpage, $item_count, $view->submit_url);
		$view->pagination = $pagination;

		$perpage_select .= '<select name="perpage" onchange="checkShouldSave(\'' .
			$view->formid . '\', \'perpage\', \'' . vB_Template_Runtime::escapeJS(new vB_Phrase('cpcms', 'confirm_save_section')) .
			 '\', \'' . vB_Template_Runtime::escapeJS($view->submit_url)  . '\');">' . "\n";
		foreach (array(5,10,15,20,25,50,75,100,200, 250, 500) as $this_perpage)
		{
			$perpage_select .= "<option value=\"$this_perpage\""
				. (intval($this_perpage) == intval($perpage) ? ' selected="selected" ' : '')
				. ">$this_perpage</option>\n" ;
		}
		$perpage_select	.= "</select>";
		$view->perpage_select = $perpage_select;

		$record = vB::$vbulletin->db->query_first("SELECT SUM(childinfo.viewcount) AS viewcount,
          SUM(CASE when child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") ." THEN 1 ELSE 0 END) AS content,
          SUM(CASE when (child.parentnode = node.nodeid AND child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") .") THEN 1 ELSE 0 END) AS children,
          SUM(CASE when child.contenttypeid =" . vb_Types::instance()->getContentTypeID("vBCms_Section") ." AND child.parentnode = node.nodeid THEN 1 ELSE 0 END) AS subsections
				FROM " . TABLE_PREFIX . "cms_node AS node
				LEFT JOIN " . TABLE_PREFIX . "cms_node AS child ON (child.nodeleft >= node.nodeleft AND child.nodeleft <= node.noderight AND child.nodeid <> node.nodeid AND child.new != 1)
				LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS childinfo ON childinfo.nodeid = child.nodeid AND child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") ."
				WHERE node.nodeid = " . $this->content->getNodeId());
		$view->viewcount = $record['viewcount'];
		$view->content = $record['content'];
		$view->children = $record['children'];
		$view->subsections = $record['subsections'];

		$view->nodes = $nodes;

		$view->metadata = $this->content->getMetadataEditor();

		//Here we create some url's. This should allow to sort in reverse direction

		$view->sorttitle_url = $base_url . 'sortby=title&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'title'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortpub_url = $base_url . 'sortby=setpublish&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'setpublish'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortorder_url = $base_url . 'sortby=displayorder&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'displayorder'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortauthor_url = $base_url . 'sortby=username&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'username'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortdate_url = $base_url . 'sortby=publishdate&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'publishdate'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sorthits_url = $base_url . 'sortby=pageviews&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'pageviews'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortreplycount_url = $base_url . 'sortby=replycount&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'replycount'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortsection_url = $base_url . 'sortby=section&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'section'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->editbar = $this->content->getEditBar($view->submit_url, $view->view_url, $view->formid,
				(intval($this->content->getNodeId()) ? 'edit' : 'add'), $candelete);
		$view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid, false,
			false, false, false, $this->config['pagination_links']);

		$view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Section");

		$this->addPostId($view);

		// Sub menu
		if (!$this->content->isRoot())
		{
			$view->inherit_section = $this->content->getNavigationParentTitle();
			$view->inherited = !$this->content->hasNavigation();
		}

		$navigation_nodes = $this->content->getNavigationNodes();

		$subnav_nodes = vBCms_ContentManager::getSections(false, true);


		// array for the navigation display order drop-down menu
		$displayorder_array = array(0 => '');
		$count = max(count($nodes), 40);
		for ($i=1; $i <= $count; $i++)
		{
			$displayorder_array[$i] = $i;
		}

		// populate sub-nav configuration menu with all cms sections
		$sections = array();

		$subnav = new vB_View('vbcms_content_section_subnavedit');
		$subnav->displayorder_array = $displayorder_array;
		foreach ($subnav_nodes AS $node)
		{
			$nodeid = $node['nodeid'];

			// check if the section has already been selected for the menu nav
			// if so, its position in the array (key+1) is its display order
			$displayorder = 0; //default display order is 0
			$selected = false;
			if (isset($navigation_nodes) AND is_array($navigation_nodes))
			{
				if ($selected = in_array($nodeid, $navigation_nodes))
				{
					$displayorder = array_search($nodeid, $navigation_nodes) + 1;
				}
			}

			$sections[] = array('id' => $nodeid, 'title' => $node['title'], 'depth' => $node['depth'], 'selected' => $selected, 'displayorder' => $displayorder);
		}
		$subnav->sections = $sections;
		$subnav_rendered = $subnav->render();
		$view->subnav = $subnav_rendered;
		unset($nodes, $subnav_nodes, $sections);
		return $view;
	}
Пример #7
0
	/**
	* This function adds node url & indent for non-javascript navigation
	*
	* @param	array	$nodes
	*/
	public function setNavArray($nodes)
	{
		//We need to set the indent level and the url
		$indentlevel = array();
		//What is the current section
		$sectionid = ($this->content->getContentTypeId() == vb_Types::instance()->getContentTypeID("vBCms_Section")) ?
			$this->content->getNodeId() : $this->content->getParentId();

		//because we're ordered by nodeleft, we'll always see parents before children
		foreach ($nodes as $key => $node)
		{
			//get the url
			$nodeurl = $node['nodeid'] . ($node['url'] ? '-'. $node['url'] : '');
			$segments = array('node' => $nodeurl, 'action' => 'view');
			$nodes[$key]['url'] = vBCms_Route_Content::getURL($segments);
			//get the indent
			if (isset($node['parentnode']))
			{
				if (array_key_exists($node['parentnode'], $indentlevel))
				{
					//This is the root node
					$indent = $indentlevel[$node['parentnode']] + 1;
					$indentlevel[$node['nodeid']] = $indent;
					$nodes[$key]['indent'] = $indent;
				}
				else
				{
					$nodes[$key]['indent'] = 1;
					$indentlevel[$node['nodeid']] = 1;
				}
			}
			else
			{
				//This is the root node
				unset($nodes[$key]);
				continue;
			}
			//Set a flag to tell the template if it's the current page.
			//In my experience with templates, 0/1 is more reliable than true-false
			$nodes[$key]['current_page'] = $sectionid == $node['nodeid'] ? 1 : 0;
		}
		return $nodes;
	}
Пример #8
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();

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

		// Create view
		$view = new vBCms_View_Widget($config['template_name']);
		$this->sectionid = $this->content->getContentTypeId() == vb_Types::instance()->getContentTypeID("vBCms_Section") ?
			$this->content->getNodeId() : $this->content->getParentId();

		try
		{
			$categoryid = max(1, intval(vB_Router::getSegment('value')));
		}
		catch (vB_Exception_Router $e)
		{
			$categoryid = 0;
		}

		if (!$nodes = vB_Cache::instance()->read($cache_key = $this->getHash($this->widget->getId(), $this->sectionid), true, true
			))
		{
			//First we'll generate the category list

			//compose the sql
			$rst = vB::$vbulletin->db->query_read($sql = "SELECT  parent.category AS parentcat, cat.categoryid, cat.category,
			cat.catleft, cat.catright, info.title AS node, node.nodeid, count(nodecat.nodeid) as qty
      	FROM " . TABLE_PREFIX . "cms_node AS node
			INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid
      	INNER JOIN " . TABLE_PREFIX . "cms_category AS parent on parent.parentnode = node.nodeid
			INNER JOIN " . TABLE_PREFIX . "cms_category AS cat ON (cat.catleft >= parent.catleft AND cat.catleft <= parent.catright)
			LEFT JOIN " . TABLE_PREFIX . "cms_nodecategory AS nodecat ON nodecat.categoryid = cat.categoryid
			WHERE node.nodeid = " . $this->sectionid . " AND " . vBCMS_Permissions::getPermissionString() . "
			GROUP BY parent.category, cat.categoryid, cat.category,
			cat.catleft, cat.catright, info.title
			ORDER BY catleft;");

			$parents = array();
			$level = 0;
			$nodes = array();
			if ($record = vB::$vbulletin->db->fetch_array($rst))
			{
				$record['level'] = $level;
				$record['route_info'] = $record['categoryid'] .
					($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : '');
				$nodes[strtolower($record['category'])] = $parents[0] = $record;
				$last_category = -1;

				while($record = vB::$vbulletin->db->fetch_array($rst))
				{
					$record['route_info'] = $record['categoryid'] .
						($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : '');

					if ($record['categoryid'] == $last_category )
					{
						continue;
					}

					//note that since we're already sorted by by catleft we don't need to check that.
					while((intval($record['catright']) > intval($parents['level']['catright'])) AND $level > 0)
					{
						$level--;
					}
					$level++;
					$record['level'] = $level;

					$nodes[strtolower($record['category'])] = $parents[$level] = $record;
					$last_category = $record['categoryid'];
				}
			}
			ksort($nodes);
			$key = array_keys($nodes);
			$size = sizeOf($key);
			for ($i = 0; $i < $size; $i++)
			{
				if ($categoryid == $nodes[$key[$i]]['categoryid'])
				{
					$nodes[$key[$i]]['myself'] = true;
				}
				else
				{
					$nodes[$key[$i]]['myself'] = false;
				}
			}
			vB_Cache::instance()->write($cache_key,
				$nodes, $this->cache_ttl, 'categories_updated');
		}

		foreach ($nodes as $nodeid => $record)
		{
			$route = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL();
			$nodes[$nodeid]['view_url'] = $route;

		}
		// Modify $nodes to add myself var (currently selected category)


		$view->widget_title = $this->widget->getTitle();
		$view->nodes = $nodes;
		return $view;
	}
Пример #9
0
	public function getContentTypeId()
	{
		return vb_Types::instance()->getContentTypeID("vBCms_Article");
	}
Пример #10
0
	/**
	 * This gets a list of the publicly viewable "leaf" nodes. It was created for
	 * use by the sitemap builder but it seems it could have other uses.
	 *
	 * @param	int	$sortby	1:section order, then title, 2: title, 3:publish_date
	 * @return array
	 */
	public static function getPublicContent($startat = 0, $qty = 10000, $sortby = 1)
	{
		$perms = vBCMS_Permissions::getPerms(0);

		$sql = "SELECT node.nodeid, node.contenttypeid, node.hidden, info.title, parentinfo.title AS section,
		parent.nodeid AS sectionid, node.setpublish, node.publishdate, node.url FROM " . TABLE_PREFIX .
		"cms_node AS node INNER JOIN " . TABLE_PREFIX .	"cms_nodeinfo AS info ON info.nodeid = node.nodeid
		INNER JOIN " . TABLE_PREFIX .	"cms_node AS parent ON parent.nodeid = node.parentnode
		INNER JOIN " . TABLE_PREFIX .	"cms_nodeinfo AS parentinfo ON parentinfo.nodeid = parent.nodeid
		WHERE node.setpublish > 0 AND parent.setpublish > 0 AND parent.publishdate < " . TIMENOW .
		" AND node.publishdate < " . TIMENOW . " AND node.permissionsfrom IN (" .
		implode(',', $perms['canview']) . ") AND (node.contenttypeid <> " .
		vb_Types::instance()->getContentTypeID("vBCms_Section") . ") ";

		switch($sortby){
			case 3 :
				$sql .= " ORDER BY node.setpublish DESC";
				break;
			case 2 :
				$sql .= " ORDER BY info.title";
				break;
			default:
				$sql .= " ORDER BY parent.nodeleft, info.title";
		} // switch

		$sql .= " LIMIT $startat, $qty ";
		$rst = vB::$db->query_read($sql);
		$nodes = array();
		while($node = vB::$db->fetch_array($rst))
		{
			$nodes[$node['nodeid']] = $node;
		}
		return $nodes;
	}
Пример #11
0
	/**
	 * function to return the rendered html for this result
	 *
	 * @param string $current_user
	 * @param object $criteria
	 * @return
	 */
	public function render($current_user, $criteria, $template_name = '')
	{
		global $vbulletin;
		global $show;
		require_once DIR . '/vb/search/searchtools.php';
		require_once DIR . "/includes/functions_user.php";
		require_once DIR . "/includes/functions.php";

		if (!strlen($template_name))
		{
			$template_name = 'vbcms_searchresult_article_general';
		}
		$template = vB_Template::create($template_name);

		$template->register('title', vBCMS_Permissions::canUseHtml($this->record['nodeid'], vb_Types::instance()->getContentTypeId('vBCms_Article'),
			 $this->record['userid']) ? $this->record['title'] : htmlspecialchars_uni($this->record['title']));
		$template->register('html_title', vBCMS_Permissions::canUseHtml($this->record['nodeid'], vb_Types::instance()->getContentTypeId('vBCms_Article'),
			 $this->record['userid']) ? $this->record['html_title'] : htmlspecialchars_uni($this->record['html_title']));

		// Bug 35855: due to a different bug, 35413, users are able to save articles with
		// invalid seo url aliases. this causes the getCurrentUrl to throw a vB_Exception_Router
		// exception when attempting to build article URL's for search. so, to prevent
		// the search from blowing up on these articles results, we will trap these exceptions,
		// and generate the url without the alias in that case
		try
		{
			$page_url = vB_Route::create('vBCms_Route_Content', $this->record['nodeid'] .
				($this->record['url'] == '' ? '' : '-' . $this->record['url'] ))->getCurrentURL();
		}
		catch (vB_Exception_Router $e)
		{
			$page_url = vB_Route::create('vBCms_Route_Content', $this->record['nodeid'])->getCurrentURL();
		}
		$template->register('page_url', $page_url);
		$this->record['page_url'] = $page_url;
		try
		{
			$parent_url = vB_Route::create('vBCms_Route_Content', $this->record['parentid'] .
				($this->record['parenttitle'] == '' ? '' : '-' . $this->record['parenttitle'] )	)->getCurrentURL();
		}
		catch (vB_Exception_Router $e)
		{
			$parent_url = vB_Route::create('vBCms_Route_Content', $this->record['parentid'])->getCurrentURL();
		}
		$template->register('parent_url', $parent_url);

		$template->register('lastcomment_url', $page_url . "#new_comment");
		$template->register('username', $this->record['username']);
		$template->register('description', $this->record['description']);
		$template->register('parenttitle' , htmlspecialchars_uni($this->record['parenttitle']) );
		$template->register('parentid' , $this->record['parentid'] );
		$template->register('threadid' , $this->record['threadid'] );
		$template->register('postauthor' , $this->record['postauthor'] );
		$template->register('poststarter' , $this->record['poststarter'] );
		$template->register('blogpostid' , $this->record['blogpostid'] );
		$template->register('parentnode' , $this->record['parentnode'] );
		$template->register('postid' , $this->record['postid'] );
		$template->register('post_started' , $this->record['post_started'] );
		$template->register('post_posted' , $this->record['post_posted'] );
		$can_use_html = vBCMS_Permissions::canUseHtml($this->record['nodeid'], vb_Types::instance()->getContentTypeId('vBCms_Article'),
			 $this->record['userid']) ;
		$template->register('previewtext', $this->getPreviewText($this->record));
		$template->register('pagetext',
			 $can_use_html ? fetch_censored_text($this->record['pagetext']) :
			 fetch_censored_text(htmlspecialchars_uni($this->record['pagetext'])));
		$template->register('publish_phrase', ($this->record['publishdate'] ?
			$vbphrase['page_published'] : $vbphrase['page_unpublished']) );
		$template->register('author_phrase', 'author');
		$template->register('published', ($this->record['publishdate'] ?
			true : false));
		$template->register('categories', $this->categories);
		$template->register('tags', $this->tags);
		$template->register('replycount', ($this->record['replycount'] ?
			$this->record['replycount'] : '0'));
		$template->register('article', $this->record);
		$template->register('publishdate', vbdate($vbulletin->options['dateformat'], $this->record['publishdate'], true));
		$template->register('publishtime', vbdate($vbulletin->options['timeformat'], $this->record['publishdate']));
		$template->register('lastpostdate', vbdate($vbulletin->options['dateformat'], $this->record['lastpost'], true));
		$template->register('lastpostdatetime', vbdate($vbulletin->options['timeformat'], $this->record['lastpost']));
		$template->register('lastposter', $this->record['lastposter']);
		$template->register('lastposterinfo', array('userid'=>$this->record['lastposterid'], 'username'=>$this->record['lastposter']));
		$template->register('dateformat', $vbulletin->options['dateformat']);
		$template->register('timeformat', $vbulletin->options['default_timeformat']);
		$user = vB_Legacy_User::createFromId($this->record['userid']);

		//get the avatar
		if (intval($this->record['userid']))
		{
			$avatar = fetch_avatar_url($this->record['userid']);
		}

		if (!isset($avatar) OR (count($avatar) < 2))
		{
			$avatar = false;
		}
		$template->register('avatar', $avatar);
		$result = $template->render();

		return $result;
	}
Пример #12
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();


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

		// Create view
		$view = new vBCms_View_Widget($config['template_name']);
		$this->sectionid = $this->content->getContentTypeId() == vb_Types::instance()->getContentTypeID("vBCms_Section") ?
			$this->content->getNodeId() : $this->content->getParentId();
		$cache_key = $this->getHash($this->widget->getId(), $this->sectionid);

		if (!$nodes = vB_Cache::instance()->read($cache_key, true, true))
		{
			//First we'll generate the category list
			$parentnodes = $this->content->getParentNodes();
			$nodeids = array($this->content->getNodeId());

			if ($parentnodes AND (count($parentnodes) > 0))
			{
				foreach ($parentnodes as $node)
				{
					$nodeids[] = $node['nodeid'];
				}
			}

			//compose the sql
			$rst = vB::$vbulletin->db->query_read($sql = "SELECT parent.category AS parentcat, cat.categoryid, cat.category, info.title,
			cat.catleft, cat.catright, info.title AS node, node.nodeid, count(nodecat.nodeid) as qty
      	FROM " . TABLE_PREFIX . "cms_node AS node
			INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid
      	INNER JOIN " . TABLE_PREFIX . "cms_category AS parent on parent.parentnode = node.nodeid
			INNER JOIN " . TABLE_PREFIX . "cms_category AS cat ON (cat.catleft >= parent.catleft AND cat.catleft <= parent.catright)
			LEFT JOIN " . TABLE_PREFIX . "cms_nodecategory AS nodecat ON nodecat.categoryid = cat.categoryid
			WHERE node.nodeid in (" . implode(',', $nodeids ) . ")
			GROUP BY parent.category, cat.categoryid, cat.category,
			cat.catleft, cat.catright, info.title, node.nodeid, info.title
			ORDER BY node.nodeleft, catleft;");

			$parents = array();
			$level = 0;
			$nodes = array();
			if ($record = vB::$vbulletin->db->fetch_array($rst))
			{
				$record['level'] = $level;
				$record['route_info'] = $record['categoryid'] .
					($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : '');
				$nodes[strtolower($record['category'])] = $parents[0] = $record;
				$last_category = -1;
				while($record = vB::$vbulletin->db->fetch_array($rst))
				{

					if ($record['categoryid'] == $last_category )
					{
						continue;
					}
					//note that since we're already sorted by by catleft we don't need to check that.
					while((intval($record['catright']) > intval($parents['level']['catright'])) AND $level > 0)
					{
						$level--;
					}
					$level++;
					$record['level'] = $level;
					$record['route_info'] = $record['categoryid'] .
						($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : '');

					$nodes[strtolower($record['category'])] = $parents[$level] = $record;
					$last_category = $record['categoryid'];
				}
			}
			ksort($nodes);
			vB_Cache::instance()->write($cache_key,
				$nodes, $this->cache_ttl,'categories_updated');
		}

		foreach ($nodes as $nodeid => $record)
		{
			$route = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL();
			$nodes[$nodeid]['view_url'] = $route;

		}

		$view->widget_title = $this->widget->getTitle();
		$view->nodes = $nodes;
		return $view;
	}
Пример #13
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;
	}
Пример #14
0
	public function getCategories()
	{
		if (vb_Types::instance()->getContentTypeID("vBCms_Section") == $this->contenttypeid )
		{
			return array();
		}
		$categories = array();


		if ($rst = vB::$vbulletin->db->query_read("SELECT category, cat.categoryid FROM "
			. TABLE_PREFIX . "cms_nodecategory nc INNER JOIN "
			. TABLE_PREFIX . "cms_category cat ON cat.categoryid = nc.categoryid
			WHERE nc.nodeid = " . $this->nodeid ))
		{
			while($record = vB::$vbulletin->db->fetch_array($rst))
			{
				$route_info = $record['categoryid'] .
					($record['category'] != '' ? '-' . $record['category'] : '');
				$record['category_url'] = vB_Route::create('vBCms_Route_List',
						"category/$route_info/1")->getCurrentURL();
				$categories[] = $record;
			}
		}
		return $categories;
	}
Пример #15
0
function getSectionList($orderby = 1)
{
    //We make use of the preorder structure of the data. We compose a query where each
    //leat of the specific content type gets its complete parentage.
    global $vbulletin;
    global $vbphrase;
    $sql = "SELECT DISTINCT info.title AS section, info2.title,\n\t\tnode2.nodeid, node.nodeid AS parentid\n\t\tFROM " . TABLE_PREFIX . "cms_node node INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo info ON info.nodeid = node.nodeid\n\t\tINNER JOIN " . TABLE_PREFIX . "cms_node AS node2 ON (node2.nodeleft >= node.nodeleft AND node2.nodeleft <= node.noderight)\n\t\tINNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info2 ON info2.nodeid = node2.nodeid\n\t\tWHERE node2.contenttypeid = " . vb_Types::instance()->getContentTypeID("vBCms_Section") . " ORDER BY " . ($orderby == 0 ? "info2.title" : "node2.nodeleft") . " , node.nodeleft;";
    if ($rst = $vbulletin->db->query_read($sql)) {
        //Now it's simple. We walk down the list. We know we have reached a leaf when
        // nodeid = parentid
        $stack = array();
        $count = 0;
        while ($row = $vbulletin->db->fetch_array($rst)) {
            if (intval($row['nodeid']) == intval($row['parentid'])) {
                $stack[$count][] = '<a id="set_section_' . $row['nodeid'] . '" href="javascript: setSection(' . $row['nodeid'] . '); return false;" onclick="javascript:void setSection(' . $row['nodeid'] . '); return false;" style="font-weight:bold;">' . htmlspecialchars_uni($row['title']) . '</a>';
                $count++;
            } else {
                $stack[$count][] = htmlspecialchars_uni($row['section']);
            }
        }
    }
    $result = '';
    $break = '<li style="float:' . vB_Template_Runtime::fetchStyleVar('left') . '">&nbsp;&gt;&nbsp; </li>';
    foreach ($stack as $values) {
        $result .= '<ul class="floatcontainer floatlist">';
        foreach ($values as $value) {
            $result .= $break;
            $result .= '<li style="float:' . vB_Template_Runtime::fetchStyleVar('left') . '">' . $value . '</li>';
        }
        $result .= '</ul>';
    }
    return $result;
}
Пример #16
0
	/**
	 * Fetches the SQL for loading.
	 * $required_query is used to identify which query to build for classes that
	 * have multiple queries for fetching info.
	 *
	 * This can safely be based on $this->required_info as long as a consitent
	 * flag is used for identifying the query.
	 *
	 * @param int $required_query				- The required query
	 * @param bool $force_rebuild				- Whether to rebuild the string
	 *
	 * @return string
	 */
	protected function getLoadQuery($required_query = self::QUERY_BASIC, $force_rebuild = false)
	{
		// Hooks should check the required query before populating the hook vars
		$hook_query_fields = $hook_query_joins = $hook_query_where = '';
		($hook = vBulletinHook::fetch_hook($this->query_hook)) ? eval($hook) : false;

		if (self::QUERY_BASIC == $required_query)
		{
			if (! isset(vB::$vbulletin->userinfo['permissions']['cms']))
			{
				vBCMS_Permissions::getUserPerms();
			}

			$extrasql =	'' ;

			$permissionstring = "( (" . vBCMS_Permissions::getPermissionString() .
				($this->filter_includepreview ? ") OR (node.setpublish AND node.publishdate <" . TIMENOW .
				" AND node.publicpreview > 0" : '' ) . "))" ;

			if (!$this->sortby)
			{
				if ($this->orderby == 3)
				{
					$extrasql =	" INNER JOIN (SELECT parentnode, MAX(lastupdated) AS lastupdated
					FROM " . TABLE_PREFIX . "cms_node  AS node WHERE contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") .
					" AND	" .  vBCMS_Permissions::getPermissionString() .
					" GROUP BY parentnode ) AS ordering ON ordering.parentnode = node.parentnode
					AND node.lastupdated = ordering.lastupdated WHERE 1=1";

					$this->sortby = " ORDER BY node.setpublish DESC, node.publishdate DESC ";
				}
				else if ($this->orderby == 2)
				{
					$this->sortby = " ORDER BY node.publishdate DESC ";
				}
				else if ($this->orderby == 4)
				{
					$this->sortby = " ORDER BY info.title ASC ";
				}
				else if ($this->orderby == 5)
				{
					$this->sortby = " ORDER BY sectionorder.displayorder ASC ";
				}
				else
				{
					$this->sortby =	" ORDER BY CASE WHEN sectionorder.displayorder > 0 THEN sectionorder.displayorder ELSE 9999999 END ASC,
					 node.publishdate DESC";
				}
			}
			//We need a nodeid for the displayorder below
			if ($this->filter_node_exact AND !$this->filter_node )
			{
				$this->filter_node = $this->filter_node_exact;
			}


			//enforce the max_records limits
			if ($this->max_records)
			{
				$this->paginate = true;

				if (!$this->start)
				{
					$this->start = 0;
				}
				$this->quantity = $this->max_records;
			}

			$sql = "SELECT " . ($this->count_records ? 'SQL_CALC_FOUND_ROWS': '') .
					" node.nodeid AS itemid,
					(node.nodeleft = 1) AS isroot, node.nodeid, node.contenttypeid, node.contentid, node.url, node.parentnode, node.styleid, node.userid,
					node.layoutid, node.publishdate, node.setpublish, node.issection, parent.permissionsfrom as parentpermissions,
					node.permissionsfrom, node.publicpreview, node.showtitle, node.showuser, node.showpreviewonly, node.showall,
					node.showupdated, node.showviewcount, node.showpublishdate, node.settingsforboth, node.includechildren, node.editshowchildren,
					node.shownav, node.hidden, node.nosearch, node.nodeleft,
					info.description, info.title, info.html_title, info.viewcount, info.creationdate, info.workflowdate,
					info.workflowstatus, info.workflowcheckedout, info.workflowlevelid, info.associatedthreadid,
					user.username, sectionorder.displayorder, thread.replycount, parentinfo.title AS parenttitle
					$hook_query_fields
				FROM " . TABLE_PREFIX . "cms_node AS node
				INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid
				$hook_query_join
				LEFT JOIN " . TABLE_PREFIX . "user AS user ON user.userid = node.userid
				LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.threadid = info.associatedthreadid
				LEFT JOIN " . TABLE_PREFIX . "cms_sectionorder AS sectionorder ON sectionorder.sectionid = " . intval($this->filter_node) ."
					AND sectionorder.nodeid = node.nodeid
				LEFT JOIN " . TABLE_PREFIX . "cms_node AS parent ON parent.nodeid = node.parentnode
				LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS parentinfo ON parentinfo.nodeid = parent.nodeid
				"
				. (intval($this->filter_node) ? " INNER JOIN " . TABLE_PREFIX . "cms_node AS rootnode
					ON rootnode.nodeid = " . intval($this->filter_node) .
					" AND (node.nodeleft >= rootnode.nodeleft AND node.nodeleft <= rootnode.noderight) AND node.nodeleft != rootnode.nodeleft " : '')
				  . $extrasql .
				" AND node.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") .
				" AND node.new != 1 " .
				($this->itemid ? "AND node.nodeid IN (" . implode(',', $this->itemid) . ") " : '') .
				($this->filter_contenttype ? "AND node.contenttypeid = " . intval($this->filter_contenttype) . " " : '') .
				($this->filter_contentid ? "AND node.contentid = " . intval($this->contentid) . " ": '') .
				($this->filter_nosections ? "AND node.issection != '1' " : '') .
				($this->filter_onlysections ? "AND node.issection = '1' " : '') .
				($this->filter_ignorepermissions ? '' : " AND " . $permissionstring) .
				($this->filter_userid ? "AND node.userid = " . intval($this->filter_userid) . " " : '') .
				($this->visible_only ? "AND node.hidden = 0 " : '') .
				($this->filter_published ? "AND node.setpublish = '1' AND node.publishdate <= " . intval(TIMENOW) . " " : '') .
				($this->filter_unpublished ? "AND node.setpublish = '0' OR node.publishdate > " . intval(TIMENOW) . " " : '') . " " .
				$this->getFilterNotContentTypeSql() .
				 (intval($this->filter_node_exact) ? "AND (node.parentnode = " . $this->filter_node_exact . " OR sectionorder.displayorder > 0 )": '')
				. (($this->orderby == 5) ? " AND sectionorder.displayorder > 0 " : '')
				. "
				$content_query_where
				$hook_query_where " . $this->sortby
			 .
				( ($this->paginate AND intval($this->quantity)) ?
					(" LIMIT " . intval($this->start) . ', ' . intval($this->quantity))  : '')	;

			return $sql;

		}
		else
		{
			return parent::getLoadQuery();
		}

	}
Пример #17
0
function do_get_cms_section()
{
    global $vbulletin, $db;
    $vbulletin->input->clean_array_gpc('r', array('sectionid' => TYPE_UINT, 'page' => TYPE_UINT, 'perpage' => TYPE_UINT));
    $sectionid = $vbulletin->GPC['sectionid'];
    if (!$vbulletin->GPC_exists['sectionid']) {
        $sectionid = 1;
    }
    $sectionid = intval($sectionid);
    $page = 1;
    if ($vbulletin->GPC['page']) {
        $page = $vbulletin->GPC['page'];
    }
    $perpage = 10;
    if ($vbulletin->GPC['perpage']) {
        $perpage = $vbulletin->GPC['perpage'];
    }
    if ($perpage > 50 || $perpage < 5) {
        $perpage = 10;
    }
    if ($page < 1) {
        $page = 1;
    }
    $limitsql = 'LIMIT ' . ($page - 1) * $perpage . ', ' . $perpage;
    if (!isset(vB::$vbulletin->userinfo['permissions']['cms'])) {
        vBCMS_Permissions::getUserPerms();
    }
    $config = $vbulletin->db->query_first("\n\tSELECT config1.value AS priority, config2.value AS contentfrom, nodeinfo.title AS section_title\n\tFROM " . TABLE_PREFIX . "cms_node AS node\n\tLEFT JOIN " . TABLE_PREFIX . "cms_nodeconfig AS config1 ON config1.nodeid = node.nodeid AND config1.name = 'section_priority'\n\tLEFT JOIN " . TABLE_PREFIX . "cms_nodeconfig AS config2 ON config2.nodeid = node.nodeid AND config2.name = 'contentfrom'\n\tLEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS nodeinfo ON nodeinfo.nodeid = node.nodeid\n\tWHERE node.nodeid = {$sectionid}\n\tGROUP BY node.nodeid\n    ");
    $sortby = 3;
    $exact = false;
    $section_title = 'News';
    if ($config) {
        if (isset($config['priority'])) {
            $sortby = intval($config['priority']);
        }
        if (isset($config['contentfrom'])) {
            if (intval($config['contentfrom']) != 2) {
                $exact = true;
            }
        }
        if (isset($config['section_title'])) {
            $section_title = $config['section_title'];
        }
    }
    $extrasql = $orderby = '';
    if ($sortby == 3) {
        $extrasql = " INNER JOIN (SELECT parentnode, MAX(lastupdated) AS lastupdated\n\t    FROM " . TABLE_PREFIX . "cms_node  AS node WHERE contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") . " AND\t" . vBCMS_Permissions::getPermissionString() . " GROUP BY parentnode ) AS ordering ON ordering.parentnode = node.parentnode\n\t    AND node.lastupdated = ordering.lastupdated WHERE 1=1";
        $orderby = " ORDER BY node.setpublish DESC, node.publishdate DESC ";
    } else {
        if ($sortby == 2) {
            $orderby = " ORDER BY node.publishdate DESC ";
        } else {
            if ($sortby == 4) {
                $orderby = " ORDER BY info.title ASC ";
            } else {
                if ($sortby == 5) {
                    $orderby = " ORDER BY sectionorder.displayorder ASC ";
                } else {
                    $orderby = " ORDER BY CASE WHEN sectionorder.displayorder > 0 THEN sectionorder.displayorder ELSE 9999999 END ASC,\n\t    node.publishdate DESC";
                }
            }
        }
    }
    $sql = "\n\tSELECT SQL_CALC_FOUND_ROWS\n\t    node.nodeid AS itemid,\n\t    (node.nodeleft = 1) AS isroot, node.nodeid, node.contenttypeid, node.contentid, node.url, node.parentnode, node.styleid, node.userid,\n\t    node.layoutid, node.publishdate, node.setpublish, node.issection, parent.permissionsfrom as parentpermissions,\n\t    node.permissionsfrom, node.publicpreview, node.showtitle, node.showuser, node.showpreviewonly, node.showall,\n\t    node.showupdated, node.showviewcount, node.showpublishdate, node.settingsforboth, node.includechildren, node.editshowchildren,\n\t    node.shownav, node.hidden, node.nosearch, node.nodeleft,\n\t    info.description, info.title, info.html_title, info.viewcount, info.creationdate, info.workflowdate,\n\t    info.workflowstatus, info.workflowcheckedout, info.workflowlevelid, info.associatedthreadid,\n\t    user.username, sectionorder.displayorder, thread.replycount, parentinfo.title AS parenttitle\n\tFROM " . TABLE_PREFIX . "cms_node AS node\n\tINNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid\n\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON user.userid = node.userid\n\tLEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.threadid = info.associatedthreadid\n\tLEFT JOIN " . TABLE_PREFIX . "cms_sectionorder AS sectionorder ON sectionorder.sectionid = {$sectionid}\n\tAND sectionorder.nodeid = node.nodeid\n\tLEFT JOIN " . TABLE_PREFIX . "cms_node AS parent ON parent.nodeid = node.parentnode\n\tLEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS parentinfo ON parentinfo.nodeid = parent.nodeid\n\t" . ($sectionid ? " INNER JOIN " . TABLE_PREFIX . "cms_node AS rootnode\n\t\t\t\t\tON rootnode.nodeid = {$sectionid}\n\t\t\t\t\tAND (node.nodeleft >= rootnode.nodeleft AND node.nodeleft <= rootnode.noderight) AND node.nodeleft != rootnode.nodeleft " : '') . $extrasql . " AND node.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") . " AND node.new != 1 " . " AND ( (" . vBCMS_Permissions::getPermissionString() . ") OR (node.setpublish AND node.publishdate <" . TIMENOW . " AND node.publicpreview > 0)) " . ($exact ? "AND (node.parentnode = " . intval($sectionid) . " OR sectionorder.displayorder > 0 )" : '') . ($sortby == 5 ? " AND sectionorder.displayorder > 0 " : '') . "\n\t\t\t\t{$orderby}\n\t\t\t\t{$limitsql}\n    ";
    $articles = array();
    $items = $vbulletin->db->query_read_slave($sql);
    $total = $vbulletin->db->found_rows();
    while ($item = $vbulletin->db->fetch_array($items)) {
        $article = new vBCms_Item_Content_Article($item['nodeid'], vBCms_Item_Content::INFO_CONTENT);
        $tmp = array('articleid' => $article->getNodeId(), 'title' => prepare_utf8_string($article->getTitle()), 'pubdate' => prepare_utf8_string(vbdate('M j, Y g:i A T', $article->getPublishDate())), 'preview' => prepare_utf8_string(preview_chop(str_replace(array("\n", "\r", "\t"), array('', '', ''), strip_tags($article->getPreviewText(false))), FR_PREVIEW_LEN)));
        $thread_id = $article->getThreadId();
        if ($thread_id) {
            $tmp['threadid'] = $thread_id;
        }
        $previewimage = $article->getPreviewImage();
        if ($previewimage) {
            if (strpos($previewimage, 'http') === false) {
                $previewimage = $vbulletin->options['bburl'] . '/' . $previewimage;
            }
            $tmp['image'] = $vbulletin->options['bburl'] . "/forumrunner/image.php?url={$previewimage}&w=160&h=160";
        }
        $articles[] = $tmp;
    }
    $out = array('total_articles' => $total, 'articles' => $articles, 'section_title' => prepare_utf8_string(strip_tags($section_title)));
    return $out;
}
Пример #18
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();

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

		// Create view
		$view = new vBCms_View_Widget($config['template_name']);
		$this->sectionid = $this->content->getContentTypeId() == vb_Types::instance()->getContentTypeID("vBCms_Section") ?
			$this->content->getNodeId() : $this->content->getParentId();

		try
		{
			$categoryid = max(1, intval(vB_Router::getSegment('value')));
		}
		catch (vB_Exception_Router $e)
		{
			$categoryid = 0;
		}

		$nodes = vBCms_ContentManager::getAllCategories();
		ksort($nodes);

		foreach ($nodes as $nodeid => $record)
		{
			$route = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL();
			$nodes[$nodeid]['view_url'] = $route;

		}
		// Modify $nodes to add myself var (currently selected category)


		$view->widget_title = $this->widget->getTitle();
		$view->nodes = $nodes;
		return $view;
	}