model() 공개 정적인 메소드

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : Banner
$className string active record class name.
리턴 Banner the static model class
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     die;
     $model = new Customer();
     // $jaspers_franchise = JaspersFranchise::model()->findAll();
     $jaspers_companies = JaspersCompanies::model()->findAllByAttributes(array('franchise_id' => Yii::app()->user->franchise));
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $bannerImg = Banner::model()->findByAttributes(array('isactive' => 1, 'loc' => 1));
     $curUser = User::model()->findByPk(Yii::app()->user->uid);
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         $model->jaspers_franchise = Yii::app()->user->franchise;
         $curUser->name = $model->contact;
         $curUser->save();
         if (Yii::app()->user->isUser()) {
             $model->attendee = Yii::app()->user->uid;
             $model->franchise = Yii::app()->user->franchise;
         }
         if ($model->save()) {
             Yii::app()->session['last_created_user'] = $model->attributes;
             $istApp = new CustAppoint();
             $istApp->app_id = 1;
             $istApp->cus_id = getCurCusId();
             $istApp->status = 0;
             $istApp->save();
             if (isset($_GET['back'])) {
                 $this->redirect(array('site/index'));
             }
             //$this->redirect(array('site/getstarted', 'id' => getCurCusId()));
             $this->redirect(array('workingwell/create', 'id' => getCurCusId()));
         }
     }
     $this->render('create', array('model' => $model, 'bannerImg' => $bannerImg, 'curUser' => $curUser, 'jaspers_companies' => $jaspers_companies));
 }
 public function loadModel($id)
 {
     if (($model = Banner::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
예제 #3
0
 public function actionIndex()
 {
     $this->tituloManual = "Novo pedido";
     $modelPizzaria = Pizzaria::model()->find();
     $modelBanner = Banner::model()->ativos()->find();
     if (!$this->validaSituacao()) {
         $this->render('indisponivel', array('modelPizzaria' => $modelPizzaria, 'modelBanner' => $modelBanner));
         Yii::app()->end();
     }
     $dataBebidas = new Produto();
     $dataPratosLanche = new Produto();
     $dataPromocao = new Promocao();
     $modelSabor = array();
     $modelTamanho = array();
     $arrayTipoSabor = array();
     $listCombinado = array();
     switch ($modelPizzaria->tipo_restaurante) {
         case TipoRestaurante::_TIPO_PIZZARIA_:
             $modelSabor = Sabor::model()->ativos()->findAll();
             $modelTamanho = Tamanho::getArrayTamanho();
             $arrayTipoSabor = TipoSabor::getArrayTipoSabor();
             break;
         default:
             $listCombinado = CHtml::listData(Combinado::model()->ativos()->findAll(), 'id', 'nome');
             break;
     }
     $this->render('index', array('modelPedido' => new Pedido(), 'loginForm' => new LoginForm(), 'modelCliente' => new Cliente(), 'modelUsuario' => new Usuario(), 'dataBebidas' => $dataBebidas->ativos()->bebidas()->search(), 'dataPratosLanche' => $dataPratosLanche->ativos()->pratoLanche()->search(), 'dataPromocao' => $dataPromocao->ativas()->search(), 'modelSabor' => $modelSabor, 'modelTamanho' => $modelTamanho, 'arrayTipoSabor' => $arrayTipoSabor, 'modelPizzaria' => $modelPizzaria, 'arrayBairro' => CHtml::listData(EnderecoPermitido::model()->ativos()->findAll(array('group' => 'bairro', 'distinct' => true)), 'bairro', 'bairro'), 'arrayFormaPagamento' => CHtml::listData(FormaPagamento::model()->ativos()->findAll(), 'id', 'nome'), 'listCombinado' => $listCombinado, 'modelBanner' => $modelBanner));
 }
예제 #4
0
 public function banner($params = array())
 {
     //获取最新banner图片列表
     $images = Banner::model()->getBannerList();
     //获取通卡信息列表
     $cards = Yii::app()->params['cards'];
     return $this->notice('OK', 0, '成功', ['images' => $images, 'cards' => $cards]);
 }
예제 #5
0
 public function init()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'sequence';
     $criteria->addColumnCondition(array('id_banner_place' => $this->idBannerPlace));
     $this->banners = Banner::model()->with('bannerFile')->findAll($criteria);
     parent::init();
 }
예제 #6
0
 public function actionSuccess()
 {
     $criteria = new CDbCriteria();
     $criteria->compare('t.banner_position_id', 4);
     $banner = Banner::model()->localized()->find($criteria);
     $this->pageTitle = Yii::t('common', '反馈中心') . SEPARATOR . Setting::getValueByCode('inside_title', true);
     $this->layout = 'main';
     $this->render('success', array('banner' => $banner));
 }
예제 #7
0
파일: BannerW.php 프로젝트: Telemedellin/tm
 public function getBanner()
 {
     $ya = date('Y-m-d H:i:s');
     $c = new CDbCriteria();
     $c->condition = 'estado = :estado AND (inicio_publicacion < :inicio_p OR inicio_publicacion IS NULL) AND (fin_publicacion > :fin_p OR fin_publicacion IS NULL)';
     $c->params = array(':estado' => 1, 'inicio_p' => $ya, 'fin_p' => $ya);
     $dependencia = new CDbCacheDependency("SELECT GREATEST(MAX(creado), MAX(modificado)) FROM banner WHERE estado = 1 AND (inicio_publicacion < '" . $ya . "' OR inicio_publicacion IS NULL) AND (fin_publicacion > '" . $ya . "' OR fin_publicacion IS NULL)");
     return Banner::model()->cache(3600, $dependencia)->find($c);
 }
예제 #8
0
 public function run()
 {
     $model = Banner::model()->findByAttributes(array('active' => 1));
     if ($model != null && (!isset(Yii::app()->request->cookies['closeBanner']) || Yii::app()->request->cookies['closeBanner'] != $model->id) && ($model->presence == 'all' || Yii::app()->controller->id . '/' . Yii::app()->controller->action->id == 'site/index')) {
         Yii::app()->clientScript->registerCssFile(Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('banner.assets'), false, -1, YII_DEBUG) . '/css/banner.css');
         Yii::app()->clientScript->registerCoreScript('jquery');
         Yii::app()->clientScript->registerScript('banner-message', "\n\n\t\t\t\$(document).ready(function() {\n\t\t\t    \$('#banner-message').fadeIn('slow');\n\t\t\t    \$('#banner-message a.banner-message-close-notify').click(function() {\n\t\t\t        \$('#banner-message').fadeOut('slow');\n\n\t\t\t\t    var d = new Date();\n\t\t\t\t    d.setTime(d.getTime() + (180*24*60*60*1000));\n\t\t\t\t    var expires = 'expires='+d.toUTCString();\n\t\t\t\t    document.cookie = 'closeBanner' + '=' + " . $model->id . " + '; ' + expires;\n\n\t\t\t        return false;\n\t\t\t    });\n\t\t\t});", CClientScript::POS_READY);
         $this->render('bannerMessageWidget', array('model' => $model));
     }
 }
예제 #9
0
 public function run()
 {
     //
     //		$model = Banner::model()->find(array(
     //			'condition' => ' dateTo <= NOW() AND dateFrom >= NOW() ',
     //			'order' => 'bannerId DESC'
     //		));
     $model = Banner::model()->find(array('condition' => " dateFrom >= '" . date('Y-m-d') . "' AND dateFrom <= '" . date('Y-m-d') . "'"));
     if (!$model) {
         $model = new $this->modelName();
     }
     if (!in_array('CModel', class_parents($model))) {
         throw new CException('Not correct model class');
     }
     if (Yii::app()->request->isPostRequest && $_FILES['file']['name']) {
         $t = $_FILES['file']['type'];
         if ($t != 'image/png' && $t != 'image/jpg' && $t != 'image/jpeg' && $t != 'image/gif') {
             echo CJSON::encode(array('status' => 'ok', 'msg' => "Error incorrect file format"));
             Yii::app()->end();
         }
         $newFileName = Yii::getPathOfAlias('webroot') . '/public/' . time() . '_' . $_FILES['file']['name'];
         $newFileUrl = '/public/' . time() . '_' . $_FILES['file']['name'];
         move_uploaded_file($_FILES['file']['tmp_name'], $newFileName);
         $s = getimagesize($newFileName);
         echo CJSON::encode(array('status' => 'ok', 'name' => $newFileUrl, 'path' => $newFileName, 'size' => $s[0] . 'x' . $s[1]));
         Yii::app()->end();
     }
     if (!empty($_REQUEST['Banner'])) {
         $model->setAttributes($_REQUEST['Banner']);
         $model->save();
     }
     if (isset($_POST[$this->modelName])) {
         $model->attributes = $_POST[$this->modelName];
     }
     $modelColumns = array_keys($model->tableSchema->columns);
     //
     //		if ( $model->asa('AdminBehavior') ) {
     //			$columns = $model->getColumnSettingsForAdminPanel();
     //		} else {
     //			$columns = array($model->tableSchema->primaryKey, $modelColumns[1]);
     //		}
     $columns = array('bannerId', 'dateFrom', 'dateTo');
     //		var_dump($this->params);
     //		exit();
     $buttonColumn = array('template' => '{delete}', 'class' => 'CButtonColumn', 'deleteButtonUrl' => '"/admin/".$this->grid->owner->params["path"]."/delete/".$data->primaryKey');
     if (Yii::app()->request->isPostRequest) {
         echo $this->render('banner', array('model' => $model, 'columns' => $columns, 'buttonColumn' => $buttonColumn), true);
         Yii::app()->end();
     } else {
         $this->render('banner', array('model' => $model, 'columns' => $columns, 'buttonColumn' => $buttonColumn));
     }
 }
예제 #10
0
 public function run()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 't.sort ASC';
     if ($this->view == 'animation') {
         $criteria->with = array('images');
     }
     $models = Banner::model()->published()->cache($this->cacheTime)->findAll($criteria);
     if (empty($models)) {
         return;
     }
     $this->render($this->view, array('models' => $models));
 }
