コード例 #1
0
ファイル: Documents.php プロジェクト: posiadacz/wsm
 private function parseRow($row)
 {
     if ($row == null) {
         return null;
     }
     $news = new Wsm_Document();
     $news->setId($row['id']);
     $news->setTitle($row['title']);
     $news->setFilename($row['filename']);
     $news->setImportance($row['importance']);
     $news->setType($row['type']);
     $news->setCategory($row['category']);
     $news->setOrder($row['order']);
     $news->setArchived($row['archived'] == '1');
     return $news;
 }
コード例 #2
0
ファイル: DocumentsController.php プロジェクト: posiadacz/wsm
 public function saveAction()
 {
     $news = new Wsm_Document();
     if ($this->has('id')) {
         $news->setId($this->get('id'));
     }
     $news->setTitle($this->get('title'));
     $news->setType($this->get('type'));
     $news->setCategory($this->get('category'));
     $news->setImportance($this->get('importance'));
     $file = $_FILES['file'];
     if (!empty($file) && !empty($file['name'])) {
         $filename = $file['name'];
         $uploadDir = '/documents/';
         $filePath = $uploadDir . $filename;
         if (file_exists($filePath)) {
             unlink($filePath);
         }
         if (!move_uploaded_file($file['tmp_name'], $filePath)) {
             $this->redirect($this->getBaseUrl() . '&msg=save_error', true);
         }
         $news->setFilename($filename);
     } else {
         $news->setFilename($this->get('filename'));
     }
     $newsDb = new Wsm_Db_Documents();
     try {
         $newsDb->save($news);
         $this->redirect($this->getBaseUrl() . '&msg=saved', true);
     } catch (Exception $e) {
         $this->redirect($this->getBaseUrl() . '&msg=save_error', true);
     }
 }