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


PHP Model_Category::getParents方法代码示例

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


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

示例1: getPath

 public function getPath($dir)
 {
     //первым делом ищем в структуре
     $category = new Model_Category('tree');
     $categoryId = $category->getCategoryIdByUrl($dir);
     if ($categoryId) {
         $dirs = [];
         $categoryData = $category->getCategory($categoryId);
         $parents = $category->getParents($categoryId);
         foreach ($parents as $parent) {
             if ($parent['level'] > 1 && $parent['url'] != 'glavnaya') {
                 $dirs[] = $parent['url'];
             }
         }
         return array('name' => $categoryData['name'], 'path' => implode('/', $dirs));
     }
     //теперь ищем в материалах
     $materials = new Model_Material('group');
     $materialUrl = str_replace('.html', '', $dir);
     $materialId = $materials->getMaterialIdByUrl($materialUrl);
     if ($materialId) {
         $materialData = $materials->getMaterial($materialId);
         $categoryId = $materials->getTreeIdByMid($materialId);
         $categoryData = $category->getCategory($categoryId);
         return array('name' => $materialData['name'], 'path' => $categoryData['url'] . '/' . $dir);
     } else {
         return FALSE;
     }
 }
开发者ID:chernogolov,项目名称:blank,代码行数:29,代码来源:Breadcrumb.php

示例2: action_cart

 public function action_cart()
 {
     /* Добавление товара в корзину
     					$data:
     							$item_id* - id товара
     							$item_count* - кол-во товара
     							$order_id - id заказа
     			*/
     $methods['add_item'] = function ($data) {
         PC::debug($data, 'add item data');
         $model_orders = new Model_Orders();
         $materials = new Model_Material('groups');
         // Добавление товара к существующему заказу
         if (isset($data['order_id'])) {
             PC::debug(1, 1);
             $res = $model_orders->addGood(Arr::get($data, 'order_id'), Arr::get($data, 'item_id'), Arr::get($data, 'item_count'));
         } else {
             PC::debug(2, 1);
             $item_count = Arr::get($data, 'item_count');
             $res = $model_orders->newOrder(Arr::get($data, 'item_id'), $item_count);
             $new_count = $item_count;
         }
         $material = $materials->getMaterial(Arr::get($data, 'item_id'));
         $fields = $materials->getFields2(Arr::get($data, 'item_id'), TRUE);
         $catalog = new Model_Category('tree');
         $categoryId = $materials->getTreeIdByMid(Arr::get($data, 'item_id'));
         $parents = $catalog->getParents($categoryId);
         $node = '';
         foreach ($parents as $parent) {
             if ($parent['level'] > 1 && $parent['url'] != 'glavnaya') {
                 $node .= $parent['url'] . '/';
             }
         }
         $itemdata = $model_orders->getOrderCount(Arr::get($data, 'order_id'), Arr::get($data, 'item_id'));
         $item[Arr::get($data, 'item_id')] = array_merge($material, $fields);
         if (isset($new_count)) {
             $item[Arr::get($data, 'item_id')]['cnt'] = $new_count;
         } else {
             $item[Arr::get($data, 'item_id')]['cnt'] = $itemdata['cnt'];
         }
         $item[Arr::get($data, 'item_id')]['node'] = $node;
         return array('order_id' => $res, 'item' => $item);
     };
     /* Удаление товара из корзины
     					$data:
     							$order_id* - id заказа
     							$item_id* - id товара
     							$item_count* - кол-во товара
     			*/
     $methods['del_item'] = function ($data) {
         $model_orders = new Model_Orders();
         extract($data);
         // Удаление товара из корзины
         $res = $model_orders->deleteItem(Arr::get($data, 'order_id'), Arr::get($data, 'item_id'), Arr::get($data, 'item_count'));
         return $res;
     };
     /* Получение информации о заказе
     				$data:
     					$order_id* - id заказа
     			*/
     $mathods['get_order'] = function ($data) {
         $model_orders = new Model_Orders();
         $order_data = $model_orders->getOrder($data['order_id']);
         return $order_data;
     };
     /* Удаление заказа
     				$data:
     					$order_id* - id заказа
     			*/
     $mathods['del_order'] = function ($data) {
         PC::debug($data, 'del_order');
         $model_orders = new Model_Orders();
         $res = $model_orders->deleteOrder($data['order_id']);
         return $res;
     };
     /* Получение информации о заказе
     				$data:
     					$order_id* - id заказа
     			*/
     $methods['get_items'] = function ($data) {
         $model_orders = new Model_Orders();
         //extract($data);
         $res = $model_orders->getOrder(Arr::get($data, 'order_id', ''));
         return $res;
     };
     $data = Arr::get($_POST, 'data', '');
     if ($data == '') {
         $data = Arr::get($_GET, 'data', '');
     }
     extract(json_decode($data, true));
     $res = false;
     if (isset($methods[$method])) {
         $res = $methods[$method]($data);
         PC::debug($res, 'Ajax: "' . $method . '"');
     }
     exit(json_encode($res));
 }
开发者ID:chernogolov,项目名称:blank,代码行数:97,代码来源:Ajax.php

示例3: getOrder

 public function getOrder($orderId)
 {
     $order = ORM::factory("Orders")->where("id", "=", $orderId)->find()->as_array();
     $items = DB::select()->from("order_materials")->where("order_id", "=", $orderId)->execute()->as_array();
     $materials = new Model_Material("groups");
     $catalog = new Model_Category("tree");
     foreach ($items as $item) {
         $material = $materials->getMaterial($item["mid"]);
         $fields = $materials->getFields2($item["mid"], TRUE);
         $categoryId = $materials->getTreeIdByMid($item["mid"]);
         $parents = $catalog->getParents($categoryId);
         $node = "";
         foreach ($parents as $key => $parent) {
             if ($parent["url"] == "glavnaya") {
                 $node .= $parents[$key + 1]["url"] . "/";
                 break;
             }
         }
         $order["items"][$item["mid"]] = array_merge($material, $fields);
         $order["items"][$item["mid"]]["cnt"] = $item["cnt"];
         $order["items"][$item["mid"]]["node"] = $node;
     }
     return $order;
 }
开发者ID:chernogolov,项目名称:blank,代码行数:24,代码来源:Orders.php

示例4: getTopMaterials

    public function getTopMaterials($gid, $field, $limit, $time = 0)
    {
        $data = array();
        $query = 'SELECT a.* FROM materials a, group_materials_rel b
			WHERE b.gid = ' . $gid . '
			AND b.mid = a.id
			ORDER BY a.' . $field . ' DESC
			LIMIT 0, ' . $limit;
        $materials = DB::query(Database::SELECT, $query)->execute();
        foreach ($materials as $material) {
            $node = '';
            //получаем поля
            $fields = $this->getFields2($material['id'], TRUE);
            $category = new Model_Category('tree');
            $parents = $category->getParents($this->getTreeIdByMid($material['id']));
            foreach ($parents as $parent) {
                if ($parent['level'] > 1 && $parent['url'] != 'glavnaya') {
                    $node .= $parent['url'] . '/';
                }
            }
            $arr = array_merge($material, $fields);
            $arr['node'] = $node;
            $data[$material['id']] = $arr;
        }
        return $data;
    }
开发者ID:chernogolov,项目名称:blank,代码行数:26,代码来源:Material.php


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