Example #1
0
 /**
  * @param \pavlinter\adm\Adm $adm
  */
 public function loading($adm)
 {
     if (Yii::$app->user->can('AdmRoot')) {
         $adm->on($adm::EVENT_TOP_MENU, function ($event) {
             echo \app\widgets\Menu::widget(['options' => ['class' => 'nav navbar-nav navbar-left'], 'items' => [['key' => 'admhidemenu', 'label' => '<span>' . self::t('', 'Root Tools') . '</span>', 'url' => ['/admhidemenu']]], 'encodeLabels' => false]);
         });
     }
     $this->leftMenu = $adm->params['left-menu'];
     $this->checkMenu($adm);
 }
Example #2
0
 public function init()
 {
     $id = $this->getId();
     $buttonId = 'fm-btn-' . $id;
     $this->fileManager = ArrayHelper::merge(['controller' => Adm::getInstance()->id . '/elfinder', 'filter' => 'image', 'template' => '<div class="input-group fm-input-cont"><span class="input-group-addon">{button}</span>{input}</div>', 'options' => ['class' => 'form-control'], 'buttonTag' => 'a', 'buttonName' => '', 'buttonOptions' => ['class' => 'glyphicon glyphicon-folder-open filemanager-btn', 'href' => 'javascript:void(0);', 'id' => $buttonId, 'data' => ['placement' => 'top']], 'multiple' => true], $this->fileManager);
     if ($this->enablePreview) {
         $basePath = Yii::getAlias($this->basePath);
         $this->getView()->registerJs('
         $("#' . $buttonId . '").tooltip({
             html: true,
             title: function(){
                 var v = $(this).closest(".fm-input-cont").find("#' . Html::getInputId($this->model, $this->attribute) . '").val();
                 var $img = $("<img src=\\"' . $basePath . '" + v + "\\" class=\\"hide file-input-img\\">");
                 var $loading = $("<span class=\\"file-input-loading fa fa-spinner rotating\\"></span>");
                 $img.on("load", function(){
                     $img.removeClass("hide");
                     $loading.hide();
                 })
                 return $("<div class=\\"file-input-cont\\"><div>").append($loading).append($img);
             },
         });
     ');
     }
     parent::init();
 }
Example #3
0
 public function init()
 {
     if ($this->controller === null) {
         $this->controller = Adm::getInstance()->id . '/elfinder';
     }
     parent::init();
 }
Example #4
0
 /**
  * Initializes the object.
  * This method is invoked at the end of the constructor after the object is initialized with the
  * given configuration.
  */
 public function init()
 {
     parent::init();
     $request = Yii::$app->getRequest();
     $headers = $request->getHeaders();
     //ajax
     if (isset($headers['adm-nestable-ajax'])) {
         $this->ajax();
     } else {
         $view = $this->getView();
         if ($this->btn === null || $this->btn === false) {
             $this->btn = Html::tag('button', '', ['class' => 'btn btn-primary btn-adm-nestable' . ($this->btn === false ? ' hide' : ''), 'data' => ['is-nestable' => Yii::$app->getRequest()->get('nestable', 0), 'gridview-text' => Adm::t('', 'Search', ['dot' => false]), 'nestable-text' => Adm::t('', 'Sort', ['dot' => false])]]);
         }
         $pagination = $this->grid->dataProvider->getPagination();
         if (($params = $pagination->params) === null) {
             $params = $request instanceof Request ? $request->getQueryParams() : [];
         }
         $params['nestable'] = 1;
         $pagination->params = $params;
         $models = $this->grid->dataProvider->getModels();
         if (!$models) {
             $view->registerJs('$(".btn-adm-nestable-view").hide();');
             return null;
         }
         $keys = $this->grid->dataProvider->getKeys();
         $this->registerAssets($view);
         $output = strtr($this->template, ['{btn}' => $this->renderBtn(), '{nestableId}' => $this->id, '{items}' => $this->renderItems($models, $keys), '{pager}' => $this->renderPager()]);
         echo $output;
         unset($params['nestable']);
         $pagination->params = $params;
     }
 }
Example #5
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = Adm::getInstance()->manager->createUserQuery('findByUsername', $this->username);
     }
     return $this->_user;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $sourceMessageTable = static::tableName();
     $query = static::find()->from(['s' => $sourceMessageTable]);
     $sort = isset($params['sort']) ? $params['sort'] : null;
     $emptyTranslation = Yii::$app->request->get('is-empty');
     $isTranslationSearch = $emptyTranslation || isset($params['SourceMessageSearch']['translation']) && $params['SourceMessageSearch']['translation'];
     $isTranslationSort = in_array($sort, ['-translation', 'translation']) ? $sort : null;
     if ($isTranslationSearch || $isTranslationSort) {
         $messageTable = Adm::getInstance()->manager->createMessageQuery('tableName');
         $query->innerJoin(['m' => $messageTable], 'm.id=s.id')->with(['messages']);
         if ($emptyTranslation) {
             $query->andWhere(['m.translation' => '', 'm.language_id' => Yii::$app->i18n->getId()]);
         }
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 100]]);
     $dataProvider->sort->attributes['translation']['asc'] = ['m.translation' => SORT_ASC];
     $dataProvider->sort->attributes['translation']['desc'] = ['m.translation' => SORT_DESC];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($isTranslationSearch) {
         $query->andFilterWhere(['like', 'm.translation', $this->translation]);
     }
     $query->andFilterWhere(['like', 's.category', $this->category])->andFilterWhere(['like', 's.message', $this->message]);
     return $dataProvider;
 }
