function processMedium(&$medium, &$gallery)
 {
     $mime = $medium->getMimeType();
     zmgimport('org.zoomfactory.lib.mime.zmgMimeHelper');
     $ok = true;
     if (zmgMimeHelper::isImage($mime, true)) {
         zmgimport('org.zoomfactory.var.plugins.toolbox.tools.imageTool');
         $ok = zmgImageTool::process($medium, $gallery);
         if (!$ok) {
             zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Could not create thumbnail of image file'));
             //TODO: cleanup
         }
     } else {
         if (zmgMimeHelper::isDocument($mime, true) && zmgMimeHelper::isIndexable($mime, true)) {
             zmgimport('org.zoomfactory.var.plugins.toolbox.tools.documentTool');
             $ok = zmgDocumentTool::process($medium, $gallery);
             if (!$ok) {
                 zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Could not index document'));
                 //TODO: cleanup
             }
         } else {
             if (zmgMimeHelper::isVideo($mime, true) && zmgMimeHelper::isThumbnailable($mime, true)) {
                 zmgimport('org.zoomfactory.var.plugins.toolbox.tools.videoTool');
                 $ok = zmgVideoTool::process($medium, $gallery);
                 if (!$ok) {
                     zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Could not create thumbnail of video file'));
                     //TODO: cleanup
                 }
             } else {
                 if (zmgMimeHelper::isAudio($mime, true)) {
                     zmgimport('org.zoomfactory.var.plugins.toolbox.tools.audioTool');
                     $ok = zmgAudioTool::process($medium, $gallery);
                     if (!$ok) {
                         zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Audio file not supported'));
                         //TODO: cleanup
                     }
                 } else {
                     zmgToolboxPlugin::registerError(T_('Upload medium'), T_('Unsupported medium type.'));
                 }
             }
         }
     }
     return $ok;
 }
Пример #2
0
 function getViewableFile($gallery_path, $smallthumb = false)
 {
     if (!$this->filename) {
         zmgError::throwError('zmgMedium: medium data not loaded yet');
     }
     $file = array('path' => $gallery_path, 'name' => null);
     $template_path = zmgEnv::getSiteURL() . "/components/com_zoom/var/www/templates/" . zmgFactory::getView()->getActiveTemplate() . "/images/mimetypes";
     if ($smallthumb) {
         $template_path .= "/small";
     }
     $ext = $this->getExtension();
     zmgimport('org.zoomfactory.lib.mime.zmgMimeHelper');
     if (zmgMimeHelper::isDocument($ext)) {
         $file['path'] = $template_path;
         if (strstr($ext, 'pdf')) {
             $file['name'] = "pdf.png";
         } else {
             $file['name'] = "doc.png";
         }
     } else {
         if (zmgMimeHelper::isVideo($ext)) {
             if (zmgMimeHelper::isThumbnailable($ext)) {
                 zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper');
                 $filename = ereg_replace("(.*)\\.([^\\.]*)\$", "\\1", $this->filename) . ".jpg";
                 if (zmgFileHelper::exists(str_replace($this->filename, $filename, $this->getAbsPath(ZMG_MEDIUM_THUMBNAIL)))) {
                     $file['name'] = $filename;
                 }
             }
             if (!$file['name']) {
                 $file['path'] = $template_path;
                 $file['name'] = strstr('flv', $ext) ? "flv.png" : "video.png";
             }
         } else {
             if (zmgMimeHelper::isAudio($ext)) {
                 $file['path'] = $template_path;
                 $file['name'] = "audio.png";
             }
         }
     }
     return $file;
 }