Esempio n. 1
0
 public function editAction()
 {
     SxCms_Acl::requireAcl('sheets', 'sheets.edit');
     $proxy = new SxModule_Sheets_Type_Proxy();
     $this->view->types = $proxy->getAllActive($_SESSION['System']['lng']);
     $proxy = new SxModule_Sheets_Proxy();
     $sheets = $proxy->getById((int) $this->_getParam('id'));
     $subcat = new SxModule_Sheets_Subtype_Proxy();
     $this->view->subcat = $subcat->getAllbyType($sheets->getType(), $_SESSION['System']['lng'], true);
     if ($this->getRequest()->isPost()) {
         $mapper = new SxModule_Sheets_Mapper();
         $fields = $mapper->fromInput($this->_getAllParams(), $this->_editablefields());
         $data = $mapper->toObject($fields, $sheets);
         $this->uploadFile($data, $this->_getParam('type'), $this->_getParam('subtype'));
         $validator = new SxModule_Sheets_Validator();
         if ($validator->validate($data)) {
             $data->save();
             $cache = Zend_Registry::get('cache');
             $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('SxModule_Sheets'));
             $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             $flashMessenger->addMessage($this->admin_tmx->_('itemedited'));
             $this->_helper->redirector->gotoSimple('index', 'sheets');
         }
         $sheets = $data;
     }
     $this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Sheets');
     $this->view->item = $sheets;
 }
Esempio n. 2
0
 public function save($params = '*', $tsl_params = '*')
 {
     $db = Zend_Registry::get('db');
     $mapper = new SxModule_Sheets_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() == 0) {
         $config = Zend_Registry::get('config');
         $data['date_created'] = new Zend_Db_Expr('NOW()');
         $data['date_updated'] = new Zend_Db_Expr('NOW()');
         $db->insert('Sheets', $data);
         $this->setId($db->lastInsertId());
         $tslData['s_id'] = $this->getId();
         foreach ($config->system->language as $lng => $slng) {
             $tslData['lng'] = $lng;
             $db->insert('SheetsTsl', $tslData);
         }
     } else {
         $data['date_updated'] = new Zend_Db_Expr('NOW()');
         $db->update('Sheets', $data, 'id = ' . (int) $this->getId());
         $tslData['s_id'] = $this->getId();
         $db->update('SheetsTsl', $tslData, 's_id = ' . (int) $this->getId() . ' AND lng = ' . $db->quote($this->getLng()));
     }
 }