/** * Gets the config editor page. * * @return vB_View */ public function actionConfigEditor() { // Create the page view $view = new vB_View_Page('vbcms_editor_page'); $view->editor_view = $this->widget->getConfigEditorView(); $view->setBreadcrumbInfo(array()); vB::$vbulletin->debug = false; // can't return debug info // Render view and return return $view; }
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(); }
/** * Config Widget * * @return string - The final page output */ public function actionConfig($widget = false) { if (!$widget) { throw (new vB_Exception_404(new vB_Phrase('error', 'page_not_found'))); } // Setup the templater for xhtml vB_View::registerTemplater(vB_View::OT_XHTML, new vB_Templater_vB()); // Get the content controller $this->content = vBCms_Content::create($this->node->getPackage(), $this->node->getClass(), $this->node->getContentId()); // Add the node as content $this->content->castFrom($this->node); // Get Widget that we're configuring $widgets = vBCms_Widget::getWidgetCollection(array($widget), vBCms_Item_Widget::INFO_CONFIG, $this->node->getId()); $widgets = vBCms_Widget::getWidgetControllers($widgets, true, $this->content); if (!isset($widgets[$widget])) { throw (new vB_Exception_404()); } $widget = $widgets[$widget]; // Render the content's config view and return return $widget->getConfigView()->render(true); }
/** * View a list page. Currently not used, because it was replaced by the list controller * * @return string - The final page output */ public function actionList() { //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. // Create the page view $view = new vB_View_Page('vbcms_page'); $view->page_url = vB_Router::getURL(); $view->pagetitle = $this->node->getTitle(); vB::$vbulletin->options['description'] = $this->node->getDescription(); vB::$vbulletin->options['keywords'] = $this->node->getKeywords(); // Get layout $this->layout = $this->node->getLayout(); // Create the layout view $layout = new vBCms_View_Layout($this->layout->getTemplate()); // Get content controller $this->content = vBCms_Content::create($this->node->getPackage(), $this->node->getClass(), $this->node->getContentId()); // Add the node as content $this->content->castFrom($this->node); // Check this user's permissions $this->authorizeAction(); // Get the content view $layout->content = $this->content->getPageView($this->parameters); $layout->contentcolumn = $this->layout->getContentColumn(); $layout->contentindex = $this->layout->getContentIndex(); // Get widget locations $layout->widgetlocations = $this->layout->getWidgetLocations(); if (count($layout->widgetlocations)) { // Get Widgets $widgetids = $this->layout->getWidgetIds(); if (count($widgetids)) { $widgets = vBCms_Widget::getWidgetCollection($widgetids, vBCms_Item_Widget::INFO_CONFIG, $this->node->getId()); $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->setBreadcrumbInfo($this->node->getBreadcrumbInfo()); $view->setPageTitle($this->content->getTitle()); $view->pagedescription = $this->content->getDescription(); // Add toolbar view $view->toolbar = $this->getToolbarView(); // Render view and return return $view->render(); }