Пример #1
0
 public function run()
 {
     $model = new Special();
     if (isset($_POST['Special'])) {
         $model->attributes = $_POST['Special'];
         //封面、图标、 文件
         $model->img_cover = isset($_POST['img_cover']) ? $_POST['img_cover'] : '';
         $model->img_banner = isset($_POST['img_banner']) ? $_POST['img_banner'] : '';
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $this->controller->render('update', array('model' => $model));
 }
Пример #2
0
 /**
  * 查看专题
  */
 public function actionShow($name)
 {
     $specialModel = Special::model()->find('title_alias=:titleAlias', array('titleAlias' => CHtml::encode(strip_tags($name))));
     if (false == $specialModel) {
         throw new CHttpException(404, '专题不存在');
     }
     //更新浏览次数
     $specialModel->updateCounters(array('view_count' => 1), 'id=:id', array('id' => $specialModel->id));
     $specialPostModel = new Post();
     $criteria = new CDbCriteria();
     $criteria->addCondition('t.status_is=:status AND special_id=:specialId');
     $criteria->params = array('status' => 'Y', 'specialId' => $specialModel->id);
     $criteria->order = 't.id DESC';
     $bagecmsSpecialCount = $specialPostModel->count($criteria);
     $postPage = new CPagination($bagecmsSpecialCount);
     $postPage->pageSize = 10;
     $postPageParams = XUtils::buildCondition($_GET, array());
     $postPageParams['#'] = 'list';
     $postPage->params = is_array($postPageParams) ? $postPageParams : array();
     $criteria->limit = $postPage->pageSize;
     $criteria->offset = $postPage->currentPage * $postPage->pageSize;
     $specialPostList = $specialPostModel->findAll($criteria);
     $this->_seoTitle = empty($specialModel->seo_title) ? $specialModel->title . ' - ' . $this->_conf['site_name'] : $specialModel->seo_title;
     $tpl = empty($specialModel->tpl) ? 'show' : $specialModel->tpl;
     $data = array('specialShow' => $specialModel, 'specialPostList' => $specialPostList, 'bagecmsPagebar' => $postPage);
     $this->render($tpl, $data);
 }
Пример #3
0
 public function init()
 {
     parent::init();
     //内容模型id
     $this->_type = $this->_type_ids['image'];
     //图集栏目
     $this->_catalog = Catalog::getTopCatalog(true, $this->_type);
     //专题
     $this->_special = Special::model()->findAll('status=:status', array('status' => 'Y'));
 }
Пример #4
0
 public function run()
 {
     $model = new Special();
     //查询条件
     $criteria = new CDbCriteria();
     $condition = '1';
     $title = Yii::app()->request->getParam('title');
     $title && ($condition .= ' AND title LIKE \'%' . $title . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $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
 public function init()
 {
     parent::init();
     //内容模型id
     $this->_type = $this->_type_ids['post'];
     //文章栏目
     $this->_catalog = Catalog::model()->findAll('status=:status AND type=:type', array(':status' => 'Y', ':type' => $this->_type));
     //专题
     $this->_special = Special::model()->findAll('status=:status', array('status' => 'Y'));
 }
Пример #6
0
 /**
  * 获取专题
  */
 public function actionGetSpecial()
 {
     $catalog_id = intval($this->_gets->getPost('catalog_id'));
     $special = Special::model()->findAll(array('select' => array('id', 'title'), 'condition' => 'catalog_id=:catalog_id', 'params' => array(':catalog_id' => $catalog_id)));
     $options = '';
     if (!empty($special)) {
         foreach ($special as $val) {
             $options .= "<option value='{$val['id']}'>{$val['title']}</option>";
         }
     }
     echo $options;
 }
Пример #7
0
 /**
  * 判断数据是否存在
  * 
  * return \$this->model
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (isset($_GET['id'])) {
             $this->model = Special::model()->findbyPk($_GET['id']);
         }
         if ($this->model === null) {
             throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
         }
     }
     return $this->model;
 }
Пример #8
0
 public static function autoscroll($query, $param, $key, $sort = '', $isloadold = true, $minl = null, $maxl = null)
 {
     setifnn($minl, $param["minl"]);
     setifnn($maxl, $param["maxl"]);
     if ($key != null) {
         if ($isloadold) {
             $querylimit = "select * from (" . gtable($query, false) . ") outpquery where ({$key}<{min} OR {min}=-1) " . ($param["minl"] == -1 ? '' : "limit {minl} ");
         } else {
             $querylimit = "select * from (" . gtable($query, false) . ") outpquery where {$key}>{max} " . ($param["maxl"] == -1 ? '' : "limit {maxl} ");
         }
     } else {
         //max,maxl must be +ve int
         $querylimit = "select * from (" . $query . ") outpquery limit {maxl} offset {max} ";
     }
     if ($key != null) {
         $querysort = "select * from (" . $querylimit . ") sortquery " . $sort;
     } else {
         $querysort = $querylimit;
     }
     $qresult = Sqle::getA($querysort, $param);
     $outp["qresult"] = $qresult;
     $outp["maxl"] = $maxl;
     $outp["minl"] = $minl;
     $outp["qresultlen"] = count($qresult);
     if ($key == null) {
         $outp["max"] = $param["max"] + $param["maxl"];
     } else {
         if (count($qresult) == 0) {
             $outp["min"] = $param["min"];
             $outp["max"] = $param["max"];
         } else {
             $e1 = $qresult[0][$key];
             $e2 = $qresult[count($qresult) - 1][$key];
             $s = new Special();
             $outp["min"] = $s->min($e1, $e2, $param["min"]);
             $outp["max"] = $s->max($e1, $e2, $param["max"]);
         }
     }
     return $outp;
 }
Пример #9
0
 private function fetchPosts()
 {
     $with['select'] = array('id', 'category_id', 'topic_id', 'title', 'create_time', 'comment_nums', 'digg_nums', 'visit_nums', 'state', 'thumbnail');
     $with['order'] = 'posts.create_time desc, posts.id desc';
     $with['limit'] = $this->count;
     $condition = 'posts.state = ' . POST_STATE_DISABLED;
     if ($this->cid) {
         $condition .= ' and posts.category_id = ' . $this->cid;
     }
     if ($this->tid) {
         $condition .= ' and posts.topic_id = ' . $this->tid;
     }
     $with['condition'] = $condition;
     $model = Special::model()->with(array('posts' => $with))->findByAttributes(array('token' => $this->token));
     return $model;
 }
Пример #10
0
 public function run()
 {
     $this->controller->layout = false;
     $id = intval(Yii::app()->request->getParam('id'));
     $special = Special::model()->findByPk($id);
     if (!$special) {
         throw new Exception(Yii::t('common', 'The requested page does not exist.'));
     }
     $this->controller->_seoTitle = $special->seo_title ? $special->seo_title : $special->title . ' - ' . $this->controller->_setting['site_name'];
     $this->controller->_seoKeywords = $special->seo_keywords;
     $this->controller->_seoDescription = $special->seo_description;
     //专题资讯
     $special_news = Post::model()->findAll(array('select' => 'id, title', 'condition' => 'special_id =' . $id . ' AND status ="' . Post::STATUS_SHOW . '"', 'limit' => 30));
     //专题图集
     $special_images = Image::model()->findAll(array('select' => 'id, title', 'condition' => 'special_id =' . $id . ' AND status ="' . Image::STATUS_SHOW . '"', 'limit' => 30));
     $this->controller->render('index', array('special' => $special, 'special_news' => $special_news, 'special_images' => $special_images));
 }
Пример #11
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':
             //删除
             Special::model()->deleteAll($criteria);
             break;
         case 'sortOrder':
             $sortOrder = $_POST['sortOrder'];
             foreach ((array) $ids as $id) {
                 $res = Special::model()->findByPk($id);
                 if ($res) {
                     $res->sort_order = $sortOrder[$id];
                     $res->save();
                 }
             }
             break;
         case 'show':
             //显示
             Special::model()->updateAll(['status' => 'Y'], $criteria);
             break;
         case 'hidden':
             //隐藏
             Special::model()->updateAll(['status' => 'N'], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
Пример #12
0
 /**
  * @dataProvider dataProviderForSoftmax
  */
 public function testSoftmax(array $𝐳, array $expected)
 {
     $σ⟮𝐳⟯ⱼ = Special::softmax($𝐳);
     $this->assertEquals($expected, $σ⟮𝐳⟯ⱼ, '', 1.0E-5);
     $this->assertEquals(1, array_sum($σ⟮𝐳⟯ⱼ));
 }
Пример #13
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif ($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 'specialDelete':
             foreach ((array) $ids as $id) {
                 $specialModel = Special::model()->findByPk($id);
                 if ($specialModel) {
                     Uploader::deleteFile($specialModel->attach_file);
                     Uploader::deleteFile($specialModel->attach_thumb);
                     $specialModel->delete();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
Пример #14
0
 $foot01_title = $MyArticle->getCateTitle();
 $MyArticle->CateId = FOOT02;
 //底部链接02
 $foot02 = $MyArticle->getArticleList();
 $foot02_title = $MyArticle->getCateTitle();
 $MyArticle->CateId = FOOT03;
 //底部链接03
 $foot03 = $MyArticle->getArticleList();
 $foot03_title = $MyArticle->getCateTitle();
 $MyArticle->CateId = FOOT04;
 //底部链接04
 $foot04 = $MyArticle->getArticleList();
 $foot04_title = $MyArticle->getCateTitle();
 //各个地方的连接
 //获取对应专题的信息
 $MySpecial = new Special();
 $MySpecial->id = $specialid;
 $MySpecial->getURLById();
 $special_url1 = $MySpecial->url1;
 $special_url2 = $MySpecial->url2;
 $special_url3 = $MySpecial->url3;
 $special_url4 = $MySpecial->url4;
 $special_url5 = $MySpecial->url5;
 $special_html = $MySpecial->html;
 //顶部链接
 $contents = str_replace("{topurl}", $topurl, $contents);
 //底部连接01-04
 $contents = str_replace("{foot01}", $foot01, $contents);
 $contents = str_replace("{foot01_title}", $foot01_title, $contents);
 $contents = str_replace("{foot02}", $foot02, $contents);
 $contents = str_replace("{foot02_title}", $foot02_title, $contents);
Пример #15
0
 /**
  * @param Special $special
  * @return void
  */
 public function removeSpecial($special)
 {
     unset($this->specials[$special->getId()]);
 }
Пример #16
0
 /**
  * 专题录入
  */
 public function actionSpecialCreate()
 {
     parent::_acl('post_special_create');
     $model = new Special();
     if (isset($_POST['Special'])) {
         $model->attributes = $_POST['Special'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(500, 400)));
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             $model->attach_thumb = $file['paththumbname'];
         }
         if ($model->save()) {
             self::_adminiLogger(array('catalog' => 'update', 'intro' => '专题录入:' . $this->id . ',ID:' . $id));
             $this->redirect(array('special'));
         }
     }
     $this->render('special_create', array('model' => $model));
 }
Пример #17
0
 /**
  * Returns the static model of the specified AR class.
  * @return AdminSpecial the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }