public static function runPageRankSculpting($siloId, $pageContent) { self::$_websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website'); $silo = Application_Model_Mappers_SiloMapper::getInstance()->find($siloId); $sculptingReplacement = array(); $links = Tools_Content_Tools::findLinksInContent($pageContent); if (empty($links) || !isset($links[1])) { return $pageContent; } $hrefs = array_combine($links[0], $links[1]); $siloedPagesUrls = array_merge(array(self::$_websiteHelper->getUrl() . 'index.html', self::$_websiteHelper->getUrl() . 'index.htm'), array_map(array('self', '_callbackUrls'), $silo->getRelatedPages())); foreach ($hrefs as $key => $href) { if (in_array($href, $siloedPagesUrls)) { unset($hrefs[$key]); continue; } $page = Application_Model_Mappers_PageMapper::getInstance()->findByUrl(str_replace(self::$_websiteHelper->getUrl(), '', $href)); if ($page === null) { continue; } $pageContent = str_replace($key, '<span class="' . md5($key) . '">' . $page->getNavName() . '</span>', $pageContent); $sculptingReplacement[] = array('id' => md5($key), 'repl' => $key); unset($page); } Zend_Registry::set('sculptingReplacement', json_encode($sculptingReplacement)); return $pageContent; }
public function ajaxcontentAction() { $currentPage = Application_Model_Mappers_PageMapper::getInstance()->find($this->getRequest()->getParam('pageId')); $currentPage = $currentPage == null ? array() : $currentPage->toArray(); $parseContent = new Tools_Content_Parser('{$' . $this->getRequest()->getParam('widget') . '}', $currentPage, array('websiteUrl' => $this->_helper->website->getUrl())); $this->_helper->response->success($parseContent->parseSimple()); }
protected function _load() { $this->_container = $this->_find(); $isPublished = $this->_checkPublished(); if (end($this->_options) == 'ajax') { $this->_view = new Zend_View(array('scriptPath' => dirname(__FILE__) . '/views')); $this->_view->websiteUrl = Zend_Controller_Action_HelperBroker::getStaticHelper('website')->getUrl(); $this->_view->type = $this->_type; $this->_view->name = $this->_name; if ($this->_pageId == null) { $page = Application_Model_Mappers_PageMapper::getInstance()->findByUrl($this->_toasterOptions['url']); $this->_pageId = $page->getId(); } $this->_view->pageId = $this->_pageId; $this->_view->isPublished = $isPublished; $this->_view->controls = Tools_Security_Acl::isAllowed($this) ? $this->_generateAdminControl(self::POPUP_WIDTH, self::POPUP_HEIGHT) : ''; $params = Zend_Json::encode(Zend_Controller_Front::getInstance()->getRequest()->getParams()); $this->_view->params = $params; $this->_cacheId = $this->_name . '_' . $this->_type . '_pid_' . $this->_pageId . '_' . Zend_Controller_Action_HelperBroker::getStaticHelper('Session')->getCurrentUser()->getRoleId() . substr(md5($params), 0, 27); return !$isPublished && !Tools_Security_Acl::isAllowed($this) ? '' : $this->_view->render('ajax.phtml'); } $content = $this->_container === null ? '' : $this->_container->getContent(); if (Tools_Security_Acl::isAllowed($this)) { $content .= $this->_generateAdminControl(self::POPUP_WIDTH, self::POPUP_HEIGHT); if ((bool) Zend_Controller_Action_HelperBroker::getStaticHelper('config')->getConfig('inlineEditor')) { $content = '<div class="container-wrapper ' . ($isPublished ? '' : 'unpublished') . '">' . $content . '</div>'; } elseif (!$isPublished) { $content = '<div class="unpublished">' . $content . '</div>'; } } else { $content = !$isPublished ? '' : $content; } return $content; }
private function _onContainerUpdateChain() { $page = Application_Model_Mappers_PageMapper::getInstance()->find($this->_object->getPageId()); if ($page !== null) { Tools_Search_Tools::removeFromIndex($page->getId()); Tools_Search_Tools::addPageToIndex($page); } }
private function _saveSiloPages($siloId, $pages) { if (!empty($pages)) { foreach ($pages as $page) { $page->setSiloId($siloId); Application_Model_Mappers_PageMapper::getInstance()->save($page); } } }
private function _findPagesListByCategoryName($categoryName) { $pageMapper = Application_Model_Mappers_PageMapper::getInstance(); $page = $pageMapper->findByNavName($categoryName); if (!$page instanceof Application_Model_Models_Page) { throw new Exceptions_SeotoasterWidgetException('There is no category with such name: ' . $categoryName); } return Application_Model_Mappers_PageMapper::getInstance()->findByParentId($page->getParentId() > 0 ? $page->getParentId() : $page->getId()); }
private function _renderFlatMenu() { $flatMenuPages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllStaticMenuPages(); if ($flatMenuPages && is_array($flatMenuPages) && !empty($flatMenuPages)) { $this->_view->staticPages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllStaticMenuPages(); return $this->_view->render('staticmenu.phtml'); } return ''; }
/** * $this->_object represents Application_Model_Models_Silo */ private function _cleanSiloPages() { $siloPages = $this->_object->getRelatedPages(); if (!empty($siloPages)) { array_map(function ($page) { $page->setSiloId(0); Application_Model_Mappers_PageMapper::getInstance()->save($page); }, $siloPages); } }
public static function renewIndex($forceCreate = false) { $pages = Application_Model_Mappers_PageMapper::getInstance()->getPagesForSearchIndex(); if (!is_array($pages)) { return false; } Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8'); Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive()); self::removeIndex() && self::initIndex(); array_walk($pages, array('Tools_Search_Tools', 'addPageToIndex')); self::$_index->optimize(); }
private function _renderFeaturedPage($params) { if (!is_array($params) || empty($params) || !isset($params[0]) || !$params[0] || preg_match('~^\\s*$~', $params[0])) { throw new Exceptions_SeotoasterWidgetException($this->_translator->translate('Featured page id required.')); } $page = Application_Model_Mappers_PageMapper::getInstance()->find(intval($params[0])); if ($page === null) { throw new Exceptions_SeotoasterWidgetException($this->_translator->translate('Page with such id is not found')); } $this->_view->useImage = isset($params[2]) && ($params[2] == 'img' || $params[2] == 'imgc') ? $params[2] : false; $this->_view->descLength = isset($params[1]) && is_numeric($params[1]) ? intval($params[1]) : self::AREA_DESC_LENGTH; $this->_view->page = $page; array_push($this->_cacheTags, 'pageid_' . $page->getId()); return $this->_view->render('page.phtml'); }
protected function _renderClassic() { $defaultPageUrl = Zend_Controller_Action_HelperBroker::getStaticHelper('website')->getUrl(); $crumbs = array($this->_translator->translate('Home') => $defaultPageUrl); if ($this->_toasterOptions['url'] != $defaultPageUrl && $this->_toasterOptions['parentId'] > 0) { $categoryPage = Application_Model_Mappers_PageMapper::getInstance()->find($this->_toasterOptions['parentId']); if (!$categoryPage instanceof Application_Model_Models_Page) { return $crumbs; } $crumbs[$categoryPage->getNavName()] = $categoryPage->getUrl(); } else { $crumbs[$this->_toasterOptions['navName']] = $this->_toasterOptions['url']; } $this->_view->crumbs = $crumbs; return $this->_view->render('crumbs.phtml'); }
public function getAction() { // at first we will try to find content by id if (($containerId = intval(filter_var($this->_request->getParam('id'), FILTER_SANITIZE_NUMBER_INT))) == 0) { $containerId = filter_var($this->_request->getParam('name'), FILTER_SANITIZE_STRING); } $pageId = $this->_request->getParam('pid', null); // return only content for the containers $contentOnly = $this->_request->getParam('co', false); $mapper = Application_Model_Mappers_ContainerMapper::getInstance(); $parser = new Tools_Content_Parser(null, array(), array('websiteUrl' => Zend_Controller_Action_HelperBroker::getStaticHelper('website')->getUrl())); // querying all containers if (!$containerId) { $containers = $mapper->fetchAll(); if (empty($containers)) { return $this->_error('404 Containers not found.', self::REST_STATUS_NOT_FOUND); } return array_map(function ($container) use($contentOnly, $parser, $pageId) { $container = $container->toArray(); $page = $pageId ? Application_Model_Mappers_PageMapper::getInstance()->find($pageId) : null; $parser->setPageData($page instanceof Application_Model_Models_Page ? $page->toArray() : array()); $container['content'] = $parser->setContent($container['content'])->parseSimple(); return $contentOnly ? array($container['name'] => $container['content']) : $container; }, $containers); } $type = $this->_request->getParam('type', Application_Model_Models_Container::TYPE_REGULARCONTENT); $pageId = $this->_request->getParam('pid', null); if ((int) $type == Application_Model_Models_Container::TYPE_STATICCONTENT) { $pageId = null; } $container = is_integer($containerId) ? $mapper->find($containerId) : $mapper->findByName($containerId, $pageId, $type); $pageId = $this->_request->getParam('pid', null); if (!$container instanceof Application_Model_Models_Container) { $container = new Application_Model_Models_Container(array('containerType' => $type, 'name' => $containerId)); } else { if (!$pageId) { $pageId = $container->getPageId(); } $page = $pageId ? Application_Model_Mappers_PageMapper::getInstance()->find($pageId) : null; $parser->setPageData($page instanceof Application_Model_Models_Page ? $page->toArray() : array())->setContent($container->getContent()); $container->setContent($parser->parseSimple()); } return $contentOnly ? array($container->getName() => $container->getContent()) : $container->toArray(); }
protected function _load() { $keywordCount = isset($this->_options[0]) ? $this->_options[0] : self::REL_WORD_COUNT; $keywords = $this->_prepareKeywords($this->_toasterOptions['metaKeywords']); $currPageId = $this->_toasterOptions['id']; $related = array(); if (sizeof($keywords) >= sizeof($keywordCount)) { $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAll('id != ' . $currPageId); foreach ($pages as $page) { $pageKeywords = $this->_prepareKeywords($page->getMetaKeywords()); if (sizeof(array_intersect($keywords, $pageKeywords)) >= $keywordCount) { $related[] = $page; } } } //$this->_view->descLength = (isset($this->_options[1])) ? $this->_options[1] : self::REL_DESC_LENGTH; $this->_view->descLength = self::REL_DESC_LENGTH; $this->_view->useImg = isset($this->_options[2]) ? $this->_options[2] : self::REL_USEIMAGE; $this->_view->related = $this->_options[1] >= sizeof($related) ? $related : array_slice($related, 0, $this->_options[1]); return $this->_view->render('related.phtml'); }
protected function _load() { $pagesList = array(); $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllMainMenuPages(); $configHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('config'); $showMemberPages = (bool) $configHelper->getConfig('memPagesInMenu'); $isAllowed = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PROTECTED); $flatPages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllStaticMenuPages(); $nomenuPages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllNoMenuPages(); foreach ($pages as $key => $page) { if ($page['parentId'] == 0) { if ((bool) $page['protected'] && !$isAllowed && !$showMemberPages) { continue; } $pagesList[$key]['category'] = $page; foreach ($pages as $subPage) { if (isset($subPage['protected']) && (bool) $subPage['protected'] && !$isAllowed && !$showMemberPages) { continue; } if ($subPage['parentId'] == $page['id']) { $pagesList[$key]['subPages'][] = $subPage; } } } } $this->_view->pages = $pagesList; $this->_view->flatPages = $flatPages; if (isset($this->_options[0])) { if ($this->_options[0] == 'nomenuPages') { $this->_view->nomenuPages = $nomenuPages; } } $newslogPlugin = Application_Model_Mappers_PluginMapper::getInstance()->findByName('newslog'); if ($newslogPlugin instanceof Application_Model_Models_Plugin) { if ($newslogPlugin->getStatus() == Application_Model_Models_Plugin::ENABLED) { $this->_view->newsFolder = Newslog_Models_Mapper_ConfigurationMapper::getInstance()->fetchConfigParam('folder'); } } return $this->_view->render('sitemap.phtml'); }
public function complexsearchAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $containersNames = $this->_request->getParam('containerNames'); $searchValues = $this->_request->getParam('searchValues'); $resultsPageId = filter_var($this->getRequest()->getParam('resultsPageId'), FILTER_VALIDATE_INT); $pageMapper = Application_Model_Mappers_PageMapper::getInstance(); $redirectPage = 'index.html'; if (!$resultsPageId === false) { $pageToRedirect = $pageMapper->find($resultsPageId); $redirectPage = $pageToRedirect->getUrl(); } else { $pageToRedirect = $pageMapper->fetchByOption(self::PAGE_OPTION_SEARCH); if (!empty($pageToRedirect)) { $redirectPage = $pageToRedirect[0]->getUrl(); } } $containerContentArray = array_combine($containersNames, $searchValues); $queryID = md5(serialize($containerContentArray)); $this->_helper->flashMessenger->addMessage($containerContentArray, $queryID); echo json_encode(array('redirect' => $this->_helper->website->getUrl() . $redirectPage . '?' . http_build_query(array('queryID' => $queryID)))); }
private function _generateCategoryOption() { if (isset($this->_options[1])) { $content = ''; switch ($this->_options[1]) { case 'name': $pageMapper = Application_Model_Mappers_PageMapper::getInstance(); $page = $pageMapper->find($this->_toasterOptions['id']); if (!$page instanceof Application_Model_Models_Page) { throw new Exceptions_SeotoasterWidgetException('Cant load page!'); } if ($page->getParentId() > 0) { $page = $pageMapper->find($page->getParentId()); $content = $page->getNavName(); } break; default: break; } return $content; } return ''; }
private function _renderSearchButton($options) { $searhResultPage = Application_Model_Mappers_PageMapper::getInstance()->fetchByOption(self::PAGE_OPTION_SEARCH); if (!empty($searhResultPage)) { $seacrhResultPageId = $searhResultPage[0]->getId(); } if (isset($options[0])) { $seacrhResultPageId = $options[0]; } if (isset($seacrhResultPageId)) { $this->_view->pageResultsPage = $seacrhResultPageId; return $this->_view->render('searchButton.phtml'); } }
/** * Fetch pages by given option * * @param string $option * @param bool $firstOccurrenceOnly If true returns only first element of the result array * @return array|null */ public function fetchByOption($option, $firstOccurrenceOnly = false) { $entries = array(); $optionTable = new Application_Model_DbTable_PageOption(); $optionRowset = $optionTable->find($option); if (!$optionRowset) { return null; } $optionRow = $optionRowset->current(); if (!$optionRow) { return null; } $pagesRowset = $optionRow->findManyToManyRowset('Application_Model_DbTable_Page', 'Application_Model_DbTable_PageHasOption'); foreach ($pagesRowset as $pageRow) { $templateRow = $pageRow->findParentRow('Application_Model_DbTable_Template'); $pageRow = $pageRow->toArray(); $pageRow['content'] = $templateRow !== null ? $templateRow->content : ''; $pageRow['extraOptions'] = Application_Model_Mappers_PageMapper::getInstance()->getDbTable()->fetchPageOptions($pageRow['id']); $select = $this->getDbTable()->getAdapter()->select()->from('container', array('uniqHash' => new Zend_Db_Expr("MD5(CONCAT_WS('-',`name`, COALESCE(`page_id`, 0), `container_type`))"), 'id', 'name', 'page_id', 'container_type', 'content', 'published', 'publishing_date'))->where('page_id IS NULL OR page_id = ?', $pageRow['id']); $pageRow['containers'] = $this->getDbTable()->getAdapter()->fetchAssoc($select); $entries[] = $this->_toModel($pageRow); } if ($firstOccurrenceOnly) { return isset($entries[0]) ? $entries[0] : null; } return $entries; }
private function _findFarowPages($faRow) { $faPages = array(); $rowsPageFeaturedarea = $faRow->findDependentRowset('Application_Model_DbTable_PageFeaturedarea'); foreach ($rowsPageFeaturedarea as $key => $rowPageFa) { $order = array_key_exists($rowPageFa->order, $faPages) ? array_search(end($faPages), $faPages) + 1 : $rowPageFa->order; $page = Application_Model_Mappers_PageMapper::getInstance()->find($rowPageFa->page_id); if ($page->getSystem()) { continue; } $faPages[$order] = Application_Model_Mappers_PageMapper::getInstance()->find($rowPageFa->page_id); } return $faPages; }
/** * Method returns list of templates or template content if id given in params (AJAX) * @return html || json */ public function gettemplateAction() { if ($this->getRequest()->isPost()) { $mapper = Application_Model_Mappers_TemplateMapper::getInstance(); $listtemplates = $this->getRequest()->getParam('listtemplates'); $additional = $this->getRequest()->getParam('additional'); $pageId = $this->getRequest()->getParam('pageId'); if ($pageId) { $page = Application_Model_Mappers_PageMapper::getInstance()->find($pageId); } $currentTheme = $this->_helper->config->getConfig('currentTheme'); //get template preview image $templatePreviewDir = $this->_websiteConfig['path'] . $this->_themeConfig['path'] . $currentTheme . DIRECTORY_SEPARATOR . $this->_themeConfig['templatePreview']; if ($templatePreviewDir && is_dir($templatePreviewDir)) { $tmplImages = Tools_Filesystem_Tools::findFilesByExtension($templatePreviewDir, '(jpg|gif|png)', false, true, false); } else { $tmplImages = array(); } $types = $mapper->fetchAllTypes(); if (array_key_exists($listtemplates, array_merge($types, array('all' => 'all')))) { $template = isset($page) && $page instanceof Application_Model_Models_Page ? $mapper->find($page->getTemplateId()) : $mapper->find($listtemplates); $this->view->templates = $this->_getTemplateListByType($listtemplates, $tmplImages, $currentTheme, $template instanceof Application_Model_Models_Template ? $template->getName() : ''); if (empty($this->view->templates) || !$this->view->templates) { $this->_helper->response->response($this->_translator->translate('Template not found'), true); return true; } $this->view->protectedTemplates = $this->_protectedTemplates; $this->view->types = $this->_sortTemplates($types); echo $this->view->render($this->getViewScript('templateslist')); } else { $template = $mapper->find($listtemplates); if ($template instanceof Application_Model_Models_Template) { $template = array('id' => $template->getId(), 'name' => $template->getName(), 'fullName' => $template->getName(), 'type' => $template->getType(), 'content' => $template->getContent(), 'preview' => isset($tmplImages[$template->getName()]) ? $this->_themeConfig['path'] . $currentTheme . '/' . $this->_themeConfig['templatePreview'] . $tmplImages[$template->getName()] : 'system/images/no_preview.png'); $this->_helper->response->response($template, true); } else { //$response = array('done'=> false); $this->_helper->response->response($this->_translator->translate('Template not found'), true); } } exit; } }
/** * Checks if file/image is linked in any content and return list of pages where it used * @param string $filename Name of file * @return array List of pages where file linked */ private function _checkFileInContent($filename) { $containers = Application_Model_Mappers_ContainerMapper::getInstance()->findByContent($filename); // formatting list of pages where image used in $usedOnPages = array(); if (!empty($containers)) { foreach ($containers as $container) { $page = Application_Model_Mappers_PageMapper::getInstance()->find($container->getPageId()); if ($page !== null && !in_array($page->getUrl(), $usedOnPages)) { array_push($usedOnPages, $page->getUrl()); } } } return $usedOnPages; }
/** * @todo Should me moved to the shopping plugin * @static * @return null */ public static function getProductCategoryPage() { // We need to know product category page url // This url specified in the bundle plugin "Shopping" // But this plugin may not be present in the system (not recommended) $shopping = Tools_Plugins_Tools::findPluginByName('shopping'); $pageUrl = $shopping->getStatus() == Application_Model_Models_Plugin::ENABLED ? Shopping::PRODUCT_CATEGORY_URL : null; if ($pageUrl === null) { return null; } return Application_Model_Mappers_PageMapper::getInstance()->findByUrl($pageUrl); }
private function _restoreOriginalValues($pageData) { $page = Application_Model_Mappers_PageMapper::getInstance()->find($pageData['pageId'], true); $pageData['h1'] = $page->getH1(); $pageData['headerTitle'] = $page->getHeaderTitle(); $pageData['navName'] = $page->getNavName(); $pageData['url'] = $this->_helper->page->clean($page->getUrl()); // TODO: review this part $pageData['metaKeywords'] = $page->getMetaKeywords(); $pageData['metaDescription'] = $page->getMetaDescription(); unset($page); return $pageData; }
protected function _load() { if (!is_array($this->_options) || empty($this->_options) || !isset($this->_options[0]) || !$this->_options[0] || preg_match('~^\\s*$~', $this->_options[0])) { throw new Exceptions_SeotoasterException($this->_translator->translate('You should provide a form name.')); } if (strtolower($this->_options[0]) == 'conversioncode') { return $this->_conversionCode($this->_options); } $sessionHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Session'); $useCaptcha = isset($this->_options[1]) && $this->_options[1] == 'captcha' ? true : false; $useRecaptcha = isset($this->_options[1]) && $this->_options[1] == 'recaptcha' ? true : false; $uploadLimitSize = is_numeric(end($this->_options)) ? end($this->_options) : self::UPLOAD_LIMIT_SIZE; $formMapper = Application_Model_Mappers_FormMapper::getInstance(); $pageMapper = Application_Model_Mappers_PageMapper::getInstance(); $form = $formMapper->findByName($this->_options[0]); $pageHelper = new Helpers_Action_Page(); $pageHelper->init(); if ($useCaptcha || $useRecaptcha) { if ($form != null) { $form->setCaptcha(1); $formMapper->save($form); } if ($useRecaptcha) { $recaptchaTheme = 'red'; $recaptchaWidgetId = uniqid('recaptcha_widget_'); if (isset($this->_options[2])) { $recaptchaTheme = $this->_options[2]; if ($recaptchaTheme == 'custom') { $this->_view->customRecaptcha = true; } } $this->_view->recaptchaWidgetId = $recaptchaWidgetId; $this->_view->addScriptPath($this->_websiteHelper->getPath() . 'seotoaster_core/application/views/scripts/backend/form/'); $this->_view->recaptchaCode = Tools_System_Tools::generateRecaptcha($recaptchaTheme, $recaptchaWidgetId); } if ($useCaptcha) { $this->_view->captchaId = Tools_System_Tools::generateCaptcha(); } } if (isset($sessionHelper->toasterFormError)) { $this->_view->toasterFormError = $sessionHelper->toasterFormError; unset($sessionHelper->toasterFormError); } if (isset($sessionHelper->toasterFormSuccess)) { $this->_view->toasterFormSuccess = $sessionHelper->toasterFormSuccess; unset($sessionHelper->toasterFormSuccess); } $trackingConversionUrl = 'form-' . $this->_options[0] . '-thank-you'; $trackingConversionUrl = $pageHelper->filterUrl($trackingConversionUrl); $trackingPageExist = $pageMapper->findByUrl($trackingConversionUrl); if ($trackingPageExist instanceof Application_Model_Models_Page) { $this->_view->trackingConversionUrl = $trackingConversionUrl; } $this->_view->useRecaptcha = $useRecaptcha; $this->_view->useCaptcha = $useCaptcha; $this->_view->form = Application_Model_Mappers_FormMapper::getInstance()->findByName($this->_options[0]); $this->_view->allowMidification = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL); $this->_view->formName = $this->_options[0]; $this->_view->uploadLimitSize = $uploadLimitSize; $filter = new Zend_Filter_Alnum(); $this->_view->formId = $filter->filter($this->_options[0]); $this->_view->pageId = $this->_toasterOptions['id']; $this->_view->websiteTmp = $this->_websiteHelper->getTmp(); $this->_view->formUrl = $this->_toasterOptions['url']; return $this->_view->render('form.phtml'); }
private function _massDeeplinkApply() { $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllByContent($this->_object->getName()); if (!empty($pages)) { foreach ($pages as $page) { Tools_Content_Tools::applyDeeplinkPerPage($this->_object, $page); } } }
private function _addConversionCode() { $pageMapper = Application_Model_Mappers_PageMapper::getInstance(); $seoDataMapper = Application_Model_Mappers_SeodataMapper::getInstance(); $seoDataModel = new Application_Model_Models_Seodata(); $seoData = $seoDataMapper->fetchAll(); if (empty($seoData)) { $seoDataModel->setSeoTop('{$form:conversioncode}'); $seoDataMapper->save($seoDataModel); } else { $seoTopData = $seoData[0]->getSeoTop(); $seoHeadData = $seoData[0]->getSeoHead(); $seoBottomData = $seoData[0]->getSeoBottom(); $id = $seoData[0]->getId(); if (!preg_match('~\\{\\$form\\:conversioncode\\}~', $seoTopData)) { $seoDataModel->setId($id); $seoDataModel->setSeoTop($seoTopData . ' {$form:conversioncode}'); $seoDataModel->setSeoHead($seoHeadData); $seoDataModel->setSeoBottom($seoBottomData); $seoDataMapper->save($seoDataModel); } } }
public function indexAction() { $page = null; $pageContent = null; $currentUser = $this->_helper->session->getCurrentUser(); // tracking referer if (!isset($this->_helper->session->refererUrl)) { $refererUrl = $this->getRequest()->getHeader('referer'); $currentUser->setReferer($refererUrl); $this->_helper->session->setCurrentUser($currentUser); $this->_helper->session->refererUrl = $refererUrl; } // Getting requested url. If url is not specified - get index.html $pageUrl = filter_var($this->getRequest()->getParam('page', Helpers_Action_Website::DEFAULT_PAGE), FILTER_SANITIZE_STRING); // Trying to do canonical redirects $this->_helper->page->doCanonicalRedirect($pageUrl); //Check if 301 redirect is present for requested page then do it $this->_helper->page->do301Redirect($pageUrl); // Loading page data using url from request. First checking cache, if no cache // loading from the database and save result to the cache $pageCacheKey = md5($pageUrl); if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_CACHE_PAGE)) { $page = $this->_helper->cache->load($pageCacheKey, 'pagedata_'); } // page is not in cache if ($page === null) { $page = Application_Model_Mappers_PageMapper::getInstance()->findByUrl($pageUrl); } // page found if ($page instanceof Application_Model_Models_Page) { $cacheTag = preg_replace('/[^\\w\\d_]/', '', $page->getTemplateId()); $this->_helper->cache->save($pageCacheKey, $page, 'pagedata_', array($cacheTag, 'pageid_' . $page->getId())); } // If page doesn't exists in the system - show 404 page if ($page === null) { //show 404 page and exit $page = Application_Model_Mappers_PageMapper::getInstance()->find404Page(); if (!$page instanceof Application_Model_Models_Page) { $this->view->websiteUrl = $this->_helper->website->getUrl(); $this->view->adminPanel = $this->_helper->admin->renderAdminPanel($this->_helper->session->getCurrentUser()->getRoleId()); $this->_helper->response->notFound($this->view->render('index/404page.phtml')); exit; } $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found'); $this->getResponse()->setHeader('Status', '404 File not found'); } //if requested page is not allowed - redirect to the signup landing page if (!Tools_Security_Acl::isAllowed($page)) { $signupLanding = Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_SIGNUPLAND); $this->_helper->redirector->gotoUrl($signupLanding instanceof Application_Model_Models_Page ? $this->_helper->website->getUrl() . $signupLanding->getUrl() : $this->_helper->website->getUrl()); } // Mobile switch if ((bool) $this->_config->getConfig('enableMobileTemplates')) { if ($this->_request->isGet() && $this->_request->has('mobileSwitch')) { $showMobile = filter_var($this->_request->getParam('mobileSwitch'), FILTER_SANITIZE_NUMBER_INT); if (!is_null($showMobile)) { $this->_helper->session->mobileSwitch = (bool) $showMobile; } } if (!isset($showMobile) && isset($this->_helper->session->mobileSwitch)) { $showMobile = $this->_helper->session->mobileSwitch; } else { $showMobile = $this->_helper->mobile->isMobile(); } // Mobile detect if ($showMobile === true) { $mobileTemplate = Application_Model_Mappers_TemplateMapper::getInstance()->find('mobile_' . $page->getTemplateId()); if (null !== $mobileTemplate) { $page->setTemplateId($mobileTemplate->getName())->setContent($mobileTemplate->getContent()); } unset($mobileTemplate); } } $pageData = $page->toArray(); //Parsing page content and saving it to the cache if ($pageContent === null) { $themeData = Zend_Registry::get('theme'); $parserOptions = array('websiteUrl' => $this->_helper->website->getUrl(), 'websitePath' => $this->_helper->website->getPath(), 'currentTheme' => $this->_config->getConfig('currentTheme'), 'themePath' => $themeData['path']); $parser = new Tools_Content_Parser($page->getContent(), $pageData, $parserOptions); $pageContent = $parser->parse(); unset($parser); unset($themeData); //$this->_helper->cache->save($page->getUrl(), $pageContent, 'page_'); } $pageContent = $this->_pageRunkSculptingDemand($page, $pageContent); // Finalize page generation routine $this->_complete($pageContent, $pageData, $parserOptions); }
/** * Serve sitemaps * */ public function sitemapAction() { //disable renderer $this->_helper->viewRenderer->setNoRender(true); //get sitemap type from the params if (($sitemapType = $this->getRequest()->getParam('type', '')) == Tools_Content_Feed::SMFEED_TYPE_REGULAR) { //regular sitemap.xml requested if (null === ($this->view->pages = $this->_helper->cache->load('sitemappages', 'sitemaps_'))) { if (in_array('newslog', Tools_Plugins_Tools::getEnabledPlugins(true))) { $this->view->newsPageUrlPath = Newslog_Models_Mapper_ConfigurationMapper::getInstance()->fetchConfigParam('folder'); } $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAll(); if (is_array($pages) && !empty($pages)) { $quoteInstalled = Tools_Plugins_Tools::findPluginByName('quote')->getStatus() == Application_Model_Models_Plugin::ENABLED; $pages = array_filter($pages, function ($page) use($quoteInstalled) { if ($page->getExtraOption(Application_Model_Models_Page::OPT_PROTECTED) || $page->getDraft() || $page->getIs404page() || $quoteInstalled && intval($page->getParentId()) === Quote::QUOTE_CATEGORY_ID) { return false; } return true; }); } else { $pages = array(); } $this->view->pages = $pages; $this->_helper->cache->save('sitemappages', $this->view->pages, 'sitemaps_', array('sitemaps')); } } else { if ($sitemapType == Tools_Content_Feed::SMFEED_TYPE_INDEX) { //default sitemaps $sitemaps = array('sitemap' => array('extension' => 'xml', 'lastmod' => date(DATE_ATOM)), 'sitemapnews' => array('extension' => 'xml', 'lastmod' => date(DATE_ATOM))); //real sitemaps (in the toaster root) $sitemapFiles = Tools_Filesystem_Tools::findFilesByExtension($this->_helper->website->getPath(), 'xml', false, false, false); if (is_array($sitemapFiles) && !empty($sitemapFiles)) { foreach ($sitemapFiles as $sitemapFile) { if (preg_match('~sitemap.*\\.xml.*~', $sitemapFile)) { $fileInfo = pathinfo($this->_helper->website->getPath() . $sitemapFile); if (is_array($fileInfo)) { $sitemaps[$fileInfo['filename']] = array('extension' => $fileInfo['extension'], 'lastmod' => date(DATE_ATOM, fileatime($this->_helper->website->getPath() . $sitemapFile))); } } } } $this->view->sitemaps = $sitemaps; } } $template = 'sitemap' . $sitemapType . '.xml.phtml'; if (null === ($sitemapContent = $this->_helper->cache->load($sitemapType, Helpers_Action_Cache::PREFIX_SITEMAPS))) { try { $sitemapContent = $this->view->render('backend/seo/' . $template); } catch (Zend_View_Exception $zve) { // Try to find plugin's sitemap try { $sitemapContent = Tools_Plugins_Tools::runStatic('getSitemap', $sitemapType); if (!$sitemapContent) { $sitemapContent = Tools_Plugins_Tools::runStatic('getSitemap' . ucfirst($sitemapType)); } } catch (Exception $e) { Tools_System_Tools::debugMode() && error_log($e->getMessage()); $sitemapContent = false; } if ($sitemapContent === false) { $this->getResponse()->setHeader('Content-Type', 'text/html', true); return $this->forward('index', 'index', null, array('page' => 'sitemap' . $sitemapType . '.xml')); } } $this->_helper->cache->save($sitemapType, $sitemapContent, Helpers_Action_Cache::PREFIX_SITEMAPS, array('sitemaps'), Helpers_Action_Cache::CACHE_WEEK); } echo $sitemapContent; }
public function rempagefromfaAction() { if ($this->getRequest()->isPost()) { $page = Application_Model_Mappers_PageMapper::getInstance()->find($this->getRequest()->getParam('pid')); $fa = Application_Model_Mappers_FeaturedareaMapper::getInstance()->find($this->getRequest()->getParam('faid'), false); $fa->registerObserver(new Tools_Featured_GarbageCollector(array('action' => Tools_System_GarbageCollector::CLEAN_ONUPDATE))); if (!$fa instanceof Application_Model_Models_Featuredarea) { } if (!$page instanceof Application_Model_Models_Page) { //page is no created yet, but we want to add it to fa $faPull = $this->_helper->session->faPull; if (is_array($faPull) && !empty($faPull)) { if (in_array($fa->getId(), $faPull)) { unset($faPull[array_search($fa->getId(), $faPull)]); $this->_helper->session->faPull = $faPull; } } $this->_helper->response->success($this->_helper->language->translate('Page removed from featured area')); //return; } $fa->deletePage($page); Application_Model_Mappers_FeaturedareaMapper::getInstance()->save($fa); $fa->notifyObservers(); $this->_helper->response->success($this->_helper->language->translate('Page removed from featured area')); } }