Example #1
2
 public function run()
 {
     $tags = Tag::model()->findAll();
     if ($tags) {
         foreach ($tags as $tag) {
             $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             $video = Video::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             if (!$post && !$image && !$soft && !$video) {
                 $tag->delete();
             } else {
                 $tag->data_count = count($post) + count($image) + count($soft);
                 $tag->save();
             }
         }
     }
     $tagdatas = TagData::model()->findAll();
     if ($tagdatas) {
         foreach ($tagdatas as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $data = $model::model()->findByPk($value->content_id);
             if (!$data) {
                 $value->delete();
             }
         }
     }
     $this->controller->message('success', Yii::t('admin', 'Reset Tags Success'), $this->controller->createUrl('index'));
 }
Example #2
0
 public function init()
 {
     $this->_yii = Yii::app();
     $this->_baseUrl = Yii::app()->baseUrl;
     $this->_basePath = Yii::app()->basePath;
     $this->_request = Yii::app()->request;
     $this->_fonts = ROOT_PATH . '/public';
     $this->_data = ROOT_PATH . '/protected/data/';
     $this->_static_public = $this->_baseUrl . '/public';
     //检测系统是否已经安装
     if (!file_exists($this->_data . '/install.lock')) {
         $this->redirect($this->createUrl('/install/step1'));
     }
     //后台全局设置
     $settings = Setting::model()->findAll();
     foreach ($settings as $row) {
         $this->_setting[$row['variable']] = $row['value'];
     }
     //内容模型id
     $model_types = ModelType::model()->findAll();
     if ($model_types && is_array($model_types)) {
         foreach ($model_types as $tp) {
             $this->_type_ids[$tp->type_key] = $tp->id;
         }
     }
     //内容模型对象
     $this->_content_models = ModelType::getContentModel();
 }
