예제 #1
0
 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             Ad::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             Ad::model()->updateAll(['status' => Ad::STATUS_SHOW], $criteria);
             break;
         case 'hide':
             //隐藏
             Ad::model()->updateAll(['status' => Ad::STATUS_HIDE], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
예제 #2
0
 public function run()
 {
     //SEO
     $this->controller->_seoTitle = $this->controller->_setting['seo_title'];
     $this->controller->_seoKeywords = $this->controller->_setting['seo_keywords'];
     $this->controller->_seoDescription = $this->controller->_setting['seo_description'];
     //头部banner
     $index_top_banner = Ad::model()->getAdOne(4);
     //中部banner
     $index_mid_banner = Ad::model()->getAdOne(3);
     //底部banner
     $index_bottom_banner = Ad::model()->getAdOne(5);
     //最新资讯
     $news_new = Post::model()->getList(array('limit' => 20));
     //热门资讯
     $news_hot = Post::model()->getList(array('order' => 't.view_count DESC, t.id DESC', 'limit' => 20));
     //最新图集
     $image_new = Image::model()->getList(array('limit' => 10));
     //热门图集
     $image_hot = Image::model()->getList(array('limit' => 10, 'order' => 'view_count DESC, t.id DESC'));
     //最新软件
     $soft_new = Soft::model()->getList(array('limit' => 20));
     //热门软件
     $soft_hot = Soft::model()->getList(array('limit' => 10, 'order' => 'down_count DESC, t.id DESC'));
     //最新视频
     $video_new = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY id DESC Limit 20", array(':status' => 'Y'));
     //热门视频
     $video_hot = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY view_count DESC, video_score DESC, id DESC Limit 20", array(':status' => 'Y'));
     //友情链接
     $link_logos = Link::model()->findAll("logo !='' AND status='Y'", array('order' => 'sortorder ASC, id DESC'));
     $link_texts = Link::model()->findAll("logo ='' AND status='Y'", array('order' => 'sortorder ASC, id DESC'));
     $this->controller->render('index', array('index_top_banner' => $index_top_banner, 'index_mid_banner' => $index_mid_banner, 'index_bottom_banner' => $index_bottom_banner, 'link_logos' => $link_logos, 'link_texts' => $link_texts, 'news_new' => $news_new, 'news_hot' => $news_hot, 'image_new' => $image_new, 'image_hot' => $image_hot, 'soft_new' => $soft_new, 'soft_hot' => $soft_hot, 'video_new' => $video_new, 'video_hot' => $video_hot));
 }
예제 #3
0
 public static function saveAdToRt($adID)
 {
     $ad = Ad::model()->findByPk($adID);
     $connection = new CDbConnection(Yii::app()->params['sphinx']['dsn'], Yii::app()->params['sphinx']['user'], Yii::app()->params['sphinx']['pass']);
     $connection->active = true;
     $sphinxIndexes = Yii::app()->params['sphinx']['indexes'];
     $rt = $sphinxIndexes['rt'][0];
     $sql = "INSERT INTO {$rt} (id, title, description, added)\n                VALUES (:id, :title, :description, :added)";
     $command = $connection->createCommand($sql);
     $command->execute(array(':id' => $ad->id, ':title' => $ad->title, ':description' => $ad->description, ':added' => time()));
 }
예제 #4
0
 /**
  * 判断数据是否存在
  * 
  * return \$this->model
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (isset($_GET['id'])) {
             $this->model = Ad::model()->findbyPk($_GET['id']);
         }
         if ($this->model === null) {
             throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
         }
     }
     return $this->model;
 }
예제 #5
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition('level', array(1, 2));
     $criteria->order = 'root, lft';
     $categories = Category::model()->findAll($criteria);
     $form = new SearchForm();
     $criteria = new CDbCriteria(array('condition' => 'status="published"', 'order' => 'added DESC', 'with' => array('photos'), 'limit' => 20));
     $models = Ad::model()->withEavAttributes()->findAll($criteria);
     $dp = new CActiveDataProvider('Ad', array('data' => $models, 'pagination' => false));
     $regionList = Region::model()->getRegionList();
     $this->render('index', array('categories' => $categories, 'form' => $form, 'dataProvider' => $dp, 'regionList' => $regionList));
 }
예제 #6
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     //首页banner幻灯片
     $banner = Ad::model()->findAll('position_id=:pid', array(':pid' => 1));
     //SEO
     $this->_seoTitle = $this->_setting['seo_title'];
     $this->_seoKeywords = $this->_setting['seo_keywords'];
     $this->_seoDescription = $this->_setting['seo_description'];
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/index.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     //友情链接
     $link_logos = Link::model()->findAll("logo !='' AND status_is='Y'", array('order' => 'sortorder ASC, id DESC'));
     $link_texts = Link::model()->findAll("logo ='' or logo is null AND status_is='Y'", array('order' => 'sortorder ASC, id DESC'));
     $this->render('index', compact(array('link_logos', 'link_texts')));
 }
예제 #7
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     //首页banner幻灯片
     $banner = Ad::model()->findAll('position_id=:pid', array(':pid' => 1));
     //SEO
     $this->_seoTitle = $this->_setting['seo_title'];
     $this->_seoKeywords = $this->_setting['seo_keywords'];
     $this->_seoDescription = $this->_setting['seo_description'];
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/index.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.easytabs.min.js");
     //头部banner
     $index_top_banner = Ad::model()->getAdOne(4);
     //中部banner
     $index_mid_banner = Ad::model()->getAdOne(3);
     //底部banner
     $index_bottom_banner = Ad::model()->getAdOne(5);
     //最新资讯
     Yii::app()->cache && ($news_new = Yii::app()->cache->get('news_new'));
     if ($news_new == false) {
         $news_new = Post::model()->getList(array('limit' => 20));
         Yii::app()->cache && Yii::app()->cache->set('news_new', $news_new);
     }
     //热门资讯
     Yii::app()->cache && ($news_hot = Yii::app()->cache->get('news_host'));
     if ($news_hot == false) {
         $news_hot = Post::model()->getList(array('order' => 't.view_count DESC, t.id DESC', 'limit' => 20));
         Yii::app()->cache && Yii::app()->cache->set('news_hot', $news_hot);
     }
     //最新图集
     $image_new = Image::model()->getList(array('limit' => 10));
     //热门图集
     $image_hot = Image::model()->getList(array('limit' => 10, 'order' => 'view_count DESC, t.id DESC'));
     //最新软件
     $soft_new = Soft::model()->getList(array('limit' => 20));
     //热门软件
     $soft_hot = Soft::model()->getList(array('limit' => 10, 'order' => 'down_count DESC, t.id DESC'));
     //最新视频
     //$video_new = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY id DESC Limit 20", array(':status'=>'Y'));
     //热门视频
     //$video_hot = Video::model()->findAll("status=:status AND catalog_id = 13 ORDER BY view_count DESC, video_score DESC, id DESC Limit 20", array(':status'=>'Y'));
     //友情链接
     $link_logos = Link::model()->findAll("logo !='' AND status_is='Y'", array('order' => 'sortorder ASC, id DESC'));
     $link_texts = Link::model()->findAll("logo ='' or logo is null AND status_is='Y'", array('order' => 'sortorder ASC, id DESC'));
     $this->render('index', compact(array('index_top_banner', 'index_mid_banner', 'index_bottom_banner', 'link_logos', 'link_texts', 'news_new', 'news_hot', 'image_new', 'image_hot', 'soft_new', 'soft_hot', 'video_new', 'video_hot')));
 }
예제 #8
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $ads = Ad::model()->findAll();
     $posts = Post::model()->findAll(new CDbCriteria(array('limit' => 5, 'order' => 'id desc')));
     $hotCategories = Category::model()->hot()->level(2)->limit(3)->findAll();
     $hotItems = array();
     foreach ($hotCategories as $hotCategory) {
         $hotItems[$hotCategory->name] = Item::getItemsByCategory($hotCategory, 4);
     }
     $newCategories = Category::model()->new()->level(2)->limit(3)->findAll();
     $newItems = array();
     foreach ($newCategories as $key => $newCategory) {
         if ($key == 0) {
             $newItems[$newCategory->name] = Item::getItemsByCategory($newCategory, 7);
         } else {
             $newItems[$newCategory->name] = Item::getItemsByCategory($newCategory, 8);
         }
     }
     Yii::app()->params['ads'] = $ads;
     //        $newItems[0] = array_slice($newItems[0], 7);
     $this->render('index', array('ads' => $ads, 'posts' => $posts, 'hotCategories' => $hotCategories, 'hotItems' => $hotItems, 'newCategories' => $newCategories, 'newItems' => $newItems));
 }
예제 #9
0
파일: index.php 프로젝트: yinhe/yincart
<div class="main-container col1-layout">
    <div class="main container show-bg">
        <div class="preface grid-full in-col1">
            <div class="the-slideshow-wrapper nested-container clearer">
                <div class="the-slideshow gen-slider-arrows2 gen-slider-pager1 gen-slider-pager1-pos-bottom-right grid12-9  ">

                    <!--<div class="viewport" style="overflow: hidden; position: relative; height: 390px;">-->
                        <ul class="slides">
                            <?php 
$ad_list = Ad::model()->findAll();
foreach ($ad_list as $k => $a) {
    ?>
                            <li>
                                <a title="Click to see all features" href="<?php 
    echo $a->url;
    ?>
">
                                    <?php 
    echo CHtml::image(F::baseUrl() . '/../../upload/ad/' . $a->pic);
    ?>
                                    <div class="caption dark3">
                                        <h2 class="heading permanent"><?php 
    echo $a->title;
    ?>
</h2>
                                        <p><?php 
    echo $a->content;
    ?>
</p>
                                    </div>
                                </a>
예제 #10
0
파일: AdController.php 프로젝트: zwq/unpei
 /**
  * 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 = Ad::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #11
0
파일: WAd.php 프로젝트: jackycgq/advanced
 public function run()
 {
     $cri = new CDbCriteria(array('order' => 'sort_order asc'));
     $ads = Ad::model()->findAll($cri);
     $this->render('ad', array('ads' => $ads));
 }
예제 #12
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } else {
         if ($this->method() == 'POST') {
             $command = trim($_POST['command']);
             $ids = $_POST['id'];
         } else {
             $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
         }
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'adDelete':
             foreach ((array) $ids as $id) {
                 $adModel = Ad::model()->findByPk($id);
                 if ($adModel) {
                     Uploader::deleteFile($adModel->attach_file);
                     $adModel->delete();
                 }
             }
             break;
         case 'adVerify':
             foreach ((array) $ids as $id) {
                 $adModel = Ad::model()->findByPk($id);
                 if ($adModel) {
                     $adModel->status = 'Y';
                     $adModel->save();
                 }
             }
             break;
         case 'adUnVerify':
             foreach ((array) $ids as $id) {
                 $adModel = Ad::model()->findByPk($id);
                 if ($adModel) {
                     $adModel->status = 'N';
                     $adModel->save();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index'));
 }
예제 #13
0
파일: Common.php 프로젝트: s-nice/snece
 public static function getad($id)
 {
     $ad = Ad::model()->find('id=:id', array('id' => $id));
     return $ad;
 }
예제 #14
0
파일: WAd.php 프로젝트: zwq/unpei
 public function getAds()
 {
     $cri = new CDbCriteria(array('condition' => 'theme LIKE "%default%"', 'order' => 'sort_order asc'));
     $ads = Ad::model()->findAll($cri);
     return $ads;
 }
예제 #15
0
 /**
  * @author: Biner
  * @date: 2010-12-14上午02:23:42
  * @description: 获得广告
  */
 public function getAds($limit = 8, $location_id)
 {
     if ($limit == 0) {
         $rows = array();
     } else {
         $rows = Ad::model()->getAdList($limit, 0, $location_id);
     }
     return $rows;
 }
예제 #16
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 Ad the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Ad::model()->withEavAttributes()->with('author', 'category', 'city', 'photos')->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #17
0
파일: WAd.php 프로젝트: rainsongsky/yincart
 public function getAds()
 {
     $cri = new CDbCriteria(array('order' => 'sort_order asc'));
     $ads = Ad::model()->findAll($cri);
     return $ads;
 }