/**
  * 根据图片类型id,删除图片类型
  * @param $picture_category_id
  */
 public function ActionDelPictureCategory($picture_category_id)
 {
     $picture_category_model = PictureCategory::model();
     $picture_category_info = $picture_category_model->findByPk($picture_category_id);
     $pictures = Picture::model()->findAllByAttributes(array('CategoryId' => $picture_category_id));
     //判断图片类型是否有图片管理
     if (empty($pictures)) {
         if ($picture_category_info->delete()) {
             Yii::app()->user->setFlash('delete_pic', '删除成功');
             $this->redirect(Yii::app()->createUrl('PictureCategory/ListPictureCategory'));
         } else {
             Yii::app()->user->setFlash('delete_pic', '删除失败');
         }
     } else {
         Yii::app()->user->setFlash('delete_pic', '该图片类型不可删除,已有图片关联。');
         $this->redirect(Yii::app()->createUrl('PictureCategory/ListPictureCategory'));
     }
 }
Ejemplo n.º 2
0
 /**
  * 根据一级菜单Id拉取二级菜单
  */
 public function ActionAjaxGetSecondMenuByParentId()
 {
     // 获取一级菜单ID
     $fist_menu_id = $_POST['fist_menu_id'];
     // 根据一级菜单ID查询二级菜单
     $second_menu = PictureCategory::model()->findAllByAttributes(array('ParentId' => $fist_menu_id));
     // 生成下拉菜单
     $select = '';
     foreach ($second_menu as $val) {
         $select .= '<option value="' . $val['ID'] . '">' . $val['PictureCategoryName'] . '</option>';
     }
     echo empty($select) ? false : $select;
 }
Ejemplo n.º 3
0
 /**
  * 景点管理
  */
 public function actionListViewSpot()
 {
     //搜索条件处理 [E]
     $searchType = Yii::app()->request->getParam('searchType');
     if ($searchType === 'page') {
         //判断是分页提交还是搜索列表提交的查询条件
         $search = Yii::app()->request->getParam('search');
         $search = unserialize(base64_decode($search));
         //对分布传来的数据进行还原
     } else {
         $search = Yii::app()->request->getParam('search');
     }
     $search_continentid = '';
     //搜索的大洲ID
     $search_countryid = '';
     //搜索的国家ID
     $search_cityids = '';
     //要搜索的所有城市id
     $search_name = '';
     //要搜索的图片名称或标题
     $continent = array();
     $country = array();
     $city = array();
     //得到国家名下对应的所有城市ID信息字符串
     if (isset($search) && !empty($search['continent'])) {
         //大洲
         $search_continentid = intval($search['continent']);
         if ($search['country']) {
             //大洲+国家
             $search_countryid = intval($search['country']);
             if (empty($search['city'])) {
                 //大洲+国家+城市
                 $search_cityids = AreaManage::getCityIdStrByCountryId($search_countryid);
             } else {
                 //大洲+国家
                 $search_cityids = intval($search['city']);
             }
         } else {
             //只选择大洲
             $search_countryid = AreaManage::getCountryStrByContinentId($search_continentid);
             if (empty($search['city'])) {
                 $search_cityids = AreaManage::getCityIdStrByCountryId($search_countryid);
             } else {
                 $search_cityids = trim($search['city']);
             }
         }
     }
     //图片标题
     if (trim($search['name'])) {
         $search_name = trim($search['name']);
     }
     //所有图片类型
     $picture_category = PictureCategory::model()->findAll();
     $picture_category_list = array();
     if (!empty($picture_category)) {
         foreach ($picture_category as $v) {
             $picture_category_list[$v['ID']] = $v;
         }
     }
     $continent = Continent::model()->findAll();
     //获取所有的大洲信息
     if (!empty($search_continentid)) {
         //返回搜索大洲的下级国家信息
         $country = AreaManage::getCountryByContinentId($search_continentid);
     }
     if (!empty($search_countryid)) {
         //返回搜索国家的下级城市信息
         $city = AreaManage::getCityByCountryId($search_countryid);
     }
     //搜索条件处理 [E]
     $criteria = new CDbCriteria();
     $criteria->order = 'ID desc';
     $criteria->compare('Valid', '0', true);
     //增加搜索条件 [S]
     $cityIdArr = !empty($search_cityids) ? explode(',', $search_cityids) : array();
     if (count($cityIdArr) > 0) {
         $criteria->addInCondition('CityID', $cityIdArr);
     }
     if (!empty($search_name)) {
         $criteria->addSearchCondition('NameCn', $search_name);
         //$criteria->addSearchCondition('NameCnShort',$search_name,true,'or');
     }
     //增加搜索条件 [E]
     $view_spot_count = ViewSpot::model()->count($criteria);
     $pager = new CPagination($view_spot_count);
     if (!empty($search)) {
         //判断是否存在搜索条件,并对搜索条件进行数据处理(便于url传输)
         $pager->params = array('search' => base64_encode(serialize($search)), 'searchType' => 'page');
     }
     $pager->pageSize = 20;
     $pager->applyLimit($criteria);
     $view_spot_models = ViewSpot::model()->findAll($criteria);
     $cityIDStr = '';
     //城市ID字符串
     if (!empty($view_spot_models)) {
         foreach ($view_spot_models as $val) {
             $cityIDStr .= $val['CityID'] . ',';
         }
     }
     //得到每张图片所在的名称:(城市-国家-大洲)
     $area = AreaManage::getAreaByCityid($cityIDStr);
     $this->render('list_view_spot', array('view_spot_models' => $view_spot_models, 'pager' => $pager, 'country' => $country, 'continent' => $continent, 'city' => $city, 'search' => $search, 'area' => $area));
 }