Ejemplo n.º 1
1
 public function actionIndex($url)
 {
     $model = Page::findOne(['url' => $url]);
     if (!$model) {
         Alert::add('Strona nie została znaleziona', Alert::TYPE_ERROR);
         return $this->goHome();
     }
     return $this->render('index', ['model' => $model]);
 }
Ejemplo n.º 2
0
 public function actionView($slug)
 {
     $model = new Page();
     $node = $model->findOne(['slug' => $slug]);
     if (empty($node)) {
         throw new NotFoundHttpException('Không tim thấy nội dung theo yêu cầu.');
     }
     return $this->render('view', ['node' => $node]);
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchNews($params)
 {
     $lang = Lang::getCurrent();
     switch ($lang->local) {
         case Lang::LANG_EN:
             $category_id = self::NEWS_CATEGORY_EN;
             break;
         case Lang::LANG_RU:
         default:
             $category_id = self::NEWS_CATEGORY;
             break;
     }
     $query = Page::find()->joinWith('user');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => Yii::$app->params['items-per-page'], 'pageSizeParam' => false]]);
     $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, 'category_id' => $category_id, 'published' => 1, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     /*
             $query->andFilterWhere(['like', 'name', $this->name])
                 ->andFilterWhere(['like', 'intro', $this->intro])
                 ->andFilterWhere(['like', 'text', $this->text])
                 ->andFilterWhere(['like', 'meta_title', $this->meta_title])
                 ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])
                 ->andFilterWhere(['like', 'meta_descr', $this->meta_descr]);
     */
     return $dataProvider;
 }
Ejemplo n.º 4
0
 public function actionIndex()
 {
     $query = Page::find()->where(['user_id' => Yii::$app->user->identity->id]);
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $pages = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['pages' => $pages, 'pagination' => $pagination]);
 }
Ejemplo n.º 5
0
 public function actionUpdate($id)
 {
     if ($id) {
         $model = Page::findOne($id);
         if (!$model) {
             throw new NotFoundHttpException();
         }
     } else {
         $model = new Page();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->addFlash('success', 'Страница сохранена');
         return $this->redirect(['index']);
     }
     return $this->render('update', ['model' => $model]);
 }
