constructCurrent() public static method

public static constructCurrent ( ) : static
return static
 public function create()
 {
     $rr = new RequestResponse();
     $modelClass = $this->modelClassName;
     $model = new $modelClass();
     $model->loadDefaultValues();
     if ($post = \Yii::$app->request->post()) {
         $model->load($post);
     }
     $handler = $model->handler;
     if ($handler) {
         if ($post = \Yii::$app->request->post()) {
             $handler->load($post);
         }
     }
     if ($rr->isRequestPjaxPost()) {
         if (!\Yii::$app->request->post($this->notSubmitParam)) {
             $model->component_settings = $handler->toArray();
             $handler->load(\Yii::$app->request->post());
             if ($model->load(\Yii::$app->request->post()) && $model->validate() && $handler->validate()) {
                 $model->save();
                 \Yii::$app->getSession()->setFlash('success', \Yii::t('skeeks/cms', 'Saved'));
                 return $this->redirect(UrlHelper::constructCurrent()->setCurrentRef()->enableAdmin()->setRoute($this->modelDefaultAction)->normalizeCurrentRoute()->addData([$this->requestPkParamName => $model->{$this->modelPkAttribute}])->toString());
             } else {
                 \Yii::error(Json::encode($model->errors), self::className());
                 \Yii::$app->getSession()->setFlash('error', \Yii::t('skeeks/cms', 'Could not save'));
             }
         }
     }
     return $this->render('_form', ['model' => $model, 'handler' => $handler]);
 }
 public function create(AdminAction $adminAction)
 {
     $modelClassName = $this->modelClassName;
     $model = new $modelClassName();
     $model->loadDefaultValues();
     if ($content_id = \Yii::$app->request->get("content_id")) {
         $contentModel = \skeeks\cms\models\CmsContent::findOne($content_id);
         $model->content_id = $content_id;
     }
     $relatedModel = $model->relatedPropertiesModel;
     $relatedModel->loadDefaultValues();
     $rr = new RequestResponse();
     if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
         $model->load(\Yii::$app->request->post());
         $relatedModel->load(\Yii::$app->request->post());
         return \yii\widgets\ActiveForm::validateMultiple([$model, $relatedModel]);
     }
     if ($rr->isRequestPjaxPost()) {
         $model->load(\Yii::$app->request->post());
         $relatedModel->load(\Yii::$app->request->post());
         if ($model->save() && $relatedModel->save()) {
             \Yii::$app->getSession()->setFlash('success', \Yii::t('skeeks/cms', 'Saved'));
             if (\Yii::$app->request->post('submit-btn') == 'apply') {
                 return $this->redirect(UrlHelper::constructCurrent()->setCurrentRef()->enableAdmin()->setRoute($this->modelDefaultAction)->normalizeCurrentRoute()->addData([$this->requestPkParamName => $model->{$this->modelPkAttribute}])->toString());
             } else {
                 return $this->redirect($this->indexUrl);
             }
         } else {
             \Yii::$app->getSession()->setFlash('error', \Yii::t('skeeks/cms', 'Could not save'));
         }
     }
     return $this->render('_form', ['model' => $model, 'relatedModel' => $relatedModel]);
 }
 public function run()
 {
     $modelClassName = $this->controller->modelClassName;
     $model = new $modelClassName();
     $scenarios = $model->scenarios();
     if ($scenarios && $this->modelScenario) {
         if (isset($scenarios[$this->modelScenario])) {
             $model->scenario = $this->modelScenario;
         }
     }
     $rr = new RequestResponse();
     if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
         return $rr->ajaxValidateForm($model);
     }
     if ($rr->isRequestPjaxPost()) {
         if ($model->load(\Yii::$app->request->post()) && $model->save($this->modelValidate)) {
             \Yii::$app->getSession()->setFlash('success', \Yii::t('app', 'Saved'));
             if (\Yii::$app->request->post('submit-btn') == 'apply') {
                 return $this->controller->redirect(UrlHelper::constructCurrent()->setCurrentRef()->enableAdmin()->setRoute($this->controller->modelDefaultAction)->normalizeCurrentRoute()->addData([$this->controller->requestPkParamName => $model->{$this->controller->modelPkAttribute}])->toString());
             } else {
                 return $this->controller->redirect($this->controller->indexUrl);
             }
         } else {
             \Yii::$app->getSession()->setFlash('error', \Yii::t('app', 'Could not save'));
         }
     }
     $this->viewParams = ['model' => $model];
     return parent::run();
 }
