コード例 #1
0
 public function actionParams($modal = null)
 {
     $paramsPath = Yii::getAlias($this->module->paramsPath);
     $paramsFile = $paramsPath . DIRECTORY_SEPARATOR . 'params.php';
     $params = $this->module->params;
     $model = new ObjectModel(PlatformParams::className());
     $model->setAttributes($params);
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate() && Yii::$app->request->getBodyParam('task') !== 'refresh') {
             FileHelper::createDirectory($paramsPath);
             try {
                 file_put_contents($paramsFile, '<?php return ' . var_export($model->toArray(), true) . ';');
                 @chmod($paramsFile, 0777);
                 Yii::$app->session->setFlash(Alert::TYPE_SUCCESS, Yii::t('gromver.platform', 'Configuration saved.'));
                 if ($modal) {
                     ModalIFrame::refreshParent();
                 }
             } catch (\Exception $e) {
                 Yii::$app->session->setFlash(Alert::TYPE_DANGER, $e->getMessage());
             }
         }
     }
     if ($modal) {
         Yii::$app->grom->applyModalLayout();
     }
     return $this->render('params', ['model' => $model]);
 }
コード例 #2
0
 public function actionLogin($modal = null)
 {
     if (!\Yii::$app->user->isGuest) {
         $this->goHome();
     }
     $model = new LoginForm();
     //make the captcha required if the unsuccessful attempts are more of thee
     if ($this->getLoginAttempts() >= $this->module->attemptsBeforeCaptcha) {
         $model->scenario = 'withCaptcha';
     }
     if ($model->load($_POST)) {
         if ($model->login()) {
             $this->setLoginAttempts(0);
             //if login is successful, reset the attempts
             if ($modal) {
                 ModalIFrame::refreshPage();
             }
             return $this->goBack();
         } else {
             //if login is not successful, increase the attempts
             $this->setLoginAttempts($this->getLoginAttempts() + 1);
             Yii::$app->session->setFlash(Alert::TYPE_DANGER, Yii::t('gromver.platform', 'Authorization is failed.'));
         }
     }
     if ($modal) {
         Yii::$app->grom->layout = 'modal';
     } else {
         $this->module->layout = $this->module->loginLayout;
     }
     return $this->render('login', ['model' => $model]);
 }