Example #7
0
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     $adm = Adm::register();
     if (!parent::beforeAction($action) || !$adm->user->can('AdmRoot')) {
         return false;
     }
     return true;
 }
 /**
  * @return string
  */
 public function actionLogin($username)
 {
     $user = User::findByUsername($username);
     if (Yii::$app->user->login($user, 0)) {
         return $this->redirect(['/adm/user/update']);
     }
     return Adm::goBack(['/adm/user/update']);
 }
Example #9
0
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     $adm = Adm::register();
     //required load adm,if use adm layout
     /*if (!parent::beforeAction($action) || !$adm->user->can('AdmRoot')) {
           throw new ForbiddenHttpException('Access denied');
           return false;
       }*/
     return parent::beforeAction($action);
 }
Example #10
0
 /**
  * Executes the widget.
  * @return string the result of widget execution to be outputted.
  */
 public function run()
 {
     $ckeditorOptions = [];
     if ($this->removeFirstTag) {
         $ckeditorOptions['enterMode'] = new JsExpression('CKEDITOR.ENTER_BR');
     }
     $ckeditorOptions = ArrayHelper::merge($ckeditorOptions, $this->clientOptions);
     $options = ArrayHelper::merge(['initOnEvent' => 'focus', 'options' => ['class' => 'form-control form-redactor']], $this->options);
     $options['editorOptions'] = ElFinder::ckeditorOptions(Adm::getInstance()->id . '/elfinder', $ckeditorOptions);
     return $this->form->field($this->model, $this->attribute)->widget(CKEditor::className(), $options);
 }
Example #11
0
 /**
  * Initializes the [[rules]] array by instantiating rule objects from configurations.
  */
 public function init()
 {
     if ($this->user === null) {
         $this->user = Adm::getInstance()->user;
     }
     $this->user = Instance::ensure($this->user, User::className());
     foreach ($this->rules as $i => $rule) {
         if (is_array($rule)) {
             $this->rules[$i] = Yii::createObject(array_merge($this->ruleConfig, $rule));
         }
     }
 }
 /**
  * @return string
  */
 public function actionIndex()
 {
     $module = Module::getInstance();
     /* @var $model \app\modules\admlivechat\models\SettingsForm */
     $model = $module->manager->createSettingsForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->save()) {
             Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully changed!'));
             return Adm::redirect(['index']);
         }
     }
     return $this->render('index', ['model' => $model]);
 }
