Пример #1
0
 /**
  * Fetches any set reroute message from the current route.
  *
  * @return string
  */
 public static function getRerouteMessage()
 {
     if (isset(self::$current_route)) {
         return self::$current_route->getRerouteMessage();
     }
     return '';
 }
Пример #2
0
 public function fetchTemplate($templatename, $activity, $skipgroup = false, $fetchphrase = false)
 {
     $postinfo =& $this->content['cms_post'][$activity['contentid']];
     $nodeinfo =& $this->content['cms_node'][$postinfo['nodeid']];
     $articleinfo =& $this->content['cms_article'][$nodeinfo['contentid']];
     $activity['postdate'] = vbdate(vB::$vbulletin->options['dateformat'], $activity['dateline'], true);
     $activity['posttime'] = vbdate(vB::$vbulletin->options['timeformat'], $activity['dateline']);
     $preview = strip_quotes($postinfo['pagetext']);
     $articleinfo['preview'] = htmlspecialchars_uni(fetch_censored_text(fetch_trimmed_title(strip_bbcode($preview, false, true, true, true), vb::$vbulletin->options['as_snippet'])));
     $articleinfo['fullurl'] = vB_Route::create('vBCms_Route_Content', $nodeinfo['nodeid'] . ($nodeinfo['url'] == '' ? '' : '-' . $nodeinfo['url']))->getCurrentURL();
     $nodeinfo['parenturl'] = $this->fetchParentUrl($nodeinfo['parentnode']);
     $nodeinfo['parenttitle'] = $this->fetchParentTitle($nodeinfo['parentnode']);
     $userinfo = $this->fetchUser($activity['userid'], $postinfo['username']);
     if ($fetchphrase) {
         if ($userinfo['userid']) {
             $phrase = construct_phrase($this->vbphrase['x_commented_on_an_article_y_in_z'], fetch_seo_url('member', $userinfo), $userinfo['username'], $articleinfo['fullurl'], $nodeinfo['title'], $nodeinfo['parenturl'], $nodeinfo['parenttitle']);
         } else {
             $phrase = construct_phrase($this->vbphrase['guest_x_commented_on_an_article_y_in_z'], $userinfo['username'], $articleinfo['fullurl'], $nodeinfo['title'], $nodeinfo['parenturl'], $nodeinfo['parenttitle']);
         }
         return array('phrase' => $phrase, 'userinfo' => $userinfo, 'activity' => $activity);
     } else {
         $templater = vB_Template::create($templatename);
         $templater->register('userinfo', $userinfo);
         $templater->register('postinfo', $postinfo);
         $templater->register('activity', $activity);
         $templater->register('nodeinfo', $nodeinfo);
         $templater->register('articleinfo', $articleinfo);
         return $templater->render();
     }
 }
Пример #3
0
 protected function fetchParentUrl($nodeid)
 {
     if (!$this->content['cms_section']) {
         $sections = vBCms_ContentManager::getSections();
         foreach ($sections as $key => $section) {
             $this->content['cms_section'][$section['nodeid']] = $section;
         }
     }
     return vB_Route::create('vBCms_Route_Content', $nodeid . ($this->content['cms_section'][$nodeid]['url'] == '' ? '' : '-' . $this->content['cms_section'][$nodeid]['url']))->getCurrentURL();
 }
Пример #4
0
 /**
  * Sets a reroute message.
  *
  * @param string $message
  */
 public function setRerouteMessage($message)
 {
     self::$_reroute_message = $message;
 }