예제 #11
0
 public function actionView()
 {
     $previd = 0;
     // 上一个品牌
     $nextid = 0;
     // 下一个品牌
     $brand = null;
     $prevname = '';
     $nextname = '';
     $products = null;
     if (isset($_GET['id'])) {
         $id = Yii::app()->request->getQuery('id');
         // 浏览数量加1
         $brandModel = Brand::model()->findByPk($id);
         $brandModel->view_count += 1;
         $brandModel->update();
         $brand = Brand::model()->localized()->findByPk($id);
         $criteria = new CDbCriteria();
         $criteria->compare('t.is_released', 1);
         $criteria->compare('t.brand_id', $id);
         $products = Product::model()->localized()->findAll($criteria);
         $criteria = new CDbCriteria();
         $criteria->compare('t.is_released', 1);
         $criteria->order = 'sort_order ASC';
         $brands = Brand::model()->localized()->findAll($criteria);
         foreach ($brands as $key => $value) {
             if ($value->brand_id == $id && $key != 0) {
                 $previd = isset($brands[$key - 1]) ? $brands[$key - 1]['brand_id'] : 0;
                 $nextid = isset($brands[$key + 1]) ? $brands[$key + 1]['brand_id'] : 0;
                 $prevname = isset($brands[$key - 1]) ? $brands[$key - 1]['title'] : '';
                 $nextname = isset($brands[$key + 1]) ? $brands[$key + 1]['title'] : '';
             } else {
                 if ($value->brand_id == $id && $key == 0) {
                     $nextid = isset($brands[$key + 1]) ? $brands[$key + 1]['brand_id'] : 0;
                     $nextname = isset($brands[$key + 1]) ? $brands[$key + 1]['title'] : '';
                 }
             }
         }
     }
     if (empty($brand)) {
         throw new CHttpException(404);
     }
     // 广告图
     $criteria = new CDbCriteria();
     $criteria->compare('t.banner_position_id', 2);
     $banner = Banner::model()->localized()->find($criteria);
     $this->pageTitle = Yii::t('common', '品牌中心') . SEPARATOR . Setting::getValueByCode('inside_title', true);
     $this->render('view', array('brand' => $brand, 'banner' => $banner, 'previd' => $previd, 'nextid' => $nextid, 'prevname' => $prevname, 'nextname' => $nextname, 'products' => $products));
 }
