public function actionReorder($id) { if (Yii::$app->request->getIsAjax()) { $section = Section::findOne(['id' => $id]); $section->reorder(Yii::$app->request->post()); } }
public function actionDelete($id) { $model = Section::find()->with('nextSection')->with('prevSection')->where(['id' => $id])->one(); if ($model->markDeleted() === false && !$model->hasErrors()) { throw new ServerErrorHttpException('Failed to update the object for unknown reason.'); } return $model; }
public function parseRequest($manager, $request) { /* @var Section $section */ $pathInfo = $request->getPathInfo(); if (($pos = strpos($pathInfo, '-')) === false && is_numeric($pathInfo)) { $section = Section::find()->where('id = :id', array(':id' => $pathInfo))->andWhere('slug = "" OR slug IS NULL')->one(); } elseif ($pos !== false && is_numeric($id = substr($pathInfo, 0, $pos))) { $section = Section::findOne(['id' => $id, 'slug' => substr($pathInfo, $pos + 1)]); } if (isset($section)) { return ['section/view', ['id' => $section->id, 'slug' => $section->slug]]; } return false; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Section::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'sectionNum', $this->sectionNum])->andFilterWhere(['like', 'sectionCode', $this->sectionCode])->andFilterWhere(['like', 'sectionName', $this->sectionName])->andFilterWhere(['like', 'sectionDesc', $this->sectionDesc]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Section::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'parent' => $this->parent, 'next' => $this->next, 'prev' => $this->prev, 'toc_mode' => $this->toc_mode, 'status' => $this->status, 'comment_mode' => $this->comment_mode, 'comment_num' => $this->comment_num, 'ver' => $this->ver, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { $orders = $this->getDirtyAttributes(['orders']); if (!empty($orders)) { $this->reOrder($orders); } $parent = $this->getDirtyAttributes(['parent']); if (!empty($parent)) { $ancestor = $this->find()->where(['id' => $parent])->one(); $this->ancestor = $ancestor->ancestor; } return true; } return false; }
public function actionCreate($id = null) { if ($id === null) { $post = new Post(); } else { if (($post = Post::findOne(['id' => $id, 'author_id' => Yii::$app->getUser()->getId()])) === null) { throw new HttpException(404, 'Cannot find the requested post.'); } } if (Yii::$app->getRequest()->getIsAjax() && $post->load(Yii::$app->getRequest()->post())) { Yii::$app->getResponse()->format = Response::FORMAT_JSON; return ActiveForm::validate($post); } if ($post->load(Yii::$app->getRequest()->post()) && $post->save()) { return $this->redirect(Post::findOne($id)->getUrl()); } $rootSections = Section::find()->roots()->orderBy('title')->all(); $mainSections = $post->rootSectionId === null ? [] : Section::find()->where(['section_id' => $post->rootSectionId])->orderBy('title')->all(); return $this->render('create', ['post' => $post, 'rootSections' => $rootSections, 'mainSections' => $mainSections]); }
public function actionIndex() { $article = Article::find()->orderBy(['date_time' => SORT_DESC])->one(); if ($article->articlePhotos[0]->photo_path == '') { if (Yii::$app->language == 'ru') { $articleimage = Yii::getAlias('@resource/img/news_ru.jpg'); } else { $articleimage = Yii::getAlias('@resource/img/news_en.jpg'); } } else { $articleimage = $article->articlePhotos[0]->photo_path; } $event = Event::find()->orderBy(['start_timedate' => SORT_ASC])->limit(3)->all(); $section = Section::find()->limit(8)->all(); $innovation_text_on_main_page = Setting::find()->where(['key' => 'innovation_text_on_main_page'])->one(); $cooperation_with_aic = Setting::find()->where(['key' => 'cooperation_with_aic'])->one(); $fill_in_the_blank = Setting::find()->where(['key' => 'fill_in_the_blank'])->one(); $find_out_how_we_can_help_you = Setting::find()->where(['key' => 'find_out_how_we_can_help_you'])->one(); $information_for_Students = Setting::find()->where(['key' => 'information_for_Students'])->one(); $for_scientists_and_enterpreneurs = Setting::find()->where(['key' => 'for_scientists_and_enterpreneurs'])->one(); return $this->render('index', ['article' => $article, 'articleimage' => $articleimage, 'event' => $event, 'section' => $section, 'innovation_text_on_main_page' => $innovation_text_on_main_page->settingLan->index, 'cooperation_with_aic' => $cooperation_with_aic->settingLan->index, 'fill_in_the_blank' => $fill_in_the_blank->settingLan->index, 'find_out_how_we_can_help_you' => $find_out_how_we_can_help_you->settingLan->index, 'information_for_Students' => $information_for_Students->settingLan->index, 'for_scientists_and_enterpreneurs' => $for_scientists_and_enterpreneurs->settingLan->index]); }
/** * Finds the Section model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Section the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Section::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return ActiveQuery */ public function getSection() { return $this->hasOne(Section::className(), ['id' => 'section_id']); }
<?php use backend\assets\ArticleUpdateAsset; use common\models\Section; use yii\web\View; use yii\helpers\Json; /* @var $this yii\web\View */ /* @var $model common\models\Article */ /* @var $sections array */ $items = []; $allTags = ['toc_mode' => Section::getAllTocMode(), 'comment_mode' => Section::getAllCommentMode()]; foreach ($allTags as $field => $fieldTags) { $tmpTags = []; foreach ($fieldTags as $k => $s) { $tmpTags[] = ['value' => strval($k), 'label' => $s]; } $fieldTitle = $model->attributeLabels()[$field]; $items[$field] = ['label' => $fieldTitle, 'title' => $fieldTitle, 'groups' => [['label' => $fieldTitle, 'tags' => $tmpTags]]]; } $js = 'window.digpage=window.digpage||{};window.digpage.update_dropdown_items = ' . Json::encode($items) . ';'; $this->registerJs($js, View::POS_END); ArticleUpdateAsset::register($this); $this->title = Yii::t('backend/section', 'Update {modelClass}: ', ['modelClass' => 'Section']) . ' ' . $model->title; $this->params['breadcrumbs'][] = ['label' => Yii::t('backend/section', 'Sections'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = Yii::t('backend/section', 'Update'); ?> <div class="section-update"> <?php echo $this->render('_update', ['sections' => $sections, 'rootId' => $model->id, 'level' => 1]); ?>
public function actionChildren($id) { $sections = Section::find()->where(['section_id' => $id])->orderBy('title')->all(); Yii::$app->getResponse()->format = Response::FORMAT_JSON; return ArrayHelper::map($sections, 'id', 'title'); }
/** * @return ActiveQuery */ public function getChildren() { return $this->hasMany(Section::className(), ['section_id' => 'id'])->inverseOf('parent'); }
public function actionRelease($id) { $model = $this->findModel($id); $workflowid = ArrayHelper::getValue(Docworkflow::find()->where(['document_id' => $id])->orderBy(['id' => SORT_DESC])->one(), 'id'); //print_r($workflowid . ' level0 ' . $model->user_id); if ($model->load(Yii::$app->request->post())) { //$userid1 = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'id'); $sectionid = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'section_id'); $userFName = ArrayHelper::getValue(User::find()->where(['id' => $model->user_id])->one(), 'userFName'); $userLName = ArrayHelper::getValue(User::find()->where(['id' => $model->user_id])->one(), 'userLName'); $section = ArrayHelper::getValue(Section::find()->where(['id' => $sectionid])->one(), 'sectionName'); $documentname = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'documentName'); $pendingdoc = new Pendingdoc(); $pendingdoc->pendingDocFName = $userLName . ', ' . $userFName; $pendingdoc->pendingDocSection = $section; $pendingdoc->pendingDocName = $documentname; if ($workflowid == null) { if ($pendingdoc->save()) { print_r('level3'); return $this->redirect(['index']); //return $this->redirect('index.php?r=pendingdoc'); } } else { $workflow1 = new Docworkflow(); $workflow1 = $this->findModelWorkflow($workflowid); //$workflow1->id = $workflowid; $workflow1->timeRelease = date('Y-m-d H:i:s'); //$workflow1->totalTimeSpent = date('Y-m-d H:i:s'); $workflow1->user_release = $model->user_id; print_r('level1'); if ($workflow1->save()) { print_r('level2'); if ($pendingdoc->save()) { print_r('level3'); return $this->redirect(['index']); //return $this->redirect('index.php?r=pendingdoc'); } } } } else { return $this->renderAjax('release', ['model' => $model]); } }
public function actionIndex() { /** @var Section[] $sections */ $sections = Section::findRoots(); return $this->render('index', ['sections' => $sections]); }
/** * @return ActiveQuery */ public function getSections() { return $this->hasMany(Section::className(), ['category_id' => 'id']); }
<?php echo Html::a(Yii::t('backend/section', 'Create {modelClass}', ['modelClass' => 'Section']), ['create'], ['class' => 'btn btn-success']); ?> <?php echo Html::a(Yii::t('backend/section', 'Sort {modelClass}', ['modelClass' => 'Section']), ['toc'], ['class' => 'btn btn-primary']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model, $key, $index, $grid) { return ['data' => ['sectionver' => $model->ver]]; }, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'title', 'value' => function ($model, $key, $index, $column) { return Html::a($model->title, ['article/view', 'id' => $key]); }, 'format' => 'raw'], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'status', 'value' => function ($model, $key, $index, $column) { return Html::dropDownList('status' . $key, $model->status, $model->getAllStatus(), ['class' => 'stauts-dropdown', 'data' => ['sectionfield' => 'status']]); }, 'format' => 'raw', 'filter' => Section::getAllStatus()], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'toc_mode', 'value' => function ($model, $key, $index, $column) { return Html::dropDownList('toc_mode' . $key, $model->toc_mode, $model->getAllTocMode(), ['class' => 'toc_mode-dropdown', 'data' => ['sectionfield' => 'toc_mode']]); }, 'format' => 'raw', 'filter' => Section::getAllTocMode()], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'comment_mode', 'value' => function ($model, $key, $index, $column) { return Html::dropDownList('comment_mode' . $key, $model->comment_mode, $model->getAllCommentMode(), ['class' => 'comment_mode-dropdown', 'data' => ['sectionfield' => 'comment_mode']]); }, 'format' => 'raw', 'filter' => Section::getAllCommentMode()], 'updated_at:datetime', ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'created_by', 'value' => function ($model, $key, $index, $column) { if ($model->getCreatedBy() === null) { return ''; } return $model->getCreatedBy()->one()->username; }, 'filter' => false], ['class' => 'yii\\grid\\ActionColumn', 'header' => Yii::t('backend/section', 'Operation'), 'buttons' => ['delete' => function ($url, $model, $key) { return Html::a('<span class="glyphicon glyphicon-trash"></span>', 'javascript:void(0);', ['title' => Yii::t('backend/section', 'Delete'), 'class' => 'lnk-del-section']); }]]]]); ?> </div>
</div> <div class="col-md-12"> <?php echo $form->field($mip, 'phone')->textInput(['maxlength' => true, 'class' => 'ntSaveForms form-control']); ?> </div> <div class="col-md-12"> <?php echo $form->field($mip, 'email')->textInput(['maxlength' => true, 'class' => 'ntSaveForms form-control']); ?> </div> <div class="col-md-12"> <?php echo $form->field($mip, 'section_id')->dropDownList(ArrayHelper::map(Section::find()->all(), 'id', 'sectionRus.section_name')); ?> </div> <div class="col-md-12"> <?php echo '<label>Начало</label>'; echo DateTimePicker::widget(['model' => $mip, 'attribute' => 'created_date', 'language' => 'ru', 'name' => 'datetime_1', 'options' => ['placeholder' => 'Select operating time ...'], 'convertFormat' => true, 'pluginOptions' => ['format' => 'yyyy-MM-dd H:mm:ss', 'startDate' => '01-Mar-2015 12:00 AM', 'todayHighlight' => true, 'todayBtn' => true, 'autoclose' => true]]); ?> </div> <div class="col-md-12"> <?php echo $form->field($mip, 'user_id')->dropDownList(ArrayHelper::map(User::find()->all(), 'id', 'username')); ?> </div> <div class="col-md-12"> <?php
<div class="section-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'content')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'toc_mode')->dropDownList(Section::getAllTocMode()); ?> <?php echo $form->field($model, 'comment_mode')->dropDownList(Section::getAllCommentMode()); ?> <?php echo Html::hiddenInput('isPublish', 0, ['id' => 'hdn-ispublish']); ?> <div class="form-group"> <?php echo Html::submitButton(Yii::t('backend/section', 'Create'), ['class' => 'btn btn-primary']); ?> <?php echo Html::button(Yii::t('backend/section', 'Publish'), ['class' => 'btn btn-success', 'id' => 'btn-publish']); ?> </div>
?> --> <!--<?php echo $form->field($model, 'section_id')->dropDownList(ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), ['prompt' => 'Section']); ?> --> <?php //$form->field($model, 'position_id') echo $form->field($model, 'position_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\Position::find()->all(), 'id', 'positionName'), 'options' => ['placeholder' => 'Select a position'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php //$form->field($model, 'section_id') echo $form->field($model, 'section_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), 'options' => ['placeholder' => 'Select a section'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'userFName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'userMName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'userLName')->textInput(['maxlength' => true]); ?> <?php
public function actionView($id) { $mip = mip::find()->where(['id' => $id])->one(); return $this->render('view', ['mip' => $mip, 'sections' => $sections = Section::find()->all()]); }
/* @var $model common\models\Pendingdoc */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="pendingdoc-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'pendingDocFName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'pendingDocSection')->dropDownList(ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), ['prompt' => 'Section']); ?> <?php echo $form->field($model, 'pendingDocName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'pendingDocTimeRelease')->textInput(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
public static function getArticleToc($id = null, $status = [Section::STATUS_DRAFT, Section::STATUS_PUBLISH]) { $query = new Query(); $query->select(['id', 'title', 'ancestor', 'parent', 'next', 'prev', 'ver'])->from(Section::tableName())->where(['parent' => $id, 'toc_mode' => Section::TOC_MODE_NORMAL, 'status' => $status])->indexBy('id'); return $query->all(); }
/** * @return \yii\db\ActiveQuery */ public function getPrevSection() { return $this->hasOne(Section::className(), ['id' => 'prev']); }
/** * Action method for auto completion sections by the given parent category. * @param integer $id of the category to be used to auto complete sections. * @return string|Response action method execution result. */ public function actionSections($id) { $sections = Section::findAll(['category_id' => $id]); $items = array_merge(['(choose section)'], ArrayHelper::map($sections, 'id', 'title')); return Html::renderSelectOptions(null, $items); }