public function actionUpdate($id) { $model = new SettingsForm(); if (isset($_POST['SettingsForm'])) { $model->attributes = $_POST['SettingsForm']; if ($model->validate() && $model->save()) { $this->redirect(array('index')); } } else { $model->loadDataFromStore($id); } $directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR); $themes = array(); foreach ($directories as $directory) { $themes[] = basename($directory); } $layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name'); $countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name'); $zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name'); $languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name'); $currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title'); $yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes')); $lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title'); $weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title'); $taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address")); $customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name'); $informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title')); // TODO: localisation $orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name'); // TODO: localisation $returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name'); $mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP")); $this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols)); }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = Layout::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * 房源详情 */ public function actionView($id) { Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/house.css'); Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/flowplayer-3.2.11.min.js'); $cookies = Yii::app()->request->getCookies(); if (!empty($cookies['fzd_house'])) { $house_ids = explode(',', $cookies['fzd_house']->value); array_push($house_ids, $id); $house_ids = array_unique($house_ids); $cookie_str = implode(',', $house_ids); $cookie = new CHttpCookie('fzd_house', $cookie_str); $cookie->expire = time() + 60 * 60 * 24 * 30; //有限期30天 Yii::app()->request->cookies['fzd_house'] = $cookie; } else { $cookie = new CHttpCookie('fzd_house', $id); $cookie->expire = time() + 60 * 60 * 24 * 30; //有限期30天 Yii::app()->request->cookies['fzd_house'] = $cookie; } $criteria = new CDbCriteria(); $criteria->addCondition('t.id="' . $id . '"'); $criteria->with = array('mname', 'propertyType'); //$house = House::model()->find('id=:id',array(':id'=>$id)); $house = House::model()->find($criteria); $layouts = Layout::model()->findAll('house_id=:house_id', array(':house_id' => $id)); $matches = Match::model()->findAll(); $collection_list = array(); if ($this->_account['userId']) { $collect_model = Collect::model()->find('user_id=:user_id', array(':user_id' => $this->_account['userId'])); if (!empty($collect_model)) { $collection_list = explode(',', $collect_model->collection); } } //附件房源 $criteria = new CDbCriteria(); $criteria->select = 'id,addr,lp_dol,house_image'; $criteria->condition = 'zip=:zip AND id<>:id'; $criteria->params = array(':zip' => $house->zip, ':id' => $id); $criteria->order = 'id DESC'; $nearby_houses = House::model()->findAll($criteria); //浏览记录 $cookies = Yii::app()->request->getCookies(); $house_ids = explode(',', $cookies['addr']->value); $criteria = new CDbCriteria(); $criteria->select = 'id,addr,lp_dol,house_image'; $criteria->addInCondition('id', $house_ids); $view_history = House::model()->findAll($criteria); $exchangeRate = 0; $exchangeRateList = ExchangeRate::model()->findAll(); if (!empty($exchangeRateList)) { $exchangeRate = $exchangeRateList[0]->rate; } $data = array('house' => $house, 'layouts' => $layouts, 'matches' => $matches, 'collection_list' => $collection_list, 'nearby_houses' => $nearby_houses, 'view_history' => $view_history, 'exchangeRate' => $exchangeRate); $this->render('view', $data); }