コード例 #3
0
 /**
  * Creates a new Tag model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param string|null $backUrl
  * @param bool|null $modal
  * @return mixed
  * @throws NotFoundHttpException
  */
 public function actionCreate($backUrl = null, $modal = null)
 {
     $model = new Tag();
     $model->loadDefaultValues();
     $model->status = Tag::STATUS_PUBLISHED;
     if ($modal) {
         Yii::$app->applyModalLayout();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if ($modal) {
             ModalIFrame::postData(['id' => $model->id, 'title' => $model->title, 'description' => Yii::t('gromver.platform', 'Tag: {title}', ['title' => $model->title]), 'link' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'value' => $model->id . ':' . $model->alias]);
         }
         return $this->redirect($backUrl ? $backUrl : ['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #4
0
 public function actionParams($type = 'main', $modal = null)
 {
     /*$paramsPath = Yii::getAlias($this->module->paramsPath);
             $paramsFile = $paramsPath . DIRECTORY_SEPARATOR . 'params.php';
     
             $params = $this->module->params;
     
             $model = new ObjectModel(MainParams::className());
             $model->setAttributes($params);*/
     /** @var \gromver\platform\core\components\ParamsObject $params */
     $params = Yii::$app->paramsManager->{$type};
     $model = new ObjectModel($params);
     $model->setAttributes($params->toArray());
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate() && Yii::$app->request->getBodyParam('task') !== 'refresh') {
             try {
                 $params->load($model->toArray())->save();
                 Yii::$app->session->setFlash(Alert::TYPE_SUCCESS, Yii::t('gromver.platform', 'Configuration saved.'));
                 if ($modal) {
                     ModalIFrame::refreshParent();
                 }
             } catch (\Exception $e) {
                 Yii::$app->session->setFlash(Alert::TYPE_DANGER, $e->getMessage());
             }
         }
     }
     if ($modal) {
         Yii::$app->applyModalLayout();
     }
     $items = [];
     foreach (Yii::$app->paramsManager->getParamsInfo() as $itemType => $info) {
         /** @var \gromver\platform\core\components\ParamsObject $params */
         $params = Yii::$app->paramsManager->{$itemType};
         $items[] = ['label' => $params->paramsName(), 'url' => ['params', 'type' => $itemType, 'modal' => $modal], 'active' => $itemType == $type];
     }
     return $this->render('params', ['paramsMenuItems' => $items, 'model' => $model]);
 }
コード例 #5
0
ファイル: _form.php プロジェクト: ezsky/yii2-platform-core
    </div>

    <div class="row">
        <div class="col-sm-6">
            <?php 
$idTags = Html::getInputId($model, 'tags');
$handlerJs = <<<JS
function(data) {
    var select = \$("#{$idTags}").append('<option value="' + data.id + '">' + data.title + '</option>'),
        selectedValues = select.val() || [];
        selectedValues.push(data.id);

    select.val(\$.unique(selectedValues)).trigger('change');
}
JS;
echo $form->field($model, 'tags', ['wrapperOptions' => ['class' => 'col-sm-9'], 'inputTemplate' => '<div class="input-group select2-bootstrap-append">{input}' . \gromver\widgets\ModalIFrame::widget(['options' => ['class' => 'input-group-addon', 'title' => \Yii::t('gromver.platform', 'Select Tag')], 'label' => '<i class="glyphicon glyphicon-folder-open"></i>', 'url' => ['/tag/backend/default/select', 'modal' => true], 'dataHandler' => $handlerJs]) . \gromver\widgets\ModalIFrame::widget(['options' => ['class' => 'input-group-addon', 'title' => \Yii::t('gromver.platform', 'Add Tag')], 'label' => '<i class="glyphicon glyphicon-plus"></i>', 'url' => ['/tag/backend/default/create', 'modal' => true], 'dataHandler' => $handlerJs]) . '</div>'])->widget(\kartik\select2\Select2::className(), ['data' => \yii\helpers\ArrayHelper::map($model->tags, 'id', 'title'), 'options' => ['multiple' => true], 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'pluginOptions' => ['multiple' => true, 'placeholder' => Yii::t('gromver.platform', 'Select ...'), 'ajax' => ['url' => \yii\helpers\Url::to(['/tag/backend/default/tag-list'])]]]);
?>
        </div>
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'ordering', ['horizontalCssClasses' => ['wrapper' => 'col-xs-8 col-sm-4', 'label' => 'col-xs-4 col-sm-3']])->textInput();
?>
        </div>
    </div>

    <?php 
//описание версии удобнее выставлять в списках версий
//= $form->field($model, 'versionNote')->textInput()
?>

    <ul class="nav nav-tabs">
コード例 #6
0
 /**
  * Возвращает html кнопки настройки виджета, или false, если у пользователя нет доступа
  * @return string | bool
  */
 public function widgetConfigControl()
 {
     if (!$this->hasConfigureAccess()) {
         return false;
     }
     $objectModel = new ObjectModel($this->className());
     $objectModel->setAttributes($this->_config);
     return ModalIFrame::widget(['options' => ['class' => 'btn btn-default', 'title' => Yii::t('gromver.platform', 'Configure widget')], 'label' => '<i class="glyphicon glyphicon-cog"></i>', 'url' => [$this->getConfigureRoute(), 'modal' => 1], 'formOptions' => ['method' => 'post', 'params' => ['url' => Yii::$app->request->getAbsoluteUrl(), 'widget_id' => $this->id, 'widget_class' => $this->className(), 'widget_context' => $this->context, 'widget_config' => Json::encode($objectModel->toArray(array_keys($this->_config)))]]]);
 }
コード例 #7
0
ファイル: select.php プロジェクト: gromver/yii2-platform
 * @var string $route
 */
$this->title = Yii::t('gromver.platform', 'Select Page');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="page-index">

	<?php 
/*<h1><?= Html::encode($this->title) ?></h1>*/
?>

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

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'grid', 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['attribute' => 'id', 'width' => '50px'], ['attribute' => 'language', 'width' => '50px', 'filter' => Yii::$app->getLanguagesList()], ['attribute' => 'title', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\Page */
    return $model->title . '<br/>' . Html::tag('small', $model->alias, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'value' => function ($model, $index, $widget) {
    /** @var $model \gromver\platform\common\models\Page */
    return $model->getStatusLabel();
}, 'filter' => \gromver\platform\common\models\Page::statusLabels()], ['attribute' => 'tags', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\Page */
    return implode(', ', \yii\helpers\ArrayHelper::map($model->tags, 'id', 'title'));
}, 'filterType' => \dosamigos\selectize\Selectize::className(), 'filterWidgetOptions' => ['items' => \yii\helpers\ArrayHelper::map(\gromver\platform\common\models\Tag::find()->where(['id' => $searchModel->tags])->all(), 'id', 'title', 'group'), 'clientOptions' => ['maxItems' => 1], 'url' => ['/grom/default/tag-list']]], ['value' => function ($model) use($route) {
    return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::emitDataJs(['id' => $model->id, 'description' => Yii::t('gromver.platform', 'Page: {title}', ['title' => $model->title]), 'link' => \gromver\platform\common\models\MenuItem::toRoute($route, ['id' => $model->id]), 'value' => $model->id . ':' . $model->alias])]);
}, 'format' => 'raw']], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['scrollingTop' => 0], 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . '</h3>', 'type' => 'info', 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), [null], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>
コード例 #8
0
 /**
  * @param integer $id
  * @param null $modal
  * @throws HttpException
  * @throws NotFoundHttpException
  */
 public function actionRestore($id, $modal = null)
 {
     $model = $this->findModel($id);
     if ($model->restore()) {
         if ($modal) {
             ModalIFrame::refreshParent();
         } else {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     throw new HttpException(409, Yii::t('gromver.platform', "Version restore is failed:\n{errors}", ['errors' => implode("\n", $model->getRestoreErrors())]));
 }
コード例 #9
0
 */
$this->title = Yii::t('gromver.platform', 'Select Post');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-index">

    <?php 
/*<h1><?= Html::encode($this->title) ?></h1>*/
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'grid', 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['attribute' => 'id', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px'], ['attribute' => 'category_id', 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '80px', 'value' => function ($model) {
    return @$model->category->title;
}, 'filter' => \yii\helpers\ArrayHelper::map(\gromver\platform\basic\modules\news\models\Category::find()->excludeRoots()->orderBy('lft')->all(), 'id', function ($model) {
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title;
})], ['attribute' => 'language', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px', 'filter' => Yii::$app->getAcceptedLanguagesList()], ['attribute' => 'title', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\basic\modules\news\models\Post */
    return $model->title . '<br/>' . Html::tag('small', $model->alias, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\basic\modules\news\models\Post */
    return $model->getStatusLabel();
}, 'width' => '100px', 'filter' => \gromver\platform\basic\modules\news\models\Post::statusLabels()], ['attribute' => 'published_at', 'vAlign' => GridView::ALIGN_MIDDLE, 'format' => ['date', 'd MMM Y H:mm'], 'width' => '160px', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'dd.mm.yyyy'], 'type' => \kartik\date\DatePicker::TYPE_RANGE, 'attribute2' => 'published_at_to']], ['attribute' => 'tags', 'width' => '120px', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\basic\modules\news\models\Category */
    return implode(', ', \yii\helpers\ArrayHelper::map($model->tags, 'id', 'title'));
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => \yii\helpers\ArrayHelper::map(\gromver\platform\basic\modules\tag\models\Tag::find()->where(['id' => $searchModel->tags])->all(), 'id', 'title'), 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'pluginOptions' => ['allowClear' => true, 'placeholder' => Yii::t('gromver.platform', 'Select ...'), 'ajax' => ['url' => \yii\helpers\Url::to(['/grom/tag/backend/default/tag-list'])]]]], ['header' => Yii::t('gromver.platform', 'Action'), 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) use($route) {
    /** @var $model \gromver\platform\basic\modules\news\models\Post */
    return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::postDataJs(['id' => $model->id, 'title' => $model->title, 'description' => Yii::t('gromver.platform', 'Post: {title}', ['title' => $model->title]), 'route' => \gromver\platform\basic\modules\menu\models\MenuItem::toRoute($route, ['id' => $model->id]), 'link' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'value' => $model->id . ':' . $model->alias])]);
}, 'width' => '80px', 'mergeHeader' => true, 'format' => 'raw']], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['scrollingTop' => 0], 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . '</h3>', 'type' => 'info', 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), [null], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>
コード例 #10
0
 public function actionRequestPasswordResetToken($modal = null)
 {
     $model = new ForgotPasswordForm();
     $model->scenario = ForgotPasswordForm::SCENARIO_REQUEST;
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($this->sendPasswordResetEmail($model->email)) {
             Yii::$app->getSession()->setFlash(Alert::TYPE_SUCCESS, Yii::t('gromver.platform', 'Check your email for further instructions.'));
             if ($modal) {
                 ModalIFrame::refreshParent();
             }
             return $this->goBack();
         } else {
             Yii::$app->getSession()->setFlash(Alert::TYPE_DANGER, Yii::t('gromver.platform', 'There was an error sending email.'));
         }
     }
     if ($modal) {
         Yii::$app->applyModalLayout();
     } elseif ($this->module->authLayout) {
         Yii::$app->layout = $this->module->authLayout;
     }
     return $this->render('requestPasswordResetToken', ['model' => $model]);
 }
