public function actionUpload()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     if (!Yii::$app->request->isAjax) {
         throw new BadRequestHttpException();
     }
     $files = UploadedFile::getInstancesByName('files');
     $baseDir = Yii::getAlias(Module::getInstance()->basePath);
     if (!is_dir($baseDir)) {
         mkdir($baseDir);
     }
     $dir = $baseDir . DIRECTORY_SEPARATOR . $_POST['galleryId'];
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $response = [];
     foreach ($files as $key => $file) {
         if (Module::getInstance()->uniqueName) {
             $name = $this->getUniqueName($file);
         } else {
             $name = $file->name;
         }
         $file->saveAs($dir . DIRECTORY_SEPARATOR . $name);
         $model = new GalleryFile();
         $model->galleryId = $_POST['galleryId'];
         $model->file = $name;
         if ($model->save()) {
             $response = ['status' => true, 'message' => 'Success', 'html' => $this->renderAjax('_image', ['model' => $model])];
         }
         break;
     }
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Remove model directory with all files
  */
 private function removeModelDirectory()
 {
     $dir = Yii::getAlias(Module::getInstance()->basePath . DIRECTORY_SEPARATOR . $this->id);
     $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
     $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($files as $file) {
         if ($file->isDir()) {
             rmdir($file->getRealPath());
         } else {
             unlink($file->getRealPath());
         }
     }
     rmdir($dir);
 }
Exemplo n.º 3
0
            <div class="actions">
                <a href="<?php 
echo $model->src;
?>
" rel="<?php 
echo $model->galleryId;
?>
" class="fancy" title="<?php 
echo $model->caption;
?>
">
                    <i class="watch glyphicon glyphicon-eye-open" title="<?php 
echo Module::t('default', 'ORIGINAL');
?>
"></i>
                </a>

                <i class="edit glyphicon glyphicon-pencil" title="<?php 
echo Module::t('default', 'UPDATE_CAPTION');
?>
"></i>

                <i class="remove glyphicon glyphicon-trash" title="<?php 
echo Module::t('default', 'REMOVE_IMAGE');
?>
"></i>
            </div>
        </div>
    </div>
</div>
Exemplo n.º 4
0
<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use sadovojav\gallery\Module;
$this->title = Module::t('default', 'GALLERY_MANAGER');
$this->params['breadcrumbs'] = [Module::t('default', 'GALLERIES')];
?>

<div class="gallery-index">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['type' => GridView::TYPE_DEFAULT, 'heading' => $this->title], 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-plus"></i>', ['create'], ['title' => Module::t('default', 'CREATE'), 'class' => 'btn btn-success']) . ' ' . Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Module::t('default', 'RESET')])], '{toggleData}'], 'export' => false, 'pjax' => true, 'condensed' => true, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'id', 'width' => '75px'], 'name', ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'status', 'vAlign' => 'middle'], ['class' => 'kartik\\grid\\ActionColumn', 'vAlign' => 'middle']]]);
?>
</div>
Exemplo n.º 5
0
<?php

use yii\helpers\Html;
use sadovojav\gallery\Module;
$this->title = Module::t('default', 'CREATE');
$this->params['breadcrumbs'] = [['label' => Module::t('default', 'GALLERIES'), 'url' => ['index']], $this->title];
?>

<div class="gallery-create">
    <div class="page-header">
        <div class="row">
            <div class="col-md-12">
                <h1><?php 
echo $this->title;
?>
</h1>
            </div>
        </div>
    </div>

    <?php 
echo $this->render('_form', ['model' => $model]);
?>
</div>
Exemplo n.º 6
0
                                }']]);
    ?>

                    <div id="images" class="row">
                        <?php 
    if (count($model->files)) {
        foreach ($model->files as $key => $value) {
            echo $this->render('_image', ['model' => $value]);
        }
    }
    ?>
                    </div>
                <?php 
}
?>
            </div>
        </div>
    </div>

    <hr />

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Module::t('default', 'CREATE') : Module::t('default', 'UPDATE'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
</div>
Exemplo n.º 7
0
use yii\helpers\Html;
use sadovojav\gallery\Module;
$this->title = Module::t('default', 'UPDATE') . ' ' . Html::encode($model->name);
$this->params['breadcrumbs'] = [['label' => Module::t('default', 'GALLERIES'), 'url' => ['index']], ['label' => Html::encode($model->name), 'url' => ['view', 'id' => $model->id]], Module::t('default', 'UPDATE')];
?>

<div class="gallery-update">
    <div class="page-header">
        <div class="row">
            <div class="col-md-9">
                <h1><?php 
echo Html::encode($model->name);
?>
</h1>
            </div>

            <div class="col-md-3">
                <div class="pull-right">
                    <?php 
echo Html::a(Module::t('default', 'VIEW'), ['view', 'id' => $model->id], ['class' => 'btn btn-warning btn-sm']);
?>
                </div>
            </div>
        </div>
    </div>

    <?php 
echo $this->render('_form', ['model' => $model]);
?>
</div>
Exemplo n.º 8
0
<div class="gallery-view">
    <div class="page-header">
        <div class="row">
            <div class="col-md-9">
                <h1><?php 
echo Html::encode($model->name);
?>
</h1>
            </div>

            <div class="col-md-3">
                <div class="pull-right">
                    <?php 
echo Html::a(Module::t('default', 'CREATE'), ['create'], ['class' => 'btn btn-success btn-sm']);
?>
                    <?php 
echo Html::a(Module::t('default', 'UPDATE'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary btn-sm']);
?>
                    <?php 
echo Html::a(Module::t('default', 'DELETE'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger btn-sm', 'data' => ['confirm' => Module::t('default', 'DELETE_ITEM'), 'method' => 'post']]);
?>
                </div>
            </div>
        </div>
    </div>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'name', 'status:boolean', 'created', 'updated']]);
?>
</div>