Пример #5
0
    $templater->register('pagenav', $pagenav);
    $templater->register('prev', $prev);
    $templater->register('responsebits', $responsebits);
    $templater->register('status', $status);
    $templater->register('trackbackbits', $trackbackbits);
    $templater->register('url', $url);
    $templater->register('vBeditTemplate', $vBeditTemplate);
    $templater->register('vbulletin', $vbulletin);
    $templater->register('votechecked', $votechecked);
    $templater->register('voteselected', $voteselected);
    //See if we want to display the authorization to escalate a blog post to
    // an article
    if (count(vB::$vbulletin->userinfo['permissions']['cms']['cancreate'])) {
        $templater->register('promote_sectionid', vB::$vbulletin->userinfo['permissions']['cms']['canpublish'][0]);
        $templater->register('articletypeid', vB_Types::instance()->getContentTypeID('vBCms_Article'));
        $promote_url = vB_Route::create('vBCms_Route_Content', '1/addcontent/')->getCurrentURL();
        $promote_url .= (strrpos($promote_url, '?') ? '&' : '?') . 'contenttypeid=' . vB_Types::instance()->getContentTypeID('vBCms_Article') . "&blogid=" . $blog['blogid'] . '&parentid=1';
        $templater->register('promote_url', $promote_url);
    }
    $templater->register('vbulletin', $vbulletin);
    $content = $templater->render();
}
// #######################################################################
if ($_REQUEST['do'] == 'list') {
    $vbulletin->input->clean_array_gpc('r', array('pagenumber' => TYPE_UINT, 'perpage' => TYPE_UINT, 'month' => TYPE_UINT, 'year' => TYPE_UINT, 'day' => TYPE_UINT, 'blogtype' => TYPE_NOHTML, 'commenttype' => TYPE_NOHTML, 'type' => TYPE_STR, 'blogcategoryid' => TYPE_INT, 'userid' => TYPE_UINT, 'username' => TYPE_NOHTML, 'tag' => TYPE_NOHTML, 'span' => TYPE_UINT, 'featured' => TYPE_STR));
    require_once DIR . '/includes/class_bbcode_blog.php';
    if ($vbulletin->GPC['username']) {
        $user = $db->query_first_slave("SELECT userid FROM " . TABLE_PREFIX . "user WHERE username = '******'username']) . "'");
        $vbulletin->GPC['userid'] = $user['userid'];
    }
    if ($vbulletin->GPC['userid']) {
Пример #6
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;
		include_once DIR . '/vb/search/searchtools.php';
		include_once DIR . '/includes/functions_user.php';

		if (!strlen($template_name))
		{
			$template_name = strtolower($this->package) . '_searchresult_' .  strtolower($this->class);
		}
		$view = new vB_View($template_name);
		$view->title = $this->record['title'];
		$view->html_title =  $this->record['html_title'];
		$view->categories = $this->record['categories'];
		$view->published = $this->record['publishdate'] >= TIMENOW ?
		 true : false ;
		$view->publishdate = $this->record['publishdate'];
		$view->previewtext = $this->record['previewtext'];
		$view->pagetext = $this->record['pagetext'];
		$view->parent_html_title = $this->record['parent_html_title'];
		$view->dateformat = $vbulletin->options['dateformat'];
		$view->parenttitle = $this->record['parenttitle'];
		$view->timeformat = $vbulletin->options['default_timeformat'];
		$view->parentnode = $this->record['parentnode'];
		$view->username = $this->record['username'];
		$view->user = array(
			'username' => $this->record['username'],
			'userid' => $this->record['userid']);
		$view->page_url = vB_Route::create('vBCms_Route_Content', $this->record['nodeid'])->getCurrentURL();

		if (vB::$vbulletin->options['avatarenabled'])
		{
			$view->avatar = fetch_avatar_url($this->record['userid']);
		}

		//When we can we'll return the view, but right now the calling objects
		//want strings.

		// Create the standard vB templater
		$templater = new vB_Templater_vB();

		// Register the templater to be used for XHTML
		vB_View::registerTemplater(vB_View::OT_XHTML, $templater);
		return $view->render();

	}
Пример #7
0
	/**
	 * Populates a view with the expected info from a content item.
	 *
	 * @param vB_View $view
	 * @param int $viewtype
	 */
	protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true)
	{
		global $show;
		$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC);
		$this->content->requireInfo(vBCms_Item_Content::INFO_CONTENT);
		$this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG);
		$this->content->requireInfo(vBCms_Item_Content::INFO_NODE);
		$this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS);

		if ($_REQUEST['goto'] == 'newcomment')
		{
			require_once DIR . '/includes/functions_bigthree.php' ;

			$record = vB::$vbulletin->db->query_first("SELECT associatedthreadid
				FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId());
			$threadid = $record['associatedthreadid'];
			$threadinfo = verify_id('thread', $threadid, 1, 1);

			if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid'])
			{
				vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400));
			}
			else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit'])
			{
				vB::$vbulletin->userinfo['lastvisit'] = $tview;
			}

			$coventry = fetch_coventry('string');
			$posts = vB::$vbulletin->db->query_first("
				SELECT MIN(postid) AS postid
				FROM " . TABLE_PREFIX . "post
				WHERE threadid = $threadinfo[threadid]
					AND visible = 1
					AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . "
					". ($coventry ? "AND userid NOT IN ($coventry)" : "") . "
				LIMIT 1
			");

			$target_url = vB_Router::getURL();
			$join_char = strpos($target_url,'?') ? '&' : '?';
			if ($posts['postid'])
			{
				exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]");
			}
			else
			{
				exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]");
			}
		}
		if ($_REQUEST['commentid'])
		{
			vB::$vbulletin->input->clean_array_gpc('r', array(
				'commentid' => vB_Input::TYPE_INT,
			));
			$postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1);
			$record = vB::$vbulletin->db->query_first("SELECT associatedthreadid
				FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId());
			$threadid = $record['associatedthreadid'];

			// if comment id and node id do not match, we ignore commentid
			if ($postinfo['threadid'] == $threadid)
			{
				$getpagenum = vB::$vbulletin->db->query_first("
					SELECT COUNT(*) AS posts
					FROM " . TABLE_PREFIX . "post AS post
					WHERE threadid = $threadid AND visible = 1
					AND dateline <= $postinfo[dateline]
				");
				$_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20);
			}
		}

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

		($hook = vBulletinHook::fetch_hook('vbcms_article_populate_start')) ? eval($hook) : false;

		//Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply
		// the settings to the current page, and there are the six "show" variables.

		if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit())
		{
			$dm = $this->content->getDM();
			$dm->delete();
			$this->cleanContentCache();

			// Create route to redirect the user to
			$route = new vBCms_Route_Content();
			$route->node = $this->content->getParentId();
			$_REQUEST['do'] = '';
			throw (new vB_Exception_Reroute($route));
		}

		//When we come from the link to upgrade a blog post, blog, or forum post, the
		// router puts us here.
		$settings_for = $this->content->getSettingsForboth();
		$showfor_this = (((self::VIEW_PAGE == $viewtype)
			AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype)
			AND ($settings_for == 2))) ? 0 : 1;

		$view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1;
		$view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1;
		$view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1;
		$view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1;
		$view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1;
		$view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1;
		$view->lastupdated = $this->content->getLastUpdated();
		$showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1;

		parent::populateViewContent($view, $viewtype);

		$segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view');
		$view->page_url =  vBCms_Route_Content::getURL($segments);

		if ($this->editing)
		{
			$view->pagetext = $this->content->getPageText();
		}
		else
		{
			$rendered = $this->content->getRendered($this->data_saved);
			$view->pagetext = $rendered['pages'][$this->parameters['page']];

			if ($this->content->canDownload())
			{
				$view->attachments = $rendered['attachments'];
				$view->showattachments = empty($rendered['viewinfo']) ? 0 : 1 ;


				if (!empty($rendered['viewinfo']))
				{
					foreach ($rendered['viewinfo'] as $key => $viewbit)
					{
						$view->$key = $viewbit;
					}
				}
			}

			$view->parenttitle = $this->content->getParentTitle();

			$view->showattachments = empty($view->attachments) ? 0 : 1 ;

			if (!empty($viewinfo))
			{
				foreach ($viewinfo as $key => $viewbit)
				{
					$view->$key = $viewbit;
				}
			}

			$view->pagelist = $rendered['pagelist'];
			$view->nodesegment = $this->content->getUrlSegment();
			$view->current_page = $this->parameters['page'];
			if ($this->content->canDownload())
			{
				$show['lightbox'] = (vB::$vbulletin->options['lightboxenabled'] AND vB::$vbulletin->options['usepopups']);
			}
		}

		// Only break pages for the page view
		if ((self::VIEW_PAGE == $viewtype) OR (self::VIEW_PREVIEW == $viewtype))
		{
			if (self::VIEW_PAGE == $viewtype)
			{
				if ($increment_count)
				{
					//update the view count
					vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX .
							"cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId());
				}

				//tagging code
				require_once DIR . '/includes/class_taggablecontent.php';
				$taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(),
					$this->content->getContentId(), $this->content);
				$view->tags = $taggable->fetch_rendered_tag_list();
				$view->tag_count = $taggable->fetch_existing_tag_count();
				$view->showtags = vB::$vbulletin->options['threadtagging'];

				// promoted threadid
				if ($promoted_threadid = $this->content->getThreadId())
				{
					if ($promoted_threadid = verify_id('thread', $promoted_threadid, false))
					{
						// get threadinfo
						$threadinfo = fetch_threadinfo($promoted_threadid);
						$forumperms = fetch_permissions($threadinfo['forumid']);
						$view->threadinfo = $threadinfo;
						// check permissions
						if ($threadinfo['visible'] != 1)
						{
							$promoted_threadid = false;
						}
						else if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canview'])
							OR !($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewthreads'])
							OR (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewothers'])
								AND ($threadinfo['postuserid'] != vB::$vbulletin->userinfo['userid'] OR vB::$vbulletin->userinfo['userid'] == 0)
							))
						{
							$promoted_threadid = false;
						}
						else
						{
							// check forum password
							$foruminfo = fetch_foruminfo($threadinfo['forumid']);

							if ($foruminfo['password'] AND !verify_forum_password($foruminfo['forumid'], $foruminfo['password'], false))
							{
								$promoted_threadid = false;
							}
						}

						$view->promoted_threadid = $promoted_threadid;
					}
				}

				// get pagelist for navigation
				$view->postitle = $this->content->getPostTitle();
				$view->poststarter = $this->content->getPostStarter();
				$view->postauthor = $this->content->getPostAuthor();
				$view->postid = ($this->content->getPostId());
				$view->threadid = $this->content->getThreadId();
				$view->blogpostid = ($this->content->getBlogPostId());
				$view->post_started = ($this->content->getPostStarted());
				$view->post_posted = ($this->content->getPostPosted());
				$view->promoted_blogid = $this->content->getBlogId();

				//make links to original post and/or blog if appropriate
				if ($view->promoted_blogid)
				{
					$view->blog_url = fetch_seo_url('blog',
						array('userid' => $this->content->getPostStarter(),
						'blog_title' => $this->content->getPostTitle()));
				}
				else if ($view->threadid)
				{
					$threadinfo = vB::$vbulletin->db->query_first("SELECT threadid, title FROM " .
						TABLE_PREFIX . "thread where threadid = " . $view->threadid);

					if ($threadinfo)
					{
						$post_url = fetch_seo_url('thread', $threadinfo);
						$post_url .= (strpos($post_url, '?' ) ? '&amp;p=' :  '?p=') . $view->postid .
							'#post' . $view->postid;
						$view->post_url = $post_url;
					}
				}

				$view->comment_count = $this->content->getReplyCount();
				$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
				$view->newcomment_url = $view->page_url . "#new_comment";
				$view->authorid = ($this->content->getUserId());
				$view->authorname = ($this->content->getUsername());
				$view->viewcount = ($this->content->getViewCount());
				$view->replycount = ($this->content->getReplyCount());
				$view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0;
				$view->parentid = $this->content->getParentId();

				// facebook options
				if (is_facebookenabled())
				{
					// display the like button for this article?
					$view->fblikebutton = construct_fblikebutton();
				}

				//check to see if there is an associated thread.
				if ($associatedthreadid = $this->content->getAssociatedThreadId()
					and $this->content->getComments_Enabled())
				{
					$comment_block = new vBCms_Comments();
					$view->comment_block = $comment_block->getPageView($this->content->getNodeId(),
						$view->page_url);
				}
			}
			else if (self::VIEW_PREVIEW == $viewtype)
			{
				if ($showpreviewonly)
				{
					$view->previewtext = $this->content->getPreviewText();
					$view->preview_chopped = 1;
				}
				else
				{
					$view->previewtext = $view->pagetext;

					if (count($view->pagelist) > 1)
					{
						$view->preview_chopped = 1;
					}
				}

				$segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit');
				$view->edit_url =  vBCms_Route_Content::getURL($segments) ;
				$view->read_more_phrase = new vB_Phrase('vbcms', 'read_more');
				$view->parenttitle = $this->content->getParentTitle();
				$view->pagetext = $pagetext;
				$view->setpublish = $view->published = $this->content->getPublished();
				$view->publishdate = $this->content->getPublishDateLocal();
				$view->promoted_blogid = $this->content->getBlogId();
				$view->comment_count = $this->content->getReplyCount();
				$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
				$view->newcomment_url = $view->page_url . "#new_comment";
				$view->authorid = ($this->content->getUserId());
				$view->authorname = ($this->content->getUsername());
				$view->viewcount = ($this->content->getViewCount());
				$view->replycount = ($this->content->getReplyCount());
				$view->postid = ($this->content->getPostId());
				$view->blogpostid = $this->content->getBlogPostId();
				$view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0;
				$view->parentid = $this->content->getParentId();
				$view->post_started = $this->content->getPostStarted();
				$view->post_posted = $this->content->getPostPosted();


				//We need to check rights. If this user doesn't have download rights we hide the image.
				if ($this->content->canDownload())
				{
					if ($view->previewimage= $this->content->getPreviewImage())
					{
						$view->imagewidth= $this->content->getImageWidth();
						$view->imageheight= $this->content->getImageHeight();
					}

					if ($view->previewvideo= $this->content->getPreviewVideo())
					{
						$view->haspreviewvideo = true;
					}
				}
				else
				{
					$view->previewimage = false;
					$view->previewvideo = false;
				}

				if (($associatedthreadid = $this->content->getAssociatedThreadId())
					AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0)
				{
					$view->echo_comments = 1;
					$view->comment_count = $this->content->getReplyCount();
				}
				else
				{
					$view->echo_comments = 0;
					$view->comment_count = 0;
				}
			}
		}

		//If this was promoted from a blog or post, we need to verify the permissions.
		if (intval($view->blogpostid))
		{
			$view->can_view_post =
				(!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) ?
				0 : 1 ;
		}
		else if (intval($view->postid))
		{
			$user = new vB_Legacy_CurrentUser();
			if ($post = vB_Legacy_Post::create_from_id($view->postid))
			{
				$view->can_view_post = $post->can_view($user) ? 1 : 0;
			}
		}

		$view->poststarter = array('userid' => $this->content->getPostStarter(),
			'username' => $this->content->getPostAuthor());
		$view->setpublish = $this->content->getSetPublish();
		$view->publishdate = $this->content->getPublishDate();
		$view->published = $this->content->getPublished() ?
			1 : 0;

		$view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate());
		$view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() );

		//Get links to the author, section, and categories search pages
		//categories- this comes as an array
		$view->categories = $this->content->getCategories();
		$route_info = 'author/' . $this->content->getUserid() .
			($this->content->getUsername() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : '');
		$view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL();

		// prepare the member action drop-down menu
		$view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId()));

		//Section
		$route_info = 'section/' .$this->content->getParentId() .
			($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : '');
		$view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL();
		//and the content
		$route_info = $this->content->getParentId() .
			($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : '');
		$view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL();

		$view->html_title = $this->content->getHtmlTitle();
		$view->title = $this->content->getTitle();
		$view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article");
		$view->dateformat = vB::$vbulletin->options['dateformat'];
		$view->showrating = $this->content->getShowRating();
		($hook = vBulletinHook::fetch_hook('vbcms_article_populate_end')) ? eval($hook) : false;
		$this->content->cacheNow();
		return $view;
	}