コード例 #11
0
ファイル: _form.php プロジェクト: gromver/yii2-platform-basic
    </div>

    <div class="row">
        <div class="col-sm-6">
            <?php 
$idTags = Html::getInputId($model, 'tags');
$handlerJs = <<<JS
function(data) {
    var select = \$("#{$idTags}").append('<option value="' + data.id + '">' + data.title + '</option>'),
        selectedValues = select.val() || [];
        selectedValues.push(data.id);

    select.val(\$.unique(selectedValues)).trigger('change');
}
JS;
echo $form->field($model, 'tags', ['wrapperOptions' => ['class' => 'col-sm-9'], 'inputTemplate' => '<div class="input-group select2-bootstrap-append">{input}' . \gromver\widgets\ModalIFrame::widget(['options' => ['class' => 'input-group-addon', 'title' => \Yii::t('gromver.platform', 'Select Tag')], 'label' => '<i class="glyphicon glyphicon-folder-open"></i>', 'url' => ['/grom/tag/backend/default/select', 'modal' => true], 'handler' => $handlerJs, 'actionHandler' => 'function(url) {return (new URI(url)).addSearch("TagSearch[language]", $("#' . $idLanguage . '").val())}']) . \gromver\widgets\ModalIFrame::widget(['options' => ['class' => 'input-group-addon', 'title' => \Yii::t('gromver.platform', 'Add Tag')], 'label' => '<i class="glyphicon glyphicon-plus"></i>', 'url' => ['/grom/tag/backend/default/create', 'modal' => true], 'handler' => $handlerJs, 'actionHandler' => 'function(url) {return (new URI(url)).addSearch("language", $("#' . $idLanguage . '").val())}']) . '</div>'])->widget(\kartik\select2\Select2::className(), ['data' => \yii\helpers\ArrayHelper::map($model->tags, 'id', 'title'), 'options' => ['multiple' => true], 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'pluginOptions' => ['multiple' => true, 'placeholder' => Yii::t('gromver.platform', 'Select ...'), 'ajax' => ['url' => \yii\helpers\Url::to(['/grom/tag/backend/default/tag-list']), 'data' => new \yii\web\JsExpression('function(params) { return {q:params.term, language:$("#' . $idLanguage . '").val()}; }')]]]);
?>
        </div>
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'ordering', ['horizontalCssClasses' => ['wrapper' => 'col-xs-8 col-sm-4', 'label' => 'col-xs-4 col-sm-3']])->textInput();
?>
        </div>
    </div>

    <?php 
