Esempio n. 1
0
 public function renderTeaser2($code, $menuItemId = null, $lang = null, $params = array())
 {
     if (!isset($lang)) {
         $lang = CURR_LANG;
     }
     $teaserMapper = Teaser_Model_TeaserMapper::getInstance();
     //preview mode
     if (isset($params['preview_teaser_id'])) {
         //fetch all with code
         $teasers = $teaserMapper->fetchWithItems(array('lang' => $lang, 'active' => true, 'box_code' => $code, 'preview_teaser_id' => $params['preview_teaser_id'], 'preview_dt' => $params['preview_dt']));
     } elseif (isset($menuItemId)) {
         //try to speed up if we know the menu item, since we're caching them per page render
         $teasers = $teaserMapper->getActiveTeasers($lang, $menuItemId, $code);
     } else {
         //fetch all with code
         $teasers = $teaserMapper->fetchWithItems(array('lang' => $lang, 'active' => true, 'box_code' => $code));
     }
     //no teasers found
     if (count($teasers) == 0) {
         return;
     }
     //get first teaser
     /* @ var $teaser Teaser_Model_Teaser */
     $teaser = $this->getBestTeaser($teasers);
     $box = $teaserMapper->getBox($teaser->get_box_code());
     //get view
     $view = $this->getView();
     $view->assign(array('teaser' => $teaser, 'items' => $this->_processFeedbackItems($teaser->get_items()), 'box' => $box));
     return $view->render($box['template']);
 }
 public function indexAction()
 {
     $teaserId = $this->_getParam('preview_teaser_id');
     $previewDTIso = $this->_request->getParam('preview_dt');
     if (!isset($teaserId)) {
         throw new Exception('Slider not defined');
     }
     if (!isset($previewDTIso)) {
         throw new Exception('Date/time not defined');
     }
     $teaser = new Teaser_Model_Teaser();
     if (!Teaser_Model_TeaserMapper::getInstance()->find($teaserId, $teaser)) {
         throw new Exception('Slider not found');
     }
     echo $this->view->renderTeaser2($teaser->get_box_code(), null, CURR_LANG, array('preview_teaser_id' => $teaserId, 'active' => 'yes', 'preview_dt' => HCMS_Utils_Date::dateLocalToIso($previewDTIso)));
     $this->_helper->viewRenderer->setNoRender(true);
 }
Esempio n. 3
0
 /**
  * Get box configuration
  * @param string $boxCode
  * @return array|null
  */
 public function getBox($boxCode = null)
 {
     if (self::$_boxes === null) {
         //self::$_boxes = json_decode(file_get_contents($filePath), true);
         $boxes = HCMS_Utils::loadThemeConfig('boxes.php', 'teaser');
         foreach ($boxes as $code => $box) {
             if (isset($boxes[$code]['params']['images_dims'])) {
                 $section = isset($boxes[$code]['params']['images_section']) ? $boxes[$code]['params']['images_section'] : 'default';
                 $boxes[$code]['params']['images'] = $this->getImagesParams($boxes[$code]['params']['images_dims'], $section);
             }
         }
         self::$_boxes = $boxes;
     }
     if (isset($boxCode)) {
         if (isset(self::$_boxes[$boxCode])) {
             return self::$_boxes[$boxCode];
         } else {
             return null;
         }
     }
     return self::$_boxes;
 }
 public function getBoxCodes()
 {
     $codes = array();
     $teasers = Teaser_Model_TeaserMapper::getInstance()->fetchAll();
     /* @var $teaser Teaser_Model_Teaser */
     foreach ($teasers as $teaser) {
         $codes[$teaser->get_box_code()] = true;
     }
     return $codes;
 }
Esempio n. 5
0
 /**
  * Save relation teaser ids
  * 
  * @param Teaser_Model_Item $item 
  */
 protected function _saveTeaserIds(Teaser_Model_Item $item)
 {
     //get existing teaser ids
     $oldItem = new Teaser_Model_Item();
     $oldTeaserIds = array();
     if ($this->find($item->get_id(), $oldItem)) {
         $this->populateTeaserIds($oldItem);
         $oldTeaserIds = $oldItem->get_teaser_ids();
     }
     //new ids
     $teaserIds = $item->get_teaser_ids();
     $data = array('item_id' => $item->get_id());
     foreach ($teaserIds as $teaserId) {
         //new teaser
         if (!in_array($teaserId, $oldTeaserIds)) {
             $data['teaser_id'] = $teaserId;
             //put this item as last one
             if ($item->get_fallback() == 'yes') {
                 $data['order_num'] = 100000;
             } else {
                 $data['order_num'] = Teaser_Model_TeaserMapper::getInstance()->getMaxItemOrderNum($teaserId) + 1;
             }
             $this->_dbTable->getAdapter()->insert('teaser_has_items', $data);
         } else {
             $pos = array_search($teaserId, $oldTeaserIds);
             if ($pos !== false) {
                 unset($oldTeaserIds[$pos]);
             } elseif ($item->get_fallback() == 'yes' && $oldItem->get_fallback() != $item->get_fallback()) {
                 Teaser_Model_TeaserMapper::getInstance()->setItemOrder($teaserId, $item->get_id(), 100000);
             }
         }
     }
     //now delete pending old ids
     foreach ($oldTeaserIds as $oldTeaserId) {
         $this->_dbTable->getAdapter()->delete('teaser_has_items', array('teaser_id = ?' => $oldTeaserId, 'item_id = ?' => $item->get_id()));
     }
 }
 public function dirSelectAction()
 {
     $boxCode = $this->_getParam('box_code');
     $dir = $this->_getParam('dir');
     //get teaser box
     $box = Teaser_Model_TeaserMapper::getInstance()->getBox($boxCode);
     if (!isset($dir) || !isset($box) || !isset($box['params']['images'])) {
         return $this->_helper->json(array('success' => false, 'message' => 'Invalid parameters provided'));
     }
     //init file server
     Zend_Registry::set("fileserver_helper", $this->_fileHelper);
     $fileServer = new Admin_Model_FileServer();
     $result = $this->_browseFolder($dir, $box, $fileServer);
     if ($result === FALSE) {
         return $this->_helper->json(array('success' => false, 'message' => 'Directory not created'));
     }
     return $this->_helper->json(array('success' => true, 'message' => 'Selected', 'images' => $result));
 }