protected function _toHtml() { if (!AW_Kbase_Helper_Data::getFrontendEnabled()) { return ''; } return parent::_toHtml(); }
protected function _toHtml() { if (!AW_Kbase_Helper_Data::getFrontendEnabled()) { return ''; } if (!Mage::getStoreConfig('kbase/search/enabled')) { return ''; } return parent::_toHtml(); }
protected function _toHtml() { if (!AW_Kbase_Helper_Data::getFrontendEnabled()) { return ''; } if (!Mage::getStoreConfig('kbase/category/enabled')) { return ''; } $this->setCategories(Mage::getResourceModel('kbase/article')->getCategoryWithArticleList(Mage::getStoreConfig('kbase/category/count'))); return parent::_toHtml(); }
protected function _toHtml() { if (!AW_Kbase_Helper_Data::getFrontendEnabled()) { return ''; } $this->_readBlock('search'); $this->_readBlock('category'); $this->_readBlock('top'); $this->_readBlock('latest'); $this->_readBlock('tag'); asort($this->_blocks); return parent::_toHtml(); }
protected function _toHtml() { if (!AW_Kbase_Helper_Data::getFrontendEnabled()) { return ''; } if (!Mage::getStoreConfig('kbase/latest/enabled')) { return ''; } $collection = Mage::getResourceModel('kbase/article_collection')->addStatusFilter()->setStoreFilter()->applySorting(AW_Kbase_Model_Source_Sorting::BY_DATE, AW_Kbase_Model_Source_Sorting::SORT_DESC)->limit(Mage::getStoreConfig('kbase/latest/count')); $collection->getSelect()->distinct(); $collection->load(); $this->setArticles($collection); return parent::_toHtml(); }
protected function _toHtml() { if (!AW_Kbase_Helper_Data::getFrontendEnabled()) { return ''; } if (!Mage::getStoreConfig('kbase/tag/enabled')) { return ''; } $autoSize = Mage::getStoreConfig('kbase/tag/auto_size'); $tagMaxCount = AW_Kbase_Model_Mysql4_Article::getTagMaxCount(); if (!$tagMaxCount) { $autoSize = false; } $this->setAutoSize($autoSize); $this->setTagMaxCount($tagMaxCount); $this->setTags(AW_Kbase_Model_Mysql4_Article::getAllTags($autoSize)); return parent::_toHtml(); }
protected function _checkFrontendEnabled() { if (AW_Kbase_Helper_Data::isModuleOutputDisabled() || !AW_Kbase_Helper_Data::getFrontendEnabled()) { $this->_redirect('noroute'); } }
public static function matchUrl(Zend_Controller_Request_Http $request) { if (AW_Kbase_Helper_Data::isModuleOutputDisabled() || !AW_Kbase_Helper_Data::getFrontendEnabled()) { return false; } $urlKey = self::getModuleUrlKey(); $pathInfo = $request->getPathInfo(); $requestUri = $request->getRequestUri(); if ($request->getParam('___from_store')) { $_fromStore = Mage::app()->getSafeStore($request->getParam('___from_store')); if ($_fromStore->getData()) { $_oldUrlKey = self::getModuleUrlKeyFromConfig($_fromStore); if (strpos($pathInfo, '/' . $_oldUrlKey) === 0 && $_oldUrlKey != $urlKey) { $_newUrl = self::secureUrl(Mage::getBaseUrl() . $urlKey . '/'); $response = Mage::app()->getResponse(); $response->setRedirect($_newUrl); $response->sendHeaders(); $request->setDispatched(true); return true; } } } if (0 !== strpos($pathInfo, '/' . $urlKey . '/')) { // if path does not begin with /kbase/ return false; } $pathInfo = substr($pathInfo, strlen($urlKey) + 2); $request->setModuleName('kbase')->setControllerName('article'); if (!strlen($pathInfo)) { $request->setActionName('index'); return AW_Kbase_Helper_Data::getFrontendEnabled() && self::cacheRewrite($request->getPathInfo(), 'kbase/article/index'); } $urlKeySuffix = self::getUrlKeySuffix(); $isArticle = false; if (!$urlKeySuffix) { $_path = explode('/', $pathInfo); $_aUrl = false; if (count($_path) == 1) { $_aUrl = $_path[0]; } if (count($_path) == 2) { $_aUrl = $_path[1]; } if ($_aUrl) { $_aUrl = urldecode($_aUrl); $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_aUrl); if (!$_aId) { $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_aUrl, true); } if ($_aId) { $isArticle = true; } } } /** * Checking is customer comes from other store view * having various article suffix id in comparison * with current */ if ($request->getParam('___from_store') && !$isArticle) { if (!isset($_fromStore)) { $_fromStore = Mage::app()->getSafeStore($request->getParam('___from_store')); } if ($_fromStore->getData()) { $_oldUrlSuffix = self::getUrlKeySuffixFromConfig($_fromStore); if ($urlKeySuffix != $_oldUrlSuffix) { $_path = explode('/', $pathInfo); $_aUrl = false; if (count($_path) == 1) { $_aUrl = $_path[0]; } if (count($_path) == 2) { $_aUrl = $_path[1]; } if ($_aUrl) { $_articleUrlKey = substr($_aUrl, 0, strpos($_aUrl, $_oldUrlSuffix)); $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_articleUrlKey); if (!$_aId) { $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_articleUrlKey, true); } if ($_aId) { $_storeIds = Mage::getModel('kbase/article')->getResource()->getArticleStoreIds($_aId); if (in_array(Mage::app()->getStore()->getId(), $_storeIds)) { $_newUrl = self::secureUrl(Mage::getBaseUrl() . $urlKey . '/' . $_articleUrlKey . $urlKeySuffix); $response = Mage::app()->getResponse(); $response->setRedirect($_newUrl); $response->sendHeaders(); $request->setDispatched(true); return true; } } } } } } if ($urlKeySuffix && '/' != $urlKeySuffix && $urlKeySuffix == substr($pathInfo, -strlen($urlKeySuffix)) || $isArticle) { $pathInfo = substr($pathInfo, 0, strlen($pathInfo) - strlen($urlKeySuffix)); $path = explode('/', $pathInfo); if (count($path) == 1) { $request->setActionName('article'); self::$_queryParams[self::URL_PARAM_NAME_ARTICLE] = $path[0]; return self::cacheRewrite($request->getPathInfo(), 'kbase/article/article/' . self::URL_PARAM_NAME_ARTICLE . '/' . $path[0]); } elseif (count($path) == 2) { $request->setActionName('article'); self::$_queryParams[self::URL_PARAM_NAME_CATEGORY] = $path[0]; self::$_queryParams[self::URL_PARAM_NAME_ARTICLE] = $path[1]; return self::cacheRewrite($request->getPathInfo(), 'kbase/article/article/' . self::URL_PARAM_NAME_CATEGORY . '/' . $path[0] . '/' . self::URL_PARAM_NAME_ARTICLE . '/' . $path[1]); } return false; } // since further there will be listing pages only, we should check the condition here if (!Mage::getStoreConfig('kbase/general/frontent_enabled')) { return false; } // init parameters with optional ones self::$_queryParams = array(self::URL_PARAM_NAME_LIMIT => false, self::URL_PARAM_NAME_PAGE => false, self::URL_PARAM_NAME_SORT => false, self::URL_PARAM_NAME_SORT_DIR => false, self::URL_PARAM_NAME_QUERY => false); $pathInfo = substr($pathInfo, 0, strlen($pathInfo) - 1); $path = explode('/', $pathInfo); for ($i = count($path) - 1; $i > 0; $i -= 2) { $paramName = $path[$i - 1]; if (array_key_exists($paramName, self::$_queryParams)) { // for(; $path[$i] != $decoded = urldecode($path[$i]); $path[$i] = $decoded); // self::$_queryParams[$paramName] = $path[$i]; self::$_queryParams[$paramName] = urldecode($path[$i]); unset($path[$i]); unset($path[$i - 1]); } } foreach (self::$_queryParams as $paramName => $value) { if ($value = self::getQueryParam($requestUri, $paramName)) { self::$_queryParams[$paramName] = urldecode($value); $requestUri = self::unsetQueryParam($requestUri, $paramName); } } if (1 == count($path)) { if ('search' == $path[0]) { // if there were known parameters passed as query params if ($requestUri != $request->getRequestUri()) { foreach (self::$_queryParams as $name => $value) { if ($value) { self::$_queryParams[$name] = self::encodeSpecialChars($value); } } Mage::app()->getFrontController()->getResponse()->setRedirect(self::getUrl(self::URL_TYPE_SEARCH, self::$_queryParams))->sendResponse(); exit; } $request->setActionName('search'); return true; } $request->setActionName('category'); self::$_queryParams[self::URL_PARAM_NAME_CATEGORY] = $path[0]; return true; } elseif (2 == count($path) && 'tag' == $path[0] && $path[1]) { $request->setActionName('tag'); self::$_queryParams[self::URL_PARAM_NAME_TAG] = $path[1]; return true; } return false; }
protected function _toHtml() { if (!AW_Kbase_Helper_Data::getFrontendEnabled()) { return ''; } $this->_prepareCollection(); if ($sorter = $this->getChild('kbase_sorter')) { list($sortOrder, $sortDir) = $sorter->getCurrentSorting(); if ($sortOrder) { $this->_collection = $this->_collection->applySorting($sortOrder, $sortDir); } } if ($pager = $this->getChild('kbase_pager')) { $this->_collection = $pager->setCollection($this->_collection)->getCollection(); } return parent::_toHtml(); }