コード例 #1
0
ファイル: Image.php プロジェクト: kstep/pnut
 public function actionMetadata($params)
 {
     $attachment = new Model_Attachment($this->getStorage(), $params['id']);
     if ($attachment->getId()) {
         $view = new View_Json();
         $view->id = $attachment->getId();
         $view->info = $attachment->toArray();
         if ($attachment->isImage() && $attachment->checkFile()) {
             $view->image = getimagesize($attachment->getFilepath());
         }
     } else {
         $this->imageNotFound();
     }
     return $view;
 }
コード例 #2
0
ファイル: Article.php プロジェクト: kstep/pnut
 public function actionDettach($params)
 {
     $view = $this->ajaxView('file');
     $view->state = 'failed';
     if ($params['id']) {
         $attachment = new Model_Attachment($this->getStorage(), $params['id']);
         $view->id = $attachment->getId();
         if ($view->id) {
             $this->canPerform($attachment, 'remove');
             $this->canPerform($attachment->getArticle(), 'edit');
             $view->state = 'removed';
             try {
                 $attachment->remove();
             } catch (Exception $e) {
                 $view->state = 'failed';
                 $view->error = $e->getMessage();
             }
         } else {
             $view->error = 'Attachment not found.';
         }
     } else {
         $view->error = 'Attachment ID is not set.';
     }
     return $view;
 }