Пример #8
0
	/**
	 * Populates a view with the expected info from a content item.
	 *
	 * @param vB_View $view
	 * @param int $viewtype
	 */
	protected function populateViewContent(vB_View $view, $viewtype)
	{
		global $vbphrase;
		global $show;

		if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode')
		{
			$this->checkSaveData($view);
		}
		//Make sure the proper data is loaded.
		$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC  &
			vBCms_Item_Content::INFO_DEPTH & vBCms_Item_Content::INFO_CONFIG & vBCms_Item_Content::INFO_NODE &
			vBCms_Item_Content::INFO_NAVIGATION & vBCms_Item_Content::INFO_PARENTS);
		$this->content->isValid();

		($hook = vBulletinHook::fetch_hook('vbcms_section_populate_start')) ? eval($hook) : false;

		//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 $vbphrase['cannot_delete_with_subnodes'];
			}
			$dm = $this->content->getDM();
			$dm->delete();

			$events = $this->getCleanCacheEvents();
			vB_Cache::instance()->event($events);
			vB_Cache::instance()->cleanNow();
			return $vbphrase['section_deleted'];
		}

		//We don't want the child nodes trying to save data.
		$_REQUEST['do'] = 'view';

		$view->nodeid = $this->content->getNodeId();
		$this->config = $this->getConfig();
		$view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Section");

		$route_info = 'section/' .	$this->content->getURLSegment();
		$view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL();
		$view->showall = $this->content->getShowall();

		parent::populateViewContent($view, $viewtype);
		$view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDateLocal());
		$view->publishtimelocal = date(vB::$vbulletin->options['timeformat'], $this->content->getPublishDateLocal());
		$view->setpublish = $this->content->getSetPublish();
		$view->published = ($this->content->getSetPublish() AND ($this->content->getPublishDate() < TIMENOW)) ?
			1 : 0;

		if (self::VIEW_PAGE == $viewtype)
		{
			$view->unpublished = $this->parameters['unpublished'];

			if (!$this->content->canView())
			{
				return '';
			}

			$page_nav = false;
			$aggregate =  $this->aggregateContent($viewtype, $page_nav);
			$results = $aggregate['results'];
			$view_content = new vB_View_Content('vbcms_content_section_type' . $this->config['content_layout']);
			$view->result_count = count($results);
			$view_content->class = 'Section';
			$view_content->package = 'vBCms';
			$view->can_create = $this->content->canCreate();
			$view->can_publish = $this->content->canPublish();

			if ($results AND sizeof($results))
			{
				$contents = array();
				$i = 1;
				foreach ($results as $id => $result)
				{
					$contents[$i++] = $result;
				}

				$view_content->result_count = count($results);
				$view_content->contents = $contents;
				$show['lightbox'] = (vB::$vbulletin->options['lightboxenabled'] AND vB::$vbulletin->options['usepopups']);

				$view->content = $view_content;

		 		$page_info = $aggregate['aggregate']->getCounts();
				if ($this->config['pagination_links'])
				{
					if ($this->config['simple_paging'])
					{
						// from $rawcount we know how many more we definitely have,
						// so we construct from that.
						$route = vB_Route::create('vBCms_Route_Content');
						$route->node = $this->content->getUrlSegment();
						$pageurl = $route->getCurrentURL();
						$view->pagenav = construct_window_page_nav (
						$this->current_page,
						6,
						intval($this->config['items_perhomepage']),
						$page_info['total'],
						$pageurl);
					}
					else if (intval($page_info['total']))
					{
						$route = vB_Route::create('vBCms_Route_Content');
						$route->node = $this->content->getUrlSegment();
						$pageurl = $route->getCurrentURL();
						$view->pagenav = construct_page_nav($this->current_page, intval($this->config['items_perhomepage']), $page_info['total'], $pageurl);
					}
				}
			}
			else
			{
				$view_content->result_count = 0;
				$view->no_results_phrase = new vB_Phrase('vbcms', 'no_content_in_section');
				$title = $this->content->getTitle();
				$view->title = $view_content->title = $this->content->getTitle();
			}
		}
		$this->content->cacheNow();
		($hook = vBulletinHook::fetch_hook('vbcms_section_populate_end')) ? eval($hook) : false;
	}
Пример #9
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;
	}
