/** * Renders the navigation tabs & links. */ protected function getNavigation() { global $vbulletin; $root = ''; $root_tab = $roots['vbtab_forum']; $tabs = build_navigation_menudata(); $roots = get_navigation_roots(build_navigation_list()); $request_tab = intval($_REQUEST['tabid']); $script_tab = get_navigation_tab_script(); $hook_tabid = $tabid = 0; ($hook = vBulletinHook::fetch_hook('set_navigation_tab_vbview')) ? eval($hook) : false; if ($root) { $tabid = $roots[$root]; } /* Tab setting logic, using above choices. Preference order is (low > high) root > script > hookroot > hookid > request */ $current_tab = $script_tab ? $script_tab : $root_tab; $current_tab = $tabid ? $tabid : $current_tab; $current_tab = $hook_tabid ? $hook_tabid : $current_tab; $current_tab = $request_tab ? $request_tab : $current_tab; $tabid = set_navigation_tab($current_tab, $tabs); $view = new vB_View('navbar_tabs'); $view->tabs = $tabs; $view->selected = $tabid; return $view->render(); }
/** * Renders the view to a string and returns it. * * @return string */ public function render($send_content_headers = false) { require_once DIR . '/includes/class_xml.php'; $xml = new vB_AJAX_XML_Builder(vB::$vbulletin, 'text/xml'); $xml->add_group('container'); $xml->add_tag('success', 1); if ($this->content) { $xml->add_tag('html', $this->content->render()); } $xml->add_tag('title', $this->title); $xml->add_tag('status', $this->status); $xml->add_tag('message', $this->feedback); if (sizeof($this->errors)) { $xml->add_group('errors'); foreach ($this->errors as $error) { $xml->add_tag('error', $error['message'], array('errcode' => $error['code'])); } $xml->close_group(); } if (sizeof($this->urls)) { $xml->add_group('urls'); foreach ($this->urls as $type => $url) { $xml->add_tag('url', $url, array('type' => $type)); } $xml->close_group(); } $xml->close_group(); if ($send_content_headers and !vB::contentHeadersSent()) { $xml->send_content_type_header(); $xml->send_content_length_header(); vB::contentHeadersSent(true); } return $xml->fetch_xml(); }
/** * Fetches the prepared nabar view. * * @return vB_View - The navbar link view */ public static function renderView() { global $template_hook; if (self::$view) { vB::$vbulletin->options['selectednavtab'] = 'vbcms'; return self::$view->render(); } else { return false; } }
/** * 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(); }
private function getAttachData($attachmentid, &$dm, &$bbcodesearch) { $imgtypes = array('gif', 'jpg', 'jpeg', 'jpe', 'png', 'bmp'); if (intval($attachmentid)) { $image_location = $i; $record = vB::$vbulletin->db->query_first(" SELECT data.thumbnail_width, data.thumbnail_height, data.width, data.height, data.extension, attach.settings FROM " . TABLE_PREFIX . "attachment AS attach INNER JOIN " . TABLE_PREFIX . "filedata AS data ON (data.filedataid = attach.filedataid) WHERE attach.attachmentid = $attachmentid "); if ($record AND (in_array($record['extension'], $imgtypes))) { $image_template = new vB_View('vbcms_image_src'); $settings = unserialize($record['settings']); $image_template->attachmentid = $attachmentid; $image_template->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article"); $image_template->altattribute = empty($settings['description']) ? ' ' : $settings['description']; $image_template->title = empty($settings['title']) ? ' ' : $settings['title'] ; $image_template->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article"); $image_tag = $image_template->render(); // parse the src attribute value from the image tag // since that is what we want to store in the db if (preg_match('/src=\"([^"]*)\"/', $image_tag, $matches) && isset($matches[1])) { $dm->set('previewimage', $matches[1]); $bbcodesearch[] = substr($pagetext, $i, $j + 9); } if ($record['thumbnail_width'] AND $record['thumbnail_height']) { $dm->set('imagewidth', $record['thumbnail_width']); $dm->set('imageheight', $record['thumbnail_height']); } else { $dm->set('imagewidth', $record['width']); $dm->set('imageheight', $record['height']); } } return true; } return false; }
/** * Fetches a rich page view of the specified content item. * This method can accept parameters from the client code which are usually * derived from user input. Parameters are passed as an array in the order that * they were received. Parameters do not normally have assoc keys. * * Note: Parameters are always passed raw, so ensure that validation and * escaping is performed where required. * * Skip permissions should allow content to be rendered regardless of the * current user's permissions. * * Child classes will inevitably override this with wildly different * implementations. * * @param array mixed $parameters - Request parameters * @param bool $skip_permissions - Whether to skip can view permission checking * @return vB_View | bool - Returns a view or false */ public function getInlineEditBodyView($parameters = false) { global $vbphrase; require_once DIR . '/includes/functions.php'; require_once DIR . '/includes/functions_databuild.php'; fetch_phrase_group('cpcms'); $this->editing = true; //confirm that the user has edit rights if (!$this->content->canPublish()) { return new vB_Phrase('cpcms', 'no_edit_permissions'); } if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode') { $this->checkSaveData($view); unset($_REQUEST['do']); } $this->content->requireInfo(vBCms_Item_Content::INFO_BASIC & vBCms_Item_Content::INFO_CONFIG & vBCms_Item_Content::INFO_NODE & vBCms_Item_Content::INFO_NAVIGATION & vBCms_Item_Content::INFO_PARENTS); $this->content->isValid(); $config = $this->content->getConfig(); //See if we're deleting if ($_REQUEST['do'] == 'delete') { //We can't delete if there is content below if ($record = vB::$vbulletin->db->query_first("SELECT nodeid FROM " . TABLE_PREFIX . "cms_node WHERE parentnode = " . $this->content->getNodeId() . " limit 1") and intval($record['nodeid'])) { return new vB_Phrase('cpcms', 'cannot_delete_with_subnodes'); } $dm = $this->content->getDM(); $dm->delete(); $events = $this->getCleanCacheEvents(); vB_Cache::instance()->event($events); vB_Cache::instance()->cleanNow(); return new vB_Phrase('cpcms', 'section_deleted'); } vB::$vbulletin->input->clean_array_gpc('r', array( 'sortby' => vB_Input::TYPE_STR, 'dir' => vB_Input::TYPE_STR, 'page' => vB_Input::TYPE_INT, 'item_count' => vB_Input::TYPE_INT, 'per_page' => TYPE_INT, 'simple_paging' => TYPE_INT, 'page' => TYPE_INT )); // Load the content item if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE))) { throw (new vB_Exception_404()); } // Create view $view = $this->createView('inline', self::VIEW_PAGE); // Add the content to the view parent::populateViewContent($view, self::VIEW_PAGE); $this->config = $this->getConfig(); $view->formid = 'cms_content_data'; $view->title = $this->content->getTitle(); $view->html_title = $this->content->getHtmlTitle(); $view->url = $this->content->getUrl(); $view->contentfrom = $this->config['contentfrom']; $view->editshowchildren = $this->content->getEditShowchildren() ? 1 : 0; $view->layout_select = vBCms_ContentManager::getLayoutSelect($this->content->getLayoutSetting(), $this->getParentId()); $view->style_select = vBCms_ContentManager::getStyleSelect($this->content->getStyleSetting()) ; $view->display_order_select = vBCms_ContentManager::getSectionPrioritySelect($this->config['section_priority']) ; $view->content_layout_select = $tmp = vBCms_ContentManager::getContentLayoutSelect($this->config['content_layout']); $view->simple_paging = $this->config['simple_paging']; $view->per_page = $this->config['items_perhomepage']; $view->nodeid = $this->content->getNodeId(); $view->dateformat = vB::$vbulletin->options['dateformat'] . " " . vB::$vbulletin->options['timeformat']; if (intval($this->content->getPublishDate)) { $view->publishdate = $this->content->getPublishDate(); } $aggregate = new vBCms_Collection_Content_Section(); switch(vB::$vbulletin->GPC['sortby']) { case 'title' : $aggregate->setSortBy('ORDER BY title ' . vB::$vbulletin->GPC['dir']); break; case 'setpublish' : $aggregate->setSortBy('ORDER BY setpublish ' . vB::$vbulletin->GPC['dir']); break; case 'displayorder' : $aggregate->setSortBy('ORDER BY displayorder ' . vB::$vbulletin->GPC['dir']); break; case 'username' : $aggregate->setSortBy('ORDER BY username ' . vB::$vbulletin->GPC['dir']); break; case 'publishdate' : $aggregate->setSortBy('ORDER BY publishdate ' . vB::$vbulletin->GPC['dir']); break; case 'pageviews' : $aggregate->setSortBy('ORDER BY viewcount ' . vB::$vbulletin->GPC['dir']); break; case 'replycount': $aggregate->setSortBy('ORDER BY replycount ' . vB::$vbulletin->GPC['dir']); ; break; case 'section': $aggregate->setSortBy('ORDER BY parenttitle ' . vB::$vbulletin->GPC['dir']); ; break; default: $aggregate->setOrderBy(1); ; } // switch //See if we need to hide the children $filter_node = $this->content->getEditShowchildren(); if (!$filter_node) { $aggregate->setFilterNodeExact($this->content->getNodeId()); } else { $aggregate->filterNode($this->content->getNodeId()); } $nodes = array(); $sequence = 0; $candelete = 1; if (vB::$vbulletin->GPC_exists['perpage'] AND intval(vB::$vbulletin->GPC['perpage'])) { $perpage = vB::$vbulletin->GPC['perpage']; } else { $perpage = vBCms_ContentManager::getPerPage(new vB_Legacy_CurrentUser()); } $current_page = (vB::$vbulletin->GPC_exists['page'] AND intval(vB::$vbulletin->GPC['page']) ) ? vB::$vbulletin->GPC['page'] : 1; $aggregate->paginate(); $aggregate->paginateQuantity($perpage); $aggregate->paginatePage($current_page); foreach ($aggregate as $id => $content_node) { $candelete = 0; if ($content_node->getContentTypeid() != vb_Types::instance()->getContentTypeID("vBCms_Section") ) { $sequence++; $nodes[] = array('sequence' => $sequence, 'class' => $content_node->getClass(), 'title' => $content_node->getTitle(), 'html_title' => $content_node->getHtmlTitle(), 'nodeid' => $content_node->getNodeid(), 'prev_checked' => ($content_node->getPublicPreview() ? " checked=\"checked\" " : ''), 'publicpreview' => $content_node->publicpreview, 'parenttitle' => $content_node->getParentTitle(), 'published_select' => vBCms_ContentManager::getPublishedSelect($content_node->getSetPublish(), $content_node->getPublishDate()), 'order_select' => vBCms_ContentManager::getOrderSelect($content_node->getDisplayOrder($this->content->getNodeId()), $this->content->getNodeId()), 'author' => $content_node->getUsername(), 'pub_date' => (intval($content_node->getPublishDate()) ? vbdate(vB::$vbulletin->options['dateformat'], $content_node->getPublishDate()) : '') , 'viewcount' => $content_node->getViewCount(), 'view_url' => vBCms_Route_Content::getURL(array('node' => $content_node->getUrlSegment())), 'replycount' => $content_node->getReplyCount()); } } if (vB::$vbulletin->GPC_exists['item_count']) { $item_count = vB::$vbulletin->GPC['item_count']; } else { $aggregate->filterNoSections(1); $item_count = $aggregate->getCount(); } $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')); $view->view_url = vBCms_Route_Content::getURL($segments); $segments = array('node' => $this->content->getUrlSegment(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')); $view->submit_url = vBCms_Route_Content::getURL($segments); $base_url = $view->submit_url; $base_url .= strpos($base_url, '?') ? '&' : '?'; $view->record_count = count($aggregate); $view->item_count = $item_count; $pagination = construct_page_nav($current_page, $perpage, $item_count, $view->submit_url); $view->pagination = $pagination; $perpage_select .= '<select name="perpage" onchange="checkShouldSave(\'' . $view->formid . '\', \'perpage\', \'' . vB_Template_Runtime::escapeJS(new vB_Phrase('cpcms', 'confirm_save_section')) . '\', \'' . vB_Template_Runtime::escapeJS($view->submit_url) . '\');">' . "\n"; foreach (array(5,10,15,20,25,50,75,100,200, 250, 500) as $this_perpage) { $perpage_select .= "<option value=\"$this_perpage\"" . (intval($this_perpage) == intval($perpage) ? ' selected="selected" ' : '') . ">$this_perpage</option>\n" ; } $perpage_select .= "</select>"; $view->perpage_select = $perpage_select; $record = vB::$vbulletin->db->query_first("SELECT SUM(childinfo.viewcount) AS viewcount, SUM(CASE when child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") ." THEN 1 ELSE 0 END) AS content, SUM(CASE when (child.parentnode = node.nodeid AND child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") .") THEN 1 ELSE 0 END) AS children, SUM(CASE when child.contenttypeid =" . vb_Types::instance()->getContentTypeID("vBCms_Section") ." AND child.parentnode = node.nodeid THEN 1 ELSE 0 END) AS subsections FROM " . TABLE_PREFIX . "cms_node AS node LEFT JOIN " . TABLE_PREFIX . "cms_node AS child ON (child.nodeleft >= node.nodeleft AND child.nodeleft <= node.noderight AND child.nodeid <> node.nodeid AND child.new != 1) LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS childinfo ON childinfo.nodeid = child.nodeid AND child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") ." WHERE node.nodeid = " . $this->content->getNodeId()); $view->viewcount = $record['viewcount']; $view->content = $record['content']; $view->children = $record['children']; $view->subsections = $record['subsections']; $view->nodes = $nodes; $view->metadata = $this->content->getMetadataEditor(); //Here we create some url's. This should allow to sort in reverse direction $view->sorttitle_url = $base_url . 'sortby=title&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'title' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortpub_url = $base_url . 'sortby=setpublish&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'setpublish' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortorder_url = $base_url . 'sortby=displayorder&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'displayorder' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortauthor_url = $base_url . 'sortby=username&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'username' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortdate_url = $base_url . 'sortby=publishdate&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'publishdate' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sorthits_url = $base_url . 'sortby=pageviews&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'pageviews' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortreplycount_url = $base_url . 'sortby=replycount&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'replycount' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->sortsection_url = $base_url . 'sortby=section&dir=' . ((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'section' AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc'); $view->editbar = $this->content->getEditBar($view->submit_url, $view->view_url, $view->formid, (intval($this->content->getNodeId()) ? 'edit' : 'add'), $candelete); $view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid, false, false, false, false, $this->config['pagination_links']); $view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Section"); $this->addPostId($view); // Sub menu if (!$this->content->isRoot()) { $view->inherit_section = $this->content->getNavigationParentTitle(); $view->inherited = !$this->content->hasNavigation(); } $navigation_nodes = $this->content->getNavigationNodes(); $subnav_nodes = vBCms_ContentManager::getSections(false, true); // array for the navigation display order drop-down menu $displayorder_array = array(0 => ''); $count = max(count($nodes), 40); for ($i=1; $i <= $count; $i++) { $displayorder_array[$i] = $i; } // populate sub-nav configuration menu with all cms sections $sections = array(); $subnav = new vB_View('vbcms_content_section_subnavedit'); $subnav->displayorder_array = $displayorder_array; foreach ($subnav_nodes AS $node) { $nodeid = $node['nodeid']; // check if the section has already been selected for the menu nav // if so, its position in the array (key+1) is its display order $displayorder = 0; //default display order is 0 $selected = false; if (isset($navigation_nodes) AND is_array($navigation_nodes)) { if ($selected = in_array($nodeid, $navigation_nodes)) { $displayorder = array_search($nodeid, $navigation_nodes) + 1; } } $sections[] = array('id' => $nodeid, 'title' => $node['title'], 'depth' => $node['depth'], 'selected' => $selected, 'displayorder' => $displayorder); } $subnav->sections = $sections; $subnav_rendered = $subnav->render(); $view->subnav = $subnav_rendered; unset($nodes, $subnav_nodes, $sections); return $view; }
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,'?') ? '&' : '?'; $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; } }