* @license PHP License * @package WB * @subpackage vfs */ WBClass::load('WBVFS_Mime'); /** * Virtual File System: Mime_Application * * Implements dummy import() and getInfo() methods. There is no * general way to treat binary files. * * @version 1.0.1 * @package WB * @subpackage vfs */ class WBVFS_Mime_Application extends WBVFS_Mime { /** * file name extension * @var string */ protected $extension = ''; /** * get information about this file * * @return array */ public function getInfo() { return $this->info; } /** * import file * */ public function import() { } /** * inform when file has been set * * Resolve file name extension * @param string $name */ protected function onSetFile($name = '') { $this->extension = $this->mimeMinor; $name = explode('.', $name); $ext = end($name); switch (strtolower($this->mimeMinor)) { case 'vnd.ms-office': if ('xls' == strtolower($ext)) { $this->mimeMinor = 'vnd.ms-excel'; $this->extension = 'xls'; } break; case 'vnd.ms-excel'; $this->extension = 'xls'; break; default: } } /** * On set viretual file * * Allow to convert every file. Set file's name extension according mime type. */ public function onSetVirtualFile() { $this->convertable[] = $this->vfile->getMime(); $this->extension = $this->mimeMinor; switch (strtolower($this->mimeMinor)) { // generic file types don't get an extra extension case 'octet-stream': $this->mimeMajor = 'application'; $this->extension = ''; break; /** * Generic MS office */ case 'vnd.ms-office': break; /** * OpenOffice.org2.0 / StarOffice 8 and later */ case 'vnd.oasis.opendocument.text': $this->extension = 'odt'; break; case 'vnd.oasis.opendocument.text-template': $this->extension = 'ott'; break; case 'vnd.oasis.opendocument.text-web': $this->extension = 'oth'; break; case 'vnd.oasis.opendocument.text-master': $this->extension = 'odm'; break; case 'vnd.oasis.opendocument.graphics': $this->extension = 'odg'; break; case 'vnd.oasis.opendocument.graphics-template': $this->extension = 'otg'; break; case 'vnd.oasis.opendocument.presentation': $this->extension = 'odp'; break; case 'vnd.oasis.opendocument.presentation-template': $this->extension = 'otp'; break; case 'vnd.oasis.opendocument.spreadsheet': $this->extension = 'ods'; break; case 'vnd.oasis.opendocument.spreadsheet-template': $this->extension = 'ots'; break; case 'vnd.oasis.opendocument.chart': $this->extension = 'odc'; break; case 'vnd.oasis.opendocument.formula': $this->extension = 'odf'; break; case 'vnd.oasis.opendocument.databas': $this->extension = 'odb'; break; case 'vnd.oasis.opendocument.image': $this->extension = 'odi'; break; case 'vnd.openofficeorg.extension': $this->extension = 'oxt'; break; /** * OpenOffice.org1.0 / StarOffice6.0 and later */ case 'vnd.sun.xml.writer': $this->extension = 'sxw'; break; case 'vnd.sun.xml.writer.template': $this->extension = 'stw'; break; case 'vnd.sun.xml.calc': $this->extension = 'sxc'; break; case 'vnd.sun.xml.calc.template': $this->extension = 'stc'; break; case 'vnd.sun.xml.draw': $this->extension = 'sxd'; break; case 'vnd.sun.xml.draw.template': $this->extension = 'std'; break; case 'vnd.sun.xml.impress': $this->extension = 'sxi'; break; case 'vnd.sun.xml.impress.template': $this->extension = 'sti'; break; case 'vnd.sun.xml.writer.global': $this->extension = 'sxg'; break; case 'vnd.sun.xml.math': $this->extension = 'sxm'; break; /** * StarOffice 5.x */ case 'vnd.stardivision.writer': $this->extension = 'sdw'; break; case 'vnd.stardivision.writer-global': $this->extension = 'sgl'; break; case 'vnd.stardivision.calc': $this->extension = 'sdc'; break; case 'vnd.stardivision.draw': $this->extension = 'sda'; break; case 'vnd.stardivision.impress': $this->extension = 'sdd'; break; case 'vnd.stardivision.impress-packed': $this->extension = 'sdp'; break; case 'vnd.stardivision.math': $this->extension = 'smf'; break; case 'vnd.stardivision.chart': $this->extension = 'sds'; break; case 'vnd.stardivision.mail': $this->extension = 'sdm'; break; /** * StarOffice 5.x */ case 'x-starwriter': $this->extension = 'sdw'; break; case 'x-starcalc': $this->extension = 'sdc'; break; case 'x-stardraw': $this->extension = 'sda'; break; case 'x-starimpress': $this->extension = 'sdd'; break; case 'x-starmath': $this->extension = 'smf'; break; case 'x-starchart': $this->extension = 'sds'; break; /** * MS Word */ case 'vnd-msword': $this->extension = 'doc'; break; case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': $this->extension = 'dotx'; break; case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template': $this->extension = 'docx'; break; case 'application/vnd.ms-word.document.macroEnabled.12': $this->extension = 'docm'; break; case 'application/vnd.ms-word.template.macroEnabled.12': $this->extension = 'dotm'; break; /** * MS Excel */ case 'vnd.ms-excel'; $this->extension = 'xls'; break; case 'vnd.openxmlformats-officedocument.spreadsheetml.sheet': $this->extension = 'xlsx'; break; case 'vnd.openxmlformats-officedocument.spreadsheetml.template': $this->extension = 'xltx'; break; case 'application/vnd.ms-excel.sheet.macroEnabled.12': $this->extension = 'xlsm'; break; case 'application/vnd.ms-excel.template.macroEnabled.12': $this->extension = 'xltm'; break; case 'application/vnd.ms-excel.addin.macroEnabled.12': $this->extension = 'xlam'; break; case 'application/vnd.ms-excel.sheet.binary.macroEnabled.12': $this->extension = 'xlsb'; break; /** * MS Power Point */ case 'vnd.ms-powerpoint'; $this->extension = 'ppt'; break; case 'vnd.openxmlformats-officedocument.presentationml.presentation'; $this->extension = 'pptx'; break; case 'vnd.openxmlformats-officedocument.presentationml.template'; $this->extension = 'potx'; break; case 'vnd.openxmlformats-officedocument.presentationml.presentation'; $this->extension = 'pptx'; break; case 'vnd.openxmlformats-officedocument.presentationml.slideshow'; $this->extension = 'ppsx'; break; case 'vnd.ms-powerpoint.addin.macroEnabled.12'; $this->extension = 'ppam'; break; case 'vnd.ms-powerpoint.presentation.macroEnabled.12'; $this->extension = 'pptm'; break; case 'vnd.ms-powerpoint.template.macroEnabled.12'; $this->extension = 'potm'; break; case 'vnd.ms-powerpoint.slideshow.macroEnabled.12'; $this->extension = 'ppsm'; break; default: $this->mimeMajor = 'application'; $this->mimeMinor = 'octet-stream'; break; } } /** * execute command * * Available commands: * - unpack * - compress * - uncompress * * @todo implement commands * @param string $cmd * @param array $arg */ public function execute($cmd, $arg = array()) { } /** * get file name of requested file * * @param bool $redirect whether to redirect * @return string */ protected function doGetRequestedFile(&$redirect) { $path = $this->vfile->getPath() . '.org'; return $path; } }