Пример #10
0
	public static function listNodes($page, $per_page = 10)
	{
		global $vbphrase;
		global $vbulletin;

		$nodes = self::getContent($page, $per_page);
		$filtersection = intval($vbulletin->GPC['filter_section']);

		//We may or may not have started at page 1

		$total_records = (($page - 1) * $per_page) + sizeof($nodes);

		$nodes = array_slice($nodes, 0, $per_page, true);
		if ($record_count = count($nodes))
		{
		$section = $vbulletin->db->query_first($sql = "SELECT info.title FROM " . TABLE_PREFIX . "cms_node AS node INNER JOIN
			" . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid WHERE " .
			( $vbulletin->GPC_exists['sectionid'] ?
				" node.nodeid = " . $vbulletin->GPC['sectionid'] :
					($vbulletin->GPC_exists['filter_section'] ?
						" node.nodeid = " . $filtersection :
						" node.nodeid IS NULL" )));
		$i = 1;
		}
		$result = print_form_header('cms_content_admin', '', false, true, 'cms_data', '100%', '_self',
				true, 'post', 0, false);
		$result .= "<input type=\"hidden\" id=\"sectionid\" value=\"" .
			( $vbulletin->GPC_exists['sectionid'] ?
			" node.parentnode = " . $vbulletin->GPC['sectionid'] :
				($vbulletin->GPC_exists['filter_section'] ?
				" node.parentnode = " . $filtersection :
				" node.parentnode IS NULL" )) .
		"\" name=\"sectionid\"/>
		<input type=\"hidden\" name=\"sentfrom\" id=\"nodes\" value=\"nodes\"/>
		<input type=\"hidden\" name=\"id\" id=\"id\" value=\"0\"/>";

		$result .= "<div class=\"tcat nodeHeaders\" style=\"width: 100%;margin:auto;\">" . self::getNodeHeaders() . "</div><br />\n";
		$result .= "<tr class=\"tcat\">
				<td colspan=\"10\" align=\"" . vB_Template_Runtime::fetchStyleVar('left') . "\" class=\"feature_management_header\" style=\"padding:5px;\">

				"  . $vbphrase['you_are_managing'] . " " . $vbphrase['section'] . ": <span class=\"section_name\">" . $section['title'] .
				($vbulletin->GPC_exists['sectionid'] ? '' : '(' . $vbphrase['all_sections'] .')') . "</span>"
				.  "
				<input type=\"button\" onclick=\"showNodeWindow('filter_nodesection')\" value=\"" . $vbphrase['filter_by_section'] ."\">
				</td>
				</tr>";
		$result .= "<tr><td>
		<table class=\"tborder\" cellpadding=\"4\" border=\"0\" width=\"100%\" align=\"center\" style=\"font-size:11px\">\n";
		$bgclass = fetch_row_bgclass();
		if ($record_count = count($nodes))
		{
			$result .= "<tr align=\"center\" class=\"thead\">\n";
			$result .= "<td class=\"thead\">#</td>
			<td class=\"thead\">&nbsp;</td>
			<td align=\"" . vB_Template_Runtime::fetchStyleVar('left') . "" . vB_Template_Runtime::fetchStyleVar('left') . "\" width=\"33%\" class=\"thead\"><a href=\"cms_content_admin.php?do=sort&sentfrom=nodes&sortby=title\" target=\"_self\">" . $vbphrase['title'] . "</a></td>
			<td class=\"thead\"><a href=\"cms_content_admin.php?do=sort&sentfrom=nodes&sortby=class\" target=\"_self\">" . $vbphrase['content_type'] . "</a></td>
			<td class=\"thead\" width=\"60\"><a href=\"cms_content_admin.php?do=sort&sentfrom=nodes&sortby=publicpreview\" target=\"_self\">" . $vbphrase['public_preview'] . "</a></td>
			<td class=\"thead\"><a href=\"cms_content_admin.php?do=sort&sentfrom=nodes&sortby=setpublish\">" . $vbphrase['published'] . "</a></td>
			<td class=\"thead\">" . $vbphrase['order'] . "</td>
			<td class=\"thead\"><a href=\"cms_content_admin.php?do=sort&sentfrom=nodes&sortby=username\">" . $vbphrase['author'] . "</a></td>
			<td class=\"thead\" width=\"120\"><a href=\"cms_content_admin.php?do=sort&sentfrom=nodes&sortby=publishdate\">" . $vbphrase['date'] . "</a></td>
			<td class=\"thead\"><a href=\"cms_content_admin.php?do=sort&sentfrom=nodes&sortby=viewcount\">" . $vbphrase['viewcount'] . "</a></td>
			<td class=\"thead\"><a href=\"cms_content_admin.php?do=sort&sentfrom=nodes&sortby=replycount\">" . $vbphrase['comments'] . "</a></td>
			</tr>";
			self::getParentage($nodes, 4);

			vB_Router::setRelativePath('../');

			foreach($nodes as $node)
			{
				$content_url = vB_Route::create('vBCms_Route_Content', $node['nodeid'] . '/edit')->getCurrentURL();

				$bgclass = fetch_row_bgclass();
				$result .= "<tr align=\"center\">\n <input type=\"hidden\" name=\"ids[]\" value=\"" .
					$node['nodeid'] . "\" /> <td class=\"$bgclass\">" . $i++ . "</td>\n";
				$result .= "  <td class=\"$bgclass\"><input type=\"checkbox\" name=\"cb_" . $node['nodeid'] . '"/>' . "</td>\n";
				$result .= "  <td align=\"" . vB_Template_Runtime::fetchStyleVar('left') . "\" class=\"$bgclass\"><a href=\"" . $content_url . "\" target=\"_blank\" >" . self::stripScript($node['title']) 	. "</a></td>\n";
				$result .= "  <td class=\"$bgclass\">" . $vbphrase[strtolower($node['class'])] 	. "</td>\n";
				$result .= "  <td class=\"$bgclass\"><input type=checkbox name=\"cb_pp_" . $node['nodeid'] . '" ' .
					(0 == intval($node['publicpreview']) ? '' : 'checked="checked"') . " /></td>\n";;
				$result .= "  <td class=\"$bgclass\"><select name=\"state_" . $node['nodeid']. "\" id=\"state_" . $node['nodeid']. "\"
					onchange=\"setFormValue('do', 'saveonenodestate');
					setFormValue('nodeid', '" . $node['nodeid']. "');document.getElementById('cms_data').submit();\">" . self::getPublishedSelect(
						intval($node['setpublish']), $node['publishdate']) . "</select></td>\n";
				$result .= "  <td class=\"$bgclass\"><select name=\"displayorder_" . $node['nodeid'] .
					"\" onchange=\"setOrder(" . $node['nodeid'] . ", " . $node['parentid'] . ", this.value);\">\n " .
					self::getOrderSelect($node['displayorder'], $node['parentnode'])	. "</select>\n</td>\n";

				$result .= "  <td align=\"" . vB_Template_Runtime::fetchStyleVar('left') . "\" class=\"$bgclass\">" . $node['username'] . "</td>\n";
				$result .= "  <td class=\"$bgclass\">" . vbdate($vbulletin->options['dateformat'],
					$node['publishdate']). "</td>\n";
				$result .= "  <td class=\"$bgclass\">" . $node['viewcount'] . "</td>\n";
				$result .= "  <td class=\"$bgclass\">" . intval($node['replycount']) . "</td>\n";
				$result .= "</tr>\n";
			}


			//moving the lines below outside of if/else -ch
			//print_hidden_fields();
			//$result .= "</table></td></tr>";
			//$result .= self::getNav($per_page, $total_records, $page, $displayfor);

		}
		else
		{
			vB_Router::setRelativePath('../');
			$content_url = vB_Route::create('vBCms_Route_Content');

			$result .= "\n<tr><td>\n\n<div style=\"text-align:middle;font-size:16px;font-weight:bold;\" class=\"notFoundMessage\">"
					. $vbphrase['no_articles_in_this_section'] . " </div>\n\n</td></tr>\n";
		}
		print_hidden_fields();
		$result .= "</table></td></tr>\n";
		$result .= "</table>";
		$result .= self::getNav($per_page, $total_records, $page, 'filter_nodesection', 100, 'page',
			true, ('cms_content_admin.php' .
			($vbulletin->GPC_exists['sectionid'] ? '?sectionid=' . $vbulletin->GPC['sectionid'] : '')));
		global $echoform;
		$echoform = false;
		$result .= "</form>";
		return $result;
	}
Пример #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;
		include_once DIR . '/vb/search/searchtools.php';

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

		$template->register('title', $this->record['title'] );
		$template->register('html_title', $this->record['html_title'] );
		$page_url = vB_Route::create('vBCms_Route_Content', $this->record['nodeid'])->getCurrentURL();
		$template->register('page_url', $page_url);
		$join_char = strpos($page_url,'?') ? '&amp;' : '?';
		$template->register('newcomment_url', $page_url . $join_char . "goto=newcomment");
		$template->register('username', $this->record['username']);
		$template->register('description', $this->record['description']);
		$template->register('pagetext',
			vB_Search_Searchtools::getSummary($this->record['pagetext'], 100));

		$template->register('dateline', date($vbulletin->options['dateformat']. ' '
			. $vbulletin->options['default_timeformat'], $this->record['dateline']));
		$result = $template->render();
		return $result;

	}
Пример #12
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;
	}
Пример #13
0
	/**
	 *This generates the rss for new content.
	 *
	 * @param mixed $user : The user object
	 * @return xml for the feed
	 */
	private static function getNewContent($user)
	{
		global $vbulletin;
		require_once DIR . '/vb/search/core.php' ;
		require_once DIR . '/vb/search/criteria.php' ;
		require_once DIR . '/includes/functions_databuild.php' ;
		require_once DIR . '/includes/functions_misc.php' ;
		global $vbphrase;

		$vbulletin->input->clean_array_gpc('r', array(
			'sectionid' => TYPE_UINT));
		//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.
		fetch_phrase_group('vbcms');

		//First we need a criteria object
		if (! file_exists(DIR . '/packages/vbcms/search/searchcontroller/newcontentnode.php'))
		{
			return false;
		}
		$criteria = vB_Search_Core::get_instance()->create_criteria(vB_Search_Core::SEARCH_NEW);

		// sort by newest published first
		$criteria->set_sort('publishdate', 'desc');

		//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 forum id? If so, limit the query.
		if ($vbulletin->GPC_exists['id'] AND intval($vbulletin->GPC['id']))
		{
			$criteria->add_forumid_filter($vbulletin->GPC['id'], true);
		}

		//ungroup.
		$criteria->set_grouped(vB_Search_Core::GROUP_NO);

		//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 - ( 2 * 86400);
		}

		$criteria->add_newitem_filter($datelimit, null, null);

		$search_controller = new vBCms_Search_SearchController_NewContentNode;

		$results = vB_Search_Results::create_from_criteria($user, $criteria, $search_controller);

		$page = $results->get_page(1, $max_count, 1);
		$items= array();
		$headers = array(
			'title' => $vbulletin->options['hometitle'] ,
			'link' => $vbulletin->options['bburl'],
			'description' => construct_phrase($vbphrase['recent_content_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)
		);

		if (count($page))
		{
			$parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());

			foreach ($page as $result)
			{
				$record = $result->get_record();
				$summary = $parser->get_preview($record['pagetext'], 800);

				$items[] = array(
					'title' => $record['title'],
					'summary' => $summary,
					'link' => vB_Route::create('vBCms_Route_Content', $record['nodeid'] .
						(empty($record['url']) ? '' : '-' . $record['url'])  )->getCurrentURL(),
					'publishdate' => (intval($record['publishdate'])));
			}
		}
		return self::makeXml($headers, null, $items);
	}
