public function getDefaultFetchOptions(array $fetchOptions = array()) { if (SimplePortal_Static::option('newsSystem')) { $fetchOptions['order'] = 'id'; $fetchOptions['direction'] = 'desc'; } return $fetchOptions; }
protected function _discussionPreSave() { parent::_discussionPreSave(); // TODO: Change the autogenerated stub if (in_array($this->get('node_id'), SimplePortal_Static::option('autopromotenodes')) or XenForo_Application::isRegistered('extraportal.promoteThread')) { $this->setOption(self::OPTION_PROMOTE_TO_PORTAL, true); } }
public static function getPromoteFormElement($content, $params, XenForo_Template_Abstract $template) { $contentType = $params['content_type']; $contentData = $params['content_data']; // if we'll ever need it, we have it now, without changing anything in the templates:) $contentId = $params['content_id']; if (self::getItemModel()->canPromoteItem($contentType, $contentData)) { if ($contentType == 'thread' && in_array($contentData['node_id'], SimplePortal_Static::option('autopromotenodes'))) { //thread will be promoted automatically... we don't need the form return ''; } $viewParams = array('categories' => self::getItemModel()->getModelFromCache('SimplePortal_Model_Category')->getAllCategories(), 'content_type' => 'thread', 'item' => self::getItemModel()->getDefaultItem()); return $template->create('el_portal_promothread', array_merge($template->getParams(), $viewParams)); } }
/** * @param $controllerResponse * @param $controllerName * @param $action */ protected function _postDispatch($controllerResponse, $controllerName, $action) { parent::_postDispatch($controllerResponse, $controllerName, $action); if ($controllerResponse instanceof XenForo_ControllerResponse_View) { if (!XenForo_Autoloader::getInstance()->autoload('SimplePortal_BrandingFree')) { $controllerResponse->params['show_portal_branding'] = true; } $portalContainer = $this->getPortalConfig(); if (isset($portalContainer->container)) { $controllerResponse->containerParams = array('containerTemplate' => $portalContainer->container); } if (SimplePortal_Static::option('defaultSidebar')) { $viewParams = $this->_getDefaultSidebarParams(); $controllerResponse->params += $viewParams; } } }
public function actionIndex() { if (isset($this->getPortalConfig()->only_container, $this->getPortalConfig()->container)) { return $this->responseView('SimplePortal_ViewPublic_Index', $this->getPortalConfig()->container, array()); } $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT)); $categoryId = $this->_input->filterSingle('category_id', XenForo_Input::UINT); $category = $this->getPortalCategoryHelper()->assertCategoryValid($categoryId); $extraReturn = $this->getExtraContent($page, $category); if ($extraReturn && $extraReturn instanceof XenForo_ControllerResponse_Abstract) { return $extraReturn; } if ($category) { $categoryId = $category['category_id']; } else { $categoryId = 0; } $itemsPerPage = SimplePortal_Static::option('perPage'); if ($categoryId) { $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('portal/categories', $category, array('page' => $page))); } else { $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('portal', $category, array('page' => $page))); } $conditions = array('category_id' => $categoryId); $fetchOptions = array('perPage' => $itemsPerPage, 'page' => $page); $categories = $this->getModelFromCache('SimplePortal_Model_Category')->getAllCategories(); $fetchOptions = SimplePortal_Static::getItemModel()->getDefaultFetchOptions($fetchOptions); $fetchOptions += array('join' => SimplePortal_Model_PortalItem::FETCH_CATEGORY); $items = SimplePortal_Static::getItemModel()->getPortalItems($conditions, $fetchOptions); $items = SimplePortal_Static::getItemModel()->fetchPortalItemsData($items); $itemHandlers = SimplePortal_Static::getItemModel()->getPortalItemHandlerClasses(); $viewParams = array('items' => $items, 'itemCount' => count($items), 'totalItems' => SimplePortal_Static::getItemModel()->countItems($conditions), 'page' => $page, 'postsPerPage' => $itemsPerPage, 'categories' => $categories, 'handlerClasses' => $itemHandlers); if (isset($this->getPortalConfig()->showInlineAttachments) or !XenForo_Application::getOptions()->strip_portal_attachments) { $viewParams['showInlineAttachments'] = true; } if ($categoryId) { $viewParams += array('current_category' => $categories[$categoryId]); $viewParams += array('linkparams' => array('category_id' => $categoryId)); } else { $viewParams += array('current_category' => false); } return $this->wrapPage($viewParams); }
public static function prepareMessage($item, XenForo_BbCode_Parser $bbCodeParser, array $bbCodeOptions, XenForo_View $view) { $message = $item['data']['message']; if ($bbCodeOptions['states']['viewAttachments']) { $string = preg_replace('#\\[(quoteee)[^\\]]*\\].*\\[/\\1\\]#siU', ' ', $message); } else { $string = preg_replace('#\\[(attach|quote)[^\\]]*\\].*\\[/\\1\\]#siU', ' ', $message); } $formatter = XenForo_BbCode_Formatter_Base::create('ImageCount'); $parser = XenForo_BbCode_Parser::create($formatter); $parser->render($string); if (isset($item['data']['attachments'])) { $item['attachments'] = $item['data']['attachments']; } $item['mediaCount'] = $formatter->getMediaCount(); $item['message'] = XenForo_Helper_String::wholeWordTrim($string, SimplePortal_Static::option('charlimit')); $item['messageHtml'] = XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($item, $bbCodeParser, $bbCodeOptions); if (strpos($item['messageHtml'], SimplePortal_Static::PORTAL_PREVIEW_ENDSTRING)) { $item['messageHtml'] = strstr($item['messageHtml'], SimplePortal_Static::PORTAL_PREVIEW_ENDSTRING, true); } return $item; }