Exemplo n.º 1
0
 /**
  * Provides upload file
  * @return mixed
  */
 public function actionUpload()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $model = new Mediafile();
     $routes = $this->module->routes;
     $rename = $this->module->rename;
     $model->saveUploadedFile($routes, $rename);
     $bundle = FilemanagerAsset::register($this->view);
     if ($model->isImage()) {
         $model->createThumbs($routes, $this->module->thumbs);
     }
     $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;
 }
Exemplo n.º 2
0
 /**
  * Provides upload file
  * @return mixed
  */
 public function actionUpload()
 {
     $model = new Attachment();
     $model->saveUploadedFile();
     $bundle = FilemanagerAsset::register($this->view);
     //        if ($model->isImage() && $this->module->thumbs) {
     //            $model->createThumbs($routes, $this->module->thumbs);
     //        }
     Yii::$app->response->format = Response::FORMAT_JSON;
     return ['files' => [['path' => $model->path, 'thumbnailUrl' => $this->module->routes['baseUrl'] . $model->path, 'name' => $model->filename, 'size' => $model->file->size, 'deleteUrl' => Url::to(['file/delete', 'id' => $model->id]), 'deleteType' => 'POST']]];
     //        $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;
 }
Exemplo n.º 3
0
<?php

use pendalf89\filemanager\assets\FilemanagerAsset;
use pendalf89\filemanager\Module;
use yii\widgets\ListView;
use yii\helpers\Html;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel pendalf89\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 Html::a(Html::img($this->context->module->routes['baseUrl'] . $model->path, ['width' => 50, 'height' => 50]) . '<span class="checked glyphicon glyphicon-check"></span>', '#mediafile', ['data-key' => $key]);
}]);
?>

    <div class="dashboard">
        <p><?php 
echo Html::a('<span class="glyphicon glyphicon-upload"></span> ' . Module::t('main', 'Upload manager'), ['file/uploadmanager'], ['class' => 'btn btn-default']);
Exemplo n.º 4
0
<?php

use yii\helpers\Html;
use pendalf89\filemanager\Module;
use pendalf89\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>
Exemplo n.º 5
0
<?php

use pendalf89\filemanager\assets\FilemanagerAsset;
use yii\helpers\Html;
/* @var $this yii\web\View */
FilemanagerAsset::register($this);
$this->beginPage();
?>
    <!DOCTYPE html>
    <html lang="<?php 
echo Yii::$app->language;
?>
">
    <head>
        <meta charset="<?php 
echo Yii::$app->charset;
?>
"/>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <?php 
echo Html::csrfMetaTags();
?>
        <title><?php 
echo Html::encode($this->title);
?>
</title>
        <?php 
$this->head();
?>
    </head>
    <body>