Пример #14
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;
	}
Пример #15
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;
	}
Пример #16
0
{

	require_once DIR . '/includes/functions.php';
	// Get the custom forum priorities
	$sitemap = new vB_SiteMap_Cms($vbulletin);

	print_form_header('sitemap', 'savecms');
	print_table_header($vbphrase['cms_priority_manager']);
	print_description_row(construct_phrase($vbphrase['sitemap_cms_priority_desc_x'],
		vb_number_format($vbulletin->options['sitemap_priority'], 1)));

	$sections = $sitemap->get_priorities('cms');

		if (! empty($sections))
	{
		$route = vB_Route::create('vBCms_Route_Content');
		foreach($sections AS $sectionid => $section)
		{

			if ($section['priority'] === false)
			{
				$section['priority'] = 'default';
			}

			if (isset($section['nodeid']) AND intval($section['nodeid']))
			{
				$cell = array();
				$route->node = $section['nodeid'] . (empty($section['url']) ? '' : '-' . $section['url']);
				$pageurl = $route->getCurrentURL();

				$cell[] = "<b>" . construct_depth_mark($section['depth'], '- - ')
Пример #17
0
	public function actionList($page_url)
	{
		//This is an aggregator. We can pull in three different modes as of this writing,
		// and we plan to add more. We can have passed on the url the following:
		// author=id, category=id, section=id, and format=id. "Format" should normally
		// be passed as for author only, and it defines a sectionid to be used for the format.

		global $vbphrase;
		//Load cached values as appropriate
		$metacache_key = 'vbcms_list_data_' . implode('_', $this->segments);
		vB_Cache::instance()->restoreCacheInfo($metacache_key);

		// Create the page view
		$view = new vB_View_Page('vbcms_page');

		$view->page_url = $page_url;
		$view->base_url = VB_URL_BASE_PATH;
		$view->html_title = $this->title;

		$this->content = vBCms_Content::create('vBCms', 'Section', $this->displaysectionid);
		$sectionnode = new vBCms_Item_Content($this->displaysectionid, vBCms_Item_Content::INFO_CONFIG) ;
		//There are configuration settings on the section for items per page and
		// section layout. If they are set let's use them. First items per page.
		$this->config = $sectionnode->getConfig();

		if (isset($this->config['items_perhomepage']) AND intval($this->config['items_perhomepage']))
		{
			$this->perpage = $this->config['items_perhomepage'];
		}

		// Get layout
		$this->layout = new vBCms_Item_Layout($this->layoutid);
		$this->layout->requireInfo(vBCms_Item_Layout::INFO_CONFIG | vBCms_Item_Layout::INFO_WIDGETS);
		// Create the layout view
		$layout = new vBCms_View_Layout($this->layout->getTemplate());
		$layout->contentcolumn = $this->layout->getContentColumn();
		$layout->contentindex = $this->layout->getContentIndex();

		// Get content controller
		$collection = new vBCms_Collection_Content();

		$collection->setContentQueryWhere($this->query_filter . " AND node.contenttypeid <> "
			. vB_Types::instance()->getContentTypeID("vBCms_Section")	);
		$collection->setContentQueryJoins($this->joins);

		vB::$vbulletin->input->clean_array_gpc('r', array('page' => TYPE_INT));
		if ((vB::$vbulletin->GPC_exists['page'] AND intval(vB::$vbulletin->GPC['page'])))
		{
			$current_page = intval(vB::$vbulletin->GPC['page']);
		}
		elseif (intval($this->segments['page']))
		{
			$current_page = intval($this->segments['page']);
		}
		else
		{
			$current_page = 1;
		}


		$collection->paginate();
		$collection->paginateQuantity($this->perpage);
		$collection->paginatePage($current_page);

		$results = array();
		// Get the content view
		//Our templates assume a counter beginning at one, not zero.
		$counter = 0;
		foreach($collection as $id => $content)
		{
			//make sure we've loaded all the information we need
			$content->requireInfo(vBCms_Item_Content::INFO_NODE | vBCms_Item_Content::INFO_CONTENT | vBCms_Item_Content::INFO_PARENTS);
			// get the content controller
			$controller = vB_Types::instance()->getContentTypeController($content->getContentTypeId(), $content);

			// set preview length
			$controller->setPreviewLength(400);

			// get the aggregate view from the controller
			if ($result = $controller->getPreview())
			{
				$counter++;
				$results[$counter] = $result;
			}
		}

		$recordcount = $collection->getCount();
		$contentview->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Section");
		$contentview->contentid = $contentview->item_id = $contentview->nodeid = $this->displaysectionid;
		$contentview = new vB_View_Content('vbcms_content_list');
		$contentview->package = 'vBCms';
		$contentview->class = 'Section';
		$contentview->result_type = $this->result_type;
		$contentview->rawtitle = $this->title;
		$contentview->title = $this->title;
		$contentview->current_page = $current_page;

		if (! $recordcount)
		{
			switch($this->segments['type']){
				case 'author':
					$contentview->contents = array(1 => new vB_Phrase('vbcms', 'no_content_for_author_x', $this->title ));
					break;
				case 'section':
					$contentview->contents = array(1 => new vB_Phrase('vbcms', 'no_content_for_section_x', $this->title ));
					break;
				case 'category':
					$contentview->contents = array(1 => new vB_Phrase('vbcms', 'no_content_for_category_x', $this->title ));
					break;
				;
			} // switch

		}
		else
		{
			if (isset($this->config['content_layout']) AND intval($this->config['content_layout'])
				AND (intval($this->config['content_layout']) < 7))
			{
				$content_rendered = new vb_View('vbcms_content_section_type' . intval($this->config['content_layout']));
				$content_rendered->contents = $results;
				$content_rendered->result_count = $counter;
				$contentview->content_rendered = $content_rendered;
			}
			else
			{
				$contentview->contents = $results;
			}
			if (intval($recordcount) > intval($this->perpage))
			{
				$baseurl = vB_Route::create('vBCms_Route_List', $this->segments['type'] .
						'/' . intval($this->segments['value']) . ($this->urlstring == '' ? '' : '-' . $this->urlstring) .
						'/')->getCurrentURL();
				$contentview->pagenav = construct_page_nav($current_page, $this->perpage, $recordcount, $baseurl);
			}
			else
			{
				$contentview->pagecount = 1;
			}

		}

		$layout->content = $contentview;

		// Get widget locations
		$layout->widgetlocations = $this->layout->getWidgetLocations();

		if (count($layout->widgetlocations))
		{

			$widgetids = $this->layout->getWidgetIds();

			if (count($widgetids))
			{
				// Get Widgets
				$widgets = vBCms_Widget::getWidgetCollection($widgetids, vBCms_Item_Widget::INFO_CONFIG, $this->displaysectionid);
				$widgets = vBCms_Widget::getWidgetControllers($widgets, true, $this->content);

				// Get the widget views
				$widget_views = array();
				foreach($widgets AS $widgetid => $widget)
				{
					try
					{
						$widget_views[$widgetid] = $widget->getPageView();
					}
					catch (vB_Exception $e)
					{
						if ($e->isCritical())
						{
							throw ($e);
						}

						if (vB::$vbulletin->debug)
						{
							$widget_views[$widgetid] = 'Exception: ' . $e;
						}
					}
				}

				// Assign the widgets to the layout view
				$layout->widgets = $widget_views;

			}
		}
		// Assign the layout view to the page view
		$view->layout = $layout;

		// Add general page info
		$view->setPageTitle($this->content->getTitle());
		$view->pagedescription = $this->content->getDescription();

		$this->resolveWolPath();
		vB_Cache::instance()->saveCacheInfo($metacache_key);

		// Render view and return
		return $view->render();
	}
Пример #18
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;
		include_once DIR . '/vb/search/searchtools.php';

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

		$template->register('title', $this->record['title'] );
		$template->register('html_title', $this->record['html_title'] );
		$template->register('page_url', vB_Route::create('vBCms_Route_Content', $this->record['nodeid'])->getCurrentURL());
		$template->register('username', $this->record['username']);
		$template->register('user', array(
			'username' => $this->record['username'],
			'userid' => $this->record['userid'],
		));
		$template->register('parentnode', $this->record['parentnode']);
		$template->register('parenttitle', $this->record['parenttitle']);
		$template->register('parent_html_title', $this->record['parent_html_title']);
		$template->register('pagetext',
			vB_Search_Searchtools::getSummary(vB_Search_Searchtools::stripHtmlTags($this->record['pagetext']), 100));
		$template->register('publishdate', $this->record['publishdate']);
		$template->register('published', $this->record['publishdate'] >= TIMENOW ?
		 true : false );
		$template->register('dateline', date($vbulletin->options['dateformat']. ' '
			. $vbulletin->options['default_timeformat'], $this->record['dateline']));
		$template->register('dateformat', $vbulletin->options['dateformat']);
		$template->register('timeformat', $vbulletin->options['default_timeformat']);
		$template->register('categories', $this->record['categories']);
		$result = $template->render();
		return $result;

	}
Пример #19
0
	/**
	 * Populates a view with the expected info from a content item.
	 *
	 * @param vB_View $view
	 * @param int $viewtype
	 */
	protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true)
	{
		global $show;

		if (empty($this->config))
		{
			$this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG);
			 $this->config = $this->content->getConfig();
		}

		if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode')
		{
			$this->saveData($view);
			$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC);
			$this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG);
			$this->content->requireInfo(vBCms_Item_Content::INFO_NODE);
			$this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS);
			$this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION);
			$this->config = $this->content->getConfig();
		}
		else
		{
			$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC);
			$this->content->requireInfo(vBCms_Item_Content::INFO_NODE);
			$this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS);
			$this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION);
		}

		if ($_REQUEST['goto'] == 'newcomment')
		{
			require_once DIR . '/includes/functions_bigthree.php' ;

			$record = vB::$vbulletin->db->query_first("SELECT associatedthreadid
				FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId());
			$threadid = $record['associatedthreadid'];
			$threadinfo = verify_id('thread', $threadid, 1, 1);

			if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid'])
			{
				vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400));
			}
			else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit'])
			{
				vB::$vbulletin->userinfo['lastvisit'] = $tview;
			}

			$coventry = fetch_coventry('string');
			$posts = vB::$vbulletin->db->query_first("
				SELECT MIN(postid) AS postid
				FROM " . TABLE_PREFIX . "post
				WHERE threadid = $threadinfo[threadid]
					AND visible = 1
					AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . "
					". ($coventry ? "AND userid NOT IN ($coventry)" : "") . "
				LIMIT 1
			");

			$target_url = vB_Router::getURL();
			$join_char = strpos($target_url,'?') ? '&amp;' : '?';
			if ($posts['postid'])
			{
				exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]");
			}
			else
			{
				exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]");
			}
		}
		if ($_REQUEST['commentid'])
		{
			vB::$vbulletin->input->clean_array_gpc('r', array(
				'commentid' => vB_Input::TYPE_INT,
			));
			$postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1);
			$record = vB::$vbulletin->db->query_first("SELECT associatedthreadid
				FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId());
			$threadid = $record['associatedthreadid'];

			// if comment id and node id do not match, we ignore commentid
			if ($postinfo['threadid'] == $threadid)
			{
				$getpagenum = vB::$vbulletin->db->query_first("
					SELECT COUNT(*) AS posts
					FROM " . TABLE_PREFIX . "post AS post
					WHERE threadid = $threadid AND visible = 1
					AND dateline <= $postinfo[dateline]
				");
				$_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20);
			}
		}

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

		($hook = vBulletinHook::fetch_hook($this->startpopulatehook)) ? eval($hook) : false;

		//Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply
		// the settings to the current page, and there are the six "show" variables.

		if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit())
		{
			$dm = $this->content->getDM();
			$dm->delete();
			$this->cleanContentCache();

			// Create route to redirect the user to
			$route = new vBCms_Route_Content();
			$route->node = $this->content->getParentId();
			$_REQUEST['do'] = '';
			throw (new vB_Exception_Reroute($route));
		}

		//When we come from the link to upgrade a blog post, blog, or forum post, the
		// router puts us here.
		$settings_for = $this->content->getSettingsForboth();
		$showfor_this = (((self::VIEW_PAGE == $viewtype)
			AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype)
			AND ($settings_for == 2))) ? 0 : 1;

		$view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1;
		$view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1;
		$view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1;
		$view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1;
		$view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1;
		$view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1;
		$view->lastupdated = $this->content->getLastUpdated();
		$view->previewtext = $this->config['previewtext'];

		if ((self::VIEW_PREVIEW != $viewtype) OR !$view->showpreviewonly)
		{
			$view->pagetext = $this->config['pagetext'];
		}
		$view->previewimage = $this->config['preview_image'];
		$view->nodeid = $this->content->getNodeId();

		parent::populateViewContent($view, $viewtype);

		$segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view');
		$view->page_url =  vBCms_Route_Content::getURL($segments);
		$view->pagetext = $this->config['pagetext'];

		if (self::VIEW_PAGE == $viewtype)
		{
			if ($increment_count)
			{
				//update the view count
				vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX .
						"cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId());
			}

			//tagging code
			require_once DIR . '/includes/class_taggablecontent.php';

			$taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(),
				$this->content->getNodeId(), $this->content);

			if ($taggable)
			{
				$view->tags = $taggable->fetch_rendered_tag_list();
				$view->tag_count = $taggable->fetch_existing_tag_count();
				$view->showtags = vB::$vbulletin->options['threadtagging'];
			}
			else
			{
				$view->showtags = false;
			}

			$view->comment_count = $this->content->getReplyCount();
			$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
			$view->newcomment_url = $view->page_url . "#new_comment";
			$view->authorid = ($this->content->getUserId());
			$view->authorname = ($this->content->getUsername());
			$view->viewcount = ($this->content->getViewCount());
			$view->replycount = ($this->content->getReplyCount());
			$view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0;
			$view->parentid = $this->content->getParentId();

			//check to see if there is an associated thread.
			if ($associatedthreadid = $this->content->getAssociatedThreadId()
				and $this->content->getComments_Enabled())
			{
				$comment_block = new vBCms_Comments();
				$view->comment_block = $comment_block->getPageView($this->content->getNodeId(),
					$view->page_url);
			}

		}
		else if (self::VIEW_PREVIEW == $viewtype)
		{

			if ($showpreviewonly)
			{
				$view->previewtext = isset($this->config['previewtext']) ? $this->config['previewtext'] :
					 substr(strip_tags( $this->config['pagetext'], '<br />'), 0, $this->config['previewlength']);
				$view->preview_chopped = 1;

			}
			else
			{
				$view->previewtext = $view->pagetext;
			}

			$segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit');
			$view->edit_url =  vBCms_Route_Content::getURL($segments) ;
			$view->read_more_phrase = new vB_Phrase('vbcms', 'read_more');
			$view->parenttitle = $this->content->getParentTitle();
			$view->pagetext = $pagetext;
			$view->setpublish = $view->published = $this->content->getPublished();
			$view->publishdate = $this->content->getPublishDateLocal();
			$view->comment_count = $this->content->getReplyCount();
			$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
			$view->newcomment_url = $view->page_url . "#new_comment";
			$view->authorid = ($this->content->getUserId());
			$view->authorname = ($this->content->getUsername());
			$view->viewcount = ($this->content->getViewCount());
			$view->replycount = ($this->content->getReplyCount());
			$view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0;
			$view->parentid = $this->content->getParentId();

			if (($associatedthreadid = $this->content->getAssociatedThreadId())
				AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0)
			{
				$view->echo_comments = 1;
				$view->comment_count = $this->content->getReplyCount();
			}
			else
			{
				$view->echo_comments = 0;
				$view->comment_count = 0;
			}
		}

		$view->setpublish = $this->content->getSetPublish();
		$view->publishdate = $this->content->getPublishDate();
		$view->published = $this->content->getPublished() ?
			1 : 0;

		$view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate());
		$view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() );

		//Get links to the author, section, and categories search pages
		//categories- this comes as an array
		$view->categories = $this->content->getCategories();
		$route_info = 'author/' . $this->content->getUserid() .
			($this->content->getUsername() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : '');
		$view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL();

		// prepare the member action drop-down menu
		$view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId()));

		//Section
		$route_info = 'section/' .$this->content->getParentId() .
			($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : '');
		$view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL();
		//and the content
		$route_info = $this->content->getParentId() .
			($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : '');
		$view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL();

		$view->html_title = $this->content->getHtmlTitle();
		$view->title = $this->content->getTitle();
		$view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article");
		$view->dateformat = vB::$vbulletin->options['dateformat'];
		$view->showrating = $this->content->getShowRating();
		($hook = vBulletinHook::fetch_hook($this->endpopulatehook)) ? eval($hook) : false;

		if (method_exists($this->content, 'cacheNow'))
		{
			$this->content->cacheNow();
		}
		return $view;
	}
