Esempio n. 1
0
 private function _renderFeaturedArea($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 area name required.'));
     }
     $areaName = $params[0];
     $pagesCount = isset($params[1]) && $params[1] ? $params[1] : self::AREA_PAGES_COUNT;
     $maxDescriptionLength = isset($params[2]) && is_numeric($params[2]) ? intval($params[2]) : self::AREA_DESC_LENGTH;
     $random = intval(end($params)) === 1 ? true : false;
     $featuredArea = Application_Model_Mappers_FeaturedareaMapper::getInstance()->findByName($areaName);
     if ($featuredArea === null) {
         if (!Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) {
             return '';
         }
         return $this->_translator->translate('Featured area ') . $areaName . $this->_translator->translate(' does not exist');
     }
     $featuredArea->setLimit($pagesCount)->setRandom($random);
     $this->_view->useImage = isset($params[3]) && ($params[3] == 'img' || $params[3] == 'imgc') ? $params[3] : false;
     $this->_view->faPages = $featuredArea->getPages();
     $this->_view->faId = $featuredArea->getId();
     $this->_view->faName = $featuredArea->getName();
     $this->_view->faPageDescriptionLength = $maxDescriptionLength;
     // adding cache tag for this fa
     array_push($this->_cacheTags, 'fa_' . $areaName);
     array_push($this->_cacheTags, 'pageTags');
     $areaPages = $featuredArea->getPages();
     foreach ($areaPages as $page) {
         array_push($this->_cacheTags, 'pageid_' . $page->getId());
     }
     return $this->_view->render('area.phtml');
 }
Esempio n. 2
0
 private function _processFaPull($pageId)
 {
     if (isset($this->_helper->session->faPull)) {
         $faPull = $this->_helper->session->faPull;
         foreach ($faPull as $key => $faId) {
             $fa = Application_Model_Mappers_FeaturedareaMapper::getInstance()->find($faId, false);
             $fa->addPage(Application_Model_Mappers_PageMapper::getInstance()->find($pageId));
             Application_Model_Mappers_FeaturedareaMapper::getInstance()->save($fa);
             unset($fa);
         }
         unset($this->_helper->session->faPull);
     }
 }
 private function _delete($id)
 {
     $faMapper = Application_Model_Mappers_FeaturedareaMapper::getInstance();
     $featuredArea = $faMapper->find($id);
     if ($featuredArea instanceof Application_Model_Models_Featuredarea) {
         return $faMapper->delete($featuredArea);
     }
 }