Example #13
0
 /**
  * Finds the AuthItem model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return AuthItem the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $model = Adm::getInstance()->manager->createAuthItemQuery('findOne', $id);
     if ($model !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #14
0
?>



<div class="languages-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Adm::t('language', 'Create Language'), ['create'], ['class' => 'btn btn-primary']);
?>

        <?php 
echo Html::a('!', '#', ['class' => 'btn btn-primary btn-adm-nestable-view']);
?>
    </p>

    <?php 
echo Adm::widget('GridView', ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'nestable' => ['id' => 'pages-nestable-grid', 'btn' => false, 'nameCol' => 'name', 'parentCol' => false, 'orderBy' => SORT_ASC], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'image', 'format' => 'raw', 'value' => function ($model, $index, $widget) {
    if ($model->image) {
        return Html::img($model->image, ['style' => 'max-width: 100px;max-height:100px;']);
    }
}, 'width' => '100px'], 'name', 'code', ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'active', 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['options' => ['placeholder' => Adm::t('', 'Select ...', ['dot' => false])], 'pluginOptions' => ['allowClear' => true]]], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update} {delete}', 'width' => '70px']]]);
?>

</div>
Example #15
0
?>
<div class="user-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Adm::t('user', 'Create User'), ['create'], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
echo Adm::widget('GridView', ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], 'username', 'email:email', ['attribute' => 'role', 'vAlign' => 'middle', 'value' => function ($model, $key, $index, $widget) {
    return $model::roles($model->role);
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $searchModel::roles(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => Adm::t('', 'Select ...', ['dot' => false])], 'format' => 'raw'], ['attribute' => 'status', 'vAlign' => 'middle', 'value' => function ($model, $key, $index, $widget) {
    return $model::status($model->status);
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $searchModel::status(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => Adm::t('', 'Select ...', ['dot' => false])], 'format' => 'raw'], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{login} {view} {update} {delete}', 'buttons' => ['delete' => function ($url, $model) {
    if ($model->id == Adm::getInstance()->user->getId()) {
        return null;
    }
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']);
}, 'login' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-sunglasses"></span>', ['/profilelogin/default/login', 'username' => $model->username], ['title' => Yii::t('adm/title', 'Login', ['dot' => false]), 'data-method' => 'post', 'data-pjax' => '0']);
}]]]]);
?>
</div>

Example #16
0
 public function init()
 {
     $this->fileManager = ArrayHelper::merge(['controller' => Adm::getInstance()->id . '/elfinder', 'filter' => 'image', 'template' => '<div class="input-group"><span class="input-group-addon">{button}</span>{input}</div>', 'options' => ['class' => 'form-control'], 'buttonTag' => 'a', 'buttonName' => '', 'buttonOptions' => ['class' => 'glyphicon glyphicon-folder-open filemanager-btn', 'href' => 'javascript:void(0);'], 'multiple' => true], $this->fileManager);
     parent::init();
 }
            </table>

            <div style="text-align: center; padding: 10px 0px;">
                <a class="text-font3" href="<?php 
echo Url::to(['default/invoice', 'alias' => $model->alias], true);
?>
" style="background: none repeat scroll 0 0 #88ad09;color: white;display: inline-block;padding: 8px 20px;text-decoration: none;">
                    <?php 
echo Adm::t('oplata/mail', "Pay");
?>
                </a>
            </div>

            <div class="text-font" style="margin: 10px 0px;">
                <?php 
echo Adm::t('oplata/mail', "Link: {url}", ['url' => Url::to(['default/invoice', 'alias' => $model->alias], true)]);
?>
            </div>
        </div>

    </div>
</div>


<?php 
$this->endBody();
?>
</body>
</html>
<?php 
$this->endPage();
Example #18
0
<?php

use pavlinter\adm\Adm;
$adm = Adm::getInstance();
$adm->trigger(Adm::EVENT_FOOTER);
?>


Example #19
0
 /**
  * @throws \yii\base\ExitException
  * @throws \yii\db\Exception
  */
 public static function addDefaultParams()
 {
     if (Yii::$app->request->post('admparams-load-params')) {
         if (Yii::$app->user->can('AdmRoot')) {
             $params = \yii\helpers\ArrayHelper::map(self::find()->asArray()->all(), 'name', 'value');
             $data = [];
             foreach (Yii::$app->params as $name => $value) {
                 if (!isset($params[$name]) && strpos($name, '_') !== 0) {
                     if (in_array(gettype($value), ['integer', 'double', 'string'])) {
                         $data[] = [$name, $value, new \yii\db\Expression('NOW()')];
                     }
                 }
             }
             if ($data) {
                 Yii::$app->db->createCommand()->batchInsert(static::tableName(), ['name', 'value', 'updated_at'], $data)->execute();
             }
             Yii::$app->end(0, \pavlinter\adm\Adm::goBack(['']));
         }
     }
 }
