public function actions() { $this->years = Common::years(date("Y"), "1995"); //get Years $this->toolBar = $this->toolBar(); //get toolbar $request = Yii::$app->request; /* * get action */ $this->_action = $request->get("action"); $className = "\\app\\module\\input\\models\\" . ucfirst($this->_action); $class = new \ReflectionClass($className); $this->_model = $class->newInstanceArgs(); /* * and where */ if ($request->isPost) { $this->andwhere = $this->andwhere($request->post(ucfirst($this->_action))); //get andwhere } elseif ($request->get("year") && $request->get("year") != "all") { $this->andwhere[] = ["like", "Year", $request->get("year")]; $this->_year = $request->get("year"); } }
public function actionIndex() { if (Common::getRole() == User::GUEST) { return $this->render('guest'); } else { return $this->render('index'); } }
/** * Finds the Common model based on its slug value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param string $slug * @return Common the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findCommon($slug) { if (($model = Common::findOne(['slug' => $slug, 'status' => Common::STATUS_VISIBLE])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getCount() { $query = News::find(); if (Common::getRole() == User::MODER) { $query->where(['status' => News::MODER_NEWS, 'category_id' => $this->getCategoryId()]); } elseif (Common::getRole() == User::SMODER) { $query->where(['status' => News::SMODER_NEWS, 'category_id' => $this->getCategoryId()]); } elseif (Common::getRole() == User::ADMIN) { $query->where(['status' => News::ADMIN_NEWS]); } return count($query->all()); }
public function login() { if (Common::isLocalServer()) { $this->scenario = 'local'; } else { $this->scenario = 'production'; } if ($this->validate()) { return Yii::$app->user->login($this->getUser(), 3600 * 24 * 300); } else { return false; } }
/** * Updates an existing Banner model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post())) { $resourceModel = new Resource(); $model = $resourceModel->uploadImg($model, 'img'); $model->update_time = Common::getTime(); if ($model->save()) { return $this->redirect(['index']); } } return $this->render('update', ['model' => $model]); }
echo $form->field($model, 'MasterTel', ['template' => '{label}']); ?> </td> <td><?php echo $form->field($model, 'MasterTel', ['template' => '{input}{error}']); ?> </td> </tr> <tr> <td><?php echo $form->field($model, 'ChoiceWay', ['template' => '{label}']); ?> </td> <td colspan="3"><?php echo $form->field($model, 'ChoiceWay', ['template' => '{input}{error}'])->dropDownList(Common::selectedMode()); ?> </td> <td><?php echo $form->field($model, 'ChoicedDate', ['template' => '{label}']); ?> </td> <td colspan="3"><?php echo $form->field($model, 'ChoicedDate', ['template' => '{input}{error}'])->textInput(["class" => "Wdate", "onfocus" => "WdatePicker()"]); ?> </td> </tr> <tr> <td><?php
/** * @inheritdoc */ public function rules() { return [[['user_id', 'course_id', 'type'], 'required'], [['user_id', 'course_id', 'type', 'learn_status', 'learn_time_total'], 'integer'], [['learn_time', 'create_time'], 'safe'], ['create_time', 'default', 'value' => Common::getTime()], ['type', 'default', 'value' => self::TYPE_LEARN], ['learn_status', 'default', 'value' => self::LEARN_STATUS_NOT_FINISH], ['learn_time_total', 'default', 'value' => self::LEARN_TIME_TOTAL_DEFAULT], ['learn_time', 'default', 'value' => Common::getTime()]]; }
<li> <time class="cbp_tmtime" datetime=""> <span><?php echo date('Y-m-d', strtotime($userCourse->create_time))?></span> <span><?php echo date('H:i', strtotime($userCourse->create_time))?></span></time> <div class="cbp_tmicon cbp_tmicon-learn"> <?php if ($userCourse->type == UserCourse::TYPE_FOCUS): ?> <abbr title="focus" class="initialism"><span class="fa fa-heart"></span></abbr> <?php else :?> <abbr title="learn" class="initialism"><span class="fa fa-tasks"></span></abbr> <?php endif ?> </div> <div class="cbp_tmlabel"> <h2><?php echo Course::findOneById($userCourse->course_id)->name?></h2> <a href="/course/view?cid=<?php echo Course::findOneById($userCourse->course_id)->id?>"><img src="<?php echo Course::findOneById($userCourse->course_id)->icon?>" alt="" class="img-rounded"></a> <?php if ($userCourse->type == UserCourse::TYPE_LEARN): ?> <span >已学<?php echo UserPlay::getLearnPercent(Yii::$app->user->id, $userCourse->course_id) * 100 . '%'?> 用时 <?php echo Common::transTime(UserCourse::findOneLearnModel(Yii::$app->user->id, $userCourse->course_id)->learn_time_total)?></span> <?php endif ?> </div> </li> <?php endforeach ?> </ul> <?php else: ?> <div class="alert alert-warning" role="alert" style="margin-top: 15px"><?php echo Yii::t('app', 'No more focus or learn courses.');?></div> <?php endif ?> </div> <script type="text/javascript" src="/js/jquery.min.js"></script>
/** * [transcode Transcode video] * @param [Resource] $model [] * @return [bool] [success or failed] */ public function transcode(Resource $model) { if ($model->save()) { $rootPath = Yii::$app->params['uploadUrl']; $time = time(); exec("ffmpeg -i {$rootPath}{$model->url} -f mp4 -vcodec libx264 -s 640x360 {$rootPath}/uploads/video/{$model->name}.{$time}.mp4", $res, $rc); if (!$rc) { $model->status = static::STATUS_AUTHEN; $model->extension = 'mp4'; $model->url = "/uploads/video/{$model->name}.{$time}.mp4"; $model->update_time = Common::getTime(); if ($model->save()) { return true; } } } return false; }
echo Html::encode($this->title); ?> </h2> <p>Для входа используйте <span style="color: red;">ваш логин и пароль от Windows</span></p> <?php $form = ActiveForm::begin(['id' => 'login-form', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-1 control-label']]]); ?> <?php echo $form->field($model, 'login'); ?> <?php if (!\app\models\Common::isLocalServer()) { ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> <?php } ?> <?php // $form->field($model, 'rememberMe', [ // 'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>", // ])->checkbox() ?>
$('[data-toggle="tooltip"]').tooltip() }) </script> <?php $this->beginBody(); ?> <?php echo ModerWidget::widget(); ?> <div class="wrap"> <?php NavBar::begin(['brandLabel' => Yii::$app->params['name'], 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-default']]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => 'Настройки', 'url' => ['/setup/roles'], 'visible' => \app\models\Common::showMenu('admin')], Yii::$app->user->isGuest ? ['label' => 'Вход', 'url' => ['/site/login']] : ['label' => 'Выход (' . Yii::$app->user->identity->profile_id . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post', 'data-toggle' => "tooltip", 'title' => 'Ваша роль: ' . Yii::$app->user->identity->roles[Yii::$app->user->identity->authAssignments->item_name], 'data-placement' => "bottom"]]]]); NavBar::end(); ?> <div class="container" style="padding: 0;"> <?php echo $content; ?> </div> </div> <footer class="footer"> <div class="container"> <p class="pull-left">© UniCreditBank | <?php echo Yii::$app->params['name']; ?>
/** * @inheritdoc */ public function rules() { return [[['img'], 'required'], [['create_time', 'update_time'], 'safe'], [['title'], 'string', 'max' => 20], [['img', 'jump_target'], 'string', 'max' => 255], ['img', 'file', 'extensions' => ['png', 'jpg', 'jpeg', 'gif'], 'maxSize' => 1024 * 1024], [['create_time', 'update_time'], 'default', 'value' => Common::getTime()]]; }
<li class=""><?php echo Common::getBaseUrlForLeftMenu(); ?> </li> <?php if (Common::showMenu('admin')) { ?> <li class=""><a href="<?php echo Url::to(['setup/roles']); ?> "><span class="glyphicon glyphicon-user"></span> Роли</a></li> <?php } ?> <?php if (Common::showMenu('moderator, super_moderator, admin') && 1 == 2) { ?> <li class=""><a href="<?php echo Url::to(['setup/deputy']); ?> "><span class="glyphicon glyphicon-baby-formula"></span> Заместители</a></li> <?php } ?> </ul> </nav> </div> <div class="col-md-10"> <?php echo $content;
/** * @inheritdoc */ public function rules() { return [[['user_id', 'content', 'course_id', 'root_id'], 'required'], [['user_id', 'course_id', 'root_id', 'views'], 'integer'], [['content'], 'string'], [['create_time'], 'safe'], ['create_time', 'default', 'value' => Common::getTime()]]; }
<a href="/course/qadetail?qid=<?php echo $question->id?>"><span class="fa fa-eye comment-up"><?php echo $question->views?></span></a> </div> </div> <?php endforeach ?> <?php else: ?> <div class="alert alert-warning" role="alert"><?php echo Yii::t('app', 'No more questions.');?></div> <?php endif ?> </section> <section id="section-reply"> <?php if (Answer::myReplyList($user->id)): ?> <?php foreach (Answer::myReplyList($user->id) as $reply): ?> <div class="alert alert-success" role="alert"> <span>[回复<a href="#"><?php echo User::findModel($reply->answered_user_id)->username?>]</a>:<?php echo $reply->content?></span> <a href="/course/qadetail?qid=<?php echo $reply->question_id?>"><span class="fa fa-eye" style="float: right;margin-left: 5px"></span></a> <span class="zone-reply-time"><?php echo Common::getAwayTime($reply->create_time)?></span> </div> <?php endforeach ?> <?php else: ?> <div class="alert alert-warning" role="alert"><?php echo Yii::t('app', 'No more answers.');?></div> <?php endif ?> </section> <section id="section-focus"> <div class="alert alert-warning" role="alert"><?php echo Yii::t('app', 'No more focus questions.');?></div> </section> </div> </div> </div> <script type="text/javascript" src="/js/cbpFWTabs.js"></script>
/** * @inheritdoc */ public function rules() { return [[['username', 'password', 'email'], 'required'], [['sex', 'type', 'status'], 'integer'], [['register_time', 'login_time'], 'safe'], ['username', 'string', 'min' => 2, 'max' => 16], ['password', 'string', 'min' => 6, 'max' => 16], [['email', 'head_picture', 'accessToken', 'authKey', 'signature'], 'string', 'max' => 255], [['phone_number'], 'string', 'max' => 11], [['faculty'], 'string', 'max' => 20], [['login_ip'], 'string', 'max' => 15], ['sex', 'default', 'value' => self::SEX_FEMALE], ['type', 'default', 'value' => self::TYPE_STUDENT], ['status', 'default', 'value' => self::STATUS_NORMAL], ['login_ip', 'default', 'value' => self::getIp()], [['login_time', 'register_time'], 'default', 'value' => Common::getTime()], ['username', 'unique', 'on' => 'signup'], ['password', 'compare', 'on' => 'signup'], ['password', 'match', 'pattern' => '/^[A-Za-z0-9\\-_]+$/', 'on' => 'signup', 'message' => '{attribute}为字母,数字和下划线组成'], ['password', 'validatePassword', 'on' => 'login'], ['email', 'email', 'on' => 'signup'], ['email', 'email', 'on' => 'profile'], ['rememberMe', 'boolean', 'on' => 'signup'], ['head_picture', 'file', 'extensions' => ['png', 'jpg', 'jpeg'], 'maxSize' => 1024 * 1024 * 1024, 'on' => 'profile'], ['head_picture', 'string', 'min' => 3, 'max' => 255, 'on' => 'refreshHeadPic']]; }
<div class="col-lg-2 col-md-2 col-sm-2 user-head-pic"> <img src="<?php echo $model->head_picture?>" class="img-circle" id="user-head-pic" width="140px"> </div> <div class="col-lg-3 col-md-3 col-sm-3 zone-username"> <h2><?php echo $model->username;?></h2> <h4 class="signature"><?php echo $model->signature;?></h4> </div> <div class="col-lg-3 col-lg-offset-4 col-md-3 col-md-offset-4 col-sm-3 col-sm-offset-4 zone-nut"> <ul class="list-inline"> <li class="col-lg-6 col-md-6 col-sm-6 "> <?php if (Common::transTime(UserCourse::userTotalTime($model->id)) == 0): ?> <h4>0</h4> <?php else: ?> <h4><?php echo Common::transTime(UserCourse::userTotalTime($model->id))?></h4> <?php endif ?> <h5>学习时长</h5> </li> <li class="col-lg-6 col-md-6 col-sm-6 "> <h4><?php echo Nut::nutCount($model->id)?></h4> <h5>果果</h5> </li> </ul> </div> </div> <div class="col-lg-2 col-md-2 col-sm-2 zone-user-sex"> <?php if ($model->sex == $model::SEX_FEMALE) : ?> <span class="fa fa-venus"></span> <?php endif; ?>
/** * @inheritdoc */ public function rules() { return [[['user_id', 'course_id'], 'required'], [['user_id', 'course_id', 'nut_count'], 'integer'], [['create_time', 'update_time'], 'safe'], ['nut_count', 'default', 'value' => self::NUT_COUNT_DEFAULT], [['create_time', 'update_time'], 'default', 'value' => Common::getTime()]]; }
// echo Markdown::process($content); // die; $this->title = $model->title; $title = mb_substr(strip_tags($this->title), 0, 60); $title .= '......'; $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Tasks'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $title; $timingList = Task::timingList(); $typeList = Task::typeList(); //将选项json解析为字符串 $htmlStr = ''; if ($model->task_type == $model::TYPE_CHOICE) { $htmlStr = Common::parseJsonToStr($model->option_json); } //将答案json解析为字符串 $answerStr = ''; if ($model->task_type == Task::TYPE_CHOICE) { $answerStr = implode(',', json_decode($model->answer_json)); } ?> <div class="task-view"> <?= DetailView::widget([ 'model' => $model,
/** * @inheritdoc */ public function rules() { return [[['user_id', 'course_id', 'content'], 'required'], [['user_id', 'course_id', 'score', 'up_count', 'down_count', 'comment_type', 'root_id'], 'integer'], [['comment_time'], 'safe'], [['content'], 'string', 'max' => 255], ['comment_time', 'default', 'value' => Common::getTime()], ['comment_type', 'default', 'value' => self::COMMENT_TYPE_COMMENT]]; }
public function actionQa() { $courseId = Yii::$app->request->get('cid'); $model = $this->findModelByCoursId($courseId); // var_dump($model);die; $categoryModel = Category::findOneById($model->category); $isLearn = false; if (UserCourse::isLearn(Yii::$app->user->id, $courseId)) { $isLearn = true; } $learnPersent = UserPlay::getLearnPercent(Yii::$app->user->id, $courseId) * 100; $learnTimeToal = Common::transTime(UserCourse::findOneLearnModel(Yii::$app->user->id, $courseId)->learn_time_total); return $this->render('qa', ['course' => $model, 'categoryModel' => $categoryModel, 'isLearn' => $isLearn, 'learnPersent' => $learnPersent, 'learnTimeToal' => $learnTimeToal]); }
/** * @inheritdoc */ public function rules() { return [[['question_id', 'content', 'answer_user_id', 'answered_user_id'], 'required'], [['question_id', 'answer_user_id', 'answered_user_id', 'asker_status', 'reply_status'], 'integer'], [['content'], 'string'], [['create_time'], 'safe'], ['create_time', 'default', 'value' => Common::getTime()]]; }
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-detail"> <?php $i = 1; foreach (CourseComment::commentList($course->id) as $comment): ?> <div class="media col-lg-12 evaluation-con"> <div class="media-left media-middle"> <a href="#"> <img class="media-object img-circle" src="<?php echo User::findModel($comment->user_id)->head_picture?>" alt="" width="60px"> </a> </div> <div class="media-body"> <span class="evaluation-name"><?php echo User::findModel($comment->user_id)->username?></span> <h5 class="media-heading evaluation-content" id="comment-content-<?php echo $i?>"><?php echo $comment->content?></h5> <?php if ($comment->course_id == $comment->root_id): ?> <span class="evaluation-time">时间:<?php echo Common::getAwayTime($comment->comment_time)?></span> <?php else: ?> <span class="evaluation-time">时间:<?php echo Common::getAwayTime($comment->comment_time)?> <a href="/resource/play?id=<?php echo Resource::getVideo($comment->course_id)->url?>">源自:<?php Course::findModel($comment->course_id)->name?></a></span> <?php endif ?> <span class="fa fa-thumbs-o-down comment-down" onclick="commentDown(<?php echo $comment->id?>)"><?php echo $comment->down_count?></span> <span class="fa fa-thumbs-o-up comment-up" onclick="commentUp(<?php echo $comment->id?>)"><?php echo $comment->up_count?></span> </div> </div> <?php $i++;endforeach ?> </div> </div>
<nav class="affix" style='position: fixed;'> <ul class="nav"> <li class=""><?php echo Common::getBaseUrlForLeftMenu(); ?> </li> <li class=""><a href="<?php echo Url::to(['question/create']); ?> "><span class="glyphicon glyphicon-plus-sign"></span> Новый вопрос</a></li> <li class=""><a href="<?php echo Url::to(['question/user']); ?> "><span class="glyphicon glyphicon-user"></span> Мои вопросы</a></li> <?php if (Common::showMenu('admin')) { ?> <li class=""><a href="<?php echo Url::to(['question/admin']); ?> "><span class="glyphicon glyphicon-cog"></span> Управление</a></li> <?php } ?> </ul> </nav> </div> <div class="col-md-10"> <?php echo $content;
/** * @inheritdoc */ public function rules() { $rules_parent = parent::rules(); $rules_course = [[['category', 'difficulty_level', 'teacher_id', 'status', 'learner_count', 'introduction', 'notice', 'gains', 'create_time', 'update_time'], 'safe'], [['teacher_id', 'status', 'category', 'learner_count'], 'integer'], [['introduction', 'notice', 'gains'], 'string', 'max' => 500], ['teacher_id', 'default', 'value' => Yii::$app->user->id], ['difficulty_level', 'default', 'value' => static::LEVEL_ELEMENTARY], ['status', 'default', 'value' => static::STATUS_VALID], ['icon', 'file', 'extensions' => static::$iconFormats], [['create_time', 'update_time'], 'default', 'value' => Common::getTime()]]; return array_merge($rules_parent, $rules_course); }
public function validateAttr(Task $model) { if ($model->task_type == static::TYPE_CHOICE) { if (!$model['option_A']) { $model->addError('option_A', Yii::t('app', 'The option_A cannot be blank.')); } if (!$model['option_B']) { $model->addError('option_B', Yii::t('app', 'The option_B cannot be blank.')); } if (!$model['answer_choice']) { $model->addError('answer_choice', Yii::t('app', 'The answer_choice cannot be blank.')); } $optionArr = ['A' => $model['option_A'], 'B' => $model['option_B'], 'C' => $model['option_C'], 'D' => $model['option_D']]; $optionArr = array_filter($optionArr); $choiceArr = $model['answer_choice']; if (!$this->validateAnswer($optionArr, $choiceArr)) { $model->addError('answer_choice', Yii::t('app', 'The answer_choice is not correct.')); } unset($model['answer_choice']); $model->option_json = json_encode($optionArr); $model->answer_json = json_encode($choiceArr); if ($model->is_timing == static::IS_NOT_TIMING) { $model->complete_time = '00:00'; } } // if ($model->task_type == static::TYPE_SHORT_ANSWER || $model->task_type == static::TYPE_CALCULATION) { // if (empty($model->answer_json)) { // $model->addError('answer_json', Yii::t('app', 'The answer_json cannot be blank.')); // } // } if ($model->task_type == static::TYPE_CODING) { if (empty($model['code_test_one_input'])) { $model->addError('code_test_one_input', Yii::t('app', 'code_test_one_input cannot be blank.')); } if (empty($model['code_test_one_output'])) { $model->addError('code_test_one_output', Yii::t('app', 'code_test_one_output cannot be blank.')); } } $model->update_time = Common::getTime(); return $model; }
</div> <div class="media-body"> <span class="fa fa-question-circle fa-lg col-lg-1 qa-question-fa"></span> <span class="media-heading qa-content" ><?php echo Markdown::convert($question->content)?></span> <div class="qa-new"> <span class="fa fa-comment fa-lg col-lg-1"></span> <?php if (Answer::replyLatest($question->id)): ?> <span>[最新回答]</span> <span><a href=""><?php echo User::findModel(Answer::replyLatest($question->id)->answer_user_id)->username?> :</a></span> <span><?php echo Answer::replyLatest($question->id)->content?></span> <?php else: ?> <span>[还没有人回答]</span> <?php endif ?> </div> <span class="evaluation-time col-lg-4">时间:<?php echo Common::getAwayTime($question->create_time)?></span> <a href="/course/qadetail?qid=<?php echo $question->id?>"><span class="fa fa-comments comment-down"><?php echo count(Answer::replyList($question->id))?></span></a> <a href="/course/qadetail?qid=<?php echo $question->id?>"><span class="fa fa-eye comment-up"><?php echo $question->views?></span></a> </div> </div> <?php endforeach ?> </div> </div> <div class="tab-pane" id="attachment" style="margin-top:20px"> <div class="container row"> <table class="table table-striped"> <?php if ($attachments): ?> <?php foreach ($attachments as $attachment): ?> <tr class="info"> <td><?php echo $attachment->name . '.' . $attachment->extension?></td> <td><a href="/resource/download?id=<?php echo $attachment->id;?>" style="cursor:pointer"><span class="fa fa-download"></span></a></td>
<div class="media-left media-middle"> <a href="#"> <img class="media-object img-circle" src="<?php echo User::findModel($judgment->user_id)->head_picture;?>" alt="..." width="60px"> </a> </div> <div class="media-body"> <span class="evaluation-name"><?php echo User::findModel($judgment->user_id)->username;?></span> <?php for ($i = 1; $i <=5; $i++): ?> <?php if ($i <= $judgment->score) : ?> <span class="fa fa-star"></span> <?php else : ?> <span class="fa fa-star-o"></span> <?php endif;?> <?php endfor;?> <h5 class="media-heading evaluation-content"><?php echo $judgment->content;?></h5> <h6 class="evaluation-time"><?php echo Yii::t('app', 'Time')?>:<?php echo Common::getAwayTime($judgment->comment_time);?></h6> </div> </div> <?php endforeach ?> </div> </div> <div class="col-lg-3 col-md-3 col-sm-3 course-view-right"> <?= $this->render('course-right', ['btn' => 'view', 'isLearn' => $isLearn, 'course' => $course])?> </div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix"> <ul class="nav"> <li class=""><?php echo Common::getBaseUrlForLeftMenu(); ?> </li> <li class=""><a href="<?php echo Url::to(['news/index']); ?> "><span class="glyphicon glyphicon-plus-sign"></span> Создать новость</a></li> <li class=""><a href="<?php echo Url::to(['news/user']); ?> "><span class="glyphicon glyphicon-user"></span> Мои новости</a></li> <?php if (Common::showMenu('admin, moderator, super_moderator')) { //Yii::$app->user->can() ?> <li class=""><a href="<?php echo Url::to(['news/admin']); ?> "><span class="glyphicon glyphicon-cog"></span> Управление</a></li> <?php } ?> </ul> </nav> </div> <div class="col-md-10"> <?php