public function actionBaidu() { $this->setMenus(51, "百度第三方登录"); $model = new BaiduConfig(); if ($model->load(LsYii::getRequest()->post())) { $model->save($model->attributes); LsYii::setSuccessMessage(LsYii::gT('save success')); } else { $model = $model->initValue(); } return $this->render('baidu', ['model' => $model]); }
/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $this->setMenus(30, "添加新分类"); $model = new Category(); $id = LsYii::getGetValue('id', null); if ($id) { $model->pid = $id; } if ($model->load(LsYii::getRequest()->post())) { $pid = $model->pid; if ($pid) { $c = Category::findOne(['`id`' => $pid]); $rgt = $c->rgt; $model->root = $c->root; $model->pid = $c->id; $model->level = $c->level + 1; $model->lft = $rgt; $model->rgt = $rgt + 1; } else { $maxRgt = Category::getMaxRgt(); $model->lft = $maxRgt + 1; $model->rgt = $maxRgt + 2; $model->pid = 0; $model->level = 1; } if ($model->save()) { if (!$pid) { $menu = Category::findOne(['`id`' => $model->id]); $menu->root = $model->id; $menu->save(); } else { Category::updateAllCounters(['rgt' => 2], "`lft`<{$rgt} AND `rgt`>={$rgt}"); Category::updateAllCounters(['rgt' => 2, 'lft' => 2], "`lft`>{$rgt}"); } } return $this->redirect(['index']); } else { $model->if_show = \source\libs\Constants::Category_Status_Show; return $this->render('create', ['model' => $model]); } }
public function actionLogin() { $this->layout = 'login'; if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); $message = []; if ($model->load(LsYii::getRequest()->post())) { if ($model->login()) { $this->redirect(\source\helpers\Url::to(['index'])); } else { foreach ($model->getErrors() as $errors) { foreach ($errors as $error) { $message[] = $error; } } } } return $this->render('login', ['model' => $model, 'message' => !empty($message) ? $message[0] : '']); }
#main-content { margin-left: 0px; } .container { width: 100%; } .due-time { color: red; } </style> <div class="site-error"> <h1><?php echo Html::encode($this->title); ?> </h1> <div class="alert alert-danger"> <?php echo nl2br(Html::encode($message)); ?> </div> <p> 页面将在<span class="due-time">3</span>秒后自动跳转,如未跳转<?php echo Html::a(\source\LsYii::gT('这里'), LsYii::getRequest()->getReferrer(), ["node-type" => "run-link"]); ?> </p> </div> <?php $this->registerJs("\$(function() {\n var dt = setInterval(function() {\n var due = \$('.due-time').html();\n if(parseInt(due) <= 1) {\n clearInterval(dt);\n var url = \$('a[node-type=run-link]').attr('href');\n window.location.href = url;\n }\n \$('.due-time').html(parseInt(due) - 1);\n } , 1000);\n })", yii\web\View::POS_END);
/** * 时间设置 * @return type */ public function actionDatetime() { $this->setMenus(58, "时间设置"); $model = new DatetimeConfig(); if ($model->load(LsYii::getRequest()->post())) { $model->save($model->attributes); LsYii::setSuccessMessage(LsYii::gT('save success')); } else { $model = $model->initValue(); } return $this->render('datetime', ['model' => $model]); }