//= $form->field($model, 'versionNote')->textInput()
?>

    <ul class="nav nav-tabs">
        <li class="active"><a href="#main-options" data-toggle="tab"><?php 
コード例 #12
0
    echo Html::tag('span', Yii::t('gromver.platform', 'Language'), ['class' => 'navbar-text']) . '&nbsp;';
    ?>
        <div class="btn-group">
            <?php 
    echo implode('', array_map(function ($language) {
        return Html::a($language, Yii::$app->urlManager->createUrl(Yii::$app->getHomeUrl(), $language), ['class' => 'btn navbar-btn btn-xs' . ($language === Yii::$app->language ? ' btn-primary active' : ' btn-default')]);
    }, Yii::$app->acceptedLanguages));
    ?>
        </div>
    </div>
    <div class="navbar-text navbar-right">
        <i class="glyphicon glyphicon-log-in"></i>&nbsp;&nbsp;
        <?php 
    $loginUrl = Yii::$app->user->loginUrl;
    $loginUrl['modal'] = 1;
    echo ModalIFrame::widget(['options' => ['class' => 'navbar-link'], 'popupOptions' => ['class' => 'auth-popup'], 'label' => Yii::t('gromver.platform', 'Login'), 'url' => $loginUrl]);
    ?>
    </div>
<?php 
} else {
    $items = [];
    if (Yii::$app->user->can('administrate')) {
        $items[] = ['label' => '<i class="glyphicon glyphicon-cog"></i> ' . Yii::t('gromver.platform', 'Admin Panel'), 'url' => ['/grom/backend/default/index']];
        /** @var \gromver\platform\basic\modules\menu\models\MenuItem $activeMenu */
        if ($activeMenu = Yii::$app->menuManager->activeMenu) {
            $items[] = ['label' => '<i class="glyphicon glyphicon-pencil"></i> ' . $activeMenu->getLinkTitle(), 'url' => ['/grom/menu/backend/item/update', 'id' => $activeMenu->id, 'backUrl' => Yii::$app->urlManager->createUrl($activeMenu->getFrontendViewLink())]];
        }
        $items[] = '<li class="divider"></li>';
    }
    $items[] = ['label' => '<i class="glyphicon glyphicon-log-out"></i> ' . Yii::t('gromver.platform', 'Logout'), 'url' => ['/grom/auth/default/logout']];
    ?>
コード例 #13
0
 public function run()
 {
     return \gromver\widgets\ModalIFrame::widget(['options' => $this->options, 'label' => '<i class="glyphicon glyphicon-hdd"></i> ' . Yii::t('gromver.platform', 'Versions'), 'url' => ['/grom/version/backend/default/item', 'item_id' => $this->model->getPrimaryKey(), 'item_class' => $this->model->className()]]);
 }
コード例 #14
0
ファイル: select.php プロジェクト: gromver/yii2-platform
/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var gromver\platform\backend\modules\menu\models\MenuItemSearch $searchModel
 */
$this->title = Yii::t('gromver.platform', 'Select Menu Item');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="menu-index">

	<?php 
/*<h1><?= Html::encode($this->title) ?></h1>*/
?>

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

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'grid', 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['attribute' => 'id', 'width' => '50px'], ['attribute' => 'language', 'width' => '50px', 'filter' => Yii::$app->getLanguagesList()], ['attribute' => 'title', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title . '<br/>' . Html::tag('small', $model->path, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'value' => function ($model, $index, $widget) {
    /** @var $model \gromver\platform\common\models\MenuItem */
    return $model->getStatusLabel();
}, 'filter' => \gromver\platform\common\models\MenuItem::statusLabels()], ['value' => function ($model) {
    return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::emitDataJs(['id' => $model->id, 'description' => Yii::t('gromver.platform', 'Menu Item: {title}', ['title' => $model->title]), 'link' => Yii::$app->urlManagerFrontend->createUrl($model->viewLink), 'value' => $model->id . ':' . $model->alias])]);
}, 'format' => 'raw']], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['scrollingTop' => 0], 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . '</h3>', 'type' => 'info', 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), [null], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>
コード例 #15
0
ファイル: ModalField.php プロジェクト: gromver/yii2-models
 protected function modalButton()
 {
     $inputId = Html::getInputId($this->getModel(), $this->getAttribute());
     return ModalIFrame::widget(['options' => ['class' => 'input-group-btn'], 'label' => Html::tag('span', '<i class="glyphicon glyphicon-folder-open"></i>', ['class' => 'btn btn-default']), 'url' => $this->url, 'dataHandler' => "function(data){\n                    \$('#{$inputId}').val(data.value)\n                }"]);
 }