예제 #12
0
 /**
  * 获取个人信息
  */
 public function actionIndex()
 {
     if (!isset($_POST['uid']) || !$_POST['uid']) {
         $this->_exit($this->_error['20007'], '20007');
     }
     if (!isset($_POST['page']) || !$_POST['page']) {
         $this->_exit($this->_error['20019'], '20019');
     }
     if (!isset($_POST['mac']) || !$_POST['mac']) {
         $this->_exit($this->_error['20028'], '20028');
     }
     $uid = trim($_POST['uid']);
     $page = trim($_POST['page']);
     $limit = 10;
     $mac = trim($_POST['mac']);
     $token = substr(md5($uid . $mac), 0, 16);
     $r = User::model()->haveToken($uid);
     if ($r['value'] != $token) {
         $this->_exit($this->_error['20061'], '20061');
     }
     $res = UserInfo::model()->getUserCenter($uid, $page, $limit);
     if ($res) {
         if ($page == 1) {
             $banner = Banner::model()->getBanners();
             if (!empty($banner)) {
                 foreach ($banner as $k => $b) {
                     $banner[$k]['image'] = $b['image'] ? self::HOST_HTTP_BG_IMG . str_replace('\\', '/', $b['image']) : $b['image'];
                 }
                 $res['banner'] = $banner;
             }
             $res['Photo'] = $res['Photo'] ? self::HOST_HTTP_HEAD_IMG . str_replace('\\', '/', $res['Photo']) : $res['Photo'];
             $res['bgimg'] = $res['bgimg'] ? self::HOST_HTTP_BG_IMG . str_replace('\\', '/', $res['bgimg']) : $res['bgimg'];
             $res['Voice'] = $res['Voice'] ? self::HOST_HTTP_SOUND . str_replace('\\', '/', $res['Voice']) : $res['Voice'];
             foreach ($res['trends'] as $key => $value) {
                 $res['trends'][$key]['image'] = $value['image'] ? self::HOST_HTTP_TRENDS . str_replace('\\', '/', $value['image']) : $value['image'];
             }
         } else {
             foreach ($res as $key => $value) {
                 $res[$key]['image'] = $value['image'] ? self::HOST_HTTP_TRENDS . str_replace('\\', '/', $value['image']) : $value['image'];
             }
         }
         $this->_exit($this->_error['20000'], '20000', $res, 'row');
     }
     $this->_exit($this->_error['21000'], '21000');
 }
