Ejemplo n.º 1
0
 function do_main()
 {
     //registerTypes registers the mime types and populates the needed tables.
     $indexer = Indexer::get();
     $indexer->registerTypes();
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplating->addLocation('Extractor Information', '/plugins/search2/reporting/templates');
     $oTemplate =& $oTemplating->loadTemplate('extractorinfo');
     $aExtractorInfo = KTMime::getMimeExtractorInformation();
     if (empty($aExtractorInfo)) {
         $oTemplate->setData(array('context' => $this, 'extractor_info' => $aExtractorInfo));
         return $oTemplate;
     }
     foreach ($aExtractorInfo as $key => $info) {
         $extractorClass = $info['name'];
         $extractor = $indexer->getExtractor($extractorClass);
         $info['mimeTypes'] = array();
         $aMimeTypes = $this->getSupportedMimeTypesDB($extractorClass);
         //$extractor->getSupportedMimeTypes();
         foreach ($aMimeTypes as $mimeType) {
             $sMimeInfo = KTMime::getFriendlyNameAndExtension($mimeType);
             $info['mimeTypes'][$mimeType] = array('description' => $sMimeInfo[0]['friendly_name'], 'extensions' => array($sMimeInfo[0]['filetypes']));
             $extensions = array();
             foreach ($sMimeInfo as $item) {
                 $extensions[] = $item['filetypes'];
             }
             $info['mimeTypes'][$mimeType]['extensions'] = implode(', ', $extensions);
         }
         $aExtractorInfo[$key] = $info;
     }
     $oTemplate->setData(array('context' => $this, 'extractor_info' => $aExtractorInfo));
     return $oTemplate;
 }
Ejemplo n.º 2
0
 /**
  * Get the path to the correct icon for the mime type
  *
  * @return string
  */
 function getIconPath()
 {
     $sIconPath = KTMime::getIconPath($this->_iMimeId);
     // Get mime type icon
     $sIconPath = '/resources/mimetypes/big/' . $sIconPath . '.png';
     if (!file_exists(KT_DIR . $sIconPath)) {
         // See if there is an icon for the extension
         $sMimeType = KTMime::getMimeTypeName($this->_iMimeId);
         $aMimeInfo = KTMime::getFriendlyNameAndExtension($sMimeType);
         if (!PEAR::isError($aMimeInfo) && !empty($aMimeInfo)) {
             $sExt = $aMimeInfo[0]['filetypes'];
             $sIconPath = '/resources/mimetypes/big/' . $sExt . '.png';
             if (!file_exists(KT_DIR . $sIconPath)) {
                 $generic = $this->checkForGeneric($sExt);
                 // if all else fails, use the default icon
                 $sIconPath = '/resources/mimetypes/big/' . $generic . '.png';
             }
         }
     }
     return $sIconPath;
 }