/** * Creates and processes the inventory expense form */ public function inventoryexpenseform($newItemMode = null) { $this->view->addCss('expense/inventoryexpenseform.css'); $this->view->addJs('jquery.validate.min.js'); $itemTypes = array(); $categories = array(); if ($this->input->post() != null) { $data = $this->input->post(); Debug::log($data); try { $itemExpenseService = new ItemExpenseService(); $itemExpenseService->processItemExpenseForm($data); } catch (Exception $e) { Debug::log($e->getMessage(), 'error'); $this->_showErrorMessageAndRedirect($e->getMessage()); } $this->_showMessageAndRedirect(); } else { $itemTypeService = new ItemTypeService(); $itemTypes = $itemTypeService->fetchAllItems(); $categoryService = new CategoryService(); $categories = $categoryService->fetchAll(); } $this->renderView('inventoryexpenseform', array('itemTypes' => $itemTypes, 'categories' => $categories, 'newItemMode' => $newItemMode)); }
private static function createCategories($category, $parentId = null) { if (!$category->is_active) { return; } try { $categoryEssence = MagentoConnector::$ws->catalogCategoryInfo(MagentoConnector::getActiveSession(), $category->category_id, null, null); } catch (SoapFault $e) { Logger::alert('Erro ao recuperar informacao da categoria.', $e, MagentoConnector::$ws->__getLastRequest()); } $categoryData = new Category($categoryEssence, $parentId); //If category exists, update instead of creating a new one. // if($currentCategory = self::existsByName($categoryData)) // $categoryData->Id = $currentCategory->CategoryGetByNameResult->Id; if (self::$categoryCounter) { $categoryData->Id = 1; self::$categoryCounter = 0; } try { $result = VtexConnector::$ws->CategoryInsertUpdate($categoryData->toVtex()); Logger::info("Categoria criada/atualizada: " . $result->CategoryInsertUpdateResult->Id . " - " . $result->CategoryInsertUpdateResult->Name); } catch (SoapFault $e) { Logger::alert('Erro ao inserir/atualizar categoria.', $e, VtexConnector::$ws->__getLastRequest()); } if (count($category->children) > 0) { foreach ($category->children as $subCategory) { self::createCategories($subCategory, $result->CategoryInsertUpdateResult->Id); } } }
public function editAction() { $this->userService->checkRightGate('CONTENT_EDIT'); $form = $this->formManager->initForm('catEditForm', dirname(__FILE__) . '/categoryForm.xml'); if ($form->isSubmit()) { if ($form->isValid()) { $cat = $form->getContainer('category'); $this->categoryService->save($cat); $this->forward('content', 'category', 'index', array('idCat' => $cat->id)); return; } } else { $id = $this->getParam('idCat', 0); if ($id == '') { $this->goHome(); return; } $cat = $this->categoryService->get($id); if ($cat == null) { $this->goHome(); return; } $form->setContainer('category', $cat); } $this->formManager->storeForm($form); $this->assign('form', $form); $this->assign('category', $cat); }
/** * 设置商品的SEO信息 * * @param array $product * @return boolean */ public static function set(&$product) { $category = CategoryService::get_instance()->get($product['category_id']); $seo_inf = Seo_manageService::get_instance()->get_product_seo_struct(array('category_id' => $product['category_id'], 'product_name' => $product['title'], 'category_name' => $category['title'], 'goods_price' => $product['goods_price'])); empty($product['meta_title']) and $product['meta_title'] = $seo_inf['meta_title']; empty($product['meta_keywords']) and $product['meta_keywords'] = $seo_inf['meta_keywords']; empty($product['meta_description']) and $product['meta_description'] = $seo_inf['meta_description']; return TRUE; }
/** * 获得商品前台链接 * * @param int 商品id * @param String 商品链接 */ public static function permalink($product) { static $routes = array(); static $categorys = array(); if (!is_array($product)) { $product = ProductService::get_instance()->get($product); } $routes = Myroute::instance()->get(); $domain = Mysite::instance()->get('domain'); $route_type = $routes['type']; $product_suffix = $routes['product_suffix']; $product_route = $routes['product']; if ($route_type == 2 or $route_type == 3) { if (!isset($categorys[$product['category_id']])) { $categorys[$product['category_id']] = CategoryService::get_instance()->get($product['category_id']); } } $permalink = ''; $product['uri_name'] = isset($product['uri_name']) ? $product['uri_name'] : $product['id']; switch ($route_type) { case 0: //$permalink = $product_route.'/'.$product['id'].$product_suffix; $permalink = $product_route . $product['id']; break; case 1: $permalink = $product_route . '/' . urlencode($product['uri_name']) . $product_suffix; break; case 2: $permalink = urlencode($categorys[$product['category_id']]['uri_name']) . '/' . urlencode($product['uri_name']) . $product_suffix; break; case 3: $permalink = urlencode($categorys[$product['category_id']]['uri_name']) . '/' . urlencode($product['uri_name']) . $product_suffix; break; case 4: $permalink = $product_route . '/' . urlencode($product['uri_name']) . $product_suffix; break; } return Kohana::config('config.front_protocol') . $domain . '/' . $permalink; }
/** * 获取前台分类链接 * * @param int id 分类id * @return string 分类链接 */ public static function permalink($id, $absolute = true) { $category_service = CategoryService::get_instance(); $category = $category_service->get($id); $route = Myroute::instance()->get(); $route_type = $route['type']; $category_route = $route['category']; $category_suffix = $route['category_suffix']; $domain = Mysite::instance()->get('domain'); if ($route_type == 0) { // 0: none get category and product with id $category_permalink = $category_route . '/' . $category['id']; } if ($route_type == 1) { // 1: get product with {product}/permalink $category_permalink = $category_route . '/' . urlencode($category['uri_name']); } if ($route_type == 2 || $route_type == 4) { // 2: get category and product with {category_permalink} and {category+permalink}/{product_permalink} $category_permalink = urlencode($category['uri_name']); } if ($route_type == 3) { // 3: get category and prdouct with {category_permalink1}/.../{category_permalinkn} and {category_permalink1}/.../{category_permalinkn}/{product_permalink} $parents = $category_service->get_parents_by_category_id($id); $category_permalink = ''; foreach ($parents as $category) { if ($category == end($parents)) { $category_permalink .= urlencode($category['uri_name']); } else { $category_permalink .= urlencode($category['uri_name']) . '/'; } } } if ($absolute) { return 'http://' . $domain . '/' . $category_permalink . $category_suffix; } else { return $category_permalink . $category_suffix; } }
public function search_products() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array('assoc' => NULL, 'count' => 0); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); if (empty($request_data)) { $request_data = array_merge($_POST, $_GET); } $site_ids = role::get_site_ids(); if (empty($site_ids)) { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403); } $in_site_id = site::id(); if (isset($request_data['site_id']) and $request_data['site_id'] === '0') { unset($request_data['site_id']); } if (isset($request_data['site_id']) and !in_array($request_data['site_id'], $site_ids)) { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403); } if ($in_site_id > 0) { $query_site_id = $in_site_id; } else { throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400); } $page = isset($request_data['page']) ? intval($request_data['page']) : 1; $page < 1 ? $page = 1 : ''; $per_page = 10; $query_struct = array('where' => array('site_id' => $query_site_id, 'status' => 1), 'limit' => array('page' => $page, 'per_page' => $per_page)); if (isset($request_data['type']) && trim($request_data['keyword']) != '') { $select_key = mysql_escape_string($request_data['keyword']); if ($request_data['type'] == 'sku') { $query_struct['where']['sku'] = $select_key; } elseif ($request_data['type'] == 'name_manage') { $query_struct['like']['name_manage'] = $select_key; } elseif ($request_data['type'] == 'title') { $query_struct['like']['title'] = $select_key; } elseif ($request_data['type'] == 'category_id') { $categories_select = CategoryService::get_instance()->index(array('where' => array('site_id' => $query_site_id), 'like' => array('title' => $select_key))); if (!empty($categories_select)) { $categories_ids = array(); for ($i = 0; $i < count($categories_select); $i++) { $categories_ids[] = $categories_select[$i]['id']; } $query_struct['where']['category_id'] = $categories_ids; } } elseif ($request_data['type'] == 'brand_id') { $brands_select = BrandService::get_instance()->index(array('where' => array('site_id' => $query_site_id), 'like' => array('name' => $select_key))); if (!empty($brands_select)) { $brands_ids = array(); for ($i = 0; $i < count($brands_select); $i++) { $brands_ids[] = $brands_select[$i]['id']; } $query_struct['where']['brand_id'] = $brands_ids; } else { $query_struct['where']['brand_id'] = -1; } } } //print_r($query_struct); $return_data = BLL_Product::index($query_struct); $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $per_page)); //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { // html 输出 $this->template = new View('layout/commonblank_html'); //* 模板输出 */ $this->template->return_struct = $return_struct; $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ $this->template->title = Kohana::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->products = $return_data['assoc']; $this->template->content->pagination = $this->pagination; if (isset($request_data['type'])) { $this->template->content->search_type = $request_data['type']; } $this->template->content->pagination = $this->pagination; //:: 当前应用专用数据 $this->template->content->title = Kohana::config('site.name'); } // end of request type determine } catch (MyRuntimeException $ex) { $return_struct['status'] = 0; $return_struct['code'] = $ex->getCode(); $return_struct['msg'] = $ex->getMessage(); //TODO 异常处理 //throw $ex; if ($this->is_ajax_request()) { $this->template->content = $return_struct; } else { $this->template->return_struct = $return_struct; $content = new View('info'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } } }
/** * Hook entry when article is purged (purge the gallery cache if purging the category page */ public static function onArticlePurge(WikiPage $page) { $title = $page->getTitle(); $ns = $title->getNamespace(); if ($ns == NS_CATEGORY) { // Invalidate category service and (by hooks) category gallery cache CategoryService::invalidateTopArticles($title, NS_MAIN); } return true; }
public function download() { role::check('promotion_coupon'); // 收集请求数据 $request_data = $this->input->get(); $coupon = Mycoupon::instance($request_data['id'])->get(); // 权限验证 if (!$coupon['id']) { remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error'); } if (!preg_match('/^\\d+$/', $request_data['amount']) || $request_data['amount'] >= 10000 || $request_data['amount'] <= 0) { exit; } //$used_coupons = Myused_coupon::instance()->get_used_coupon_codes($coupons['site_id']); $coupons = Mycoupon::instance()->gen_coupons($coupon['id'], $request_data['amount']); $cpn_promotion = Mycpn_promotion::instance()->get_by_couponid($coupon['id']); $coupon_scheme = Mycoupon_scheme::instance($cpn_promotion['cpns_id'])->get(); //CSV输出 $rand_name = date('Y-m-d') . '_' . mt_rand(); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Transfer-Encoding: binary "); header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:attachment;filename=coupons_{$rand_name}.csv"); //header("Content-Disposition:attachment;filename={$filename}{$file}.xls"); header("Pragma: no-cache"); header("Expires: 0"); $output = ",,,,,\n"; switch ($cpn_promotion['cpns_id']) { case 1: case 2: $output .= "订单开始金额,订单结束金额,,,,\n"; $output .= "\${$cpn_promotion['money_from']},\${$cpn_promotion['money_to']},,,,\n"; break; case 3: $related_ids = explode(',', trim($cpn_promotion['related_ids'], ',')); $request_struct = array('where' => array('id' => $related_ids), 'orderby' => array('email' => 'ASC')); $all_users = Myuser::instance()->lists($request_struct); $output .= "用户邮箱,姓名,,,,\n"; foreach ($all_users as $key => $rs) { $output .= "{$rs['email']},{$rs['firstname']} {$rs['lastname']},,,,\n"; } break; case 4: $related_ids = explode(',', trim($cpn_promotion['related_ids'], ',')); $request_struct = array('where' => array('id' => $related_ids), 'orderby' => array('name_manage' => 'ASC')); $all_products = ProductService::get_instance()->index($request_struct); $output .= "商品SKU,名称,,,,\n"; foreach ($all_products as $key => $rs) { $output .= "{$rs['sku']},{$rs['name_manage']},,,,\n"; } break; case 5: $related_ids = explode(',', trim($cpn_promotion['related_ids'], ',')); $request_struct = array('where' => array('id' => $related_ids), 'orderby' => array('title_manage' => 'ASC')); $all_categories = CategoryService::get_instance()->index($request_struct); $output .= "分类名称,,,,,\n"; foreach ($all_categories as $key => $rs) { $output .= "{$rs['title_manage']},,,,,\n"; } break; case 6: $output .= "订单商品开始数量,订单商品结束数量,,,,\n"; $output .= "{$cpn_promotion['quantity_from']},{$cpn_promotion['quantity_to']},,,,\n"; break; } $output .= ",,,,,\n"; $output .= "打折号,开始时间,结束时间,打折值,折扣类型,\n"; foreach ($coupons as $key => $rs) { $output .= $rs . "," . $cpn_promotion['time_begin'] . "," . $cpn_promotion['time_end'] . ","; switch ($cpn_promotion['discount_type']) { case 0: $output .= '百分比 ' . $cpn_promotion['price'] * 100 . "%"; break; case 1: $output .= '减去 $' . $cpn_promotion['price']; break; case 2: $output .= '减到 $' . $cpn_promotion['price']; break; } $output .= ","; $output .= "{$coupon_scheme['cpns_memo']},\n"; } echo iconv('UTF-8', 'gb2312', $output); exit; }
public function get_category_page_by_site_id($site_id) { $category_service = CategoryService::get_instance(); $categories = $category_service->get_categories_by_site_id($site_id); return $categories; }
public function add_category_name(&$products) { if (!empty($products)) { $cids = array(); foreach ($products as $record) { $cids[$record['category_id']] = TRUE; } $categories = array(); $query_struct = array('where' => array('id' => array_keys($cids))); foreach ((array) CategoryService::get_instance()->query_assoc($query_struct) as $record) { $categories[$record['id']] = $record['title_manage'] ? $record['title_manage'] : $record['title']; } foreach ($products as $index => $record) { $record['category_name'] = isset($categories[$record['category_id']]) ? $categories[$record['category_id']] : ''; $products[$index] = $record; } } }
function get_category_data() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //$profiler = new Profiler; //* 初始化返回数据 */ $return_data = array('classify' => array(), 'brand_list' => array(), 'attribute_list' => array(), 'feature_list' => array()); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); //必须为ajax请求 if (!$this->is_ajax_request()) { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } //数据验证 if (!isset($request_data['category_id']) || !is_numeric($request_data['category_id'])) { throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 404); } if ($request_data['category_id'] == 0) { //当前站点品牌 $return_data['brand_list'] = BrandService::get_instance()->get_brands(); //当前站点规格 $return_data['attribute_list'] = AttributeService::get_instance()->get_attribute_spec_options(); //当前站点品牌 $return_data['feature_list'] = AttributeService::get_instance()->get_attribute_feature_options(); } else { // 调用底层服务 $category_service = CategoryService::get_instance(); $classify_service = ClassifyService::get_instance(); //获取数据 $category = $category_service->get($request_data['category_id']); if ($category['classify_id']) { $return_data['classify'] = $classify_service->get($category['classify_id']); //获取关联品牌数组 $return_data['brand_list'] = $classify_service->get_brands_by_classify_id($category['classify_id']); //获取关联规格及规格项数组 $return_data['attribute_list'] = $classify_service->get_attribute_options_by_classify_id($category['classify_id'], AttributeService::ATTRIBUTE_SPEC); //获取关联特性及特性值数组 $return_data['feature_list'] = $classify_service->get_attribute_options_by_classify_id($category['classify_id'], AttributeService::ATTRIBUTE_FEATURE); } } //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } // end of request type determine } catch (MyRuntimeException $ex) { $return_struct['status'] = 0; $return_struct['code'] = $ex->getCode(); $return_struct['msg'] = $ex->getMessage(); //TODO 异常处理 //throw $ex; if ($this->is_ajax_request()) { $this->template->content = $return_struct; } else { $this->template->return_struct = $return_struct; $content = new View('info'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } } }
public function add_products() { role::check('product_auction'); $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $return_data = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); $experience = $this->input->get('experience', 0); $relation_query_struct = array('where' => array('status!=' => 2, 'experience' => $experience), 'orderby' => array('id' => 'DESC')); //$relations = Product_auctionService::get_instance()->index($relation_query_struct); $product_ids = array(); //foreach ($relations as $relation){ //$product_ids[] = $relation['product_id']; //} $struct = product::get_struct($request_data); $query_struct_current = $struct['query']; $request_struct_current = $struct['request']; $query_struct_current['where']['type'] = ProductService::PRODUCT_TYPE_GOODS; //* 调用后端服务获取数据 */ $product_service = ProductService::get_instance(); $return_data['assoc'] = $product_service->index($query_struct_current); $return_data['count'] = $product_service->count($query_struct_current); // 初始化分类列表 $category_list = array(); // 初始化品牌列表 $brand_list = array(); if (!empty($return_data['assoc'])) { // 获取该商品列表中涉及到的分类以及品牌ID $category_ids = array(); $brand_ids = array(); foreach ($return_data['assoc'] as $product) { if ($product['category_id'] != 0) { $category_ids[$product['category_id']] = TRUE; } if ($product['brand_id'] != 0) { $brand_ids[$product['brand_id']] = TRUE; } } // 获取分类列表 if (!empty($category_ids)) { $query_struct = array('where' => array('id' => array_keys($category_ids))); $categorys = CategoryService::get_instance()->query_assoc($query_struct); foreach ($categorys as $category) { $category_list[$category['id']] = $category['title_manage']; } } // 获取品牌列表 if (!empty($brand_ids)) { $query_struct = array('where' => array('id' => array_keys($brand_ids))); $brands = BrandService::get_instance()->query_assoc($query_struct); foreach ($brands as $brand) { $brand_list[$brand['id']] = $brand['name']; } } } // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page'])); //* 如果是ajax请求缩减返回的字段 ==根据业务逻辑定制== */ if ($this->is_ajax_request()) { $requestkeys = array('id', 'category_id', 'title', 'uri_name', 'store', 'on_sale', 'goods_price', 'sku'); array_walk($return_data['assoc'], 'util::simplify_return_array', $requestkeys); } //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //exit("<div id=\"do_debug\" style=\"clear:both;display:;\"><pre>\n".var_export($return_struct,TRUE)."\n</pre></div>"); //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { //* html 输出 ==根据业务逻辑定制== */ $this->template = new View('layout/commonfix_html'); //* 模板输出 */ $this->template->return_struct = $return_struct; $content = new View('product/auction/add_products', array('experience' => $experience)); //* 变量绑定 */ $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; //:: 当前应用专用数据 $this->template->content->title = Kohana::config('site.name'); $this->template->content->product_ids = $product_ids; $this->template->content->category_list = $category_list; $this->template->content->brand_list = $brand_list; } // end of request type determine } catch (MyRuntimeException $ex) { $this->_ex($ex, $return_struct, $request_data); } }
public function index() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //$profiler = new Profiler; //* 初始化返回数据 */ $return_data = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); //* 实现功能后屏蔽此异常抛出 */ //throw new MyRuntimeException('Not Implemented',501); //权限验证 if ($this->site_id == 0) { throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400); } role::check('default', $this->site_id, 0); // 执行业务逻辑 $category_service = CategoryService::get_instance(); $str = '<option value={$id} {$selected}>{$spacer}{$title}</option>'; $category_list = $category_service->get_tree($str); //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = ''; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { // html 输出 //* 模板输出 */ $content = new View('site/sitemap'); //* 变量绑定 */ $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; //:: 当前应用专用数据 $this->template->content->site_id = $this->site_id; $this->template->content->category_list = $category_list; } // end of request type determine } catch (MyRuntimeException $ex) { $return_struct['status'] = 0; $return_struct['code'] = $ex->getCode(); $return_struct['msg'] = $ex->getMessage(); //TODO 异常处理 //throw $ex; if ($this->is_ajax_request()) { $this->template->content = $return_struct; } else { $this->template->return_struct = $return_struct; $content = new View('info'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } } }
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ require '../../model-db-connection/config.php'; require '../../model/com.gogetrich.dao/CategoryDaoImpl.php'; require '../../model/com.gogetrich.service/CategoryService.php'; require '../../model/com.gogetrich.model/CategoryVO.php'; $cateDao = new CategoryDaoImpl(); $cateService = new CategoryService($cateDao); $cateID = $_GET['cateID']; echo $cateService->getCourseCategoryByID($cateID);
<tr> <td style="height:26px" > <input type="submit" id="btnSave" name="btnSave" class="submit_btn" onsubmit="return save()" value="Save"/> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </form> </div> </body> </html> <?php if (isset($_POST['btnSave'])) { $service = new CategoryService(); $sql = ' insert into category '; $title = $_POST["txtEditTitle"]; $dataArray = array("category_title" => "'" . $title . "'"); $sql .= $service->GetInsertSQL($dataArray); $id = $service->save($sql); if ($id != 0) { alertRedirect(true, 'DisplayCategory.php'); } else { alertRedirect(false, 'DisplayCategory.php'); } }
protected function get_category_names($category_id) { if (!isset($this->category_names[$category_id])) { $category_names = ''; $category = CategoryService::get_instance()->get($category_id); $category_names = $category['title_manage']; while ($category['pid'] != 0) { $category = CategoryService::get_instance()->get($category['pid']); if (!empty($category_names)) { $category_names = '->' . $category_names; } $category_names = $category['title_manage'] . $category_names; } $this->category_names[$category_id] = $category_names; } return $this->category_names[$category_id]; }
/** * 得到分类已经的SEO信息 */ public function get_category_product_seo() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); // 初始化返回数据 $return_data = array(); //请求结构体 $request_data = array(); try { /* 分类 */ $category_id = $this->input->get('category_id'); // 初始化默认查询条件 $query_struct = array('where' => array('category_id' => $category_id), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 100, 'offset' => 0)); if ($category_id > 0) { //判断分类下面是否有子分类 $childrens = CategoryService::get_instance()->get_childrens_by_category_id($category_id); if (isset($childrens) && !empty($childrens)) { $is_contain_child = 1; } else { $is_contain_child = 0; } } else { $query_struct['where']['category_id'] = Seo_manageService::SEO_CATEGORY_IS_NULL; $is_contain_child = 0; } $seo_manage = Seo_manageService::get_instance()->query_assoc($query_struct); if (is_array($seo_manage) && count($seo_manage) > 0) { $return_struct['status'] = 1; $return_struct['code'] = 200; $return_data['data'] = $seo_manage; $return_struct['content'] = $return_data; $return_struct['is_contain_child'] = $is_contain_child; } //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { die('No direct access allowed.'); } // end of request type determine } catch (MyRuntimeException $ex) { $return_struct['status'] = 0; $return_struct['code'] = $ex->getCode(); $return_struct['msg'] = $ex->getMessage(); if ($this->is_ajax_request()) { $this->template = new View('layout/empty_html'); $this->template->content = $return_struct['msg']; } else { $this->template->return_struct = $return_struct; $content = new View('info'); $this->template->content = $content; /* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; /* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } } }
<?php include 'init.php'; include SROOT . 'categoryService.class.php'; $service = new CategoryService(); $result = $service->getAll(); if ($result) { $data = array('result' => $result); render('category.list', $data); } else { render('category.list'); }
/** * 根据 类型ID数组批量删除类型 * @param $categorys array * @return void * @throws MyRuntimeException */ public function delete_classifies($classifies) { try { $del_all = TRUE; if (!empty($classifies)) { foreach ($classifies as $val) { $query_struct = array('where' => array('classify_id' => $val)); if (CategoryService::get_instance()->count($query_struct)) { $del_all = FALSE; } if ($del_all === TRUE and ProductService::get_instance()->count($query_struct) > 0) { $del_all = FALSE; } if ($del_all === TRUE) { $where = array('classify_id' => $val); Classify_brand_relationService::get_instance()->delete_relations($where); Classify_attribute_relationService::get_instance()->delete_relations($where); //Classify_feature_relationService::get_instance()->delete_relations($where); $this->remove($val); } } if (!$del_all) { throw new MyRuntimeException('无法删除部分被关联的类型', 500); } } } catch (MyRuntimeException $ex) { throw $ex; } }
/** * 显示编辑商品表单 */ public function edit() { // 初始化返回结构体 $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { // 初始化返回数据 $return_data = array(); // 收集请求数据 $request_data = $this->input->get(); if (empty($request_data['id'])) { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400); } $product = BLL_Product::get($request_data['id']); if (empty($product['id'])) { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400); } // 分类列表默认关联第一个 $categorys_tree = CategoryService::get_instance()->get_tree("<option value=\\\"\$id\\\" \$selected>\$spacer\$title</option>", $product['category_id']); $categories = CategoryService::get_instance()->query_assoc(array()); $categories = tree::get_tree_array($categories); $classifies = ClassifyService::get_instance()->index(array('orderby' => array('id' => 'ASC'))); $classify_content['features'] = $this->load_features($product['classify_id'], $product['fetuoptrs']); $classify_content['brands'] = $this->load_brands($product['classify_id'], $product['brand_id']); // 处理商品类型特定的模板区块 $ptype_layout = NULL; switch ($product['type']) { case ProductService::PRODUCT_TYPE_ASSEMBLY: throw new MyRuntimeException('Coming soon ...', 400); //暂时不支持组合商品 $ptype_layout = new View($this->package_name . '/' . $this->class_name . '/assembly/layout'); break; case ProductService::PRODUCT_TYPE_CONFIGURABLE: $ptype_layout = new View($this->package_name . '/' . $this->class_name . '/configurable/layout'); break; case ProductService::PRODUCT_TYPE_GOODS: default: $ptype_layout = new View($this->package_name . '/' . $this->class_name . '/simple/layout'); break; } $ptype_layout->product = $product; $return_struct['content'] = array('product' => $product); //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { // html 输出 //* 模板输出 */ $this->template->return_struct = $return_struct; $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ $this->template->title = Kohana::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; $this->template->content->categorys_tree = $categorys_tree; $this->template->content->categories = $categories; $this->template->content->classifies = $classifies; $this->template->content->classify_content = $classify_content; $this->template->content->ptype_layout = $ptype_layout; $this->template->content->listurl = isset($request_data['listurl']) ? $request_data['listurl'] : ''; } // end of request type determine } catch (MyRuntimeException $ex) { $this->_ex($ex, $return_struct, $request_data); } }
public function check_exist_uri_name() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //$profiler = new Profiler; //* 初始化返回数据 */ $return_data = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); //* 实现功能后屏蔽此异常抛出 */ //throw new MyRuntimeException('Not Implemented',501); //必须为ajax请求 if (!$this->is_ajax_request()) { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } //* 权限验证 */ $site_id = site::id(); if ($site_id == 0) { throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400); } if (!isset($request_data['uri_name']) || empty($request_data['uri_name'])) { throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 404); } $category_service = CategoryService::get_instance(); if (isset($request_data['category_id']) && is_numeric($request_data['category_id'])) { $category = $category_service->get($request_data['category_id']); //判断站点 if ($site_id != $category['site_id']) { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 404); } if (strtolower($category['uri_name']) == strtolower($request_data['uri_name'])) { exit(Kohana::lang('o_global.true')); } } // 调用底层服务 if ($category_service->check_exist_uri_name($site_id, $request_data['uri_name'])) { exit(Kohana::lang('o_global.false')); } else { exit(Kohana::lang('o_global.true')); } } catch (MyRuntimeException $ex) { $this->_ex($ex, $return_struct, $request_data); } }
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ require '../../model/com.gogetrich.dao/CategoryDaoImpl.php'; require '../../model/com.gogetrich.service/CategoryService.php'; require '../../model/com.gogetrich.model/CategoryVO.php'; $cateDao = new CategoryDaoImpl(); $cateService = new CategoryService($cateDao); $cateName = $_GET['cateName']; $cateVO = new CategoryVO(); $cateVO->setCateID(md5(date("h:i:sa"))); $cateVO->setCateName($cateName); echo $cateService->saveCourseCategory($cateVO);
<?php include 'init.php'; require_once SROOT . 'articleService.class.php'; require_once SROOT . 'categoryService.class.php'; $method = v('method'); if (!$method) { send_result(0, "request does not have method parame"); } $service = new ArticleService(); $categoryService = new CategoryService(); if ($method == 'delete') { if (v('id') && isset($_REQUEST['status'])) { if ($_REQUEST['status'] == -1) { $flag = $service->delete(v('id')); } else { $flag = $service->trash(v('id')); } if ($flag) { // 静态化文章,及更新列表 $service->staticArticle($id); $category = $categoryService->findById(v('cid')); $service->staticArticleList($category); $service->staticIndex(); } forward('article_list.php?status=' . $_REQUEST['status']); } else { send_result(0, 'request does not have id ro status parame'); } } else { if ($method == 'draft') {
public function put() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //$profiler = new Profiler; //* 初始化返回数据 */ $return_data = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->get(); if (empty($request_data['product_id']) or !isset($request_data['relation_ids'])) { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400); } //* 权限验证 ==根据业务逻辑定制== */ $product_service = ProductService::get_instance(); $product_relation_service = Product_relationService::get_instance(); $product = $product_service->get($request_data['product_id']); ORM::factory('product_relation')->where('product_id', $product['id'])->delete_all(); $query_relation_ids = explode('-', $request_data['relation_ids']); $relation_ids = array(); $products = array(); $category_ids = array(); $categorys = array(); $brand_ids = array(); $brands = array(); if (!empty($query_relation_ids)) { $query_struct = array('where' => array('id' => $query_relation_ids)); foreach ($product_service->query_assoc($query_struct) as $relation) { if ($relation['site_id'] == $product['site_id']) { $relation_ids[$relation['id']] = TRUE; $category_ids[$relation['category_id']] = TRUE; if ($relation['brand_id'] > 0) { $brand_ids[$relation['brand_id']] = TRUE; } $products[] = $relation; } } } if (!empty($category_ids)) { $query_struct = array('where' => array('id' => array_keys($category_ids))); foreach (CategoryService::get_instance()->query_assoc($query_struct) as $category) { $categorys[$category['id']] = $category['title_manage']; } } if (!empty($brand_ids)) { $query_struct = array('where' => array('id' => array_keys($brand_ids))); foreach (BrandService::get_instance()->query_assoc($query_struct) as $brand) { $brands[$brand['id']] = $brand['name']; } } if (!empty($relation_ids)) { foreach ($relation_ids as $key => $val) { $product_relation_service->create(array('product_id' => $product['id'], 'relation_product_id' => $key)); } } ProductService::get_instance()->set($product['id'], array('update_timestamp' => time())); $list = new View($this->package_name . '/' . $this->class_name . '/list'); $list->brands = $brands; $list->categorys = $categorys; $list->products = $products; $return_data['relation_ids'] = $relation_ids; $return_data['list'] = (string) $list; //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = '关联成功!'; $return_struct['content'] = $return_data; //* 请求类型 */ if ($this->is_ajax_request()) { // ajax 请求 // json 输出 $this->template->content = $return_struct; } else { throw new MyRuntimeException(); // html 输出 $this->template = new View('layout/empty_html'); //$this->template->manager_data = $this->manager; //* 模板输出 */ //$this->template->return_struct = $return_struct; $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__); //* 变量绑定 */ //$this->template->title = Kohana::config('site.name'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; //:: 当前应用专用数据 $this->template->content->title = Kohana::config('site.name'); } // end of request type determine } catch (MyRuntimeException $ex) { $return_struct['status'] = 0; $return_struct['code'] = $ex->getCode(); $return_struct['msg'] = $ex->getMessage(); //TODO 异常处理 //throw $ex; if ($this->is_ajax_request()) { $this->template->content = $return_struct; } else { //$return_struct['action']['type']= 'close'; // 当前应用为弹出窗口所以定义失败后续动作为关闭窗口 $this->template = new View('layout/default_html'); $this->template->return_struct = $return_struct; $content = new View('info2'); $this->template->content = $content; //* 请求结构数据绑定 */ $this->template->content->request_data = $request_data; //* 返回结构体绑定 */ $this->template->content->return_struct = $return_struct; } } }
/** * action list * * @param string $longitude * @param string $latitude * @return void */ public function ajaxSearchAction($longitude = null, $latitude = null) { $radius = $this->settings['defaultRadius']; if (strlen($this->settings['categories']) > 0) { $categories = array_merge(GeneralUtility::trimExplode(',', CategoryService::getChildrenCategories($this->settings['categories'], 0, '', true), true), GeneralUtility::trimExplode(',', $this->settings['categories'], true)); } else { $categories = array(); } $locations = $this->locationRepository->findNearBy($address, $latitude, $longitude, $radius, explode(',', $this->settings['searchColumns']), $categories); $this->view->assign('mapLatitude', $latitude); $this->view->assign('mapLongitude', $longitude); $this->groupByCategories($locations); $this->view->assign('locations', $locations); echo $this->view->render(); exit; }
protected function parse_category($l) { static $names = array(); static $last_category_id = 0; $categorys = $this->get($l, 'category'); if ($categorys !== '') { $cs_upper = strtoupper($categorys); if (isset($names[0][$cs_upper])) { return $names[0][$cs_upper]; } $cnames = explode('->', $categorys); $parent_id = 0; $parent_name = '根分类'; foreach ($cnames as $item) { $category = CategoryService::get_instance()->query_row(array('where' => array('pid' => $parent_id, 'title_manage' => trim($item)))); if (!empty($category)) { $parent_id = $category['id']; $parent_name = $category['title_manage']; } else { $this->set_error(new MyRuntimeException(sprintf('分类 "%s" 下未找到名称为 "%s" 的子分类', $parent_name, $item))); $is_error = TRUE; break; } } if (!isset($is_error) or $is_error === FALSE) { $names[][$cs_upper] = $category['id']; $last_category_id = $category['id']; return $category['id']; } } if ($last_category_id == 0) { $this->set_error(new MyRuntimeException('商品所属分类解析失败')); } return $last_category_id; }
require_once 'include.php'; AdminCheck(); global $arr_header; global $key_id; $key_id = "category_id"; $arr_header = array("category_title" => "category title"); global $needEdit; $needEdit = false; //global $editUrl; //$editUrl = "Login.php"; global $service_list; global $totalCount; global $curPage; global $totalPage; $service_list = new CategoryService(); global $rows; $totalCount = $service_list->GetCount("select count(*) from category"); $totalPage = $service_list->GetTotalPage($totalCount); $curPage = $service_list->GetCurrentPage($totalPage); $sql = " select * from category "; $sql = $service_list->SetPaging($sql, $curPage); $rows = $service_list->GetRows($sql); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CRAZY HATS</title> <script src="../js/Common.js" type="text/javascript"></script> <style type="text/css">
<div id="sidebar" class="float_l"> <div class="sidebar_box"><span class="bottom"></span> <h3>Categories</h3> <div class="content"> <?php $cservice = new CategoryService(); $category = $cservice->CategorysForSite(); foreach ($category as $row) { echo "<ul class='sidebar_list' style='margin-left:10px'><li class='first'>"; echo "<a href='DisplayCategory.php?cateName=" . urlencode($row["category_title"]) . "&cateId=" . urlencode($row["category_id"]) . "' >" . $row["category_title"] . "</a>"; echo "</li></ul>"; } ?> </div> </div> </div>
/** * Returns list of top articles (most viewed) in the category * @return array */ protected function getArticles() { wfProfileIn(__METHOD__); $service = new CategoryService($this->categoryPage->mTitle); $result = $service->getTopArticles($this->confMaxArticles); wfProfileOut(__METHOD__); return $result; }