Example #1
0
 /**
  * Displays the thumb
  */
 public function thumb()
 {
     $flash = \Dsc\Flash::instance();
     $this->app->set('flash', $flash);
     $slug = $this->inputfilter->clean($this->app->get('PARAMS.slug'), 'PATH');
     $item = $this->getItem();
     if ($item == null) {
         $this->app->reroute(\Assets\Models\Settings::fetch()->get('images.default_thumb'));
         exit(0);
     }
     switch ($item->storage) {
         case "s3":
         case "cloudfiles":
         case "cdn":
             $this->app->reroute($item->thumb);
             break;
         case "gridfs":
         default:
             try {
                 $thumb = \Dsc\Mongo\Collections\Assets::cachedThumb($slug);
                 if (empty($thumb['bin'])) {
                     throw new \Exception();
                 }
             } catch (\Exception $e) {
                 return $this->app->error(404, 'Invalid Thumb');
             }
             $height = $this->app->get('PARAMS.height');
             $width = $this->app->get('PARAMS.width');
             if ($height && $width) {
                 $this->app->set('height', $height);
                 $this->app->set('width', $width);
             }
             $flash->store($thumb);
             echo $this->theme->renderView('Assets/Site/Views::assets/thumb.php');
             break;
     }
 }
Example #2
0
<?php

$settings = \Assets\Models\Settings::fetch();
?>

<div class="well">
<form id="detail-form" class="form" method="post">

    <div class="row">
        <div class="col-md-12">
        
            <div class="clearfix">
                 <ul class="list-filters list-unstyled list-inline pull-right">
                    <?php 
if ($flash->old('storage') != 's3' && $settings->isS3Enabled()) {
    ?>
                 
                    <li>
 		          		<a class="btn btn-success" href="./admin/asset/moveToS3/<?php 
    echo (string) $flash->old('_id');
    ?>
">Move to S3</a>
                    </li>
                    <?php 
}
?>
                    <li>
 		          		<a class="btn btn-info" href="./admin/asset/rethumb/<?php 
echo (string) $flash->old('slug');
?>
">Rebuild Thumb</a>
Example #3
0
 /**
  * 
  * @throws \Exception
  */
 public function moveToS3()
 {
     $settings = \Assets\Models\Settings::fetch();
     $f3 = \Base::instance();
     $model = $this->getModel();
     $id = $model->inputfilter()->clean($f3->get('PARAMS.id'), 'alnum');
     $item = $this->getItem();
     try {
         if (!$settings->isS3Enabled()) {
             throw new \Exception('Amazon S3 is not enabled');
         }
         $item->moveToS3();
         \Dsc\System::instance()->addMessage('This asset was successfully uploaded to Amazon S3.');
         $route = str_replace('{id}', $id, $this->edit_item_route);
         $f3->reroute($route);
     } catch (\Exception $e) {
         \Dsc\System::instance()->addMessage('This assets upload failed.', 'error');
         \Dsc\System::addMessage($e->{$e}->getMessage(), 'error');
     }
     \Base::instance()->reroute($this->list_route);
 }