示例#1
0
 public function category_features()
 {
     // 初始化默认查询条件
     $request_struct_current = array('where' => array('site_id' => NULL), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0));
     // 收集请求数据
     $request_data = $this->input->get();
     $category_id = $request_data['id'];
     // 验证 - 数据有效性
     $category = Mycategory::instance($category_id)->get();
     if (!$category['id']) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     /* b2c类型的站点列表 */
     $site_id_list = role::check('product_virtual_category', 0, 0);
     // 权限验证
     if (empty($site_id_list)) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     if (!in_array($category['site_id'], $site_id_list)) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     // 排序处理
     controller_tool::request_orderby($request_struct_current, $request_data);
     // 每页条目数
     controller_tool::request_per_page($request_struct_current, $request_data);
     // 站点查询
     $request_struct_current['where']['site_id'] = $category['site_id'];
     //当前查询
     $request_struct_current['where']['category_id'] = $category['id'];
     $count = Mycategory_feature::instance()->count($request_struct_current);
     // 模板输出 分页
     $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $request_struct_current['limit']['per_page']));
     $request_struct_current['limit']['offset'] = $this->pagination->sql_offset;
     $category_feature_list = Mycategory_feature::instance()->lists($request_struct_current);
     foreach ($category_feature_list as $key => $rs) {
         $category_feature_list[$key]['site'] = Mysite::instance($rs['site_id'])->get();
         if ($rs['type'] == 1) {
             $category_feature_list[$key]['type'] = '规格';
             $category_feature_list[$key]['group_id'] = Myattribute_group::instance($rs['group_id'])->get('name');
             $category_feature_list[$key]['value_id'] = Myattribute::instance($rs['value_id'])->get('name');
         }
         if ($rs['type'] == 2) {
             $category_feature_list[$key]['type'] = '附加属性';
             $category_feature_list[$key]['group_id'] = Myfeature_group::instance($rs['group_id'])->get('name');
             $category_feature_list[$key]['value_id'] = Myfeature::instance($rs['value_id'])->get('name');
         }
     }
     // 模板输出
     $this->template->content = new View("product/virtualcategory_features");
     // 变量绑定
     $this->template->content->category_feature_list = $category_feature_list;
     $this->template->content->count = $count;
     // 当前应用专用数据
     $this->template->content->data = $category;
 }