Ejemplo n.º 6
0
 /**
  * Creates a new PageData model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new PageData();
     $page = new Page();
     $model->setScenario('create');
     if (Yii::$app->request->isPost) {
         $page->load(Yii::$app->request->post());
         $model->load(Yii::$app->request->post());
         if ($page->validate()) {
             $model->id_page = $page->id;
             if ($page->save() && $model->save()) {
                 return $this->redirect(['index']);
             }
         }
     }
     return $this->render('create', ['page' => $page, 'model' => $model]);
 }
Ejemplo n.º 7
0
 public function actionPage($slug)
 {
     $page = Page::find()->andWhere(['slug' => $slug])->one();
     if (!$page) {
         throw new NotFoundHttpException('页面不存在');
     }
     return $this->render('page', ['page' => $page]);
 }
Ejemplo n.º 8
0
 /**
  * Finds the Page model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($alias)
 {
     if (($model = Page::find()->where(['alias' => $alias])->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 9
0
 /**
  * Finds the Page model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Page::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 10
0
 public function actionView($id)
 {
     $model = Page::find()->andWhere(['id' => $id, 'published' => 1])->one();
     if (!$model) {
         throw new NotFoundHttpException();
     }
     return $this->render('view', ['model' => $model]);
 }
Ejemplo n.º 11
0
 public function actionView($slug)
 {
     $model = Page::find()->where(['slug' => $slug, 'status' => Page::STATUS_PUBLISHED])->one();
     if (!$model) {
         throw new NotFoundHttpException(Yii::t('frontend', 'Page not found'));
     }
     $viewFile = $model->view ?: 'view';
     return $this->render($viewFile, ['model' => $model]);
 }
Ejemplo n.º 12
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $query = Page::find()->where(['live' => 1]);
     $pagination = new Pagination(['defaultPageSize' => 2, 'totalCount' => $query->count()]);
     $pages = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     $comments = Comment::getRecentComments();
     $sidebarCategories = Category::getSidebarCategories();
     $tags = Tag::getTagList();
     return $this->render('index', ['pages' => $pages, 'pagination' => $pagination, 'comments' => $comments, 'sidebarCategories' => $sidebarCategories, 'tags' => $tags]);
 }
Ejemplo n.º 13
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'body', $this->body]);
     return $dataProvider;
 }
Ejemplo n.º 14
0
 public function search($params)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'publish_time' => $this->publish_time, 'modify_time' => $this->modify_time, 'status' => $this->status, 'sort_num' => $this->sort_num]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'title_format', $this->title_format])->andFilterWhere(['like', 'title_pic', $this->title_pic])->andFilterWhere(['like', 'summary', $this->summary])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'tpl', $this->tpl])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description]);
     return $dataProvider;
 }
Ejemplo n.º 15
0
 public function init()
 {
     $pages = Page::find()->selectNoText()->published()->all();
     $this->_htmlStr = '<ul class="menu">';
     $this->_htmlStr .= '<li role="presentation" ' . ($this->active('site', 'index', '') ? 'class="nav-current"' : '') . '>' . Html::a('首页', Url::home()) . '</li>';
     if (!empty($pages)) {
         foreach ($pages as $page) {
             $this->_htmlStr .= '<li role="presentation" ' . ($this->active('site', 'page', $page->slug) ? 'class="nav-current"' : '') . '>' . Html::a($page->title, ['site/page', 'slug' => $page->slug, $this->options]) . '</li>';
         }
     }
     $this->_htmlStr .= '</ul>';
 }
Ejemplo n.º 16
0
 public function search($params)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'name', $this->name]);
     $query->andFilterWhere(['like', 'slug', $this->slug]);
     $query->andFilterWhere(['published' => $this->published]);
     return $dataProvider;
 }
Ejemplo n.º 17
0
 /**
  * Displays a single Page model.
  *
  * @param $slug
  * @return mixed
  */
 public function actionView($slug)
 {
     $model = Page::find()->where(['slug' => $slug, 'status' => Page::STATUS_ACTIVE])->one();
     if (!$model) {
         throw new NotFoundHttpException(Yii::t('frontend', 'Page not found.'));
     }
     // meta keywords
     $this->getView()->registerMetaTag(['name' => 'description', 'content' => $model->description]);
     // meta description
     $this->getView()->registerMetaTag(['name' => 'keywords', 'content' => $model->keywords]);
     return $this->render('view', ['model' => $model]);
 }
Ejemplo n.º 18
0
 public function actionPage($alias)
 {
     $result = Page::find()->where(['alias' => $alias, 'project_id' => TFA::$info['id']])->one();
     if (!$result) {
         throw new HttpException(404, 'No Page');
     }
     if ($result->as_theme == 0) {
         echo $result->content;
         die;
     }
     return $this->render('page', ['result' => $result]);
 }
Ejemplo n.º 19
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'pid' => $this->pid, 'order' => $this->order]);
     $query->andFilterWhere(['like', 'header', $this->header])->andFilterWhere(['like', 'sid', $this->sid])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'desription', $this->desription])->andFilterWhere(['like', 'keywords', $this->keywords]);
     return $dataProvider;
 }
Ejemplo n.º 20
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'status' => $this->status, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords]);
     return $dataProvider;
 }
Ejemplo n.º 21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'project_id' => Yii::$app->request->get('project_id')]);
     $query->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'META_TITLE', $this->META_TITLE])->andFilterWhere(['like', 'META_DESC', $this->META_DESC])->andFilterWhere(['like', 'META_KEYS', $this->META_KEYS]);
     return $dataProvider;
 }
