Exemplo n.º 1
0
 public function postTN()
 {
     PHPWS_Core::initModClass('filecabinet', 'Image.php');
     if ($_POST['type'] == 'mm') {
         PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
         $obj = new PHPWS_Multimedia($_POST['id']);
         if (!$obj->id) {
             return false;
         }
     }
     $thumb = PHPWS_Settings::get('filecabinet', 'max_thumbnail_size');
     $image = new PHPWS_Image();
     $image->setMaxWidth($thumb);
     $image->setMaxHeight($thumb);
     if (!$image->importPost('thumbnail')) {
         return false;
     }
     if ($obj->isVideo() && $image->file_type != 'image/jpeg' && $image->file_type != 'image/jpg') {
         return false;
     }
     if (!$obj->embedded) {
         $image->file_directory = $obj->thumbnailDirectory();
         $image->file_name = $obj->dropExtension() . '.' . $image->getExtension();
     } else {
         $image->file_directory = 'files/multimedia/folder' . $obj->folder_id . '/tn/';
     }
     $image->write();
     $image->resize($image->file_directory . $image->file_name, $image->getMaxWidth(), $image->getMaxHeight(), true);
     if ($obj->_classtype == 'multimedia') {
         $obj->thumbnail = $image->file_name;
         $obj->save(false, false);
     }
     return true;
 }
Exemplo n.º 2
0
 private function saveFile(\Request $request)
 {
     switch ($request->getVar('ftype')) {
         case DOCUMENT_FOLDER:
             PHPWS_Core::initModClass('filecabinet', 'Document.php');
             $doc = new PHPWS_Document($request->getVar('file_id'));
             $doc->setTitle($request->getVar('title'));
             $doc->save(false);
             break;
         case IMAGE_FOLDER:
             PHPWS_Core::initModClass('filecabinet', 'Image.php');
             $img = new PHPWS_Image($request->getVar('file_id'));
             $img->setTitle($request->getVar('title'));
             $img->save(false, false, false);
             break;
         case MULTIMEDIA_FOLDER:
             PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
             $mm = new PHPWS_Multimedia($request->getVar('file_id'));
             $mm->setTitle($request->getVar('title'));
             $mm->save(false, false);
             break;
     }
 }