Example #4
0
 /**
  * Формируем данные для хлебных крошек.
  * Эти данные в layout - е будут передаваться в нужный виджет.
  *
  * @return $this
  */
 protected function _initBreadcrumbsData()
 {
     $baseRoute = $this->controller->module instanceof Application ? $this->controller->id : "/" . $this->controller->module->id . "/" . $this->controller->id;
     if ($this->controller->name) {
         $this->controller->view->params['breadcrumbs'][] = ['label' => $this->controller->name, 'url' => $this->controller->getIndexUrl()];
     }
     if ($this->controller->model) {
         $this->controller->view->params['breadcrumbs'][] = ['label' => $this->controller->model->{$this->controller->modelShowAttribute}, 'url' => UrlHelper::constructCurrent()->setRoute($baseRoute . '/' . $this->controller->modelDefaultAction)->set($this->controller->requestPkParamName, $this->controller->model->{$this->controller->modelPkAttribute})->enableAdmin()->normalizeCurrentRoute()->toString()];
     }
     if (count($this->controller->actions) > 1) {
         $this->controller->view->params['breadcrumbs'][] = $this->name;
     }
     return $this;
 }
Example #5
0
 public function create(AdminAction $adminAction)
 {
     $modelClassName = $this->modelClassName;
     $model = new $modelClassName();
     $model->loadDefaultValues();
     $relatedModel = $model->relatedPropertiesModel;
     $relatedModel->loadDefaultValues();
     $passwordChange = new PasswordChangeForm(['user' => $model]);
     $rr = new RequestResponse();
     if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
         $model->load(\Yii::$app->request->post());
         $relatedModel->load(\Yii::$app->request->post());
         $passwordChange->load(\Yii::$app->request->post());
         return \yii\widgets\ActiveForm::validateMultiple([$model, $relatedModel, $passwordChange]);
     }
     if ($rr->isRequestPjaxPost()) {
         $model->load(\Yii::$app->request->post());
         $relatedModel->load(\Yii::$app->request->post());
         if ($model->save() && $relatedModel->save()) {
             if ($passwordChange->new_password) {
                 if (!$passwordChange->changePassword()) {
                     \Yii::$app->getSession()->setFlash('error', "Пароль не изменен");
                 }
             }
             \Yii::$app->getSession()->setFlash('success', \Yii::t('skeeks/cms', 'Saved'));
             if (\Yii::$app->request->post('submit-btn') == 'apply') {
                 return $this->redirect(UrlHelper::constructCurrent()->setCurrentRef()->enableAdmin()->setRoute($this->modelDefaultAction)->normalizeCurrentRoute()->addData([$this->requestPkParamName => $model->{$this->modelPkAttribute}])->toString());
             } else {
                 return $this->redirect($this->indexUrl);
             }
         } else {
             \Yii::$app->getSession()->setFlash('error', \Yii::t('skeeks/cms', 'Could not save'));
         }
     }
     return $this->render('_form', ['model' => $model, 'relatedModel' => $relatedModel, 'passwordChange' => $passwordChange]);
 }
Example #6
0
<?php

/**
 * @author Semenov Alexander <*****@*****.**>
 * @link http://skeeks.com/
 * @copyright 2010 SkeekS (СкикС)
 * @date 09.06.2015
 */
/* @var $this yii\web\View */
/* @var $component \skeeks\cms\relatedProperties\PropertyType */
/* @var $saved bool */
$getData = \Yii::$app->request->get();
$clientOptions = $getData;
$clientOptions['saveUrl'] = \skeeks\cms\helpers\UrlHelper::constructCurrent()->setRoute('/cms/admin-universal-component-settings/save')->toString();
$clientOptions = \yii\helpers\Json::encode($clientOptions);
?>
<? if ($forSave) : ?>
    <?php 
echo $forSave;
?>
<? endif; ?>