Example #20
0
    <?php 
echo $form->field($model, 'value')->textarea(['rows' => 6]);
?>


    <div class="form-group">
        <?php 
echo InputButton::widget(['label' => $model->isNewRecord ? Adm::t('', 'Create', ['dot' => false]) : Adm::t('', 'Update', ['dot' => false]), 'options' => ['class' => 'btn btn-primary'], 'input' => 'adm-redirect', 'name' => 'redirect', 'formSelector' => $form]);
?>

        <?php 
if ($model->isNewRecord) {
    ?>
            <?php 
    echo InputButton::widget(['label' => Adm::t('', 'Create and insert new', ['dot' => false]), 'options' => ['class' => 'btn btn-primary'], 'input' => 'adm-redirect', 'name' => 'redirect', 'value' => Url::to(['create']), 'formSelector' => $form]);
    ?>
        <?php 
}
?>

        <?php 
echo InputButton::widget(['label' => $model->isNewRecord ? Adm::t('', 'Create and list', ['dot' => false]) : Adm::t('', 'Update and list', ['dot' => false]), 'options' => ['class' => 'btn btn-primary'], 'input' => 'adm-redirect', 'name' => 'redirect', 'value' => Url::to(['index']), 'formSelector' => $form]);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
 /**
  * @param null $id
  * @return string
  */
 public function actionFindUser($id = null)
 {
     $search = Yii::$app->request->get('search');
     $out = ['more' => false];
     if (!is_null($search)) {
         $data = Adm::getInstance()->manager->createUserQuery()->select(['id', 'text' => 'username'])->where(['like', 'username', $search['term']])->limit(20)->asArray()->all();
         $out['results'] = array_values($data);
     } else {
         if ($id > 0) {
             $user = Adm::getInstance()->manager->createUserQuery()->where(['id' => $id])->one();
             $out['results'] = ['id' => $id, 'text' => $user->username];
         } else {
             $out['results'] = ['id' => 0, 'text' => 'No matching records found'];
         }
     }
     return Json::encode($out);
 }
Example #22
0
<?php

use pavlinter\adm\Adm;
/**
 * @var yii\web\View $this
 */
$user = Adm::getInstance()->user;
?>


<div class="adm-default-index">
    <h1><?php 
