Esempio n. 1
0
 public function run()
 {
     $model = $this->controller->loadModel();
     if (isset($_POST['Soft'])) {
         $model->attributes = $_POST['Soft'];
         //封面、图标、 文件
         $model->cover_image = isset($_POST['cover_image']) ? $_POST['cover_image'] : '';
         $model->soft_icon = isset($_POST['soft_icon']) ? $_POST['soft_icon'] : '';
         $model->soft_file = isset($_POST['soft_file']) ? $_POST['soft_file'] : '';
         //摘要
         $model->introduce = trim($_POST['Soft']['introduce']) ? $_POST['Soft']['introduce'] : Helper::truncate_utf8_string(preg_replace('/\\s+/', ' ', $_POST['Soft']['content']), 200);
         //标签   (前5个标签有效)
         $tags = trim($_POST['Soft']['tags']);
         $unique_tags = array_unique(explode(',', str_replace(array(' ', ','), array('', ','), $tags)));
         $explodeTags = array_slice($unique_tags, 0, 5);
         $model->tags = implode(',', $explodeTags);
         $model->update_time = time();
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Update Success'), $this->controller->createUrl('index'));
         }
     }
     $parents = Catalog::getParantsCatalog($model->catalog_id);
     $catalog = Catalog::model()->findByPk($model->catalog_id);
     $belong = $catalog ? implode('>', $parents) . '>' . $catalog->catalog_name : '';
     $this->controller->render('update', array('model' => $model, 'parents' => $belong));
 }
Esempio n. 2
0
 public function run()
 {
     $catalog_id = trim(Yii::app()->request->getParam('catalog_id'));
     $order = trim(Yii::app()->request->getParam('order'));
     if (!$order) {
         $order = 'id';
     }
     switch ($order) {
         case 'id':
             $order_by = 't.id DESC';
             break;
         case 'view_count':
             $order_by = 'view_count DESC';
             break;
         default:
             $order = 'id';
             $order_by = 't.id DESC';
             break;
     }
     //SEO
     $navs = array();
     $search_cats = '所有';
     if ($catalog_id) {
         $condition = ' AND catalog_id = ' . $catalog_id;
         $catalog = Catalog::model()->findByPk($catalog_id);
         if ($catalog) {
             $this->controller->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->controller->_setting['site_name'];
             $this->controller->_seoKeywords = $catalog->seo_keywords;
             $this->controller->_seoDescription = $catalog->seo_description;
             $navs[] = array('url' => $this->controller->createUrl('image/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
             //已搜索的分类
             $cat_parents = Catalog::getParantsCatalog($catalog_id);
             $search_cats = $cat_parents ? implode('>', $cat_parents) . '>' . $catalog->catalog_name : $catalog->catalog_name;
         }
     }
     if (!$navs) {
         $condition = '';
         $catalog = array();
         $seo = ModelType::getSEO('image');
         $this->controller->_seoTitle = $seo['seo_title'] . ' - ' . $this->controller->_setting['site_name'];
         $this->controller->_seoKeywords = $seo['seo_keywords'];
         $this->controller->_seoDescription = $seo['seo_description'];
         $navs[] = array('url' => Yii::app()->request->getUrl(), 'name' => $this->controller->_seoTitle);
     }
     //获取所有符合条件的图集
     $pages = array();
     $datalist = Image::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages);
     //该栏目下最新的图集
     $last_images = Image::model()->getList(array('condition' => $condition, 'limit' => 10));
     $this->controller->render('index', array('navs' => $navs, 'catalog' => $catalog, 'datalist' => $datalist, 'pagebar' => $pages, 'last_images' => $last_images, 'order' => $order, 'search_cats' => $search_cats));
 }
Esempio n. 3
0
 public function run()
 {
     $model = $this->controller->loadModel();
     if (isset($_POST['Image'])) {
         $model->attributes = $_POST['Image'];
         //标题样式
         $title_style = Yii::app()->request->getPost('style');
         if (isset($title_style['bold']) && $title_style['bold'] != 'Y') {
             unset($title_style['bold']);
         }
         if (isset($title_style['underline']) && $title_style['underline'] != 'Y') {
             unset($title_style['underline']);
         }
         if (isset($title_style['color']) && !$title_style['color']) {
             unset($title_style['color']);
         }
         if ($title_style) {
             $model->title_style = serialize($title_style);
         } else {
             $model->title_style = '';
         }
         $model->attach_file = isset($_POST['attach_file']) ? $_POST['attach_file'] : '';
         $model->attach_thumb = isset($_POST['attach_thumb']) ? $_POST['attach_thumb'] : '';
         //组图
         $imageList = isset($_POST['imagelist']) ? $_POST['imagelist'] : array();
         if ($imageList) {
             $model->image_list = implode(',', $imageList);
         }
         //标签   (前5个标签有效)
         $tags = trim($_POST['Image']['tags']);
         $unique_tags = array_unique(explode(',', str_replace(array(' ', ','), array('', ','), $tags)));
         $explodeTags = array_slice($unique_tags, 0, 5);
         //摘要
         $model->introduce = trim($_POST['Image']['introduce']) ? $_POST['Image']['introduce'] : Helper::truncate_utf8_string(preg_replace('/\\s+/', ' ', $_POST['Image']['content']), 200);
         $model->tags = implode(',', $explodeTags);
         $model->update_time = time();
         if ($model->save()) {
             //更新标签数据
             Tag::model()->updateTagData($explodeTags, array('content_id' => $model->id, 'status' => $model->status, 'type_id' => $this->controller->_type_ids['image']));
             $this->controller->message('success', Yii::t('admin', 'Update Success'), $this->controller->createUrl('index'));
         }
     } else {
         $imageList = $model->image_list ? explode(',', $model->image_list) : array();
         $style = unserialize($model->title_style);
     }
     $parents = Catalog::getParantsCatalog($model->catalog_id);
     $catalog = Catalog::model()->findByPk($model->catalog_id);
     $belong = $catalog ? implode('>', $parents) . '>' . $catalog->catalog_name : '';
     $this->controller->render('update', array('model' => $model, 'imageList' => $imageList, 'style' => $style, 'parents' => $belong));
 }
Esempio n. 4
0
 public function run()
 {
     $model = $this->controller->loadModel();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         $now = time();
         $model->update_time = $now;
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Update Success'), $this->controller->createUrl('index'));
         }
     }
     //所有父级分类
     $parents = Catalog::getParantsCatalog($model->id);
     $this->controller->render('update', array('model' => $model, 'parents' => $parents ? implode('>', $parents) : ''));
 }