/** * Creates a new Functionality model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Functionality(); $projects = Project::find()->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->functionality_id]); } else { return $this->render('create', ['model' => $model, 'projects' => $projects]); } }
/** * Deletes an existing ProjectCategorySecond model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $projectModel = Project::find()->andWhere(['category_id' => $id])->one(); if (null === $projectModel) { $this->findModel($id)->delete(); } else { Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete category #' . $id . '. It used in other table. Change category for project #' . $projectModel->id . ' before delete.'), 'options' => ['class' => 'alert-error']]); } return $this->redirect(['index']); }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body]); return $dataProvider; }
public function actionMy() { if (\Yii::$app->user->isGuest) { throw new NotFoundHttpException(); } else { $query = Project::find(); $pagination = new Pagination(['defaultPageSize' => 25, 'totalCount' => $query->count()]); $projects = $query->where(['user_id' => \Yii::$app->user->getId()])->orderBy('created_at DESC')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('my', ['projects' => $projects, 'pagination' => $pagination]); } }
public function actionIndex($name = null) { if (is_null($name)) { $project = Project::find()->select('domain')->asArray()->all(); foreach ($project as $item) { if (strpos($item['domain'], 'backend.') === false) { $this->getDomain($item['domain']); } } } else { $this->getDomain($name); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::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, 'created' => $this->created, 'updated' => $this->updated, 'owner' => $this->owner]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'announce', $this->announce])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::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(['pr_id' => $this->pr_id]); $query->andFilterWhere(['like', 'pr_name', $this->pr_name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); if (!\Yii::$app->user->can('administrator')) { $query->forDomain(); } $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'domain_id' => $this->domain_id]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]); return $dataProvider; }
/** * Accepts the project request * @param unknown $pid */ public function actionAccept($pid) { if (Yii::$app->user->can('editProject')) { $project = Project::find()->where(['project_id' => $pid])->one(); if ($project->status == Project::STATUS_REQUESTED) { $project->accept(); $user = $project->client->user; if (!$user->password_reset_token) { $user->generatePasswordResetToken(); $user->status = User::STATUS_ACTIVE; $user->save(); } $bool = Yii::$app->mailer->compose(['html' => 'projectAccepted-html', 'text' => 'projectAccepted-text'], ['user' => $user])->setFrom('*****@*****.**')->setTo($user->email)->setSubject('Uw projectaanvraag is geaccepteerd')->send(); } } $this->redirect(['/project/view', 'id' => $pid]); }
public function init() { $domain = Yii::$app->params['domain']; $domain = str_replace('www.', '', $domain); $project = Project::find()->where(['domain' => $domain])->with(['theme', 'language'])->with(['groups' => function ($query) { /** @var $query \yii\db\ActiveQuery */ $query->with(['patterns' => function ($query) { /** @var $query \yii\db\ActiveQuery */ $query->with(['type', 'translations'])->orderBy(['priority' => SORT_ASC]); }]); }])->asArray()->one(); if (!$project) { throw new HttpException(503, 'no domain'); } $result = []; foreach ($project['groups'] as $value) { foreach ($value['patterns'] as $pattern) { if (!empty($pattern['translations']) && @$pattern['translations'][0]['language_id'] == $project['language_id']) { $result[$pattern['type']['alias']][$pattern['module']][] = $pattern['translations'][0]['value']; } else { $result[$pattern['type']['alias']][$pattern['module']][] = $pattern['value']; } } } unset($project['groups']); $project['patterns'] = $result; Yii::$app->name = $project['name']; Yii::$app->language = $project['language']['code']; // проверяем существовании папки с темой .. добавляем в список и делаем её активной if (file_exists(Yii::getAlias("@themes/" . $project['theme']['name']))) { Yii::$app->view->theme->basePath = "@themes/" . $project['theme']['name']; Yii::$app->view->theme->active = $project['theme']['name']; array_unshift(Yii::$app->view->theme->pathMap['@app/views'], "@themes/" . $project['theme']['name']); array_unshift(Yii::$app->view->theme->pathMap['@app/modules'], '@themes/' . $project['theme']['name'] . '/modules'); array_unshift(Yii::$app->view->theme->pathMap['@app/widgets'], '@themes/' . $project['theme']['name'] . '/widgets'); } self::$info = $project; }
/** * Updates an existing File 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 (!Yii::$app->user->can('editFile', ['file' => $model])) { throw new NotFoundHttpException('The requested page does not exist.'); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->file_id]); } else { return $this->render('update', ['model' => $model, 'projects' => Project::find()->all(), 'todos' => Todo::find()->all()]); } }
?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textInput(); ?> <?php echo $form->field($model, 'todo_id')->dropdownList(ArrayHelper::map(Todo::find()->all(), 'todo_id', 'name')); ?> <?php echo $form->field($model, 'project_id')->dropdownList(ArrayHelper::map(Project::find()->all(), 'project_id', 'description')); ?> <?php echo $form->field($model, 'deleted')->checkBox(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('common', 'Create') : Yii::t('common', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>
use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model common\models\Page */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="page-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'project_id')->dropdownList(\common\models\Project::find()->select(['domain', 'id'])->indexBy('id')->column(), ['prompt' => 'Domain:'])->label('Domain'); ?> <?php echo $form->field($model, 'alias')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'content')->widget(\vova07\imperavi\Widget::className(), ['settings' => ['replaceDivs' => false, 'lang' => 'ru', 'minHeight' => 200, 'plugins' => ['clips', 'fullscreen'], 'pastePlainText' => false, 'paragraphize' => false]]); ?> <?php echo $form->field($model, 'as_theme')->dropdownList([1 => 'yes', 0 => 'no']);
public static function getMetaTags() { $tags = []; $locale = null; $arr = self::parseUrl(Yii::$app->request->pathInfo); if (!empty($arr[0]) and !empty($arr[1]) and !empty($arr[2]) and !empty($arr[3])) { $shortLocale = $arr[0]; $controller = $arr[1]; $action = $arr[2]; $slug = $arr[3]; foreach (Yii::$app->params['availableLocales'] as $k => $v) { if ($shortLocale == explode('-', $k)[0]) { $locale = $k; } } switch ($controller) { case 'page': $model = self::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'article': $model = Article::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'promo': //$model = Promo::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'project': $model = Project::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; } //hardcore :) json to array if (!empty($model) and !empty($model->head)) { $arr = json_decode($model->head, true); foreach ($arr as $key => $value) { foreach ($value as $key2 => $value2) { //custom meta tag if (4 == count($value2)) { $value2 = array_values($value2); $value2 = [$value2[0] => $value2[1], $value2[2] => $value2[3]]; } $tags[] = $value2; } } } if (empty($model)) { throw new NotFoundHttpException('The requested page does not exist.'); } if (!empty($tags[0]) and !empty($tags[0]['name']) and 'title' == !empty($tags[0]['name']) and !empty($tags[0]['content'])) { Yii::$app->view->title = $tags[0]['content']; } else { Yii::$app->view->title = $model->title; } } return $tags; }
public static function getMetaTags() { $tags = []; $locale = null; preg_match('/^(.+)\\/(.+)\\/(.+)\\/(.+)/', Yii::$app->request->pathInfo, $matches); if (!empty($matches[1]) and !empty($matches[2]) and !empty($matches[3])) { $shortLocale = $matches[1]; $controller = $matches[2]; $action = $matches[3]; $slug = $matches[4]; foreach (Yii::$app->params['availableLocales'] as $k => $v) { if ($shortLocale == explode('-', $k)[0]) { $locale = $k; } } switch ($controller) { case 'page': $model = self::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'article': $model = Article::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; case 'project': $model = Project::find()->published()->andWhere(['slug' => $slug, 'locale' => $locale])->one(); break; } //hardcore :) json to array if (!empty($model) and !empty($model->head)) { $arr = json_decode($model->head, true); foreach ($arr as $key => $value) { foreach ($value as $key2 => $value2) { $tags[] = $value2; } } } Yii::$app->view->title = $model->title; } return $tags; }