示例#1
0
文件: Slug.php 项目: roman-gich/yii2
 public function parseRequest($manager, $request)
 {
     $pathInfo = $request->getPathInfo();
     if (preg_match('%^(\\w+)(/(\\w+))?' . $manager->suffix . '$%', $pathInfo, $matches)) {
         if (!isset($matches[3])) {
             if (method_exists('\\frontend\\controllers\\SiteController', 'action' . ucfirst($matches[1]))) {
                 return ['site/' . $matches[1], []];
             }
             return false;
         }
         switch ($matches[1]) {
             case 'page':
                 $page = Pages::findOne(['slug' => $matches[3]]);
                 if (!isset($page)) {
                     return false;
                 }
                 return ['page/index', ['slug' => $matches[3]]];
                 break;
             case 'site':
                 Yii::$app->response->redirect(array($matches[3] . '/'), 301);
             default:
                 return false;
         }
     }
     return false;
     // this rule does not apply
 }
示例#2
0
 public function actionIndex()
 {
     $page = Pages::findOne(['uri' => \Yii::$app->request->get('uri'), 'status' => 10]);
     if (!$page) {
         throw new NotFoundHttpException('Сторінки, яку Ви шукаєте не існує.');
     }
     return $this->render('index', ['page' => $page]);
 }
示例#3
0
 public function actionView($url)
 {
     $page = Pages::findOne(['url' => $url]);
     if ($page) {
         return $this->render('/pages/view', ['page' => $page]);
     } else {
         return $this->render('/pages/404', ['url' => $url]);
     }
 }
示例#4
0
文件: Menu.php 项目: CherryPieCo/SB
 public function show($type = 'T')
 {
     $model = new Controller();
     $userMenu = ArrayHelper::map(self::find()->where(['type' => $type])->all(), 'title', 'url');
     $pageMenu = ArrayHelper::map(Pages::find()->where(['menu' => $type])->all(), 'title', 'url');
     foreach ($pageMenu as $title => $url) {
         $pageMenu[$title] = Url::toRoute(['/page/view', 'url' => $url]);
     }
     $items = array_merge($userMenu, $pageMenu);
     return $model->renderPartial('/report/menu', ['items' => $items]);
 }
示例#5
0
 public function actionShowPage($slug = 'error')
 {
     //        var_dump($this->defaultAction);
     //        var_dump($slug);
     //        Yii::app()->clientScript->registerMetaTag($model->description, 'description');
     //        Yii::app()->clientScript->registerMetaTag($model->keywords, 'keywords');
     if (($model = Pages::find()->where(['slug' => $slug])->one()) !== null) {
         return $this->render('showPage', ['model' => $model]);
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionEdit()
 {
     $id = \Yii::$app->request->get('id');
     $page = Pages::find()->andWhere(['id' => $id])->one();
     $form = \Yii::$app->request->post('Pages');
     if ($form) {
         $page->title = $form['title'];
         $page->text = $form['text'];
         $page->save();
     }
     return $this->render('edit', ['item' => $page]);
 }
示例#7
0
 public function actionIndex()
 {
     $get = Yii::$app->request->get();
     if (!isset($get['slug'])) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     $page = Pages::find()->where(['slug' => $get['slug']])->asArray()->one();
     $this->view->title = $page['title'];
     Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => $page['meta_desc']]);
     Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => $page['meta_keys']]);
     $this->view->params['breadcrumbs'][] = $page['title'];
     return $this->render('index', ['page' => $page]);
 }
示例#8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::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_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'meta_desc', $this->meta_desc])->andFilterWhere(['like', 'meta_keys', $this->meta_keys])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'page_title', $this->page_title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
示例#9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::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, 'active' => $this->active, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
示例#10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pagesize' => 10, 'forcePageParam' => false, '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, 'created' => $this->created, 'updated' => $this->updated, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'uri', $this->uri]);
     return $dataProvider;
 }
示例#11
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pages::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_descr', $this->meta_descr])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
示例#12
0
文件: main.php 项目: CherryPieCo/SB
<?php

use yii\helpers\Html;
use common\models\Pages;
use yii\helpers\Url;
if ($result === false) {
    if (Yii::$app->options->get(2)->value != 'error') {
        $page = Pages::findOne(Yii::$app->options->get(2)->value);
    } else {
        throw new \yii\web\HttpException(203, 'Non-Authoritative Information.', 203);
    }
}
?>
<div class="col-md-12 banner-section" id="alertSection"> <!-- START "please register banner" -->
  <div class="row">
    <div class="col-md-12 box">
      
    </div>
  </div>
</div> <!-- col end --> <!-- end .banner-section -->
<?php 
if ($result !== false) {
    if (!isset(Yii::$app->user->identity->username)) {
        ?>
<div class="col-md-12 banner-section"> <!-- START "please register banner" -->
  <div class="row">
    <div class="col-md-12">
      <?php 
        foreach (Yii::$app->notifications->getAll() as $notify) {
            ?>
        <div class="alert alert-<?php 
示例#13
0
 /**
  * Finds the Pages model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Pages the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Pages::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#14
0
 /**
  * Finds the Pages model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Pages the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Pages::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Сторінки, яку Ви шукаєте не існує.');
     }
 }
示例#15
0
 public function actionAbout()
 {
     return $this->render('about', ['page' => Pages::find()->where(['id' => 1])->one()]);
 }