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


PHP Model_Category::getCategory方法代码示例

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


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

 public function action_index()
 {
     $category = new Model_Category('tree');
     $data['categories'] = $category->getTree();
     if (isset($_POST['add_category'])) {
         $categoryName = Arr::get($_POST, 'categoryName', '');
         $categoryUrl = Arr::get($_POST, 'categoryUrl', '');
         $parentId = Arr::get($_POST, 'parentId', '');
         $previousId = Arr::get($_POST, 'previousId', '');
         $res = $category->catInsert($parentId, $previousId, array('name' => $categoryName, 'url' => $categoryUrl));
         if ($res) {
             Controller::redirect('admin');
         } else {
             $data['errors'] = $category->getErrors();
         }
     }
     if (isset($_POST['save_category'])) {
         $categoryName = Arr::get($_POST, 'categoryName', '');
         $categoryKeywords = Arr::get($_POST, 'categoryKeywords', '');
         $categoryDescription = Arr::get($_POST, 'categoryDescription', '');
         $url = $this->request->param('id');
         $categoryId = $category->getCategoryIdByUrl($url);
         $res = $category->catUpdate($categoryId, array('name' => $categoryName, 'keywords' => $categoryKeywords, 'description' => $categoryDescription));
         if ($res) {
             Controller::redirect('admin/' . $url);
         } else {
             $data['errors'] = $category->getErrors();
         }
     }
     if (isset($_POST['create_from_groups'])) {
         $groupId = Arr::get($_POST, 'groupId', '');
         $parentId = Arr::get($_POST, 'parentId', '');
         $include_content = Arr::get($_POST, 'include_content', '');
         $category->createFromGroups($parentId, $groupId);
         if ($include_content == 'on') {
         }
     }
     $url = $this->request->param('id');
     $widgetId = $this->request->param('widget');
     $widgets = new Model_Widget();
     if ($url != NULL) {
         $data['thisCategory'] = $category->getCategory($category->getCategoryIdByUrl($url));
         //получаем виджеты для категории
         $data['widgets'] = $widgets->getWidgets($category->getCategoryIdByUrl($url));
     }
     if ($widgetId) {
         $data['widget'] = $widgets->getWidget($widgetId);
         $data['widgetTypes'] = $widgets->getWidgetTypes();
     }
     //Получаем группу пользователя
     $auth = Auth::instance();
     $user = $auth->get_user();
     //  echo '<pre>';
     $this->template->content = View::factory('admin/admIndex', array('data' => $data, 'user' => $this->user));
 }
开发者ID:chernogolov,项目名称:blank,代码行数:55,代码来源:Index.php

示例3: action_material

 public function action_material()
 {
     $materials = new Model_Material('groups');
     //получаем url материала
     $materialUrl = $this->request->param('id');
     $categoryUrl = $this->request->param('category');
     View::set_global('categoryName', $categoryUrl);
     $category = new Model_Category('tree');
     $categoryId = $category->getCategoryIdByUrl($categoryUrl);
     $categoryTitle = $category->getCategory($categoryId);
     $subcategoryUrl = $this->request->param('subcategory');
     if ($subcategoryUrl) {
         $categoryId = $category->getCategoryIdByUrl($subcategoryUrl);
     }
     $groupId = $materials->getGroupFromCategory($categoryId);
     $materialId = $materials->getMaterialIdByUrl($materialUrl, $groupId);
     $material = $materials->getMaterial($materialId);
     $fields = $materials->getFields2($materialId, TRUE);
     $title = '';
     $category_url = $this->request->param('category');
     $category_id = $category->getCategoryIdByUrl($category_url);
     $category_data = $category->getCategory($category_id);
     $material_url = $this->request->param('id');
     $group_id = $materials->getGroupFromCategory($category_id);
     $material_id = $materials->getMaterialIdByUrl($material_url, $group_id);
     $material_data = $materials->getMaterial($material_id);
     $this->template->title = $title . ' ' . $material['name'];
     $this->template->page_title = $material['name'];
     $this->template->keywords = $material['keywords'];
     $this->template->description = $material['description'];
     $this->template->styles = $this->getStyles($this->styles);
     if (!$material['id']) {
         throw new HTTP_Exception_404();
     }
     //обновляем просмотры
     $materials->updateViews($material['id']);
     $widgets[] = Request::factory('widgets/material/index/' . $material['id'])->execute();
     $this->template->block_center = $widgets;
 }
开发者ID:chernogolov,项目名称:blank,代码行数:39,代码来源:Material.php

示例4: action_graph

 public function action_graph($options = array("parent_id" => 4))
 {
     $this->setopt(array("name" => "parent_id", "description" => "Ид каталога", "default" => $options["parent_id"]));
     $parent_id = $this->getopt("parent_id");
     $model = array("items" => array());
     $model_tree = new Model_Widgets_Menu('tree');
     $category = new Model_Category('tree');
     $parent_node = $category->getNode($parent_id);
     $level = $parent_node["level"];
     //Получаем список меню
     $items = $model_tree->menuItems($parent_id, $level + 1);
     foreach ($items as $key => $item) {
         $this_category = $category->getCategory($category->getCategoryIdByUrl($item['url']));
         $category_id = $this_category['id'];
         $cat_photo = '/img/user/menu/' . $category_id . '_' . $item['url'];
         $cat_photo_path_jpg = $cat_photo . ".jpg";
         $cat_photo_path_png = $cat_photo . ".png";
         $cat_photo_path = "/img/noimg.png";
         if (file_exists(DOCROOT . $cat_photo_path_jpg)) {
             $cat_photo_path = $cat_photo_path_jpg;
         } elseif (file_exists(DOCROOT . $cat_photo_path_png)) {
             $cat_photo_path = $cat_photo_path_png;
         }
         $model["items"][] = array("href" => "/" . $item["parent"] . "/" . $item["url"], "photo" => Route::url('miniimg3', array('filename' => $cat_photo_path)), "name" => $item["name"]);
     }
     $this->set_template("widgets/menu/graph.php", "twig")->render($model)->body();
 }
开发者ID:chernogolov,项目名称:blank,代码行数:27,代码来源:Menu.php

示例5: getRandomMaterials

    public function getRandomMaterials($gid, $limit, $time = 0)
    {
        $data = array();
        $query = 'SELECT count(a.id) FROM materials a, group_materials_rel b
				 WHERE b.gid = ' . $gid . '
				 AND b.mid = a.id';
        $count = DB::query(Database::SELECT, $query)->execute()->current();
        $offset = rand(0, $count['count(a.id)'] - 2);
        $query = 'SELECT a.* FROM materials a, group_materials_rel b
				 WHERE b.gid = ' . $gid . '
				 AND b.mid = a.id
				 LIMIT ' . $offset . ', ' . $limit;
        $materials = DB::query(Database::SELECT, $query)->execute();
        foreach ($materials as $material) {
            //получаем поля
            $fields = $this->getFields2($material['id'], TRUE);
            $category = new Model_Category('tree');
            $node = $category->getCategory($this->getTreeIdByMid($material['id']));
            $arr = array_merge($material, $fields);
            $arr['node'] = $node['url'];
            $data[$material['id']] = $arr;
        }
        return $data;
    }
开发者ID:chernogolov,项目名称:blank,代码行数:24,代码来源:Material.php


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