public function dodajAction()
 {
     $form = new Form_Catalog();
     $this->view->form = $form;
     $user_id = Zend_Auth::getInstance()->getIdentity()->id;
     $user_name = Zend_Auth::getInstance()->getIdentity()->username;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $dane = $form->getValues();
             $katalog = $dane['catalog'];
             $sciezka = 'userdata/' . $user_name . '/photos/' . $katalog;
             $obj = new Model_Catalog();
             $obj->setName($katalog);
             $obj->setPath($sciezka);
             $obj->setUsersId($user_id);
             $mapper = Model_CatalogMapper::getInstance();
             $wynik = $mapper->sprawdzNazwe($user_id, $katalog);
             if (!$wynik) {
                 $mapper->save($obj);
                 //$dir_name = iconv('UTF-8','cp1250', $sciezka);
                 $dir_name = $sciezka;
                 mkdir($dir_name);
                 $this->view->message = 'Dodano pomyślnie.';
             } else {
                 $this->view->message = 'Katalog o podanej nazwie już istnieje.';
             }
         } else {
             $this->view->message = 'Nieprawidłowa nazwa katalogu.';
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 编辑 文件编目
  */
 function actionCatalogEdit()
 {
     $this->_pathway->addStep('编辑文件编目信息');
     $id = $this->_context->id;
     $catalog = Catalog::find()->getById($id);
     if ($catalog->isNewRecord()) {
         return "{msg:'该记录不存在'}";
     }
     $form = new Form_Catalog(url('admin::dictmanager/catalogEdit'));
     $form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden'));
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         try {
             //修改并保存数据
             $catalog->changeProps($form->values());
             $catalog->save();
             return "{id:'{$id}', msg:'编辑成功'}";
         } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
             $form->invalidate($ex);
         }
     } else {
         if (!$this->_context->isPOST()) {
             $form->import($catalog);
         }
     }
     $this->_view['form'] = $form;
 }