Example #3
0
 public function run()
 {
     $model = new Comment();
     //条件
     $criteria = new CDbCriteria();
     $type = trim(Yii::app()->request->getParam('type'));
     $type && $criteria->addColumnCondition(array('type' => $type));
     $status = trim(Yii::app()->request->getParam('status'));
     $status && $criteria->addColumnCondition(array('status' => $status));
     $title = trim(Yii::app()->request->getParam('content'));
     $title && $criteria->addSearchCondition('content', $title);
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     //全部类型
     $model_types = ModelType::model()->findAll();
     Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     $this->controller->render('index', array('model' => $model, 'model_types' => $model_types, 'datalist' => $result, 'pagebar' => $pages));
 }
 /**
  * 评论管理
  *
  */
 public function actionIndex()
 {
     $this->_model_type = ModelType::model()->findAll();
     $model = new Comment();
     $criteria = new CDbCriteria();
     $condition = '1';
     $status = $this->_request->getParam('status');
     $title = $this->_request->getParam('postTitle');
     $content = $this->_request->getParam('content');
     $type = $this->_request->getParam('type') ? $this->_request->getParam('type') : $this->_type_ids['post'];
     $type && ($condition .= " AND type={$type}");
     $status && ($condition .= " AND t.status='{$status}'");
     $table = array_search($type, $this->_type_ids);
     if ($table == 'goods') {
         $title && ($condition .= " AND {$table}.goods_name LIKE '%{$title} %'");
     } else {
         $title && ($condition .= " AND {$table}.title LIKE '%{$title} %'");
     }
     $content && ($condition .= ' AND t.content LIKE \'%' . $content . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $criteria->with = array($table);
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     $pageParams = $this->buildCondition($_GET, array('postTitle', 'status', 'content', 'type'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'table' => $table));
 }
 public function init()
 {
     //栏目
     parent::init();
     $this->_catalog = Catalog::model()->findAll();
     $this->_model_type = ModelType::model()->findAll();
 }
Example #6
0
 public function run()
 {
     $this->content_id = trim(Yii::app()->request->getParam('content_id'));
     $this->type_key = strtolower(trim(Yii::app()->request->getParam('type_key')));
     $type = ModelType::model()->findByAttributes(array('type_key' => $this->type_key));
     if (!$type) {
         $this->controller->message('error', Yii::t('admin', 'Invialid Content Type'));
     }
     if (!$this->content_id) {
         $this->controller->message('error', Yii::t('admin', 'Invialid Content'));
     }
     $this->type_id = $type->id;
     if (Yii::app()->request->isPostRequest) {
         //提交推荐
         $this->submitData();
     }
     //所有推荐位
     $positionModel = new RecommendPosition();
     $criteria = new CDbCriteria();
     $criteria->order = 'id ASC';
     //统计
     $count = $positionModel->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 20;
     $pages->applyLimit($criteria);
     //查询
     $result = $positionModel->findAll($criteria);
     $this->controller->render('create', array('model' => $positionModel, 'datalist' => $result, 'pagebar' => $pages));
 }
 /**
  * 判断数据是否存在
  * 
  * return \$this->model
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (isset($_GET['id'])) {
             $this->model = ModelType::model()->findbyPk($_GET['id']);
         }
         if ($this->model === null) {
             throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
         }
     }
     return $this->model;
 }
Example #8
0
 public function run()
 {
     $tags = preg_replace('/(\\s)+/', ',', trim(Yii::app()->request->getParam('tag')));
     $tag_ids = array();
     if ($tags) {
         $arr_tag = explode(',', $tags);
         foreach ($arr_tag as $tag) {
             $t = Tag::model()->find('tag_name = :tn', array(':tn' => $tag));
             $t && ($tag_ids[] = $t->id);
         }
     } else {
         $alltags = Tag::model()->findAll(array('order' => 'data_count'));
         foreach ((array) $alltags as $tv) {
             $tag_ids[] = $tv->id;
         }
     }
     if (!$tag_ids) {
         throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
     }
     $datas = array();
     $td = new TagData();
     $criteria = new CDbCriteria();
     $criteria->addColumnCondition(array('status' => 'Y'));
     $criteria->addInCondition('tag_id', $tag_ids);
     $criteria->group = 'content_id, type';
     //分页
     $count = $td->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $tddata = $td->findAll($criteria);
     if ($tddata) {
         foreach ($tddata as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $value['type'] = $modelType->type_key;
             $value['data'] = $model::model()->findByPk($value->content_id);
             if ($value['data']) {
                 $datas[] = $value;
             }
         }
     }
     //SEO
     $this->controller->_seoTitle = $tags ? $tags . ' - ' . $this->controller->_setting['site_name'] : '所有标签 - ' . $this->controller->_setting['site_name'];
     $navs[] = array('url' => Yii::app()->request->getUrl(), 'name' => $tags ? $tags : '所有标签');
     $this->controller->render('index', array('navs' => $navs, 'datas' => $datas, 'pagebar' => $pages, 'tags' => $tags));
 }
Example #9
0
 public function run()
 {
     $tags = preg_replace('/(\\s)+/', ',', trim(Yii::app()->request->getParam('tag')));
     $tag_ids = array();
     if ($tags) {
         $arr_tag = explode(',', $tags);
         foreach ($arr_tag as $tag) {
             $t = Tag::model()->find('tag_name = :tn', array(':tn' => $tag));
             $t && ($tag_ids[] = $t->id);
         }
     } else {
         $alltags = Tag::model()->findAll(array('order' => 'data_count'));
         foreach ((array) $alltags as $tv) {
             $tag_ids[] = $tv->id;
         }
     }
     $ajax = Yii::app()->request->getParam('ajax');
     $data = array();
     $searchData = array();
     if ($tag_ids && $ajax == 1) {
         $td = new TagData();
         $condition = "status = 'Y'";
         $criteria = new CDbCriteria();
         $criteria->condition = $condition;
         $criteria->addInCondition('tag_id', $tag_ids);
         //分页
         $count = $td->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = 10;
         $criteria->limit = $pages->pageSize;
         $criteria->offset = $pages->currentPage * $pages->pageSize;
         $tddata = $td->findAll($criteria);
         foreach ((array) $tddata as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $c = $model::model()->findByPk($value->content_id, array('select' => 'id,title'));
             if ($c) {
                 $data[] = array('type' => $modelType->type_key, 'data' => $c);
             }
         }
         foreach ($data as $key => $new) {
             $searchData[$key]['url'] = $this->controller->createUrl("{$new['type']}/view", array('id' => $new['data']['id']));
             $searchData[$key]['title'] = $new['data']['title'];
         }
     }
     exit(CJSON::encode($searchData));
 }
Example #10
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 'show':
             //显示
             ModelType::model()->updateAll(['status' => Reply::STATUS_SHOW], $criteria);
             break;
         case 'hide':
             //隐藏
             ModelType::model()->updateAll(['status' => Reply::STATUS_HIDE], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
 /**
  * 批量操作
  *
  */
 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 'show':
             foreach ((array) $ids as $id) {
                 $model = ModelType::model()->findByPk($id);
                 if ($model) {
                     $model->status = 'Y';
                     $model->save();
                 }
             }
             break;
         case 'hidden':
             foreach ((array) $ids as $id) {
                 $model = ModelType::model()->findByPk($id);
                 if ($model) {
                     $model->status = 'N';
                     $model->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'));
 }
Example #12
0
 /**
  * ajax搜索
  */
 public function actionAjax()
 {
     $tags = trim($this->_request->getParam('tag'));
     $tags = preg_replace('/(\\s)+/', ',', trim($tags));
     $arr_tag = explode(',', $tags);
     foreach ((array) $arr_tag as $tag) {
         $t = Tag::model()->find('tag_name = :tn', array(':tn' => $tag));
         $t && ($tag_ids[] = $t->id);
     }
     $ajax = $this->_request->getParam('ajax');
     $data = array();
     $searchData = array();
     if ($tag_ids && $ajax == 1) {
         $td = new TagData();
         $condition = "status = 'Y'";
         $criteria = new CDbCriteria();
         $criteria->condition = $condition;
         $criteria->addInCondition('tag_id', $tag_ids);
         //分页
         $count = $td->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = 10;
         $criteria->limit = $pages->pageSize;
         $criteria->offset = $pages->currentPage * $pages->pageSize;
         $tddata = $td->findAll($criteria);
         foreach ((array) $tddata as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $value['type'] = $modelType->type_key;
             $value['data'] = $model::model()->findByPk($value->content_id, '', array('select' => 'id,title'));
             $data[] = $value;
         }
         foreach ($data as $key => $new) {
             $searchData[$key]['url'] = $this->createUrl("{$new->type}/view", array('id' => $new->data->id));
             $searchData[$key]['title'] = $new->data->title;
         }
     }
     exit(CJSON::encode($searchData));
 }
Example #13
0
 /**
  * Get the model to which this reminder belongs. A reminder can belong to an Event or Task for example.
  * 
  * @return \GO\Base\Db\ActiveRecord|boolean 
  */
 public function getRelatedModel()
 {
     if (!$this->model_type_id || !$this->model_id) {
         return false;
     }
     $modelType = ModelType::model()->findByPk($this->model_type_id);
     $model = \GO::getModel($modelType->model_name)->findByPk($this->model_id);
     return $model;
 }
Example #14
0
    ?>
    <tr class="tb_list">
      <td ><input type="checkbox" name="id[]" value="<?php 
    echo $row->id;
    ?>
">
        <?php 
    echo $row->id;
    ?>
</td>      
      <td ><?php 
    echo $row->recommend_name;
    ?>
</td>   
      <td ><?php 
    $type = ModelType::model()->findByPk($row->type);
    echo $type->type_name;
    ?>
</td>
      <td >
	      <a href="<?php 
    echo $this->createUrl('Update', array('id' => $row->id));
    ?>
"><img src="<?php 
    echo $this->module->assetsUrl;
    ?>
/images/update.png" align="absmiddle" /></a>&nbsp;&nbsp;
	      <a href="<?php 
    echo $this->createUrl('batch', array('command' => 'Delete', 'id' => $row->id));
    ?>
" class="confirmSubmit"><img src="<?php 
 /**
  * 查看推荐的内容
  * @param unknown $id
  */
 public function actionView($id)
 {
     //推荐位
     $recomPosition = RecommendPosition::model()->findByPk($id);
     //内容类型
     $type = ModelType::model()->findByPk($recomPosition->type);
     //模型表
     $table = $type->model;
     $content = new Recommend();
     $criteria = new CDbCriteria();
     $condition = '1 = 1';
     $id = $this->_request->getParam('id');
     $title = $this->_request->getParam('title');
     $id && ($condition .= ' AND t.id =' . $id);
     $title && ($condition .= " AND {$table}.title like '%{$title}%'");
     $criteria->condition = $condition;
     $criteria->with = array($table);
     $count = $content->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 20;
     $pageParams = $this->buildCondition($_GET, array('id', 'title'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $content->findAll($criteria);
     $this->render('view', array('datalist' => $result, 'table' => $table, 'recom_position' => $recomPosition, 'pagebar' => $pages));
 }