public function editAction()
 {
     SxCms_Acl::requireAcl('block', 'block.edit');
     $proxy = new SxModule_Contentblock_Proxy();
     $block = $proxy->getById((int) $this->_getParam('id'), $_SESSION['System']['lng']);
     $block->setTmx($this->tmx);
     if ($this->getRequest()->isPost()) {
         $mapper = new SxModule_Contentblock_Mapper();
         $fields = $mapper->fromInput($this->_getAllParams(), $this->_editablefields());
         $data = $mapper->toObject($fields, $block);
         $validator = new SxModule_Contentblock_Validator();
         if ($validator->validate($data)) {
             $block->save($this->_editablefields());
             $cache = Zend_Registry::get('cache');
             $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_Contentblock'));
             $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             $flashMessenger->addMessage($this->admin_tmx->_('contentblockedited'));
             $this->_helper->redirector->gotoSimple('index', 'contentblock');
         }
         $item = $data;
     }
     $this->view->block = $block;
     $this->view->hidden = 'hidden';
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Contentblock');
 }
예제 #2
0
 public function save($params = '*', $tsl_params = '*')
 {
     $db = Zend_Registry::get('db');
     $mapper = new SxModule_Contentblock_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()) {
         $db->update('ContentBlocks', $data, 'id = ' . (int) $this->getId());
         $db->update('ContentBlocksTsl', $tslData, 'b_id = ' . (int) $this->getId() . ' AND lng = ' . $db->quote($this->getLng()));
     } else {
         $db->insert('ContentBlocks', $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('ContentBlocksTsl', $tslData);
         }
     }
     return $this;
 }