Ejemplo n.º 22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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', 'route', $this->route])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Ejemplo n.º 23
0
 /**
  * Creates a new Page model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Page();
     $model->category_id = Page::NEWS_CATEGORY_EN;
     $model->created_by = Yii::$app->user->id;
     $task = Yii::$app->request->post('task', 'save');
     if ($model->load(Yii::$app->request->post())) {
         //$model = $this->uploadFoto($model);
         if ($model->uploadFoto() === false) {
             Yii::$app->session->setFlash('error', 'Ошибка загрузки фото');
         }
         $model->save();
         Yii::$app->session->setFlash('success', 'Saved');
         if ($task == 'apply') {
             return $this->redirect(['update', 'id' => $model->id]);
         } else {
             return $this->redirect(['index']);
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Ejemplo n.º 24
0
 /**
  * page view
  * @param $id
  * @return string
  * @throws NotFoundHttpException
  * @internal param $name
  */
 public function actionPage($id)
 {
     $model = Page::findOne($id);
     if (!$model) {
         throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
     }
     /* found */
     if ($model->content->language !== Yii::$app->language) {
         Yii::$app->session->setFlash('info', Yii::t('app', 'This page has no {CUR_LANG} version. You are currently viewing the {LANGUAGE} version.', ['CUR_LANG' => Message::getLocaleList()[Yii::$app->language], 'LANGUAGE' => Message::getLocaleList()[$model->content->language]]));
     }
     /* seo */
     /* metaData */
     $title = $model->content->title;
     $keywords = $model->content->keywords;
     $description = $model->content->description;
     $metaTags[] = ['name' => 'keywords', 'content' => $keywords];
     $metaTags[] = ['name' => 'description', 'content' => $description];
     /* Facebook */
     $metaTags[] = ['property' => 'og:title', 'content' => $title];
     $metaTags[] = ['property' => 'og:description', 'content' => $description];
     $metaTags[] = ['property' => 'og:type', 'content' => 'article'];
     // article, product, profile etc
     $metaTags[] = ['property' => 'og:image', 'content' => $model->content->thumbnail];
     //best 1200 x 630
     $metaTags[] = ['property' => 'og:url', 'content' => $model->content->getViewUrl(true)];
     if ($appId = Setting::getValue('fbAppId')) {
         $metaTags[] = ['property' => 'fb:app_id', 'content' => $appId];
     }
     //$metaTags[]=['property' => 'fb:app_id', 'content' => ''];
     //$metaTags[]=['property' => 'fb:admins', 'content' => ''];
     /* Twitter */
     $metaTags[] = ['name' => 'twitter:card', 'content' => 'summary_large_image'];
     $metaTags[] = ['name' => 'twitter:site', 'content' => Setting::getValue('twitterSite')];
     //        $metaTags[]=['name'=>'twitter:title', 'content'=>$title];
     //        $metaTags[]=['name'=>'twitter:description', 'content'=>$description];
     //        $metaTags[]=['name'=>'twitter:image', 'content'=>''];
     //        $metaTags[]=['name'=>'twitter:data1', 'content'=>''];
     //        $metaTags[]=['name'=>'twitter:label1', 'content'=>''];
     //        $metaTags[]=['name'=>'twitter:data2', 'content'=>''];
     //        $metaTags[]=['name'=>'twitter:label2', 'content'=>''];
     /* jsonld */
     $imageObject = $model->content->getImageObject();
     $jsonLd = (object) ['@type' => 'Article', 'http://schema.org/name' => $title, 'http://schema.org/headline' => $description, 'http://schema.org/articleBody' => $model->content->content, 'http://schema.org/dateCreated' => Yii::$app->formatter->asDate($model->content->created_at, 'php:c'), 'http://schema.org/dateModified' => Yii::$app->formatter->asDate($model->content->updated_at, 'php:c'), 'http://schema.org/datePublished' => Yii::$app->formatter->asDate($model->content->created_at, 'php:c'), 'http://schema.org/url' => Yii::$app->request->absoluteUrl, 'http://schema.org/image' => (object) ['@type' => 'ImageObject', 'http://schema.org/url' => !empty($imageObject['url']) ? $imageObject['url'] : '', 'http://schema.org/width' => !empty($imageObject['width']) ? $imageObject['width'] : '', 'http://schema.org/height' => !empty($imageObject['height']) ? $imageObject['height'] : ''], 'http://schema.org/author' => (object) ['@type' => 'Organization', 'http://schema.org/name' => Yii::$app->name], 'http://schema.org/publisher' => (object) ['@type' => 'Organization', 'http://schema.org/name' => Yii::$app->name, 'http://schema.org/logo' => (object) ['@type' => 'ImageObject', 'http://schema.org/url' => Yii::$app->urlManager->createAbsoluteUrl(Yii::$app->homeUrl . '/images/logo.png')]], 'http://schema.org/mainEntityOfPage' => (object) ['@type' => 'WebPage', '@id' => Yii::$app->request->absoluteUrl]];
     /* OK */
     $data['title'] = $title;
     $data['metaTags'] = $metaTags;
     $data['jsonLd'] = $jsonLd;
     $this->registerMetaTagJsonLD($data);
     return $this->render('page', ['model' => $model]);
 }
