Ejemplo n.º 1
0
 public function getVbType($ext)
 {
     $ext = trim(strtolower($ext));
     if (strpos($ext, '.')) {
         $ext = PHPWS_File::getFileExtension($ext);
     }
     $all_types = PHPWS_File::getAllFileTypes();
     if (!isset($all_types[$ext])) {
         return _('Unknown type');
     } else {
         return $all_types[$ext]['vb'];
     }
 }
Ejemplo n.º 2
0
 public function fileTypes()
 {
     $known_images = null;
     $known_media = null;
     $known_documents = null;
     include PHPWS_SOURCE_DIR . 'mod/filecabinet/inc/known_types.php';
     $image_types = explode(',', PHPWS_Settings::get('filecabinet', 'image_files'));
     $media_types = explode(',', PHPWS_Settings::get('filecabinet', 'media_files'));
     $doc_types = explode(',', PHPWS_Settings::get('filecabinet', 'document_files'));
     $all_file_types = PHPWS_File::getAllFileTypes();
     $form = new PHPWS_Form('allowed-file-types');
     $form->addHidden('module', 'filecabinet');
     $form->addHidden('aop', 'post_allowed_files');
     $img_checks = $this->sortType($known_images, $all_file_types);
     if (!empty($img_checks)) {
         $form->addCheckAssoc('allowed_images', $img_checks);
         $form->setMatch('allowed_images', $image_types);
     }
     $media_checks = $this->sortType($known_media, $all_file_types);
     if (isset($media_checks)) {
         $form->addCheckAssoc('allowed_media', $media_checks);
         $form->setMatch('allowed_media', $media_types);
     }
     $doc_checks = $this->sortType($known_documents, $all_file_types);
     if (isset($doc_checks)) {
         $form->addCheckAssoc('allowed_documents', $doc_checks);
         $form->setMatch('allowed_documents', $doc_types);
     }
     $form->useRowRepeat();
     $form->addSubmit(dgettext('filecabinet', 'Save allowed files'));
     $tpl = $form->getTemplate();
     $tpl['CHECK_IMAGES'] = javascript('check_all', array('checkbox_name' => 'allowed_images'));
     $tpl['CHECK_MEDIA'] = javascript('check_all', array('checkbox_name' => 'allowed_media'));
     $tpl['CHECK_DOCUMENTS'] = javascript('check_all', array('checkbox_name' => 'allowed_documents'));
     return PHPWS_Template::process($tpl, 'filecabinet', 'Forms/allowed_types.tpl');
 }