/** * will return a pair of file_root and file_path * This is the only function that should be extended for building a different path * * @param ISyncableFile $object * @param int $subType * @param $version */ public function generateFilePathArr(ISyncableFile $object, $subType, $version = null, $storageProfileId = null) { // currently xsl paths are only used for assets if (!$object instanceof asset) { return parent::generateFilePathArr($object, $subType, $version, $storageProfileId); } $storageProfile = kPathManager::getStorageProfile($storageProfileId); $pathXsl = $storageProfile->getPathFormat(); $entry = $object->getEntry(); $xslVariables = $this->getXslVariables($storageProfile, $object, $subType, $version, $entry); $xslStr = $this->getXsl($pathXsl, $xslVariables); try { $path = $this->getPathValue($entry, $xslStr); } catch (Exception $e) { KalturaLog::err('Error executing XSL - ' . $e->getMessage()); $path = null; } if (empty($path)) { KalturaLog::log('Empty path recieved - using parent\'s path instead'); return parent::generateFilePathArr($object, $subType, $version, $storageProfileId); } $path = trim($path); KalturaLog::debug('Path value [' . $path . ']'); $root = '/'; return array($root, $path); }
/** * will return a pair of file_root and file_path * This is the only function that should be extended for building a different path * * @param ISyncableFile $object * @param int $subType * @param $version */ public function generateFilePathArr(ISyncableFile $object, $subType, $version = null, $storageProfileId = null) { $storageProfile = kPathManager::getStorageProfile($storageProfileId); $path_format = $storageProfile->getPathFormat(); if (is_null($path_format)) { $path_format = '{year}{month}{day}/{partnerDir}/{fileName}'; } $fileName = $object->generateFileName($subType, $version); $partnerDir = floor($object->getPartnerId() / 1000); $path = str_replace('{fileName}', $fileName, $path_format); $path = str_replace('{partnerDir}', $partnerDir, $path); $path = str_replace('{year}', date("Y"), $path); $path = str_replace('{month}', date("m"), $path); $path = str_replace('{day}', date("d"), $path); $root = '/'; return array($root, $path); }