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; } }
public function action_index() { $this->template->page_title = 'Главная страница'; //$this->template->block_center = array($block_center); $category = new Model_Category('tree'); $categoryName = $this->request->param('category'); $categoryId = $category->getCategoryIdByUrl('glavnaya'); //ВИДЖЕТЫ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ $widgets = $category->getWidgets($categoryId); $this->styles = array(); $wdgtarr = array(); // if($this->template->block_center!=NULL) // { // $oldWidgets = $this->template->block_center; // foreach ($oldWidgets as $oldWidget) // array_push($wdgtarr['block_center'], $oldWidget); // } $widgets = $this->getWidgets($categoryId); if (is_array($widgets)) { foreach ($widgets as $position => $widget) { $this->template->{$position} = $widget; } } $old_styles = $this->template->styles; array_unique($this->styles); $new_styles = array_merge($this->styles, $old_styles); $this->template->styles = $new_styles; }
public function action_delete() { $url = $this->request->param('id'); if ($url != NULL) { $category = new Model_Category('tree'); $result = $category->deleteCategory($category->getCategoryIdByUrl($url)); Controller::redirect('admin'); } }
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; }
public function action_category() { $url = $this->request->param('id'); $data = array(); $category = new Model_Category('tree'); $material = new Model_Material(); $category_id = $category->getCategoryIdByUrl($url); if (!$category_id) { throw new HTTP_Exception_404('Запрашиваемая категория не найдена'); return; } $data['materials'] = $material->getMaterialsByCategory($category_id); //$data['category_name'] = $category_info['name']; $this->template->content = View::factory('materialsview', $data); }
public function action_index() { $this->template->page_title = 'Главная страница'; //$this->template->block_center = array($block_center); $category = new Model_Category('tree'); $categoryName = $this->request->param('category'); $categoryId = $category->getCategoryIdByUrl('glavnaya'); //ВИДЖЕТЫ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ $GLOBALS['categoryId'] = $categoryId; $widgets = $this->getWidgets($categoryId); if (is_array($widgets)) { foreach ($widgets as $position => $widget) { $this->template->{$position} = $widget; } } $this->template->styles = $this->getStyles($this->styles); }
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(); }