예제 #1
0
 /**
  * Get appendix for an URL based on it's Source caching settings.
  *
  * @param BaseAssetSourceType $source
  * @param AssetFileModel      $file
  *
  * @return string
  */
 public static function getUrlAppendix(BaseAssetSourceType $source, AssetFileModel $file)
 {
     $appendix = '';
     if (!empty($source->getSettings()->expires) && DateTimeHelper::isValidIntervalString($source->getSettings()->expires)) {
         $appendix = '?mtime=' . $file->dateModified->format("YmdHis");
     }
     return $appendix;
 }
예제 #2
0
 /**
  * Return whether the Asset has a URL.
  *
  * @return bool
  */
 public function getHasUrls()
 {
     if (!$this->_sourceType) {
         $this->_sourceType = craft()->assetSources->populateSourceType($this->getSource());
     }
     return $this->_sourceType->getHasUrls();
 }
 /**
  * @inheritDoc BaseAssetSourceType::canMoveFileFrom()
  *
  * @param BaseAssetSourceType $originalSource
  *
  * @return mixed
  */
 protected function canMoveFileFrom(BaseAssetSourceType $originalSource)
 {
     if ($this->model->type == $originalSource->model->type) {
         $settings = $originalSource->getSettings();
         $theseSettings = $this->getSettings();
         if ($settings->keyId == $theseSettings->keyId && $settings->secret == $theseSettings->secret) {
             return true;
         }
     }
     return false;
 }
예제 #4
0
 /**
  * Move a file between sources.
  *
  * @param BaseAssetSourceType $originatingSource
  * @param BaseAssetSourceType $targetSource
  * @param AssetFileModel      $file
  * @param AssetFolderModel    $folder
  * @param string              $action
  *
  * @return AssetOperationResponseModel
  */
 private function _moveFileBetweenSources(BaseAssetSourceType $originatingSource, BaseAssetSourceType $targetSource, AssetFileModel $file, AssetFolderModel $folder, $action = '')
 {
     $localCopy = $originatingSource->getLocalCopy($file);
     // File model will be updated in the process, but we need the old data in order to finalize the transfer.
     $oldFileModel = clone $file;
     $response = $targetSource->transferFileIntoSource($localCopy, $folder, $file, $action);
     if ($response->isSuccess()) {
         // Use the previous data to clean up
         craft()->assetTransforms->deleteAllTransformData($oldFileModel);
         $originatingSource->finalizeTransfer($oldFileModel);
         IOHelper::deleteFile($localCopy);
     }
     return $response;
 }
 /**
  * @inheritDoc BaseAssetSourceType::canMoveFileFrom()
  *
  * @param BaseAssetSourceType $originalSource
  *
  * @return mixed
  */
 protected function canMoveFileFrom(BaseAssetSourceType $originalSource)
 {
     return $originalSource->isSourceLocal();
 }
예제 #6
0
 /**
  * @inheritDoc BaseAssetSourceType::canMoveFileFrom()
  *
  * @param BaseAssetSourceType $originalSource
  *
  * @return mixed
  */
 protected function canMoveFileFrom(BaseAssetSourceType $originalSource)
 {
     if ($this->model->type == $originalSource->model->type) {
         $settings = $originalSource->getSettings();
         $theseSettings = $this->getSettings();
         if ($settings->username == $theseSettings->username && $settings->apiKey == $theseSettings->apiKey) {
             return true;
         }
     }
     return false;
 }