当前位置: 首页>>代码示例>>PHP>>正文


PHP category::permalink方法代码示例

本文整理汇总了PHP中category::permalink方法的典型用法代码示例。如果您正苦于以下问题:PHP category::permalink方法的具体用法?PHP category::permalink怎么用?PHP category::permalink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在category的用法示例。


在下文中一共展示了category::permalink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build

 public function build()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //$profiler = new Profiler;
         //* 初始化返回数据 */
         $return_data = array();
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->post();
         //* 实现功能后屏蔽此异常抛出 */
         //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);
         // 调用底层服务
         $sitemap_service = SitemapService::get_instance();
         //业务逻辑
         $xmlContent = '';
         $xmlContent .= '<?xml version="1.0" encoding="UTF-8"?>';
         $xmlContent .= '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
         //添加首页
         if (!empty($request_data['index']) && is_numeric($request_data['index'])) {
             $priority = number_format($request_data['index'], 1);
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         $site_domain = Mysite::instance($this->site_id)->get('domain');
         $xmlContent .= sitemap::Render('http://' . $site_domain, 0, 'always', $priority);
         //添加分类页面
         $categories = $sitemap_service->get_category_page_by_site_id($this->site_id);
         if (!empty($request_data['category']) && is_numeric($request_data['category'])) {
             $priority = number_format($request_data['category'], 1);
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         if (!empty($categories)) {
             foreach ($categories as $category) {
                 if (empty($request_data['exclude_category']) || !empty($request_data['exclude_category']) && !in_array($category['id'], $request_data['exclude_category'])) {
                     $xmlContent .= sitemap::Render(category::permalink($category['id']), 0, 'weekly', $priority);
                 }
             }
         }
         //添加商品页面
         if (!empty($request_data['product']) && is_numeric($request_data['product'])) {
             $priority = number_format($request_data['product'], 1);
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         if (isset($request_data['on_sale'])) {
             $on_sale = intval($request_data['on_sale']);
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         $products = $sitemap_service->get_product_page_by_site_id($this->site_id, $on_sale);
         if (!empty($request_data['exclude_product'])) {
             if (preg_match('/^([a-zA-Z0-9_]+,)*[a-zA-Z0-9_]+$/i', $request_data['exclude_product'])) {
                 $request_data['exclude_product'] = explode(',', $request_data['exclude_product']);
             } else {
                 throw new MyRuntimeException(Kohana::lang('o_site.product_id_format_check'), 404);
             }
         }
         if (!empty($products)) {
             foreach ($products as $product) {
                 if (empty($request_data['exclude_product'])) {
                     $xmlContent .= sitemap::Render(product::permalink($product['id']), $product['update_timestamp'], 'weekly', $priority);
                 } elseif (!empty($request_data['exclude_product']) && !in_array($product['sku'], $request_data['exclude_product'])) {
                     $xmlContent .= sitemap::Render(product::permalink($product['id']), $product['update_timestamp'], 'weekly', $priority);
                 }
             }
         }
         //添加促销页
         if (!empty($request_data['promotion']) && is_numeric($request_data['promotion'])) {
             $priority = number_format($request_data['promotion'], 1);
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         $promotions = $sitemap_service->get_promotion_page_by_site_id($this->site_id);
         if (!empty($promotions)) {
             $route = Myroute::instance()->get();
             $action = $route['promotion'];
             foreach ($promotions as $promotion) {
                 $xmlContent .= sitemap::Render('http://' . $site_domain . '/' . $action . '/' . $promotion['id'], time(), 'weekly', $priority);
             }
         }
         //添加文案页
         if (!empty($request_data['doc']) && is_numeric($request_data['doc'])) {
             $priority = number_format($request_data['doc'], 1);
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         $docs = $sitemap_service->get_doc_page_by_site_id($this->site_id);
         if (!empty($docs)) {
             foreach ($docs as $doc) {
                 $lastmod = strtotime($doc['updated']);
                 $xmlContent .= sitemap::Render('http://' . $site_domain . '/' . $doc['permalink'], $lastmod, 'weekly', $priority);
             }
         }
         $xmlContent .= '</urlset>';
//.........这里部分代码省略.........
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:101,代码来源:sitemap.php

示例2: category_menu_edit

 /**
  * 编辑商品分类导航
  */
 public function category_menu_edit($id)
 {
     $site_menu = Mysite_menu::instance($id);
     $temp = Mysite_menu::instance()->site_menu_queue($id);
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         /* 获取要编辑的导航的level_depth并修改其下所有的子导航的level_depth*/
         $data = $_POST;
         $parent_id = $this->input->post('parent_id');
         if ($parent_id == 0) {
             $data['level_depth'] = 1;
         } else {
             $parent_level_depth = Mysite_menu::instance($parent_id)->get('level_depth');
             $data['level_depth'] = $parent_level_depth + 1;
         }
         if (!Mysite_menu::instance()->child_level_depth_edit($id, $data['level_depth'], $temp)) {
             remind::set(Kohana::lang('o_global.update_error'), 'site/menu');
         }
         /* 获取所添加的分类的url*/
         $category_id = $this->input->post('category_id');
         $data['url'] = category::permalink($category_id, false);
         //'/category/'.$category_id;
         /* 标志导航类型*/
         $data['memo'] = 'category';
         $data['type'] = $this->MENU_TYPE_CATEGORY;
         $data['relation_id'] = $category_id;
         if ($site_menu->site_menu_edit($id, $data)) {
             remind::set(Kohana::lang('o_global.update_success'), 'site/menu/', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'site/menu');
         }
     }
     $site_menu_data = $site_menu->get();
     /* 得到导航列表并删除自身及自身的子目录*/
     $child_ids = array();
     $site_menus = Mysite_menu::instance()->site_menu_queue();
     foreach ($temp as $val) {
         $child_ids[] = $val['id'];
     }
     foreach ($site_menus as $key => $value) {
         if ($value['id'] == $id || in_array($value['id'], $child_ids)) {
             unset($site_menus[$key]);
         }
     }
     /* 当前站点分类*/
     $categories = CategoryService::get_instance()->get_categories();
     $str = '<option value={$id} {$selected}>{$spacer}{$title_manage}</option>';
     $category_list = tree::get_tree($categories, $str, 0, $site_menu_data['relation_id']);
     $this->template->content = new View("site/category_menu_edit");
     $this->template->content->site_menus = $site_menus;
     $this->template->content->category_list = $category_list;
     $this->template->content->site_menu_data = $site_menu_data;
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:57,代码来源:menu.php


注:本文中的category::permalink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。