Пример #20
0
 public function getHTML($articles = false)
 {
     if (!$articles) {
         $articles = $this->getData();
     }
     if ($articles) {
         $route = vB_Route::create('vBCms_Route_Content');
         foreach ($articles as $key => $row) {
             $route->node = $row['nodeid'] . (empty($row['url']) ? '' : '-' . $row['url']);
             $articles[$key]['url'] = $route->getCurrentURL();
         }
         $templater = vB_Template::create('block_cmsarticles');
         $templater->register('blockinfo', $this->blockinfo);
         $templater->register('articlestype', $this->config['cmsarticles_type']);
         $templater->register('articles', $articles);
         return $templater->render();
     }
 }
Пример #21
0
	public function getHTML($articles = false)
	{
		if (! $articles)
		{
			$articles = $this->getData();
		}

		if ($articles)
		{
			require_once(DIR . '/includes/class_bootstrap_framework.php');
			vB_Bootstrap_Framework::init();

			$route = vB_Route::create('vBCms_Route_Content');
			foreach ($articles as $key => $row)
			{
				$route->node = $row['nodeid'] . (empty($row['url']) ? '' : '-' . $row['url']);
				$articles[$key]['url'] =  $route->getCurrentURL();
			}

			$templater = vB_Template::create('block_cmsarticles');
				$templater->register('blockinfo', $this->blockinfo);
				$templater->register('articlestype', $this->config['cmsarticles_type']);
				$templater->register('articles', $articles);
			return $templater->render();
		}

	}