예제 #13
0
 public function actionIndex()
 {
     $this->pageTitle = 'Мобильный мир - главная страница';
     $this->menu = Category::model()->findAll();
     $banner = Banner::model()->findAll();
     $news = News::model()->findAll();
     $topSales = Models::model()->findAll('top = 1');
     if (Yii::app()->request->isAjaxRequest) {
         Yii::app()->shoppingCart->put(Models::model()->findByPk($_POST['id']));
         $data[0] = Yii::app()->shoppingCart->getCost();
         $data[1] = Yii::app()->shoppingCart->getCount();
         echo json_encode($data);
         // Завершаем приложение
         Yii::app()->end();
     }
     $novelty = Models::model()->findAll('novelty = 1');
     $random = Models::randomId();
     $this->render('index', array('banner' => $banner, 'news' => $news, 'topSales' => $topSales, 'novelty' => $novelty, 'random' => $random));
 }
예제 #14
0
 public function actionView()
 {
     // 当前新闻
     if (isset($_GET['id'])) {
         $id = Yii::app()->request->getQuery('id');
         $server = Server::model()->localized()->findByPk($id);
     } else {
         $server = null;
     }
     if (empty($server)) {
         throw new CHttpException(404);
     }
     $criteria = new CDbCriteria();
     $criteria->compare('t.banner_position_id', 3);
     $banner = Banner::model()->localized()->find($criteria);
     $this->layout = 'main';
     $this->pageTitle = $server->name . "-" . Yii::t('common', '服务中心');
     $this->render('view', array('server' => $server, 'banner' => $banner));
 }
