示例#1
0
 public function save()
 {
     $db = Zend_Registry::get('db');
     $config = Zend_Registry::get('config');
     $mapper = new SxModule_Sheets_Type_Mapper();
     $typeData = $mapper->toArray($this, 'item');
     $typeTsl = $mapper->toArray($this, 'tsl');
     if ($this->getId() == 0) {
         $db->insert('SheetsType', $typeData);
         $type_id = $db->lastInsertId();
         foreach ($config->system->language as $lng => $slng) {
             $typeTsl['lng'] = $lng;
             $typeTsl['type_id'] = $type_id;
             $db->insert('SheetsTypeTsl', $typeTsl);
         }
     } else {
         $type_id = $this->getId();
         $db->update('SheetsType', $typeData, 'type_id = ' . $type_id);
         $db->update('SheetsTypeTsl', $typeTsl, 'type_id = ' . $type_id . ' AND lng = \'' . $this->getLng() . '\'');
     }
     return $this;
 }
示例#2
0
 public function editAction()
 {
     SxCms_Acl::requireAcl('sheets', 'sheets.edit');
     $proxy = new SxModule_Sheets_Type_Proxy();
     $type_id = (int) $this->_getParam('id');
     $type = $proxy->getTypeById($type_id, $_SESSION['System']['lng']);
     if ($this->getRequest()->isPost()) {
         $mapper = new SxModule_Sheets_Type_Mapper();
         $fields = $mapper->fromInput($this->_getAllParams(), $this->_editablefields());
         $data = $mapper->toObject($fields, $type);
         $validator = new SxModule_Sheets_Type_Validator();
         if ($validator->validate($data)) {
             $data->save();
             $cache = Zend_Registry::get('cache');
             $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_Sheets_Type'));
             $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             $flashMessenger->addMessage('Type werd succesvol aangepast!');
             $this->_helper->redirector->gotoSimple('index', 'sheets_type');
         }
         $type = $data;
     }
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Sheets_Type');
     $this->view->type = $type;
 }