public function render($value, $attr) { $model = $this->model; switch ($this->settings('mode')) { case self::SIMPLE_MODE: return Form::file($this->name, $attr); case self::MULTIPLE_MODE: $view = View::make('fields/image_multiple'); $method = $this->name . 's'; $images = $model->{$method}; $view->with('images', $images); $view->with('columns', $this->settings('columns', 5)); break; default: $view = View::make('fields/image'); $view->with('image', $value); if ($value) { $exists = file_exists(public_path($value)); $view->with('filename', pathinfo($value, PATHINFO_BASENAME)); $view->with('filesize', $exists ? File::size(public_path($value)) : 0); $view->with('removeAction', URL::to(Devhook::backendRoute('action/delete', $model->getModelFullKeyword(), $model->id, $this->name))); } break; } $sizeKey = false; if ($sizes = $this->settings('sizes')) { $keys = array_keys($sizes); $sizeKey = current($keys); } $view->with('field', $this->name); $view->with('attr', $attr); $view->with('sizeKey', $sizeKey); return $view; }
public function render($value, $attr) { switch ($this->settings('mode')) { case self::SIMPLE_MODE: return Form::file($this->name, $attr); default: $view = View::make('fields/file'); $view->with('field', $this->name); $view->with('file', $value); $view->with('attr', $attr); if ($value) { $view->with('filename', pathinfo($value, PATHINFO_BASENAME)); $view->with('filesize', File::size(public_path($value))); $view->with('removeAction', URL::to(Devhook::backendRoute('action/delete', $this->model->getModelFullKeyword(), $this->model->id, $this->name))); } return $view; } }
foreach ($actions as $key => $act) { ?> <?php $class = isset($act['class']) ? $act['class'] : (isset($defClass[$key]) ? $defClass[$key] : 'default'); ?> <?php $icon = isset($act['icon']) ? $act['icon'] : (isset($defIcon[$key]) ? $defIcon[$key] : ''); ?> <?php $icon = $icon ? "<i class='icon-{$icon}'></i> " : ''; ?> <?php if (!empty($act['link'])) { ?> <a href="<?php echo URL::to(Devhook::backendRoute($act['link'])); ?> " class="btn btn-xs btn-<?php echo $class; ?> "><?php echo $icon . $act['title']; ?> </a> <?php } else { ?> <span class="btn btn-xs btn-<?php echo $class; ?> "><?php