예제 #15
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $lesson = $this->loadModel($id);
     if ($lesson->is_active == 0) {
         if ($lesson->owner_by != Yii::app()->user->getId() && !Yii::app()->user->checkAccess('adminLesson')) {
             throw new CHttpException(403, Yii::t('yii', 'You are not authorized to perform this action.'));
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition(array('id_lesson' => $lesson->getPrimaryKey()));
     $count = Question::model()->count($criteria);
     $questionPages = new CPagination($count);
     // results per page
     $questionPages->pageSize = Yii::app()->params['nQuestionsInLessonPage'];
     $questionPages->applyLimit($criteria);
     $questions = Question::model()->findAll($criteria);
     $banners = Banner::model()->findAll('is_active = 1');
     $this->render('view', array('model' => $lesson, 'questions' => $questions, 'questionPages' => $questionPages, 'banners' => $banners));
 }
예제 #16
0
 /**
  * 获取轮播下面的两个banner
  * @return array|bool
  */
 public function getBanner()
 {
     $criteria = new CDbCriteria();
     $criteria->compare('station', 2);
     $criteria->compare('is_show', 1);
     $criteria->compare('start_time', '<=' . time());
     $criteria->compare('end_time', '>=' . time());
     $criteria->limit = 2;
     $criteria->order = 'sort desc ,id desc';
     $list = Banner::model()->findAll($criteria);
     if (empty($list)) {
         return false;
     }
     $newList = array();
     $i = 1;
     //用于页面展示序号
     $imageConfig = Yii::app()->params['image']['banner'];
     foreach ($list as $row) {
         $newList[$i] = $row->getAttributes();
         $newList[$i]['img'] = str_replace(ROOT_PATH, '', $imageConfig['path']) . $row->img;
         $i++;
     }
     return $newList;
 }
예제 #17
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/index.css');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/flowplayer-3.2.11.min.js');
     //Banner
     $criteria = new CDbCriteria();
     $criteria->select = 'title, url, image';
     $criteria->addCondition('status=1');
     $criteria->order = 'id ';
     $criteria->limit = 4;
     $banner = Banner::model()->findAll($criteria);
     //视频推荐
     $home_video = Video::model()->find('home=:home', array(':home' => 1));
     $criteria = new CDbCriteria();
     $criteria->select = 'id, title, date';
     $criteria->addCondition('chosen=1');
     $criteria->addCondition('home!=1');
     $criteria->order = 'id DESC';
     $criteria->limit = 3;
     $video = Video::model()->findAll($criteria);
     //热点推荐
     $criteria = new CDbCriteria();
     // $criteria->limit = 4;
     $criteria->order = 'id ASC';
     $city_list = City::model()->findAll($criteria);
     $hot = array();
     foreach ($city_list as $city) {
         $criteria = new CDbCriteria();
         $criteria->select = 'id, name, prepay, house_image, city_id,ml_num,county';
         $criteria->addCondition('city_id=' . $city->id);
         $criteria->addCondition('recommend=1');
         $criteria->order = 'id DESC';
         $criteria->limit = 1;
         $house = House::model()->findAll($criteria);
         if (!empty($house)) {
             if (count($hot) < 4) {
                 array_push($hot, $house[0]);
             } else {
                 break;
             }
         }
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     $criteria->order = 'date DESC';
     $criteria->addCondition('homepage=1');
     $count = Subject::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 6;
     $pager->applyLimit($criteria);
     $subject_list = Subject::model()->findAll($criteria);
     //豪宅鉴赏
     $criteria = new CDbCriteria();
     $criteria->select = 'id, name, prepay, house_image, introduction';
     $criteria->addCondition('total_price>=300');
     $criteria->order = 'id DESC';
     $criteria->limit = 3;
     $enjoy = House::model()->findAll($criteria);
     //学区专栏
     $criteria = new CDbCriteria();
     $criteria->select = 'id, name, prepay, house_image';
     $criteria->addCondition('investType_id=1');
     $criteria->order = 'id DESC';
     $criteria->limit = 10;
     $column = House::model()->findAll($criteria);
     //加国即时新闻
     $criteria = new CDbCriteria();
     $criteria->select = 'id, title, image';
     $criteria->addInCondition('catalog_id', array(6, 7, 8, 9));
     $criteria->addCondition('image<>""');
     $criteria->order = 'id DESC';
     $criteria->limit = 3;
     $instant = Post::model()->findAll($criteria);
     //加国新闻
     $canada_news = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 6), 'order' => 'id DESC', 'limit' => 10));
     //加国概况
     $summary = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 7), 'order' => 'id DESC', 'limit' => 5));
     //加国生活/经济
     $life = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 8), 'order' => 'id DESC', 'limit' => 5));
     //加国旅游
     $travel = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 9), 'order' => 'id DESC', 'limit' => 5));
     //房展会
     $exhibition = Post::model()->findAll(array('select' => 'id, title, image,create_time,last_update_time', 'condition' => 'catalog_id=:catalog_id AND image<>""', 'params' => array(':catalog_id' => 10), 'order' => 'id DESC', 'limit' => 5));
     //学区房新闻
     $school_distrcit_house_news = Post::model()->findAll(array('select' => 'id, title,create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 11), 'order' => 'id DESC', 'limit' => 5));
     //房产热点新闻
     $house_hotspots = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 12), 'order' => 'id DESC', 'limit' => 8));
     $house_property_special_news = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 13), 'order' => 'id DESC', 'limit' => 1));
     $house_property_special_id = $house_property_special_news[0]->id;
     //房产置业宝典
     $house_property = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 13, ':id' => $house_property_special_id), 'order' => 'id DESC', 'limit' => 10));
     //最新学区房
     $school_distrcit_house = House::model()->findAll(array('select' => 'id, name, house_image', 'condition' => 'investType_id = :investType_id', 'params' => array(':investType_id' => 1), 'order' => 'id DESC', 'limit' => 3));
     $studyabroad = Post::model()->findAll(array('select' => 'id, title, image, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 3), 'order' => 'id DESC', 'limit' => 10));
     //留学资讯 加拿大留学
     $news_lx_special_news[0] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 17), 'order' => 'id DESC', 'limit' => 1));
     $news_lx_special_id = $news_lx_special_news[0][0]->id;
     $news_lx[0] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 17, ':id' => $news_lx_special_id), 'order' => 'id DESC', 'limit' => 10));
     $news_lx[1] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id ', 'params' => array(':catalog_id' => 18), 'order' => 'id DESC', 'limit' => 8));
     $news_lx_special_news[1] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 23), 'order' => 'id DESC', 'limit' => 1));
     $news_lx_special_id = $news_lx_special_news[1][0]->id;
     $news_lx[2] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 23, ':id' => $news_lx_special_id), 'order' => 'id DESC', 'limit' => 10));
     //移民资讯 加拿大移民
     $news_ym_special_news[0] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 19), 'order' => 'id DESC', 'limit' => 1));
     $news_ym_special_id = $news_ym_special_news[0][0]->id;
     $news_ym[0] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 19, ':id' => $news_ym_special_id), 'order' => 'id DESC', 'limit' => 10));
     $news_ym[1] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id ', 'params' => array(':catalog_id' => 20), 'order' => 'id DESC', 'limit' => 8));
     $news_ym_special_news[1] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 24), 'order' => 'id DESC', 'limit' => 1));
     $news_ym_special_id = $news_ym_special_news[1][0]->id;
     $news_ym[2] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 24, ':id' => $news_ym_special_id), 'order' => 'id DESC', 'limit' => 10));
     //旅游资讯 加拿大旅游
     $news_ly_special_news[0] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 21), 'order' => 'id DESC', 'limit' => 1));
     $news_ly_special_id = $news_ly_special_news[0][0]->id;
     $news_ly[0] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 21, ':id' => $news_ly_special_id), 'order' => 'id DESC', 'limit' => 10));
     $news_ly[1] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id ', 'params' => array(':catalog_id' => 22), 'order' => 'id DESC', 'limit' => 8));
     $news_ly_special_news[1] = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 25), 'order' => 'id DESC', 'limit' => 1));
     $news_ly_special_id = $news_ly_special_news[1][0]->id;
     $news_ly[2] = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 25, ':id' => $news_ly_special_id), 'order' => 'id DESC', 'limit' => 10));
     $data = array('banner' => $banner, 'subject_list' => $subject_list, 'home_video' => $home_video, 'video' => $video, 'hot' => $hot, 'enjoy' => $enjoy, 'column' => $column, 'instant' => $instant, 'canada_news' => $canada_news, 'summary' => $summary, 'life' => $life, 'travel' => $travel, 'exhibition' => $exhibition, 'school_distrcit_house_news' => $school_distrcit_house_news, 'house_hotspots' => $house_hotspots, 'house_property_special_news' => $house_property_special_news[0], 'house_property' => $house_property, 'school_distrcit_house' => $school_distrcit_house, 'studyabroad' => $studyabroad, 'news_lx_special_news' => $news_lx_special_news, 'news_lx' => $news_lx, 'news_ym_special_news' => $news_ym_special_news, 'news_ym' => $news_ym, 'news_ly_special_news' => $news_ly_special_news, 'news_ly' => $news_ly);
     $this->render('index', $data);
 }
