コード例 #1
0
ファイル: Slide.php プロジェクト: robbytaylor/boom-core
 public function getAsset()
 {
     if ($this->asset === null) {
         $this->asset = AssetFacade::find($this->attrs['asset_id']);
     }
     return $this->asset;
 }
コード例 #2
0
ファイル: Asset.php プロジェクト: boomcms/boom-core
 /**
  * Returns the associated asset.
  *
  * @return AssetContract
  */
 public function getAsset()
 {
     if ($this->asset === null) {
         $this->asset = AssetFacade::find($this->getAssetId());
     }
     return $this->asset;
 }
コード例 #3
0
ファイル: Asset.php プロジェクト: imanghafoori1/boom-core
 public function __construct(Page $page, array $attrs, $slotname, $editable = true)
 {
     parent::__construct($page, $attrs, $slotname, $editable);
     if (isset($attrs['asset_id'])) {
         $this->asset = AssetFacade::find($this->attrs['asset_id']);
     }
 }
コード例 #4
0
 public function download()
 {
     $assets = AssetFacade::find($this->request->input('assets'));
     if (count($assets) === 1) {
         return Response::download($assets[0]->getFilename(), $assets[0]->getOriginalFilename());
     }
     $downloadFilename = rtrim($this->request->input('filename'), '.zip') . '.zip';
     $filename = tempnam(sys_get_temp_dir(), 'boomcms_asset_download');
     $zip = new ZipArchive();
     $zip->open($filename, ZipArchive::CREATE);
     foreach ($assets as $asset) {
         $zip->addFile($asset->getFilename(), $asset->getOriginalFilename());
     }
     $zip->close();
     $response = Response::make()->header('Content-type', 'application/zip')->header('Content-Disposition', "attachment; filename={$downloadFilename}")->setContent(file_get_contents($filename));
     unlink($filename);
     return $response;
 }
コード例 #5
0
ファイル: AssetController.php プロジェクト: boomcms/boom-core
 /**
  * @param Request $request
  * @param Asset   $asset
  */
 public function update(Request $request, Asset $asset, Site $site)
 {
     $this->authorize('manageAssets', $site);
     $asset->setTitle($request->input(Asset::ATTR_TITLE))->setDescription($request->input(Asset::ATTR_DESCRIPTION))->setCredits($request->input(Asset::ATTR_CREDITS))->setThumbnailAssetId($request->input(Asset::ATTR_THUMBNAIL_ID));
     AssetFacade::save($asset);
     return $this->show($asset);
 }
コード例 #6
0
 public function upload()
 {
     $assetIds = [];
     list($validFiles, $errors) = $this->validateFileUpload();
     foreach ($validFiles as $file) {
         $asset = new Asset();
         $asset->setUploadedTime(new DateTime('now'))->setUploadedBy(Auth::getPerson())->setTitle($file->getClientOriginalName())->setType(AssetHelper::typeFromMimetype($file->getMimeType()));
         $assetIds[] = AssetFacade::save($asset)->getId();
         AssetFacade::createVersionFromFile($asset, $file);
     }
     return count($errors) ? new JsonResponse($errors, 500) : $assetIds;
 }