Esempio n. 1
0
File: Sync.php Progetto: larakit/lk
 protected function importThumbs()
 {
     $this->info('Начало импорта превьюшек');
     $list = RouteThumb::$list;
     $files = [];
     foreach ($list as $item) {
         /* @var $model Model */
         $model = $this->parseModel($item);
         if (!$model) {
             continue;
         }
         $items = $model::all();
         foreach ($items as $model_item) {
             $config_names = \Config::get(Arr::get($item, 'vendor') . '::models/' . Arr::get($item, 'package') . '/thumbs');
             $sizes = (array) array_keys(Arr::get($config_names, 'sizes', []));
             foreach ($sizes as $size) {
                 $thumb = Thumb::fromModel($model_item, $size);
                 $thumb_sizes = (array) array_keys($thumb->getConfig());
                 foreach ($thumb_sizes as $s) {
                     $url = $thumb->makeUrl($s);
                     $files[$url] = ['url' => $url, 'thumb' => $thumb, 'size' => $s];
                 }
                 // Загруженная картинка
                 $url = $thumb->makeUrl();
                 $files[$url] = ['url' => $url, 'thumb' => $thumb, 'size' => ''];
             }
         }
     }
     $this->downloadFiles($files);
     $this->info('Превьюшки успешно импортированы');
 }
Esempio n. 2
0
 public function created($model)
 {
     $model_class = get_class($model);
     $session = 'tmp_upload_' . $model_class::getEntity();
     $file = \Session::get($session);
     if ($file) {
         if (file_exists($file)) {
             Thumb::fromModel($model, 'item')->processing($file);
             unlink($file);
         }
         \Session::forget($session);
     }
 }
Esempio n. 3
0
 function toHtml()
 {
     $thumb = Thumb::factory($this->vendor, $this->entity, $this->id, $this->name);
     $url = $thumb->getUrl($this->size);
     $img = \HtmlImg::addClass('img-rounded pointer img-responsive');
     //получим размеры
     $config_w = Arr::get($thumb->getConfig(), $this->size . '.size.w');
     $config_h = Arr::get($thumb->getConfig(), $this->size . '.size.h');
     if (!$url) {
         $img->setAttribute('data-src', 'holder.js/' . $config_w . 'x' . $config_h . '?theme=sky');
     } else {
         $img->setSrc($url . '?' . microtime(true));
     }
     $span = WidgetOverlay::factory()->setIcon('fa fa-crop')->setText('Обрезать миниатюру');
     return \HtmlDiv::addClass('thumb-cropper js-btn')->setAttribute('data-thumb-name', $this->name)->setAttribute('data-thumb-size', $this->size)->setAttribute('data-vendor', $this->vendor)->setAttribute('data-action', 'thumb_size')->setContent($span . $img)->__toString();
 }
Esempio n. 4
0
 function toHtml()
 {
     $thumb = Thumb::factory($this->vendor, $this->entity, $this->id, $this->name);
     $url = $thumb->getUrl($this->size);
     $img = \HtmlImg::addClass($this->img_class);
     //получим размеры
     $config_w = Arr::get($thumb->getConfig(), $this->size . '.size.w');
     $config_h = Arr::get($thumb->getConfig(), $this->size . '.size.h');
     if (!$url) {
         $img->setAttribute('data-src', 'holder.js/' . $config_w . 'x' . $config_h . '?theme=sky');
     } else {
         $img->setSrc($url . '?' . microtime(true));
     }
     $span = WidgetOverlay::factory()->setIcon('fa fa-folder-open-o');
     //        $span = \HtmlSpan::setContent('<i class="fa fa-folder-open-o"></i>');
     return \HtmlDiv::addClass('js-btn box-overlay__wrap box-overlay__wrap--fade box-overlay__wrap--blue box-overlay__wrap--inline')->setAttribute('data-thumb-name', $this->name)->setAttribute('data-thumb-size', $this->size)->setAttribute('data-action', 'thumb_name')->setContent($span . $img)->__toString();
 }
 function traitControllerEntityAjaxAutoComplete_response()
 {
     $word = trim(\Input::get('query', false));
     $items = [];
     if ($word) {
         $list = $this->model->where('name', 'like', '%' . $word . '%')->listsExt();
         if (is_array($list)) {
             foreach ($list as $id => $value) {
                 $items[$id]['id'] = $id;
                 $items[$id]['thumb_url'] = Thumb::factory($this->getVendor(), $this->getEntity(), $id, 'item')->getUrl('small');
                 $items[$id]['value'] = $value;
             }
         }
     } else {
         return ['items' => []];
     }
     sort($items);
     return ['total_count' => sizeof($items), 'incomplete_results' => false, 'items' => $items];
 }