예제 #18
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $latestProducts = Product::model()->latest()->active()->findAll();
     $banners = Banner::model()->active()->findAll();
     $this->render('index', array('latestProducts' => $latestProducts, 'banners' => $banners));
 }
예제 #19
0
 /**
  * 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 Banner the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Banner::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #20
0
 public function actionIndex()
 {
     $bannerPlacesInfo = Yii::app()->request->getQuery('bp', array());
     if ($bannerPlacesInfo === array()) {
         echo CJSON::encode(array());
         Yii::app()->end();
         //throw new CHttpException('400', 'Invalid request. Please do not repeat this request again.');
     }
     $filteredBannerPlacesInfo = array();
     $ids = array();
     $bannersWidgetsPath = Yii::app()->getModule('banners')->bannersWidgetsPath;
     $widgetsPath = Yii::getPathOfAlias($bannersWidgetsPath) . DIRECTORY_SEPARATOR;
     $countBannerPlacesInfo = count($bannerPlacesInfo);
     for ($i = 0; $i < $countBannerPlacesInfo; $i++) {
         if (!isset($bannerPlacesInfo[$i]['id'], $bannerPlacesInfo[$i]['cls'])) {
             continue;
         }
         //получаем ИД баннерного места и класс виджета, который отвечает за его отрисовку
         //если файл класса не найден, то пропускаем это баннерное место
         $curBannerPlaceId = $bannerPlacesInfo[$i]['id'];
         $curBannerPlaceWidgetClass = $bannerPlacesInfo[$i]['cls'];
         if (!file_exists($widgetsPath . $curBannerPlaceWidgetClass . '.php')) {
             Yii::log('Файл "' . $widgetsPath . $curBannerPlaceWidgetClass . '.php' . '" не найден.', CLogger::LEVEL_WARNING, 'application.modules.banners');
             continue;
         }
         //если файл класса найден, то кладем его в массив
         $filteredBannerPlacesInfo[] = array('id' => $curBannerPlaceId, 'widget' => $bannersWidgetsPath . '.' . $curBannerPlaceWidgetClass);
         $ids[] = $curBannerPlaceId;
     }
     //сюда будем собирать код для отрисовки баннерных мест
     $placesReplaceCode = array();
     if (!empty($ids)) {
         $bannerPlaces = BannerPlace::model()->findAllByPk($ids, array('index' => 'id_banner_place'));
         $countFiltered = count($filteredBannerPlacesInfo);
         for ($i = 0; $i < $countFiltered; $i++) {
             $curBannerPlaceId = $filteredBannerPlacesInfo[$i]['id'];
             $curBannerPlaceWidget = $filteredBannerPlacesInfo[$i]['widget'];
             if (!isset($bannerPlaces[$curBannerPlaceId])) {
                 continue;
             }
             //модель текущего обрабатываемого баннерного места
             $bannerPlace = $bannerPlaces[$curBannerPlaceId];
             //получаем все баннеры для данного баннерного места
             $banners = Banner::model()->with('bannerFile')->findAll(array('condition' => 't.id_banner_place = :idPlace', 'order' => 'sequence ASC', 'params' => array(':idPlace' => $curBannerPlaceId)));
             //если баннеров нет, то пропускаем это баннерное место
             $countBanners = count($banners);
             if ($countBanners == 0) {
                 continue;
             }
             $bannersToShow = array();
             $indexBannerToShow = -1;
             if ($bannerPlace->showing == BannerPlace::ST_BY_ORDER || $bannerPlace->showing == BannerPlace::ST_RANDOM) {
                 while (true) {
                     //Если баннеры выводятся в определенном порядке
                     if ($bannerPlace->showing == BannerPlace::ST_BY_ORDER) {
                         $indexBannerToShow++;
                         //Если баннеры отображаются рандомно
                     } else {
                         $indexBannerToShow = rand(0, $countBanners - 1);
                     }
                     $curBanner = $banners[$indexBannerToShow];
                     if (!$this->bannerWasShown($curBanner, $countBanners)) {
                         $bannersToShow = array($curBanner);
                         break;
                     }
                 }
                 //вывод всех баннеров
             } else {
                 $bannersToShow = $banners;
                 // TODO Добавить ограничение на количество выводимых баннеров в данном месте
                 /*
                 for ($k = 0; $k < $countBanners; $k++) {
                   $curBanner = $banners[$k];
                   $bannersToShow[] = $curBanner;
                 }
                 */
             }
             if (!empty($bannersToShow)) {
                 $idCont = Yii::app()->getModule('banners')->getBannerReplaceContainerId($curBannerPlaceId);
                 //получаем html-код для баннерных мест и html-код баннеров
                 $bannersCode = array();
                 ob_start();
                 $widget = $this->widget($curBannerPlaceWidget, array('banners' => $bannersToShow));
                 $code = ob_get_clean();
                 //сюда заносим html-код для замены по интервалу таймера
                 $bannersCode = $widget->getBannerReplacementCode();
                 $placesReplaceCode[] = array('id' => $idCont, 'code' => $code, 'banners' => $bannersCode);
             }
         }
     }
     echo CJSON::encode($placesReplaceCode);
 }