<? if ($component instanceof \skeeks\cms\base\ConfigFormInterface) : ?>


    <? $form = \skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab::begin(); ?>
        <? $component->renderConfigForm($form); ?>
        <?php 
echo $form->buttonsStandart($component);
?>
    <? \skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab::end(); ?>
Example #7
0
        sx.Blocked = new sx.classes.Blocked();
    })(sx, sx.\$, sx._);
JS
);
$logoutUrl = \skeeks\cms\helpers\UrlHelper::construct("admin/auth/logout")->enableAdmin()->setCurrentRef();
?>

<div class="main sx-content-block sx-windowReady-fadeIn">
    <div class="col-lg-4"></div>

    <div class="col-lg-4">
        <div class="panel panel-primary sx-panel">
            <div class="panel-body">
                <div class="panel-content">
                        <?php 
$form = ActiveForm::begin(['id' => 'blocked-form', 'validationUrl' => (string) \skeeks\cms\helpers\UrlHelper::constructCurrent()->enableAjaxValidateForm(), 'afterValidateCallback' => 'sx.Blocked.afterValidate']);
?>

                                <div class="row">
                                    <div class="col-lg-3">
                                        <img src="<?php 
echo \skeeks\cms\helpers\Image::getSrc(\Yii::$app->user->identity->image->src);
?>
" style="width: 100%;"/>
                                    </div>
                                    <div class="col-lg-9">
                                        <?php 
echo $form->field($model, 'password')->passwordInput(['placeholder' => 'Пароль', 'autocomplete' => 'off'])->label(\Yii::$app->user->identity->displayName);
?>
                                        <?php 
echo Html::submitButton("<i class='glyphicon glyphicon-lock'></i> Разблокировать", ['class' => 'btn btn-primary', 'name' => 'login-button']);
Example #8
0
            <?php 
echo $form->field($model, 'password')->passwordInput();
?>
            <?php 
echo $form->field($model, 'rememberMe')->checkbox();
?>

            <div class="form-group">
                <?php 
echo Html::submitButton("<i class=\"glyphicon glyphicon-off\"></i> Войти", ['class' => 'btn btn-primary', 'name' => 'login-button']);
?>
            </div>

        <?php 
ActiveForm::end();
?>
        <?php 
echo Html::a('Забыли пароль?', UrlHelper::constructCurrent()->setRoute('cms/auth/forget')->toString());
?>
 |
        <?php 
echo Html::a('Регистрация', UrlHelper::constructCurrent()->setRoute('cms/auth/register')->toString());
?>
        <!--Или социальные сети
        --><?/*= yii\authclient\widgets\AuthChoice::widget([
             'baseAuthUrl' => ['site/auth']
        ]) */?>
    </div>
</div>
<?php 
echo $this->render("_footer");
Example #9
0
?>

    <div class="panel panel-primary sx-panel sx-panel-content">
        <div class="panel-heading sx-no-icon">
            <h2>
                <?php 