Ejemplo n.º 25
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'status' => $this->status, 'domain_id' => $this->domain_id]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->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;
 }
Ejemplo n.º 26
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Page::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, 'parent_id' => $this->parent_id, 'is_url' => $this->is_url, 'is_seo' => $this->is_seo, 'status' => $this->status, 'created_dt' => $this->created_dt]);
     $query->andFilterWhere(['like', 'page_url', $this->page_url])->andFilterWhere(['like', 'page_name', $this->page_name])->andFilterWhere(['like', 'page_content', $this->page_content])->andFilterWhere(['like', 'page_seo_name', $this->page_seo_name])->andFilterWhere(['like', 'meta_values', $this->meta_values]);
     return $dataProvider;
 }
Ejemplo n.º 27
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchNews($params, $category_id = 0)
 {
     $query = Page::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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, 'category_id' => $category_id, 'published' => $this->published, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_descr', $this->meta_descr]);
     //echo'<pre>';print_r($query);echo'</pre>';die;
     return $dataProvider;
 }
Ejemplo n.º 28
0
 public function actionView($sid)
 {
     $service = Service::find()->select('*')->innerJoinWith('secs')->where(['service.sid' => $sid])->one();
     $page = Page::find()->where(['sid' => Yii::$app->controller->id])->select(['id', 'pid', 'sid', 'header'])->one();
     $pages = Page::find()->select(['id', 'pid', 'sid', 'header'])->asArray()->indexBy('id')->all();
     $mode = $pages[$page->id];
     $branch[] = $mode;
     while (!is_null($mode['pid'])) {
         $mode = $pages[$mode['pid']];
         $branch[] = $mode;
     }
     krsort($branch);
     $branch[] = ['header' => $service->header];
     return $this->render('view', ['service' => $service, 'branch' => $branch]);
 }
Ejemplo n.º 29
0
 public function actionView($slug)
 {
     /** @var Page $model */
     $model = Page::find()->where(['slug' => $slug, 'status' => Page::STATUS_PUBLISHED])->one();
     if (!$model) {
         throw new NotFoundHttpException(Yii::t('frontend', 'Page not found'));
     }
     //Мета-теги
     foreach (['description', 'keywords'] as $name) {
         $attr = 'meta_' . $name;
         \Yii::$app->view->registerMetaTag(['name' => $name, 'content' => strlen($model->{$attr}) > 0 ? $model->{$attr} : Yii::$app->keyStorage->get('frontend.' . $attr)], $name);
     }
     $viewFile = $model->view ?: 'view';
     return $this->render($viewFile, ['model' => $model]);
 }
Ejemplo n.º 30
0
 public function actionView($sid)
 {
     $model = Page::find()->where(['sid' => $sid])->one();
     $models = Page::find()->select(['id', 'pid', 'sid', 'header'])->asArray()->indexBy('id')->all();
     $mode = $models[$model->id];
     $branch[] = $mode;
     while (!is_null($mode['pid'])) {
         $mode = $models[$mode['pid']];
         $branch[] = $mode;
     }
     krsort($branch);
     $db = Yii::$app->db;
     $current_menu = $db->createCommand('call current_menu(:sid)')->bindValue(':sid', $model->sid)->queryAll();
     $current_menu = Tree::level($current_menu, $model->pid);
     return $this->render('view', ['model' => $model, 'current_menu' => $current_menu, 'branch' => $branch]);
 }