Esempio n. 1
0
 public function actionViewByHtml($id)
 {
     $model = StaticHtml::model()->findByPK($id);
     if ($model === NULL) {
         throw new CHttpException(404, Yii::t('advertisement', 'The requested page does not exist.'));
     }
     $this->render('static', array('model' => $model));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return StaticHtml the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = StaticHtml::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('staticHtml', 'The requested page does not exist.'));
     }
     return $model;
 }
Esempio n. 3
0
 public function actionGenerateLink()
 {
     $dataType = Yii::app()->request->getPost('dataType');
     $dataId = Yii::app()->request->getPost('dataId');
     $returnArr = array();
     $url = $id = $type = NULL;
     if (isset($dataType) && isset($dataId)) {
         if ($dataType === 'list_category') {
             $category = Category::model()->findByPK($dataId);
             if (empty($category->params)) {
                 $url = '/';
                 $type = '/';
                 $id = 0;
             } else {
                 $params = CJSON::decode($category->params);
                 $url = $params['cateUrl'] . '-c' . $dataId;
                 $id = $dataId;
                 $type = 'category';
             }
         } elseif ($dataType === 'list_post') {
             $post = Post::model()->getDeltailPost($dataId);
             $type = 'post';
             if (empty($post['params'])) {
                 $breadcrumbs = NULL;
             } else {
                 $params = CJSON::decode($post['params']);
                 $breadcrumbs = $params['cateUrl'];
             }
             $title = Yii::app()->extraFunctions->setRemoveFontVi_urlTitle($post['title']);
             $url = $breadcrumbs . '/' . $title . '-' . $dataId;
             $id = $dataId;
         } elseif ($dataType === 'list_staticHtml') {
             $html = StaticHtml::model()->findByPK($dataId);
             $breadcrumbs = Yii::app()->extraFunctions->setRemoveFontVi_urlTitle($html->title);
             $url = $breadcrumbs . '-s' . $dataId;
         }
     }
     $returnArr['url'] = $url;
     $returnArr['id'] = $id;
     $returnArr['type'] = $type;
     echo CJSON::encode($returnArr);
     Yii::app()->end();
 }