/** * The generate functions outputs the correct headers for * this `JSONPage`, adds `$this->getHttpStatusCode()` code to the root attribute * before calling the parent generate function and generating * the `$this->_Result` json string * * @param null $page * @return string */ public function generate($page = null) { // Set the actual status code in the xml response $this->_Result['status'] = $this->getHttpStatusCode(); parent::generate($page); return json_encode($this->_Result); }
/** * The generate functions outputs the correct headers for * this `XMLPage`, adds `$this->getHttpStatusCode()` code to the root attribute * before calling the parent generate function and generating * the `$this->_Result` XMLElement * * @param null $page * @return string */ public function generate($page = null) { // Set the actual status code in the xml response $this->_Result->setAttribute('status', $this->getHttpStatusCode()); parent::generate($page); return $this->_Result->generate(true); }
/** * 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 TextPage the loaded model * @throws CHttpException */ public function loadModel($id) { $model = TextPage::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionPage($id = false) { $this->menu = Category::model()->findAll(); if ($id) { $model = TextPage::model()->findByPk($id); $this->pageTitle = 'Мобильный мир - ' . ($model->id == 1 ? 'о компании' : ($model->id == 2 ? 'доставка и оплата' : ($model->id == 3 ? 'контакты' : ($model->id == 4 ? 'сотрудничество' : ($model->id == 5 ? 'проверить статус заказа' : ($model->id == 6 ? 'забери товар в ближайшем магазине' : '')))))); $this->render('textPage', array('model' => $model)); } else { $this->redirect('/main/index'); } }
public function __construct() { parent::__construct(); $this->addHeaderToPage('Content-Type', 'text/html'); }