echo Adm::getInstance()->id;
?>
</h1>
</div>
 /**
  * Deletes an existing Page model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @param null|integer $id_parent
  * @return mixed
  */
 public function actionDelete($id, $id_parent = null)
 {
     if (!in_array($id, Module::getInst()->closeDeletePage)) {
         $this->findModel($id)->delete();
         Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully removed!'));
     }
     $url = ['index', 'id_parent' => 0];
     if ($id_parent !== null) {
         $url['id_parent'] = $id_parent;
     }
     return $this->redirect($url);
 }
 /**
  * Deletes an existing Params model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $this->findModel($id)->delete();
     Yii::$app->getSession()->setFlash('success', Adm::t('', 'Data successfully removed!'));
     return Adm::redirect(['index']);
 }
Example #25
0
/* @var $searchModel pavlinter\adm\models\AuthAssignmentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
Yii::$app->i18n->disableDot();
$this->title = Adm::t('auth', 'Auth Assignments');
$this->params['breadcrumbs'][] = $this->title;
Yii::$app->i18n->resetDot();
?>
<div class="auth-assignment-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Adm::t('auth', 'Create Auth Assignment'), ['create'], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
echo Adm::widget('GridView', ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], 'item_name', ['attribute' => 'user_id', 'value' => function ($model, $index, $widget) {
    if ($model->user) {
        return $model->user->username;
    }
}], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update} {delete}', 'width' => '70px']]]);
?>


</div>
Example #26
0
<?php

use pavlinter\adm\Adm;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model pavlinter\adm\models\AuthAssignment */
Yii::$app->i18n->disableDot();
$this->title = Adm::t('auth', 'Update Auth Assignment: {item_name}', ['item_name' => $model->item_name]);
$this->params['breadcrumbs'][] = ['label' => Adm::t('auth', 'Auth Assignments'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->item_name, 'url' => ['index']];
$this->params['breadcrumbs'][] = Adm::t('auth', 'Update');
Yii::$app->i18n->resetDot();
?>
<div class="auth-assignment-update">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo $this->render('_form', ['model' => $model]);
?>

</div>
Example #27
0
        </div>
    </div>



    <div class="form-group">
        <?php 
echo InputButton::widget(['label' => $model->isNewRecord ? Adm::t('', 'Create', ['dot' => false]) : Adm::t('', 'Update', ['dot' => false]), 'options' => ['class' => 'btn btn-primary'], 'input' => 'adm-redirect', 'name' => 'redirect', 'formSelector' => $form]);
?>

        <?php 
if ($model->isNewRecord) {
    ?>
            <?php 
    echo InputButton::widget(['label' => Adm::t('', 'Create and insert new', ['dot' => false]), 'options' => ['class' => 'btn btn-primary'], 'input' => 'adm-redirect', 'name' => 'redirect', 'value' => Url::to(['create']), 'formSelector' => $form]);
    ?>
        <?php 
}
?>

        <?php 
echo InputButton::widget(['label' => $model->isNewRecord ? Adm::t('', 'Create and list', ['dot' => false]) : Adm::t('', 'Update and list', ['dot' => false]), 'options' => ['class' => 'btn btn-primary'], 'input' => 'adm-redirect', 'name' => 'redirect', 'value' => Url::to(['index']), 'formSelector' => $form]);
?>
    </div>

    <?php 
Adm::end('ActiveForm');
?>

</div>
Example #28
0
<?php

use pavlinter\adm\Adm;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model pavlinter\adm\models\AuthItemChild */
Yii::$app->i18n->disableDot();
$this->title = Adm::t('auth', 'Create Auth Item Child');
$this->params['breadcrumbs'][] = ['label' => Adm::t('auth', 'Auth Item Children'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
Yii::$app->i18n->resetDot();
?>
<div class="auth-item-child-create">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo $this->render('_form', ['model' => $model]);
?>

</div>
Example #29
0
/* @var $searchModel app\models\search\ContactMsgSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
Yii::$app->i18n->disableDot();
$this->title = Adm::t('app/contact_msg', 'Contact Msgs');
$this->params['breadcrumbs'][] = $this->title;
Yii::$app->i18n->resetDot();
?>
<div class="contact-msg-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Adm::t('app/contact_msg', 'Create Contact Msg'), ['create'], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
echo Adm::widget('GridView', ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'format' => 'text', 'width' => '70px', 'hAlign' => 'center'], ['attribute' => 'from_email', 'format' => 'email'], ['attribute' => 'subject', 'format' => 'raw', 'value' => function ($model) {
    return Html::a($model->subject, ['view', 'id' => $model->id]);
}], ['attribute' => 'text', 'format' => 'raw'], ['attribute' => 'created_at', 'format' => 'text', 'width' => '150px', 'vAlign' => 'middle', 'hAlign' => 'center'], ['class' => 'app\\widgets\\BooleanColumn', 'attribute' => 'viewed', 'tableName' => $searchModel::tableName()], ['class' => '\\kartik\\grid\\ActionColumn', 'template' => '{view} {update} {delete}']]]);
?>

</div>
Example #30
-1
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     $adm = Adm::register();
     //required load adm,if use adm layout
     $adm->params['left-menu-active'][] = 'admlivechat';
     return parent::beforeAction($action);
 }