コード例 #16
0
ファイル: Versions.php プロジェクト: gromver/yii2-platform
 public function run()
 {
     return ModalIFrame::widget(['modalOptions' => ['header' => Yii::t('gromver.platform', 'Item Versions Manager - "{title}" (ID:{id})', ['title' => $this->model->title, 'id' => $this->model->getPrimaryKey()]), 'size' => Modal::SIZE_LARGE], 'buttonContent' => Html::a('<i class="glyphicon glyphicon-hdd"></i> ' . Yii::t('gromver.platform', 'Versions'), ['/grom/version/default/item', 'item_id' => $this->model->getPrimaryKey(), 'item_class' => $this->model->className()], ['class' => 'btn btn-default btn-sm'])]);
 }
コード例 #17
0
ファイル: Widget.php プロジェクト: gromver/yii2-platform
 public function widgetConfigControl()
 {
     ob_start();
     ob_implicit_flush(false);
     $formId = $this->getId() . '-form';
     ModalIFrame::begin(['modalOptions' => ['header' => Yii::t('gromver.platform', 'Widget "{name}" (ID: {id})', ['name' => $this->className(), 'id' => $this->id]), 'size' => Modal::SIZE_LARGE], 'buttonOptions' => ['class' => 'btn btn-default', 'tag' => 'button', 'onclick' => "jQuery('#{$formId}').submit()", 'title' => Yii::t('gromver.platform', 'Configure widget')]]);
     echo Html::beginForm(['/grom/widget/default/configure', 'modal' => 1], 'post', ['id' => $formId]);
     echo Html::hiddenInput('url', Yii::$app->request->getAbsoluteUrl());
     echo Html::hiddenInput('widget_id', $this->id);
     echo Html::hiddenInput('widget_class', $this->className());
     echo Html::hiddenInput('widget_context', $this->context);
     $objectModel = new ObjectModel($this->className());
     $objectModel->setAttributes($this->_config);
     echo Html::hiddenInput('widget_config', Json::encode($objectModel->toArray(array_keys($this->_config))));
     echo '<i class="glyphicon glyphicon-cog"></i>';
     echo Html::endForm();
     ModalIFrame::end();
     return ob_get_clean();
 }
