* @package tao */ class tao_models_classes_TaoService extends tao_models_classes_GenerisService { /** * The key to use to store the default TAO Upload File Source Repository URI * the TAO meta-extension configuration. * * @access public * @var string */ const CONFIG_UPLOAD_FILESOURCE = 'defaultUploadFileSource'; /** * Set the default file source for TAO File Upload. * * @access public * @author Jerome Bogaerts, * @param string sourceId The repository to be used as the default TAO File Upload Source. * @return void */ public function setUploadFileSourceId($sourceId) { $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $ext->setConfig(self::CONFIG_UPLOAD_FILESOURCE, $sourceId); } /** * Store an uploaded file in the persistant storage and return a serial id * * @param File $tmpFile * @param string $name * @return string */ public function storeUploadedFile(File $tmpFile, $name = '') { $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $fsId = $ext->getConfig(self::CONFIG_UPLOAD_FILESOURCE); $fss = $this->getServiceLocator()->get(FileSystemService::SERVICE_ID); $baseDir = $fss->getDirectory($fsId); do { $unique = uniqid(); $dir = implode('/', str_split(substr($unique, 0, 3))) . '/' . substr($unique, 3); $file = $baseDir->getFile($dir . '/' . $name); } while ($file->exists()); $file->write($tmpFile->read()); $referencer = $this->getServiceLocator()->get(FileReferenceSerializer::SERVICE_ID); $serial = $referencer->serialize($file); return $serial; } /** * Get the tao platform version * @return string * @deprecated */ public function getPlatformVersion() { return $this->getServiceLocator()->get(ApplicationService::SERVICE_ID)->getPlatformVersion(); } }