echo \yii\widgets\Breadcrumbs::widget(['homeLink' => ['label' => \Yii::t("yii", "Home"), 'url' => ['admin/index', 'namespace' => 'admin']], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
            </h2>
            <div class="panel-actions">
            </div>
        </div><!-- End .panel-heading -->
        <div class="panel-body">
                <div class="panel-content-before">
                    <?php 
if (!\skeeks\cms\helpers\UrlHelper::constructCurrent()->getSystem(\skeeks\cms\modules\admin\Module::SYSTEM_QUERY_NO_ACTIONS_MODEL)) {
    ?>
                        <?php 
    echo $this->params['actions'];
    ?>
                    <?php 
}
?>
                    <?php 
/*= Alert::widget() */
?>
                </div>
                <div class="panel-content sx-unblock-onWindowReady">
                    <!--<div class="sx-show-onWindowReady">-->
                        <?php 
echo \skeeks\cms\modules\admin\widgets\Alert::widget();
Example #10
0
                        <div class="form-group">
                            <?php 
echo Html::submitButton("<i class=\"glyphicon glyphicon-off\"></i> " . \Yii::t('skeeks/cms', 'Log in'), ['class' => 'btn btn-primary', 'name' => 'login-button']);
?>
                        </div>

                    <?php 
ActiveForm::end();
?>
                    <?php 
echo Html::a(\Yii::t('skeeks/cms', 'Forgot your password?'), UrlHelper::constructCurrent()->setRoute('cms/auth/forget')->toString());
?>
 |
                    <?php 
echo Html::a(\Yii::t('skeeks/cms', 'Registration'), UrlHelper::constructCurrent()->setRoute('cms/auth/register')->toString());
?>
                </div>

                <div class="col-lg-3">

                </div>
                <!--Или социальные сети
                --><?/*= yii\authclient\widgets\AuthChoice::widget([
                     'baseAuthUrl' => ['site/auth']
                ]) */?>
            </div>
        </div>
   </section>
</div>
Example #11
0
?>
                        <?php 
echo $form->field($model, 'password')->passwordInput();
?>

                        <div class="form-group">
                            <?php 
echo Html::submitButton("<i class=\"glyphicon glyphicon-off\"></i> " . \Yii::t('skeeks/cms', 'Sign up'), ['class' => 'btn btn-primary', 'name' => 'login-button']);
?>
                        </div>

                    <?php 
ActiveForm::end();
?>
                    <?php 
echo Html::a(\Yii::t('skeeks/cms', 'Authorization'), UrlHelper::constructCurrent()->setRoute('cms/auth/login')->toString());
?>
                </div>

                <div class="col-lg-3">

                </div>
                <!--Или социальные сети
                --><?/*= yii\authclient\widgets\AuthChoice::widget([
                     'baseAuthUrl' => ['site/auth']
                ]) */?>
            </div>
        </div>
   </section>
</div>
Example #12
0
 /**
  * @return UrlHelper
  */
 public function getUrl()
 {
     if ($this->controller->module instanceof Application) {
         $route = $this->controller->id . '/' . $this->id;
     } else {
         $route = $this->controller->module->id . '/' . $this->controller->id . '/' . $this->id;
     }
     $url = UrlHelper::constructCurrent()->setRoute($route)->enableAdmin()->setCurrentRef();
     return $url;
 }
 public function createOrder()
 {
     $cmsUser = null;
     if ($userId = \Yii::$app->request->get('cmsUserId')) {
         $cmsUser = CmsUser::findOne($userId);
     }
     if ($cmsUser) {
         /**
          * @var $shopFuser ShopFuser
          */
         $shopFuser = ShopFuser::getInstanceByUser($cmsUser);
         $model = $shopFuser;
         $rr = new RequestResponse();
         if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
             $model->scenario = ShopFuser::SCENARIO_CREATE_ORDER;
             return $rr->ajaxValidateForm($model);
         }
         if ($rr->isRequestPjaxPost()) {
             try {
                 if ($model->load(\Yii::$app->request->post()) && $model->save()) {
                     $model->scenario = ShopFuser::SCENARIO_CREATE_ORDER;
                     if ($model->validate()) {
                         $order = ShopOrder::createOrderByFuser($model);
                         if (!$order->isNewRecord) {
                             \Yii::$app->getSession()->setFlash('success', \Yii::t('skeeks/shop/app', 'The order #{order_id} created successfully', ['order_id' => $order->id]));
                             if (\Yii::$app->request->post('submit-btn') == 'apply') {
                                 return $this->redirect(UrlHelper::constructCurrent()->setCurrentRef()->enableAdmin()->setRoute($this->modelDefaultAction)->normalizeCurrentRoute()->addData([$this->requestPkParamName => $order->id])->toString());
                             } else {
                                 return $this->redirect($this->indexUrl);
                             }
                         } else {
                             throw new Exception(\Yii::t('skeeks/shop/app', 'Incorrect data of the new order') . ": " . array_shift($order->getFirstErrors()));
                         }
                     } else {
                         throw new Exception(\Yii::t('skeeks/shop/app', 'Not enogh data for ordering') . ": " . array_shift($model->getFirstErrors()));
                     }
                 } else {
                     throw new Exception(\Yii::t('skeeks/shop/app', 'Could not save'));
                 }
             } catch (\Exception $e) {
                 \Yii::$app->getSession()->setFlash('error', $e->getMessage());
             }
         }
         return $this->render($this->action->id, ['cmsUser' => $cmsUser, 'shopFuser' => $model]);
     } else {
         return $this->render($this->action->id . "-select-user");
     }
 }
Example #14
0
        <?php 
$form = ActiveForm::begin(['validationUrl' => UrlHelper::construct('cms/auth/register')->setSystemParam(\skeeks\cms\helpers\RequestResponse::VALIDATION_AJAX_FORM_SYSTEM_NAME)->toString()]);
?>
            <?php 
echo $form->field($model, 'username');
?>
            <?php 
echo $form->field($model, 'email');
?>
            <?php 
echo $form->field($model, 'password')->passwordInput();
?>

            <div class="form-group">
                <?php 
echo Html::submitButton("<i class=\"glyphicon glyphicon-off\"></i> Зарегистрироваться", ['class' => 'btn btn-primary', 'name' => 'login-button']);
?>
            </div>

        <?php 
ActiveForm::end();
?>
        <?php 
echo Html::a('Авторизация', UrlHelper::constructCurrent()->setRoute('cms/auth/login')->toString());
?>

    </div>
</div>
<?php 
echo $this->render("_footer");
Example #15
0
            <button type="submit" class="btn btn-danger btn-xs" onclick="sx.ComponentSettings.Remove.removeUsers(); return false;">
                <i class="glyphicon glyphicon-remove"></i> <?php 
    echo \Yii::t('app', 'Reset settings for all users');
    ?>
            </button>
        <?php 
} else {
    ?>
            <small><?php 
    echo \Yii::t('app', 'Neither user does not have personal settings for this component');
    ?>
</small>
        <?php 
}
?>
    </div>

    <?php 