コード例 #18
0
    <div class="input-group navbar-right">
        <?php 
    echo Html::tag('span', Yii::t('gromver.platform', 'Language'), ['class' => 'navbar-text']) . '&nbsp;';
    ?>
        <div class="btn-group">
            <?php 
    echo implode('', array_map(function ($language) {
        return Html::a($language, Yii::$app->urlManager->createUrl(Yii::$app->getHomeUrl(), $language), ['class' => 'btn navbar-btn btn-xs' . ($language === Yii::$app->language ? ' btn-primary active' : ' btn-default')]);
    }, Yii::$app->languages));
    ?>
        </div>
    </div>
    <?php 
    $loginUrl = Yii::$app->user->loginUrl;
    $loginUrl['modal'] = 1;
    echo ModalIFrame::widget(['buttonOptions' => ['tag' => 'div', 'class' => 'navbar-text navbar-right'], 'modalOptions' => ['size' => Modal::SIZE_DEFAULT, 'closeButton' => false], 'iframeOptions' => ['height' => '320px'], 'buttonContent' => '<i class="glyphicon glyphicon-log-in"></i>&nbsp;&nbsp;' . Html::a(Yii::t('gromver.platform', 'Login'), $loginUrl, ['class' => 'navbar-link'])]);
} else {
    $items = [];
    if (Yii::$app->user->can('administrate')) {
        $items[] = ['label' => '<i class="glyphicon glyphicon-cog"></i> ' . Yii::t('gromver.platform', 'Admin Panel'), 'url' => Yii::$app->urlManagerBackend->createUrl('/')];
        /*$items[] = ModalIFrame::widget([
              'buttonOptions' => [
                  'tag' => 'li'
              ],
              'modalOptions' => [
                  'size' => Modal::SIZE_LARGE,
                  'closeButton' => false
              ],
              'buttonContent' => Html::a('<i class="glyphicon glyphicon-pencil"></i> ' . Yii::t('gromver.platform', 'Configuration'), ['/grom/default/params', 'modal' => 1])
          ]);*/
        $items[] = ['label' => '<i class="glyphicon glyphicon-trash"></i> ' . Yii::t('gromver.platform', 'Flush Cache'), 'url' => ['/grom/default/flush-cache']];
コード例 #19
0
ファイル: _form.php プロジェクト: gromver/yii2-platform
            <?php 
//= $form->field($model, 'path')->textInput(['maxlength' => 2048])
?>

            <?php 
echo $form->field($model, 'link_type')->dropDownList($model->getLinkTypes());
?>

            <?php 
$this->registerJs("\$('#" . Html::getInputId($model, 'link_type') . "').change(function (event){\n                if(\$(this).val() === '" . \gromver\platform\common\models\MenuItem::LINK_ROUTE . "') {\n                    \$('#router-button a').attr('href', " . \yii\helpers\Json::encode(\yii\helpers\Url::toRoute(['routers'])) . ")\n                } else {\n                    \$('#router-button a').attr('href', " . \yii\helpers\Json::encode(\yii\helpers\Url::toRoute(['select'])) . ")\n                }\n            }).change()");
?>

            <?php 
$linkLabel = Html::activeLabel($model, 'link');
$linkInputId = Html::getInputId($model, 'link');
echo $form->field($model, 'link', ['template' => "{label}\n{beginWrapper}\n<div class=\"input-group\">{input}{controls}</div>\n{error}\n{endWrapper}\n{hint}", 'parts' => ['{controls}' => \gromver\widgets\ModalIFrame::widget(['id' => 'router', 'modalOptions' => ['header' => $linkLabel, 'size' => \yii\bootstrap\Modal::SIZE_LARGE], 'buttonOptions' => ['tag' => 'span', 'class' => 'input-group-btn'], 'buttonContent' => Html::a('<span class="glyphicon glyphicon-folder-open"></span>', ['routers'], ['class' => 'btn btn-default']), 'iframeHandler' => "function(data){\n                                    \$('#{$linkInputId}').val(data.link)\n                                }"])]])->textInput(['maxlength' => 1024]);
?>

            <?php 
echo $form->field($model, 'secure')->dropDownList(['' => 'No', '1' => 'Yes']);
?>

            <?php 
echo $form->field($model, 'ordering')->textInput();
?>

            <?php 
echo $form->field($model, 'layout_path')->textInput(['maxlength' => 1024]);
?>

            <?php 
コード例 #20
0
ファイル: _form.php プロジェクト: gromver/yii2-platform-core
    </ul>
    <br/>
    <div class="tab-content">
        <div id="main" class="tab-pane active">
            <?php 
echo $form->field($model, 'link_type')->dropDownList(\gromver\platform\core\modules\menu\models\MenuItem::linkTypeLabels());
?>

            <?php 
$this->registerJs("\$('#" . Html::getInputId($model, 'link_type') . "').change(function (event){\n                if(\$(this).val() === '" . \gromver\platform\core\modules\menu\models\MenuItem::LINK_ROUTE . "') {\n                    \$('a#router').attr('href', " . \yii\helpers\Json::encode(\yii\helpers\Url::toRoute(['routers'])) . ")\n                } else {\n                    \$('a#router').attr('href', " . \yii\helpers\Json::encode(\yii\helpers\Url::toRoute(['select', 'MenuItemSearch[link_type]' => \gromver\platform\core\modules\menu\models\MenuItem::LINK_ROUTE])) . ")\n                }\n            }).change()");
?>

            <?php 
$linkLabel = Html::activeLabel($model, 'link');
$linkInputId = Html::getInputId($model, 'link');
echo $form->field($model, 'link', ['template' => "{label}\n{beginWrapper}\n<div class=\"input-group\">{input}{controls}</div>\n{error}\n{endWrapper}\n{hint}", 'parts' => ['{controls}' => \gromver\widgets\ModalIFrame::widget(['options' => ['id' => 'router', 'class' => 'input-group-btn'], 'url' => ['routers'], 'label' => Html::tag('span', '<span class="glyphicon glyphicon-folder-open"></span>', ['class' => 'btn btn-default']), 'dataHandler' => "function(data){\n                                    \$('#{$linkInputId}').val(data.route)\n                                }"])]])->textInput(['maxlength' => 1024]);
?>

            <?php 
echo $form->field($model, 'access_rule')->dropDownList(\yii\helpers\ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'name'), ['prompt' => 'Не выбрано']);
?>

            <?php 
echo $form->field($model, 'secure')->dropDownList(['' => 'No', '1' => 'Yes']);
?>

            <?php 
// формируем список шаблонов пункта меню
$layouts = Yii::$app->controller->module->menuItemLayouts;
if ($model->layout_path && !array_key_exists($model->layout_path, $layouts)) {
    // если шаблона пункта меню нету в списке(кастомный шаблон), добавляем его в список
コード例 #21
0
ファイル: select-post.php プロジェクト: gromver/yii2-platform
 * @var gromver\platform\backend\modules\news\models\PostSearch $searchModel
 */
$this->title = Yii::t('gromver.platform', 'Select Post');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-index">

    <?php 
/*<h1><?= Html::encode($this->title) ?></h1>*/
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'grid', 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['attribute' => 'id', 'width' => '50px'], ['attribute' => 'category_id', 'width' => '80px', 'value' => function ($model) {
    return @$model->category->title;
}, 'filter' => \yii\helpers\ArrayHelper::map(\gromver\platform\common\models\Category::find()->noRoots()->orderBy('lft')->all(), 'id', function ($model) {
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title;
})], ['attribute' => 'language', 'filter' => Yii::$app->getLanguagesList()], ['attribute' => 'title', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\Post */
    return $model->title . '<br/>' . Html::tag('small', $model->alias, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\Post */
    return $model->getStatusLabel();
}, 'filter' => \gromver\platform\common\models\Post::statusLabels()], ['attribute' => 'published_at', 'format' => ['date', 'd MMM Y H:mm'], 'width' => '160px', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['options' => ['value' => is_int($searchModel->published_at) ? date('d.m.Y', $searchModel->published_at) : ''], 'pluginOptions' => ['format' => 'dd.mm.yyyy']]], ['attribute' => 'tags', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\Post */
    return implode(', ', \yii\helpers\ArrayHelper::map($model->tags, 'id', 'title'));
}, 'filterType' => \dosamigos\selectize\Selectize::className(), 'filterWidgetOptions' => ['items' => \yii\helpers\ArrayHelper::map(\gromver\platform\common\models\Tag::find()->where(['id' => $searchModel->tags])->all(), 'id', 'title', 'group'), 'clientOptions' => ['maxItems' => 1], 'url' => ['/grom/default/tag-list']]], ['value' => function ($model) {
    return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::emitDataJs(['id' => $model->id, 'description' => Yii::t('gromver.platform', 'Post: {title}', ['title' => $model->title]), 'value' => $model->id . ':' . $model->alias])]);
}, 'format' => 'raw']], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['scrollingTop' => 0], 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . ' </h3>', 'type' => 'info', 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), [null], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>
コード例 #22
0
ファイル: update.php プロジェクト: gromver/yii2-platform
<?php