예제 #21
0
 public function beforeSave()
 {
     if ($this->status == 1) {
         $criteria = new CDbCriteria();
         $criteria->compare('status', 1);
         $criteria->order = 'index_no DESC';
         $last_banner = Banner::model()->findAll($criteria);
         if (count($last_banner) < 1) {
             $index = 1;
         } else {
             $index = $last_banner[0]->index_no + 1;
         }
         $this->index_no = $index;
     } else {
         $this->index_no = 0;
     }
     return true;
 }
예제 #22
0
 public function actionView()
 {
     $previd = 0;
     // 上一个品牌
     $nextid = 0;
     // 下一个品牌
     $serie = null;
     $prevname = '';
     $nextname = '';
     $products = null;
     if (isset($_GET['seriesid'])) {
         $id = Yii::app()->request->getQuery('seriesid');
         $serie = ProductSeries::model()->localized()->findByPk($id);
         $criteria = new CDbCriteria();
         $criteria->compare('t.is_released', 1);
         $criteria->compare('t.series_id', $id);
         $products = Product::model()->localized()->findAll($criteria);
         $criteria = new CDbCriteria();
         $criteria->compare('t.is_released', 1);
         $series = ProductSeries::model()->localized()->findAll($criteria);
         foreach ($series as $key => $value) {
             if ($value->series_id == $id && $key != 0) {
                 $previd = isset($series[$key - 1]) ? $series[$key - 1]['series_id'] : 0;
                 $nextid = isset($series[$key + 1]) ? $series[$key + 1]['series_id'] : 0;
                 $prevname = isset($series[$key - 1]) ? $series[$key - 1]['title'] : '';
                 $nextname = isset($series[$key + 1]) ? $series[$key + 1]['title'] : '';
             } else {
                 if ($value->series_id == $id && $key == 0) {
                     $nextid = isset($series[$key + 1]) ? $series[$key + 1]['series_id'] : 0;
                     $nextname = isset($series[$key + 1]) ? $series[$key + 1]['title'] : '';
                 }
             }
         }
     }
     if (empty($serie)) {
         throw new CHttpException(404);
     }
     // 广告图
     $criteria = new CDbCriteria();
     $criteria->compare('t.banner_position_id', 1);
     $banner = Banner::model()->localized()->find($criteria);
     $this->pageTitle = Yii::t('common', '产品中心') . SEPARATOR . Setting::getValueByCode('inside_title', true);
     $this->render('view', array('serie' => $serie, 'banner' => $banner, 'previd' => $previd, 'nextid' => $nextid, 'prevname' => $prevname, 'nextname' => $nextname, 'products' => $products));
 }
 public function actionGetStarted2nd($id)
 {
     $curUser = Customer::model()->findByPk($id);
     if (empty($curUser->id)) {
         throw new CHttpException(403, 'Customer Does\'t exists');
     }
     // saving current customer to session
     Yii::app()->session['last_created_user'] = $curUser->attributes;
     $bannerImg = Banner::model()->findByAttributes(array('isactive' => 1, 'loc' => 2));
     //        $getStarted = AppContent::model()->findAll();
     //        $this->render('getStarted2nd', array('getStarted' => $getStarted, 'customer' => $curUser, 'bannerImg' => $bannerImg));
     $model = new LoginForm();
     $this->render('getStarted2nd', array('model' => $model));
 }
