/** * Удаляет короткую ссылку тизера * * @param Teasers $teaser * * @return bool */ public function delLink(Teasers $teaser) { $key = $this->getLinkKey($teaser->getEncryptedLink()); $this->redis()->delete($key); }
/** * Do something before content is loaded from DB * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $themesPages, $page_template; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: // Get Headlines $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsHeadlines.class.php'; if (file_exists($modulespath)) { for ($i = 0; $i < 5; $i++) { $visibleI = ''; if ($i > 0) { $visibleI = (string) $i; } $headlinesNewsPlaceholder = '{HEADLINES' . $visibleI . '_FILE}'; if (strpos($page->getContent(), $headlinesNewsPlaceholder) !== false || strpos($themesPages['index'], $headlinesNewsPlaceholder) !== false || strpos($themesPages['sidebar'], $headlinesNewsPlaceholder) !== false || strpos($page_template, $headlinesNewsPlaceholder) !== false) { $category = 0; $matches = array(); if (preg_match('/\\{CATEGORY_([0-9]+)\\}/', trim($themesPages['headlines' . $visibleI]), $matches)) { $category = $matches[1]; } $newsHeadlinesObj = new NewsHeadlines($themesPages['headlines' . $visibleI]); $homeHeadlines = $newsHeadlinesObj->getHomeHeadlines($category); $page->setContent(str_replace($headlinesNewsPlaceholder, $homeHeadlines, $page->getContent())); $themesPages['index'] = str_replace($headlinesNewsPlaceholder, $homeHeadlines, $themesPages['index']); $themesPages['sidebar'] = str_replace($headlinesNewsPlaceholder, $homeHeadlines, $themesPages['sidebar']); $page_template = str_replace($headlinesNewsPlaceholder, $homeHeadlines, $page_template); } } } // Get Top news $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsTop.class.php'; $topNewsPlaceholder = '{TOP_NEWS_FILE}'; if (file_exists($modulespath) && (strpos($page->getContent(), $topNewsPlaceholder) !== false || strpos($themesPages['index'], $topNewsPlaceholder) !== false || strpos($themesPages['sidebar'], $topNewsPlaceholder) !== false || strpos($page_template, $topNewsPlaceholder) !== false)) { $newsTopObj = new NewsTop($themesPages['top_news']); $homeTopNews = $newsTopObj->getHomeTopNews(); $page->setContent(str_replace($topNewsPlaceholder, $homeTopNews, $page->getContent())); $themesPages['index'] = str_replace($topNewsPlaceholder, $homeTopNews, $themesPages['index']); $themesPages['sidebar'] = str_replace($topNewsPlaceholder, $homeTopNews, $themesPages['sidebar']); $page_template = str_replace($topNewsPlaceholder, $homeTopNews, $page_template); } // Get News categories $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsLibrary.class.php'; $newsCategoriesPlaceholder = '{NEWS_CATEGORIES}'; if (file_exists($modulespath) && (strpos($page->getContent(), $newsCategoriesPlaceholder) !== false || strpos($themesPages['index'], $newsCategoriesPlaceholder) !== false || strpos($themesPages['sidebar'], $newsCategoriesPlaceholder) !== false || strpos($page_template, $newsCategoriesPlaceholder) !== false)) { $newsLib = new NewsLibrary(); $newsCategories = $newsLib->getNewsCategories(); $page->setContent(str_replace($newsCategoriesPlaceholder, $newsCategories, $page->getContent())); $themesPages['index'] = str_replace($newsCategoriesPlaceholder, $newsCategories, $themesPages['index']); $themesPages['sidebar'] = str_replace($newsCategoriesPlaceholder, $newsCategories, $themesPages['sidebar']); $page_template = str_replace($newsCategoriesPlaceholder, $newsCategories, $page_template); } // Get News Archives $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsLibrary.class.php'; $newsArchivePlaceholder = '{NEWS_ARCHIVES}'; if (file_exists($modulespath) && (strpos($page->getContent(), $newsArchivePlaceholder) !== false || strpos($themesPages['index'], $newsArchivePlaceholder) !== false || strpos($themesPages['sidebar'], $newsArchivePlaceholder) !== false || strpos($page_template, $newsArchivePlaceholder) !== false)) { $newsLib = new NewsLibrary(); $newsArchive = $newsLib->getNewsArchiveList(); $page->setContent(str_replace($newsArchivePlaceholder, $newsArchive, $page->getContent())); $themesPages['index'] = str_replace($newsArchivePlaceholder, $newsArchive, $themesPages['index']); $themesPages['sidebar'] = str_replace($newsArchivePlaceholder, $newsArchive, $themesPages['sidebar']); $page_template = str_replace($newsArchivePlaceholder, $newsArchive, $page_template); } // Get recent News Comments $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsRecentComments.class.php'; $newsCommentsPlaceholder = '{NEWS_RECENT_COMMENTS_FILE}'; if (file_exists($modulespath) && (strpos($page->getContent(), $newsCommentsPlaceholder) !== false || strpos($themesPages['index'], $newsCommentsPlaceholder) !== false || strpos($themesPages['sidebar'], $newsCommentsPlaceholder) !== false || strpos($page_template, $newsCommentsPlaceholder) !== false)) { $newsLib = new NewsRecentComments($themesPages['news_recent_comments']); $newsComments = $newsLib->getRecentNewsComments(); $page->setContent(str_replace($newsCommentsPlaceholder, $newsComments, $page->getContent())); $themesPages['index'] = str_replace($newsCommentsPlaceholder, $newsComments, $themesPages['index']); $themesPages['sidebar'] = str_replace($newsCommentsPlaceholder, $newsComments, $themesPages['sidebar']); $page_template = str_replace($newsCommentsPlaceholder, $newsComments, $page_template); } //Teasers $arrMatches = array(); // Set news teasers $config = \Env::get('config'); if ($config['newsTeasersStatus'] == '1') { // set news teasers in the content if (preg_match_all('/{TEASERS_([0-9A-Z_-]+)}/', $page->getContent(), $arrMatches)) { /** @ignore */ $objTeasers = new Teasers(); $content = $page->getContent(); $objTeasers->setTeaserFrames($arrMatches[1], $content); $page->setContent($content); } // set news teasers in the page design if (preg_match_all('/{TEASERS_([0-9A-Z_-]+)}/', $page_template, $arrMatches)) { /** @ignore */ $objTeasers = new Teasers(); $objTeasers->setTeaserFrames($arrMatches[1], $page_template); } // set news teasers in the website design if (preg_match_all('/{TEASERS_([0-9A-Z_-]+)}/', $themesPages['index'], $arrMatches)) { /** @ignore */ $objTeasers = new Teasers(); $objTeasers->setTeaserFrames($arrMatches[1], $themesPages['index']); } } break; default: break; } }
/** * @param null $id * @return Teasers|null * @throws CHttpException */ private function loadModel($id = null) { if ($this->_model === null) { $id = isset($_GET['id']) ? $_GET['id'] : $id; if ($id) { $this->_model = Teasers::model()->notDeleted()->with('tags', 'platforms')->findbyPk($id); } if ($this->_model === null) { throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.')); } } return $this->_model; }