예제 #1
0
 public function indexAction()
 {
     if ($this->getRequest()->isPost()) {
         $paramCancel = $this->getRequest()->getParam('cancel');
         $cancelButtonPressed = isset($paramCancel);
         if ($cancelButtonPressed) {
             $this->defaultNamespace->returningAction = 'ce/editkeytable/index';
             switch ($this->defaultNamespace->callingAction) {
                 case 'ce/edit/index':
                     $this->_forward("index", "edit", "ce", array("CAEX_ID" => $this->defaultNamespace->callingActionId));
                     break;
                 case 'ce/editkeytable/list':
                     $this->_forward("list", "editkeytable", "ce");
                     break;
                 default:
                     throw new Zend_Exception();
                     break;
             }
         }
         if ($this->form->isValid($this->getRequest()->getParams())) {
             $upload = $this->form->uploadElement->getTransferAdapter();
             $filename = $this->form->uploadElement->getFilename(null, false);
             $upload->receive();
             //insert/update
             $ktTable = new KeyTable();
             $data = array(KeyTable::COL_NAME => $this->form->getValue(KeyTable::COL_NAME), KeyTable::COL_FILENAME => $filename);
             $this->ktId = $ktTable->insert($data);
             //$this->redirectTo('inserted');
             //$this->inserted();
             if ($this->defaultNamespace->callingActionId != null) {
                 $this->defaultNamespace->returningAction = 'ce/editkeytable/index';
                 $this->defaultNamespace->returningActionId = $this->ktId;
                 $this->_forward("index", "edit", "ce", array("CAEX_ID" => $this->defaultNamespace->callingActionId));
             } else {
                 $this->redirectTo('list');
             }
         } else {
             //not valid
         }
     } else {
         //not post
         $this->form->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/ce/editkeytable/index');
     }
     $this->view->form = $this->form;
 }