예제 #24
0
 public function actionSortSpecify()
 {
     if (isset($_POST['target_id']) && isset($_POST['pos'])) {
         $id = Yii::app()->request->getQuery('id');
         $targetId = Yii::app()->request->getPost('target_id');
         $pos = Yii::app()->request->getPost('pos', '1');
         $baseModel = Banner::model()->findByPk($id);
         if (empty($baseModel)) {
             echo CJSON::encode(array('result' => false, 'message' => '操作对象不存在'));
             Yii::app()->end();
         }
         $targetModel = Banner::model()->findByPk($targetId);
         if (empty($targetModel)) {
             echo CJSON::encode(array('result' => false, 'message' => '编号不存在'));
             Yii::app()->end();
         }
         if ($pos == '1') {
             $sortOrder = $targetModel->getPreviousSortOrder();
             if ($sortOrder > 0) {
                 $baseModel->updateAll(array('sort_order' => new CDbExpression('sort_order + 1')), 'sort_order > :sort_order', array(':sort_order' => $sortOrder));
                 $baseModel->updateByPk($baseModel->primaryKey, array('sort_order' => $targetModel->sort_order));
             } else {
                 $baseModel->updateAll(array('sort_order' => new CDbExpression('sort_order + 1')));
                 $baseModel->updateByPk($baseModel->primaryKey, array('sort_order' => $baseModel->getMinSortOrder() - 1));
             }
         } else {
             $sortOrder = $targetModel->getNextSortOrder();
             if ($sortOrder > 0) {
                 $targetModel->updateAll(array('sort_order' => new CDbExpression('sort_order + 1')), 'sort_order > :sort_order', array(':sort_order' => $targetModel->sort_order));
                 $baseModel->updateByPk($baseModel->primaryKey, array('sort_order' => $sortOrder));
             } else {
                 $baseModel->updateByPk($baseModel->primaryKey, array('sort_order' => $baseModel->getMaxSortOrder() + 1));
             }
         }
         echo CJSON::encode(array('result' => true));
         Yii::app()->end();
     }
     $this->layout = false;
     $this->render('sortSpecify');
 }
예제 #25
0
 public function getOperations()
 {
     return ArrayHelper::markObjects(Banner::model()->findAll(), 'name');
 }
예제 #26
0
 public function renderContent()
 {
     $banners = Banner::model()->ordered()->findAll('is_big = 0 && is_active = 1');
     $banners = Banner::filter($banners);
     $this->render('BannersSidebar', array('banners' => $banners));
 }
예제 #27
0
 public function actionChange()
 {
     $res = array('statusCode' => 200, 'message' => '修改成功!');
     try {
         $info = Banner::model()->findByPk($_REQUEST['id']);
         if (empty($info)) {
             throw new exception('记录不存在了!');
         }
         $info->is_show = $_REQUEST['is_show'];
         $flag = $info->save();
         if (!$flag) {
             throw new exception('修改失败');
         }
     } catch (Exception $e) {
         $res['statusCode'] = 300;
         $res['message'] = '修改失败【' . $e->getMessage() . '】';
     }
     $res['callbackType'] = 'reloadTab';
     $res['forwardUrl'] = '/manage/banner/index';
     $this->ajaxDwzReturn($res);
 }
예제 #28
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDeletebanner($id)
 {
     $banner = Banner::model()->findByPk($id);
     $banner->delete();
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : '../');
     }
 }