$search = new \skeeks\cms\models\Search(\skeeks\cms\models\User::className());
$search->search(\Yii::$app->request->get());
$search->getDataProvider()->query->andWhere(['active' => \skeeks\cms\components\Cms::BOOL_Y]);
?>
    <?php 
echo \skeeks\cms\modules\admin\widgets\GridViewHasSettings::widget(['dataProvider' => $search->getDataProvider(), 'filterModel' => $search->getLoadedModel(), 'columns' => [['class' => \yii\grid\DataColumn::className(), 'value' => function (\skeeks\cms\models\User $model, $key, $index, $this) {
    return \yii\helpers\Html::a('<i class="glyphicon glyphicon-cog"></i>', \skeeks\cms\helpers\UrlHelper::constructCurrent()->setRoute('cms/admin-component-settings/user')->set('user_id', $model->id)->toString(), ['class' => 'btn btn-default btn-xs', 'title' => \Yii::t('app', 'Customize')]);
}, 'format' => 'raw'], 'username', 'name', ['class' => \skeeks\cms\grid\ComponentSettingsColumn::className(), 'component' => $component]]]);
?>


<?php 
echo $this->render('_footer');
Example #16
0
 /**
  * layout пустой?
  * @return bool
  */
 public function isEmptyLayout()
 {
     if (UrlHelper::constructCurrent()->getSystem(\skeeks\cms\modules\admin\Module::SYSTEM_QUERY_EMPTY_LAYOUT)) {
         return true;
     }
     return false;
 }
Example #17
0
?>
        <?php 
echo $form->fieldSelect($model, 'orderBy', (new \skeeks\cms\models\CmsContentElement())->attributeLabels());
?>
        <?php 
echo $form->fieldSelect($model, 'order', [SORT_ASC => "ASC (" . \Yii::t('app', 'from smaller to larger') . ")", SORT_DESC => "DESC (" . \Yii::t('app', 'from highest to lowest') . ")"]);
?>
    <?php 
echo $form->fieldSetEnd();
?>

    <?php 
$columns = \skeeks\cms\helpers\UrlHelper::constructCurrent()->getSystem('columns');
?>
    <?php 
$selectedColumns = \skeeks\cms\helpers\UrlHelper::constructCurrent()->getSystem('selectedColumns');
?>

    <?php 
if ($columns) {
    ?>
        <?php 
    echo $form->fieldSet(\Yii::t('app', 'Table fields'));
    ?>

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

                    <label><?php 
    echo \Yii::t('app', 'Available fields');
    ?>