コード例 #1
0
ファイル: CreateAction.php プロジェクト: jerrylsxu/yiifcms
 public function run()
 {
     $model = new AdPosition();
     if (isset($_POST['AdPosition'])) {
         $model->attributes = $_POST['AdPosition'];
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $this->controller->render('create', array('model' => $model));
 }
コード例 #2
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 'Delete':
             foreach ((array) $ids as $id) {
                 $adModel = AdPosition::model()->findByPk($id);
                 if ($adModel) {
                     $adModel->delete();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index'));
 }
コード例 #3
0
ファイル: BatchAction.php プロジェクト: jerrylsxu/yiifcms
 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':
             //删除
             AdPosition::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             AdPosition::model()->updateAll(['status' => AdPosition::STATUS_SHOW], $criteria);
             break;
         case 'hide':
             //隐藏
             AdPosition::model()->updateAll(['status' => AdPosition::STATUS_HIDE], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
コード例 #4
0
ファイル: IndexAction.php プロジェクト: jerrylsxu/yiifcms
 public function run()
 {
     $model = new AdPosition();
     //条件
     $criteria = new CDbCriteria();
     $title = trim(Yii::app()->request->getParam('title'));
     $title && $criteria->addSearchCondition('title', $title);
     $criteria->order = 't.id ASC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
コード例 #5
0
ファイル: AdPosition.php プロジェクト: nbaiwan/yav
 public static function get_position_by_identify()
 {
     self::$__positions = self::get_positions_by_cache();
     foreach (self::$__positions as $_k => $_v) {
         if ($_v['ad_position_identify'] == $identify) {
             break;
         }
     }
 }
コード例 #6
0
 public function init()
 {
     parent::init();
     //广告位
     $positions = AdPosition::model()->findAll();
     foreach ((array) $positions as $pv) {
         $this->_adposition[''] = "==请选择广告位==";
         $this->_adposition[$pv->id] = $pv->position;
     }
 }
コード例 #7
0
ファイル: AdController.php プロジェクト: jerrylsxu/yiifcms
 public function init()
 {
     parent::init();
     //广告位
     $positions = AdPosition::model()->findAll(array('condition' => 'status = "' . AdPosition::STATUS_SHOW . '"'));
     foreach ((array) $positions as $pv) {
         $this->_adposition[''] = "==请选择广告位==";
         $this->_adposition[$pv->id] = $pv->title;
     }
 }
コード例 #8
0
ファイル: AdData.php プロジェクト: nbaiwan/yav
 public static function get_relative_info($ad_position_id, $ad_data_relative_id)
 {
     $re = array();
     $pos = AdPosition::get_one_by_id($ad_position_id, false);
     if ($pos['ad_position_relative_type'] == 'archives') {
         $archives_info = ContentArchives::get_archive_by_id($ad_data_relative_id, false);
         $re['ad_data_subject'] = $archives_info['content_archives_subject'];
         $re['ad_data_link'] = Common::sign_archives_url($ad_data_relative_id);
     }
     return $re;
 }
コード例 #9
0
 /**
  * 判断数据是否存在
  * 
  * return \$this->model
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (isset($_GET['id'])) {
             $this->model = AdPosition::model()->findbyPk($_GET['id']);
         }
         if ($this->model === null) {
             throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
         }
     }
     return $this->model;
 }
コード例 #10
0
ファイル: PositionController.php プロジェクト: nbaiwan/yav
 public function actionJs($id)
 {
     $position = AdPosition::get_one_by_id($id);
     $sql = "SELECT * FROM {{ad_data}} WHERE `ad_position_id`=:ad_position_id";
     $cmd = Yii::app()->db->createCommand($sql);
     $cmd->execute(array(':ad_position_id' => $id));
     $datas = $cmd->queryAll();
     if ($position['ad_position_type'] == 1) {
         //固定
         if (is_array($datas) && count($datas)) {
             $ad['data'] = $datas;
         } else {
             $ad['data'] = array();
         }
         $ad['position'] = $position;
         $content = 'var ' . $position['ad_position_identify'] . '_json = ' . json_encode($ad);
     } else {
         if ($position['ad_position_type'] == 2) {
             //漂浮
         } else {
             if ($position['ad_position_type'] == 3) {
                 //弹窗
             } else {
                 if ($position['ad_position_type'] == 4) {
                     //对联
                 }
             }
         }
     }
     $jspath = AdPosition::get_js_path();
     file_put_contents($jspath . "/" . $position['ad_position_identify'] . ".js", $content);
     if (!isset($_GET['ajax'])) {
         $this->redirect[] = array('text' => '', 'href' => url($this->module->id . '/Ad/Position/Index'));
         $this->message('更新成功', self::MSG_SUCCESS, true);
     }
 }
コード例 #11
0
ファイル: index.php プロジェクト: nbaiwan/yav
</td>
			<td><?php 
    echo $data['ad_position_identify'];
    ?>
</td>
			<td><?php 
    echo $categories[$data['ad_categories_id']];
    ?>
</td>
			<td><?php 
    echo $data['ad_position_system'] ? '<font color="red">是</font>' : '否';
    ?>
</td>
			<td>
				<?php 
    if (file_exists(AdPosition::get_js_path() . "/" . $data['ad_position_identify'] . ".js")) {
        ?>
				http://www.wan123.com/static/ad/js/<?php 
        echo $data['ad_position_identify'];
        ?>
.js
				<?php 
    }
    ?>
			</td>
			<td>
				<a href="<?php 
    echo url($this->module->id . "/Ad/Data/Index", array('ad_position_id' => $data['ad_position_id']));
    ?>
">素材管理</a>
				<a href="<?php 
コード例 #12
0
ファイル: DataController.php プロジェクト: nbaiwan/yav
 public function actionCreate()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!isset($_POST['F']) || !is_array($_POST['F'])) {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('保存信息错误', self::MSG_ERROR, true);
         }
         /*if($_POST['F']['ad_data_subject'] =='') {
         			$this->redirect[] = array(
         				'text' => '',
         				'href' => 'javascript:history.go(-1);',
         			);
         			$this->message('名称不能为空', self::MSG_ERROR, true);
         		}
         		if($_POST['F']['ad_data_link'] =='') {
         			$this->redirect[] = array(
         				'text' => '',
         				'href' => 'javascript:history.go(-1);',
         			);
         			$this->message('链接不能为空', self::MSG_ERROR, true);
         		}*/
         if (count($_POST['F']['ad_data_page'])) {
             $page = implode(",", $_POST['F']['ad_data_page']);
         } else {
             $page = "";
         }
         $user = Yii::app()->user;
         $flag = Yii::app()->db->createCommand()->insert('{{ad_data}}', array('ad_data_id' => 0, 'ad_position_id' => $_POST['F']['ad_position_id'], 'ad_data_type' => $_POST['F']['ad_data_type'], 'ad_data_page' => $page, 'ad_data_subject' => $_POST['F']['ad_data_subject'], 'ad_data_image_md5' => $_POST['F']['ad_data_image_md5'], 'ad_data_flash_md5' => $_POST['F']['ad_data_flash_md5'], 'ad_data_link' => $_POST['F']['ad_data_link'], 'ad_data_html' => $_POST['F']['ad_data_html'], 'ad_data_expire_start' => strtotime($_POST['F']['ad_data_expire_start']), 'ad_data_expire_end' => strtotime($_POST['F']['ad_data_expire_end']), 'ad_data_rank' => $_POST['F']['ad_data_rank'], 'ad_data_dateline' => time(), 'ad_data_status' => AdData::STAT_NORMAL, 'ad_data_relative_id' => $_POST['F']['ad_data_relative_id'], 'insert_user_id' => $user->id, 'update_user_id' => $user->id));
         if ($flag) {
             $ad_data_id = Yii::app()->db->getLastInsertID();
             $ad_data_subject = $_POST['F']['ad_data_subject'];
             //更新缓存
             AdPosition::update_cache();
             //记录操作日志
             $message = '{user_name}添加广告素材{ad_data_subject}';
             $data = array('user_id' => $user->id, 'user_name' => $user->name, 'ad_data_subject' => $ad_data_subject, 'addons_data' => array('ad_data_id' => $ad_data_id));
             AdminLogs::add($user->id, 'Ad/Data', $ad_data_id, 'Insert', 'success', $message, $data);
             if (!isset($_GET['ajax'])) {
                 $this->redirect[] = array('text' => '', 'href' => url($this->module->id . '/Ad/Data/Index'));
                 $this->message('添加成功', self::MSG_SUCCESS, true);
             }
         } else {
             //记录操作日志
             $user = Yii::app()->user;
             $message = '{user_name}添加广告素材{ad_data_subject}失败';
             $data = array('user_id' => $user->id, 'user_name' => $user->name, 'ad_data_subject' => $ad_data_subject, 'addons_data' => array('data' => $_POST['F']));
             AdminLogs::add($user->id, 'Ad/Data', $ad_data_id, 'Insert', 'failure', $message, $data);
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('添加失败', self::MSG_ERROR, true);
         }
     }
     $data = array('ad_data_id' => 0, 'ad_position_id' => isset($_GET['ad_position_id']) ? $_GET['ad_position_id'] : 0, 'ad_data_type' => 0, 'ad_data_page' => '', 'ad_data_subject' => '', 'ad_data_image_md5' => '', 'ad_data_flash_md5' => '', 'ad_data_link' => '', 'ad_data_html' => '', 'ad_data_expire_start' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']), 'ad_data_expire_end' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME'] + 3600 * 24 * 30), 'ad_data_rank' => 255, 'ad_data_relative_id' => 0);
     $sql = "SELECT `ad_position_id`,`ad_position_name`,`ad_position_relative_type` FROM `ad_position` WHERE `ad_position_status`!=:ad_position_status";
     $cmd = Yii::app()->db->createCommand($sql);
     $cmd->execute(array(':ad_position_status' => AdPosition::STAT_DELETED));
     $position_arr = $cmd->queryAll();
     $pages = AdData::$PAGE;
     $this->render('create', array('data' => $data, 'position_arr' => $position_arr, 'pages' => $pages));
 }