Пример #22
0
	/**
	 * Validates a segment.
	 * The segment scheme is checked for constraints and boolean false is returned
	 * if the segment is not valid.
	 *
	 * Child classes can extend this if they use other validation methods.
	 *
	 * @throws vB_Exception_Router
	 *
	 * @param string $name						- The key name of the segment
	 * @param mixed $value						- The value to validate
	 * @return bool								- Success
	 */
	protected function validateSegment($name, $value)
	{
		if (!parent::validateSegment($name, $value))
		{
			return false;
		}

		if ('node' != $name)
		{
			return true;
		}

		return (bool)intval($value);
	}
Пример #23
0
	/** This function gets the article information based on the defined criteria
	*
	 * @return	array
	 */
	protected function getContent()
	{
		// First, compose the sql
		$sql = "SELECT node.contenttypeid, 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_node AS node
		INNER JOIN "	. TABLE_PREFIX . "contenttype AS type on type.contenttypeid = node.contenttypeid
		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 type.isaggregator = '0' AND " . 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'];
		$items = array();
	
		//Execute
		if ($rst = vB::$db->query_read($sql))
		{
			$current_record = array('contentid' => -1);
			//now build the results array
			while($item = vB::$db->fetch_array($rst))
			{
				$item['categories'] = array();
				$item['tags'] = array();
				$class = vB_Types::instance()->getContentTypeClass($item['contenttypeid']);
				$package = vB_Types::instance()->getContentTypePackage($item['contenttypeid']);
				$node = vBCms_Content::create($package, $class, $item['nodeid']);
				$item['pagetext'] = $item['previewtext'] = '';
					
				//get the avatar
				if (vB::$vbulletin->options['avatarenabled'])
				{
					$item['avatar'] = fetch_avatar_url($item['userid']);
				}
				
				if (method_exists($node, 'getPageText'))
				{
					$item['pagetext'] = fetch_censored_text($node->getPageText());
				}
				
				if (method_exists($node, 'getPreviewText'))
				{
					$item['previewtext'] = fetch_censored_text($node->getPreviewText());
				}
				else if (!empty($item['pagetext']))
				{
					$item['previewtext'] = vB_Search_Searchtools::getSummary($item['pagetext'], 200);
				}
				
				if (method_exists($node, 'getPreviewImage'))
				{
					$item['pagetext'] = fetch_censored_text($node->getPageText());
				}
								
				$items[$item['nodeid']]  = $item;
			}

			//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($item));
				$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();

						$items[$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))
					{
						$items[$record['nodeid']]['tags'][$record['tagid']] = $record['tagtext'];
					}
				}
			}
		}
		return $items;
	}
Пример #24
0
	private function renderResult($config, $results, $criteria, $current_user)
	{
		require_once DIR . "/includes/functions_user.php";
		//None of the search result renderers do this right. Instead
		// we need two templates- one for the header and one for each row
		if (count($results))
		{
			//Here we have something of a dilemma. We need to verify permissions
			// for each post. That requires that we instantiate the object, so we've got
			// two sql calls per object. We could reduce that by instantiating an array, but we
			// still make a second query to get the thread. So I guess we'll just brute-force it.
			$views =	'' ;
			$current_user = new vB_Legacy_CurrentUser();
			$count = 0;
			foreach ($results as $result)
			{
				// title comes in encoded already and gets encoded again in the view
				$result['title'] = unhtmlspecialchars($result['title']);
				$post = vB_Legacy_Post::create_from_id($result['postid']);
				if (!empty($post) AND is_object($post) AND $post->can_view($current_user))
				{
					$view = new vB_View($config['inner_template']);
					$user = vB_Legacy_User::createFromId($post->get_field('userid'));

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

					$view->avatar = $avatar;
					$view->record = $result;
					$view->node_url = vB_Route::create('vBCms_Route_Content', $result['nodeid'] .
						($result['url'] != '' ? '-' . $result['url'] : '') )->getCurrentURL();
					$view->node_title = htmlspecialchars_uni($result['title']);

					// Comment url
					$join_char = strpos($view->node_url,'?') ? '&amp;' : '?';
					$view->comment_url = $view->node_url . $join_char . "commentid=" . $post->get_field('postid') . "#post" . $post->get_field('postid');

					$view->post = $this->addVariables($post);
					$thread = $post->get_thread();
					$view->threadinfo = array('threadid' => $thread->get_field('threadid'),
						 'title' => $thread->get_field('title'));
					$view->dateformat = $vbulletin->options['dateformat'];
					$view->timeformat = $vbulletin->options['default_timeformat'];
					$view->dateline =  $post->get_field('dateline');

					$views .= $view->render();
					$count++;
					if ($count >= intval($config['count']))
					{
						break;
					}

				}
			}
			return $views;

		}
	}
Пример #25
0
if ($_REQUEST['do'] == 'widget')
{
	$options = array(
		'editwidget' => $vbphrase['edit'],
		'deletewidget' => $vbphrase['delete'],
	);


	print_form_header('cms_admin', 'addwidget');
	print_table_header($vbphrase['widgets'], 4);
	print_cells_row(array($vbphrase['widget_name'], $vbphrase['widget_type'], $vbphrase['controls'], $vbphrase['configure']), 1);

	$widgets = new vBCms_Collection_Widget();
	foreach($widgets AS $widget)
	{
		$config_url = vB_Route::create('vBCms_Route_Widget', 'config/' . $widget->getID() . '/0')->getCurrentURL();
		$callback = method_exists($widget, 'getConfigCallback') ? $widget->getConfigCallback() : false;
		$config_col = "<a href=\"\" onclick=\"return cms_show_overlay('$config_url'" .
			($callback ? ", $callback" : '' ) . " )\">$vbphrase[configure]</a>";

		// widgetid, title, description, widgettype, package
		print_cells_row(array(
			$widget->getTitle(),
			$vbphrase['widgettype_' . strtolower($widget->getPackage() . '_' . $widget->getClass())],
			"<span style=\"white-space:nowrap\">
				<select name=\"widget" . $widget->getId() . "\" onchange=\"js_jump(" . $widget->getId() . ", this);\" class=\"bginput\">" . construct_select_options($options) . "</select>
				<input type=\"button\" value=\"" . $vbphrase['go'] . "\" onclick=\"js_jump(" . $widget->getId() . ", this.form.widget" . $widget->getId() . ");\" class=\"button\" />
			</span>",
			$config_col
		));
	}
Пример #26
0
 /**
  * Adds the CMS URLs to $this->content
  *
  * @param 	int		forumdid to start at
  * @param 	int		perpage limit defaults to 30000
  */
 public function generate_sitemap($startat = 0, $perpage = 30000)
 {
     global $config;
     //make sure we have the node information
     if (!$this->nodes) {
         $this->nodes = vBCms_ContentManager::getPublicContent($startat, $perpage);
     }
     $this->has_more = false;
     $route = vB_Route::create('vBCms_Route_Content');
     foreach ($this->nodes as $node) {
         $this->pagecount++;
         $this->lastid = $node['nodeid'];
         $route->node = $node['nodeid'] . (empty($node['url']) ? '' : '-' . $node['url']);
         $rawurl = $route->getCurrentURL();
         $pageurl = str_replace('/' . vB::$vbulletin->config['Misc']['admincpdir'] . '/', '/', $rawurl);
         $priority = $this->get_effective_priority('cms', $node['sectionid']);
         $this->content .= $this->url_block($pageurl, $node['publishdate'], $priority);
         if ($this->pagecount >= $perpage) {
             $this->has_more = true;
             break;
         }
     }
     // Return the amout done
     return $this->pagecount;
 }
Пример #27
0
 /**
  * Returns a representative URL of a route.
  * Optional segments and parameters may be passed to set the route state.
  *
  * @param array mixed $segments				- Assoc array of segment => value
  * @param array mixed $parameters			- Array of parameter values, in order
  * @return string							- The URL representing the route
  */
 public static function getURL(array $segments = null, array $parameters = null, $absolute_path = false)
 {
     return vB_Route::create('vB_Route_Error')->getCurrentURL($segments);
 }
Пример #28
0
	/**
	 * Builds the toolbar view for managing the page.
	 *
	 * @param bool $edit_mode					- Whether the user is currently in edit mode
	 * @return vB_View
	 */
	protected function getToolbarView($edit_mode = false)
	{
		global $vbulletin;
		global $vbphrase;

		if (!$this->content->canCreate() AND !$this->content->canEdit() AND !$this->content->canPublish())
		{
			return;
		}

		require_once DIR . '/includes/functions_databuild.php';

		fetch_phrase_group('cpcms');
		// Create view
		$view = new vB_View('vbcms_toolbar');
		$view->edit_mode = $edit_mode;
		$view->page_url = vB_Router::getURL();
		$view->access = ($this->content->publicCanView() ?
			$vbphrase['public'] : $vbphrase['public']);

		// Setup a new route to get URLs
		$route = new vBCms_Route_Content();
		$route->node = $this->node->getURLSegment();

		$view->view_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')));

		$view->edit_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')));
		$view->edit_label = new vB_Phrase('vbcms', 'edit_this_page');

		// New content options
		$view->add_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'AddNode')));
		$view->add_label = new vB_Phrase('vbcms', 'create_new');

		// Get placable contenttypes.  TODO: This should be a method of vB_Types for reuse

		if (!($view->contenttypes = vB_Cache::instance()->read('vbcms_controller_content.place_nonaggs', true, true)))
		{

			$contenttype_collection = new vB_Collection_ContentType();
			$contenttype_collection->filterPlaceable(true);
			$contenttype_collection->filterNonAggregators(true);

			$contenttypes = array();
			$permissionsfrom = $this->content->getPermissionsFrom();
			foreach ($contenttype_collection AS $contenttype)
			{
				$this_type = vBCms_Content::create($contenttype->getPackageClass(), $contenttype->getClass(), 0);

				if ($this_type->canCreateHere($permissionsfrom))
				{
					$title = (string)$contenttype->getTitle();
					$contenttypes[$title] = array('id' => $contenttype->getId(),
																 'title' => $title);
				};
				unset($this_type);
			}
			ksort($contenttypes);
			$view->contenttypes = $contenttypes;
			unset($contenttype_collection, $contenttypes);

			vB_Cache::instance()->write('vbcms_controller_content.place_nonaggs', $view->contenttypes, false, vB_Types::instance()->getContentTypeCacheEvents());
		}



		// Set the publish state description
		if ($this->node->isPublished())
		{
			$view->publish_status = new vB_Phrase('vbcms', 'page_is_published');
		}
		else if ($this->node->getPendingParentId())
		{
			$pending_title = $this->node->getPendingParentTitle();
			$pending_route = vB_Route::create('vBCms_Route_Content')->getCurrentURL(array('node' => $this->node->getPendingParentId()));

			$view->publish_status = new vB_Phrase('vbcms', 'section_x_not_published', $pending_route, $pending_title);
		}
		else if ($date = $this->node->getPublishDate())
		{
			$date = vbdate(vB::$vbulletin->options['dateformat'], $date, true);
			$view->publish_status = new vB_Phrase('vbcms', 'page_will_be_published_x', $date);
		}
		else
		{
			$view->publish_status = new vB_Phrase('vbcms', 'page_not_published');
		}

		$view->can_publish = $this->content->canPublish();
		$view->can_edit = $this->content->canEdit();
		$view->can_create = $this->content->canCreate();

		// Add postid
		$this->addPostId($view);

		return $view;
	}