use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model gromver\platform\common\models\Page */
$this->title = Yii::t('gromver.platform', 'Update Page: {title}', ['title' => $model->title]);
$this->params['breadcrumbs'][] = ['label' => Yii::t('gromver.platform', 'Pages'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('gromver.platform', 'Update');
?>

<div class="page-update">

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

    <p>
        <?php 
echo \gromver\widgets\ModalIFrame::widget(['modalOptions' => ['header' => Yii::t('gromver.platform', 'Item Versions Manager - "{title}" (ID:{id})', ['title' => $model->title, 'id' => $model->id]), 'size' => \yii\bootstrap\Modal::SIZE_LARGE], 'buttonContent' => Html::a('<i class="glyphicon glyphicon-hdd"></i> ' . Yii::t('gromver.platform', 'Versions'), ['/grom/version/default/item', 'item_id' => $model->id, 'item_class' => $model->className()], ['class' => 'btn btn-default btn-sm'])]);
?>
    </p>

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

</div>
コード例 #23
0
ファイル: MenuItemRoutes.php プロジェクト: oakcms/oakcms
 /**
  * Renders the content of a menu item.
  * Note that the container and the sub-menus are not rendered here.
  * @param array $item the menu item to be rendered. Please refer to [[items]] to see what data might be in the item.
  * @return string the rendering result
  */
 protected function renderItem($item)
 {
     $routers = '';
     $header = '';
     if (isset($item['label'])) {
         $template = ArrayHelper::getValue($item, 'headerTemplate', $this->headerTemplate);
         $header = strtr($template, ['{icon}' => $item['icon'], '{label}' => $item['label']]);
     }
     foreach ($item['items'] as $router) {
         $template = ArrayHelper::getValue($router, 'template', $this->routerTemplate);
         $routerContent = strtr($template, ['{icon}' => $router['icon'], '{link}' => isset($router['url']) ? Html::a($router['label'], $router['url']) : Html::a($router['label'], '#', ['onclick' => ModalIFrame::postDataJs(['route' => MenuItem::toRoute($router['route']), 'link' => Yii::$app->urlManager->createUrl($router['route'])])])]);
         $routerOptions = array_merge($this->routerOptions, $router['options']);
         $routers .= Html::tag(ArrayHelper::remove($routerOptions, 'tag', 'div'), $routerContent, $routerOptions);
     }
     $template = ArrayHelper::getValue($item, 'template', $this->itemTemplate);
     return strtr($template, ['{header}' => $header, '{routers}' => $routers]);
 }
コード例 #24
0
 public function run($modal = null)
 {
     if (!($widget_id = Yii::$app->request->getBodyParam('widget_id'))) {
         throw new BadRequestHttpException(Yii::t('gromver.platform', "Widget ID isn't specified"));
     }
     if (!($widget_class = Yii::$app->request->getBodyParam('widget_class'))) {
         throw new BadRequestHttpException(Yii::t('gromver.platform', "Widget Class isn't specified"));
     }
     if (($widget_context = Yii::$app->request->getBodyParam('widget_context')) === null) {
         throw new BadRequestHttpException(Yii::t('gromver.platform', "Widget Context isn't specified"));
     }
     $selected_context = Yii::$app->request->getBodyParam('selected_context', $widget_context);
     $task = Yii::$app->request->getBodyParam('task');
     if (($url = Yii::$app->request->getBodyParam('url')) === null) {
         throw new BadRequestHttpException(Yii::t('gromver.platform', "Widget page url isn't specified"));
     }
     //$url = Yii::$app->request->getBodyParam('url', Yii::$app->request->getReferrer());
     if ($task == 'delete') {
         if (Yii::$app->request->getBodyParam('bulk-method')) {
             foreach (WidgetConfigPersonal::find()->where('widget_id=:widget_id AND context>=:context AND language=:language', [':widget_id' => $widget_id, ':context' => $selected_context, ':language' => Yii::$app->language])->each() as $configModel) {
                 $configModel->delete();
             }
         } elseif ($configModel = WidgetConfigPersonal::findOne(['widget_id' => $widget_id, 'context' => $selected_context, 'language' => Yii::$app->language])) {
             $configModel->delete();
         }
         if ($modal) {
             ModalIFrame::refreshParent();
         }
     }
     $widget_config = Yii::$app->request->getBodyParam('widget_config', '[]');
     $widgetConfig = Json::decode($widget_config);
     $widgetConfig['id'] = $widget_id;
     $widgetConfig['context'] = $selected_context;
     $widgetConfig['skipInit'] = true;
     /** @var \gromver\platform\basic\modules\widget\widgets\Widget $widget */
     $widget = new $widget_class($widgetConfig);
     $model = new ObjectModel($widget);
     if (($task == 'save' || $task == 'refresh') && $model->load(Yii::$app->request->post())) {
         if ($model->validate() && $task == 'save') {
             $configModel = WidgetConfigPersonal::findOne(['widget_id' => $widget_id, 'context' => $selected_context, 'language' => Yii::$app->language]) or $configModel = new WidgetConfigPersonal();
             $configModel->loadDefaultValues();
             $configModel->widget_id = $widget_id;
             $configModel->widget_class = $widget_class;
             $configModel->context = $selected_context;
             $configModel->url = $url;
             $configModel->setParamsArray($model->toArray());
             $configModel->save();
             if (Yii::$app->request->getBodyParam('bulk-method')) {
                 foreach (WidgetConfigPersonal::find()->where('widget_id=:widget_id AND context>:context AND language=:language', [':widget_id' => $widget_id, ':context' => $selected_context, ':language' => Yii::$app->language])->each() as $configModel) {
                     /** @var $configModel WidgetConfigPersonal */
                     $configModel->delete();
                 }
             }
             if ($modal) {
                 ModalIFrame::refreshParent();
             } else {
                 return $this->redirect($url);
             }
         }
     }
     if ($modal) {
         Yii::$app->grom->applyModalLayout();
     }
     return $this->controller->render($this->view, ['model' => $model, 'widget' => $widget, 'widget_id' => $widget_id, 'widget_class' => $widget_class, 'widget_config' => $widget_config, 'widget_context' => $widget_context, 'selected_context' => $selected_context, 'url' => $url]);
 }
コード例 #25
0
 /**
  * Creates a new Tag model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param string|null $language
  * @param string|null $sourceId
  * @param string|null $backUrl
  * @param bool|null $modal
  * @return mixed
  * @throws NotFoundHttpException
  */
 public function actionCreate($sourceId = null, $language = null, $backUrl = null, $modal = null)
 {
     $model = new Tag();
     $model->loadDefaultValues();
     $model->language = $language ? $language : Yii::$app->language;
     $model->status = Tag::STATUS_PUBLISHED;
     if ($sourceId && $language) {
         $sourceModel = $this->findModel($sourceId);
         $model->language = $language;
         $model->translation_id = $sourceModel->translation_id;
         $model->alias = $sourceModel->alias;
         $model->status = $sourceModel->status;
         $model->metakey = $sourceModel->metakey;
         $model->metadesc = $sourceModel->metadesc;
     } else {
         $sourceModel = null;
     }
     if ($modal) {
         Yii::$app->grom->applyModalLayout();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if ($modal) {
             ModalIFrame::postData(['id' => $model->id, 'title' => $model->title, 'description' => Yii::t('gromver.platform', 'Tag: {title}', ['title' => $model->title]), 'link' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'value' => $model->id . ':' . $model->alias]);
         }
         return $this->redirect($backUrl ? $backUrl : ['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'sourceModel' => $sourceModel]);
     }
 }