public function editAction()
 {
     SxCms_Acl::requireAcl('topcontentblock', 'topcontentblock.edit');
     $id = (int) $this->_getParam('id');
     $proxy = new SxModule_Topcontentblock_Proxy();
     $block = $proxy->getById($id, $_SESSION['System']['lng']);
     if ($this->getRequest()->isPost()) {
         $mapper = new SxModule_Topcontentblock_Mapper();
         $fields = $mapper->fromInput($this->_getAllParams(), $this->_editablefields());
         $data = $mapper->toObject($fields, $block);
         $validator = new SxModule_Topcontentblock_Validator();
         if ($validator->validate($data)) {
             $this->_imageResizeAndSave($block);
             $block->save();
             $cache = Zend_Registry::get('cache');
             $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_Topcontentblock'));
             $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             $flashMessenger->addMessage($this->admin_tmx->_('itemedited'));
             $this->_helper->redirector->gotoSimple('index', 'topcontentblock');
         }
         $item = $data;
     }
     $this->view->block = $block;
     $this->view->hidden = 'hidden';
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Topcontentblock');
 }
Пример #2
0
 public function save($params = '*', $tsl_params = '*')
 {
     $db = Zend_Registry::get('db');
     $mapper = new SxModule_Topcontentblock_Mapper();
     $data = $mapper->toArray($this, 'item');
     $tslData = $mapper->toArray($this, 'tsl');
     if (is_array($params)) {
         $data = $mapper->fromInput($data, $params);
     }
     if (is_array($tsl_params)) {
         $tslData = $mapper->fromInput($tslData, $tsl_params);
     }
     if ($this->getId()) {
         $tslData['lng'] = $_SESSION['System']['lng'];
         $db->update('TopcontentBlocks', $data, 'id = ' . (int) $this->getId());
         $db->update('TopcontentBlocksTsl', $tslData, 'b_id = ' . (int) $this->getId() . ' AND lng = ' . $db->quote($_SESSION['System']['lng']));
     } else {
         $db->insert('TopcontentBlocks', $data);
         $this->setId($db->lastInsertId());
         $config = Zend_Registry::get('config');
         foreach ($config->system->language as $lng => $slng) {
             $tslData['lng'] = $lng;
             $tslData['b_id'] = (int) $this->getId();
             $db->insert('TopcontentBlocksTsl', $tslData);
         }
     }
     return $this;
 }