Пример #29
0
	/**
	* Template method. Calls all the appropriate methods to build a post and then evaluates the template.
	*
	* @param	array	Post information
	*
	* @return	string	HTML for the post
	*/
	function construct_postbit(&$post)
	{
		global $ad_location;

		$this->post =& $post;
		$thread =& $this->thread;
		$forum =& $this->forum;

		// make sure we can display this post
		if ($this->is_displayable() == false)
		{
			return '';
		}

		global $show, $vbphrase;
		global $spacer_open, $spacer_close;

		global $bgclass, $altbgclass;
		exec_switch_bg();

		$template_hook = array();

		($hook = vBulletinHook::fetch_hook('postbit_display_start')) ? eval($hook) : false;

		// put together each part of the post
		$this->prep_post_start();

		$this->process_date_status();
		$this->process_edit_info();
		$this->process_icon();
		$this->process_ip();

		if (!empty($this->post['userid']))
		{
			$this->process_registered_user();
			$this->process_im_icons();
		}
		else
		{
			$this->process_unregistered_user();
		}

		$this->bbcode_parser->containerid = $this->post['postid'];
		$this->parse_bbcode();

		$this->process_attachments();

		// finish prepping the post
		$this->prep_post_end();

		$pageinfo_post = array(
			'p' => $post['postid']
		);
		if ($this->templatename != 'postbit')
		{
			$pageinfo_post['viewfull'] = 1;
		}

		// execute hook
		($hook = vBulletinHook::fetch_hook('postbit_display_complete')) ? eval($hook) : false;

		$show['last_ad'] = $show['first_ad'] = $show['first_adsense'] = false;
		if ($post['isfirstshown'])
		{
			//this does not appear to be an ad slot, rather it appears to be some shim html
			//that needs to be rendered if the firstpost google ad is included.
			$template = vB_Template::create('ad_showthread_firstpost_sig');
			$template->register('adsense_pub_id', $this->registry->adsense_pub_id);
			$template->register('adsense_host_id', $this->registry->adsense_host_id);
			$ad_location['ad_showthread_firstpost_sig'] = $template->render();

			$template = vB_Template::create('ad_showthread_firstpost_start');
			$template->register('adsense_pub_id', $this->registry->adsense_pub_id);
			$template->register('adsense_host_id', $this->registry->adsense_host_id);
			$ad_location['ad_showthread_firstpost_start'] = trim($template->render(true));

			$ad_location['ad_showthread_firstpost_sig'] = vB_Template::create('ad_showthread_firstpost_sig')->render();
			if ($ad_location['ad_showthread_firstpost_start'])
			{
				$show['first_ad'] = true;
			}

			if ($ad_location['thread_first_post_content'] = trim(vB_Template::create('ad_thread_first_post_content')->render(true)))
			{
				if (preg_match('#^<div id="ad_thread_first_post_content">.+</div>$#si', $ad_location['thread_first_post_content']))
				{
					$show['first_ad'] = true;
				}
				else
				{
					$ad_location['thread_first_post_content'] = '';
				}
			}
		}
		else if (
			$post['islastshown']
				AND
			$ad_location['thread_last_post_content'] = trim(vB_Template::create('ad_thread_last_post_content')->render(true))
		)
		{
			if (preg_match('#^<div id="ad_thread_last_post_content">.+</div>$#si', $ad_location['thread_last_post_content']))
			{
				$show['last_ad'] = true;
			}
			else
			{
				$ad_location['thread_last_post_content'] = '';
			}
		}

		// prepare the member action drop-down menu
		// pass the local template hook so that each drop-down gets its own hook (per-postbit)
		$memberaction_dropdown = construct_memberaction_dropdown($post, $template_hook);

		// evaluate template
		$postid =& $post['postid'];

		$templater = vB_Template::create($this->template_prefix . $this->templatename);
			if ($this->add_promote_links AND $this->registry->products['vbcms'])
			{
				if (!isset($this->registry->userinfo['permissions']['cms']))
				{
					bootstrap_framework();
					vBCMS_Permissions::getUserPerms();
				}

				if ($this->registry->userinfo['permissions']['cms']['canpublish'][0] != -1)
				{
					$templater->register('promote_sectionid', $this->registry->userinfo['permissions']['cms']['canpublish'][0]);
					$templater->register('articletypeid', vB_Types::instance()->getContentTypeID('vBCms_Article'));
					$promote_url = vB_Route::create('vBCms_Route_Content', '1/addcontent/')->getCurrentURL();
					$promote_url .= (strrpos($promote_url, '?') ? '&amp;' : '?') .
						'contenttypeid=' . vB_Types::instance()->getContentTypeID('vBCms_Article') .
						"&amp;postid=" . $post['postid'] . '&amp;parentid=1';
					$templater->register('promote_url', $promote_url);
				}
			}
			$templater->register('ad_location', $ad_location);
			$templater->register('memberaction_dropdown', $memberaction_dropdown);
			$templater->register('pageinfo_post', $pageinfo_post);
			$templater->register('post', $post);
			$templater->register('postid', $postid);
			$templater->register('template_hook', $template_hook);
			$templater->register('thread', $thread);
		$postbit = $templater->render();

		$templater = vB_Template::create('postbit_wrapper');
			$templater->register('post', $post);
			$templater->register('postbit', $postbit);
			$templater->register('spacer_close', $spacer_close);
			$templater->register('spacer_open', $spacer_open);
		$retval = $templater->render();

		return $retval;
	}
Пример #30
0
	/**
	 * Returns a representative URL of a route.
	 * Optional segments and parameters may be passed to set the route state.
	 *
	 * @param array mixed $segments				- Assoc array of segment => value
	 * @param array mixed $parameters			- Array of parameter values, in order
	 * @return string							- The URL representing the route
	 */
	public static function getURL(array $segments = null, array $parameters = null)
	{
		return vB_Route::create('vBCms_Route_Widget')->getCurrentURL($segments, $parameters);
	}