Exemplo n.º 1
0
/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 * @version $Id$
 */
function filecabinet_document($file_type = null, $file_id = null)
{
    if (empty($file_type) || empty($file_id)) {
        return null;
    }
    if ($file_type == 'doc') {
        PHPWS_Core::initModClass('filecabinet', 'Document.php');
        $document = new PHPWS_Document((int) $file_id);
        if (empty($document->id)) {
            $document->logErrors();
            return NULL;
        }
        return $document->getViewLink(TRUE);
    } elseif ($file_type == 'image') {
        PHPWS_Core::initModClass('filecabinet', 'Image.php');
        $image = new PHPWS_Image((int) $file_id);
        if (empty($image->id)) {
            $image->logErrors();
            return NULL;
        }
        return $image->getTag();
    } elseif ($file_type == 'mm' || $file_type == 'media') {
        PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
        $multimedia = new PHPWS_Multimedia((int) $file_id);
        if (empty($multimedia->id)) {
            $multimedia->logErrors();
            return NULL;
        }
        return $multimedia->getTag();
    }
}
Exemplo n.º 2
0
 public function allowMultimediaType($type)
 {
     $mm = new PHPWS_Multimedia();
     return $mm->allowType($type);
 }
Exemplo n.º 3
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.º 4
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;
     }
 }