當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。