Ejemplo n.º 1
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use derekisbusy\filemanager\assets\FilemanagerAsset;
use derekisbusy\filemanager\Module;
/* @var $this yii\web\View */
/* @var $model derekisbusy\filemanager\models\Mediafile */
/* @var $form yii\widgets\ActiveForm */
$bundle = FilemanagerAsset::register($this);
?>

<?php 
echo Html::img($model->getDefaultThumbUrl($bundle->baseUrl));
?>

<ul class="detail">
    <li><?php 
echo $model->type;
?>
</li>
    <li><?php 
echo Yii::$app->formatter->asDatetime($model->getLastChanges());
?>
</li>
    <?php 
if ($model->isImage()) {
    ?>
        <li><?php 
    echo $model->getOriginalImageSize($this->context->module->routes);
    ?>
 /**
  * Provides upload file
  * @return mixed
  */
 public function actionUpload($related = null, $itemId = null, $tempId = null)
 {
     $event = new \derekisbusy\filemanager\events\UploadEvent();
     $event->relatedClass = $this->module->relations[$related];
     $this->module->trigger(Module::EVENT_UPLOAD, $event);
     $relation = null;
     if (isset($related)) {
         if (!isset($this->module->relations[$related])) {
             throw new \yii\base\InvalidParamException();
         }
         $relation = $this->module->relations[$related];
     }
     $model = new Mediafile();
     $routes = $this->module->routes;
     $rename = $this->module->rename;
     if ($tempId) {
         $model->temp_id = $tempId;
     }
     $model->saveUploadedFile($routes, $rename, $related, $itemId);
     // create relations
     if ($related && $itemId) {
         $thru = new $this->module->relations[$related]['class']();
         $thru->{$relation['model_id']} = $itemId;
         $thru->{$relation['file_id']} = $model->id;
         $thru->save();
     }
     $bundle = FilemanagerAsset::register($this->view);
     if ($model->isImage()) {
         $model->createThumbs($routes, $this->module->thumbs);
     }
     Yii::$app->response->format = Response::FORMAT_JSON;
     $response = [];
     $response['files'][] = ['url' => $model->url, 'thumbnailUrl' => $model->getDefaultThumbUrl($bundle->baseUrl), 'name' => $model->filename, 'type' => $model->type, 'size' => $model->file->size, 'deleteUrl' => Url::to(['file/delete', 'id' => $model->id]), 'deleteType' => 'POST'];
     return $response;
 }
Ejemplo n.º 3
0
<?php

use derekisbusy\filemanager\assets\FilemanagerAsset;
use derekisbusy\filemanager\Module;
use yii\widgets\ListView;
use yii\helpers\Html;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel derekisbusy\filemanager\models\Mediafile */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->params['moduleBundle'] = FilemanagerAsset::register($this);
?>

<header id="header"><span class="glyphicon glyphicon-picture"></span> <?php 
echo Module::t('main', 'File manager');
?>
</header>

<div id="filemanager" data-url-info="<?php 
echo Url::to(['file/info']);
?>
">
    <?php 
echo ListView::widget(['dataProvider' => $dataProvider, 'layout' => '<div class="items">{items}</div>{pager}', 'itemOptions' => ['class' => 'item'], 'itemView' => function ($model, $key, $index, $widget) {
    //        return $model->getDefaultThumbUrl($this->params['moduleBundle']->baseUrl);
    //               if(file_exists(substr($model->getDefaultThumbUrl($this->params['moduleBundle']->baseUrl), 1))){
    return Html::a(Html::img($model->getDefaultThumbUrl($this->params['moduleBundle']->baseUrl)) . '<span class="checked glyphicon glyphicon-check"></span>', '#mediafile', ['data-key' => $key]);
    //                }
    //                else{
    //                    return 'not found?';
    //                }
Ejemplo n.º 4
0
<?php

use yii\helpers\Html;
use derekisbusy\filemanager\Module;
use derekisbusy\filemanager\assets\FilemanagerAsset;
/* @var $this yii\web\View */
$this->title = Module::t('main', 'File manager');
$this->params['breadcrumbs'][] = $this->title;
$assetPath = FilemanagerAsset::register($this)->baseUrl;
?>

<div class="filemanager-default-index">
    <h1><?php 
echo Module::t('main', 'File manager module');
?>
</h1>

    <div class="row">
        <div class="col-md-6">

            <div class="text-center">
                <h2>
                    <?php 
echo Html::a(Module::t('main', 'Files'), ['file/index']);
?>
                </h2>
                <?php 
echo Html::a(Html::img($assetPath . '/images/files.png', ['alt' => 'Files']), ['file/index']);
?>
            </div>
        </div>