/**
  * Check if the processed file can be accepted by zOOm.
  * 
  * @return boolean
  * @param string $tag
  * @param int $isMime
  */
 function acceptableFormat($tag, $isMime = false)
 {
     if ($isMime) {
         $tag = zmgMimeHelper::convertMimeToExtension($tag);
     }
     return zmgMimeHelper::isImage($tag) || zmgMimeHelper::isVideo($tag) || zmgMimeHelper::isDocument($tag) || zmgMimeHelper::isAudio($tag);
 }
 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;
 }
 function toJSON()
 {
     $json =& zmgFactory::getJSON();
     $out = "'metadata': {\n          'mid': " . $this->_mid;
     if ($this->_raw === null || empty($this->_raw)) {
         return $out . ",'title': " . $json->encode(T_('No Metadata available.')) . "}";
     }
     zmgimport('org.zoomfactory.lib.mime.zmgMimeHelper');
     if (zmgMimeHelper::isImage($this->_ext)) {
         //TODO
         //print_r($this->_raw);
         if (empty($this->_raw['title'])) {
             $out .= ",'title': " . $json->encode(T_('No Metadata available.')) . "}";
         } else {
             $out .= ",\n                  'title' : " . $json->encode($this->_raw['title']);
             if (is_array($this->_raw['IFD'])) {
                 $out .= ",";
                 foreach ($this->_raw['IFD'] as $name => $exif_val) {
                     $out .= $this->interpretJpegMeta($name, $exif_val);
                 }
                 $out = substr($out, 0, -1);
             }
             $out .= "}";
         }
     } else {
         if (zmgMimeHelper::isAudio($this->_ext)) {
             list($artist, $title, $album, $year, $length, $data) = $this->interpretId3($this->_raw);
             $out .= ",\n              'title' : " . $json->encode($title) . "," . $json->encode(T_('Artist')) . ": " . $json->encode($artist) . "," . $json->encode(T_('Song')) . ": " . $json->encode($title) . "," . $json->encode(T_('Album')) . ": " . $json->encode($album) . "," . $json->encode(T_('Year')) . ": " . $json->encode($year) . "," . $json->encode(T_('Length')) . ": " . $json->encode($length) . "," . $json->encode(T_('Data')) . ": " . $json->encode($data) . "}";
         } else {
             if (zmgMimeHelper::isVideo($this->_ext)) {
                 //TODO
                 $out .= ",'title': " . $json->encode(T_('No Metadata available.')) . "}";
             }
         }
     }
     return $out;
 }