예제 #1
0
 public function action_index()
 {
     $materialId = $this->request->param('id');
     $materials = new Model_Material('groups');
     //получить содержимое папки
     $data = $materials->getMaterial($materialId);
     $fields = $materials->getFields2($materialId, TRUE);
     //смотрим шаблон для виджета
     $widget = new Model_Widget();
     $template = $widget->getTempalte('material', $materialId);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     $group = $materials->getGroup($materials->getGroupFromMid($materialId));
     if ($group['name'] == 'Новости') {
         $this->template = View::factory('widgets/w_news_item');
         $this->template->breadcrumbs = Request::factory('widgets/breadcrumb/index/')->execute();
     }
     //        if($group['name']=='Диспенсеры')
     //        {
     //            if(isset($fields['type'][0]))
     //            {
     //                $uri = Request::detect_uri();
     //                $dirs = explode('/', $uri);
     //                array_pop($dirs);
     //                $categoryName = array_pop($dirs);
     //
     //                $category = new Model_Category('tree');
     //                $categoryId = $category->getCategoryIdByUrl($categoryName);
     //
     //                $GLOBALS['categoryId'] = $categoryId;
     //
     //                $dopdata = $materials->getFullMaterials2($group['id'], 5, 0, NULL, array('type' => array($fields['type'][0]['value'])));
     //                unset($dopdata[$materialId]);
     //
     //                $this->template->dopdata = array_slice($dopdata, 0, 4);
     //            }
     //        }
     //получаем комментарии
     $comments = Request::factory('widgets/comments/index/' . $materialId)->execute();
     $callback_form = Request::factory('widgets/callback/index/')->execute();
     $this->template->callback = $callback_form;
     $this->template->material = $data;
     $this->template->fields = $fields;
     $this->template->comments = $comments;
 }
예제 #2
0
파일: Ajax.php 프로젝트: chernogolov/blank
 public function action_load_price()
 {
     // Получение значения ячейки
     function get_cell_value($worksheet, $cell)
     {
         return $worksheet->getCell($cell)->getValue();
     }
     // Преобразование числового значения столбца в символьное
     function col_n2str($col_n)
     {
         return PHPExcel_Cell::stringFromColumnIndex($col_n - 1);
     }
     // Преобразование символьного значения столбца в числовое
     function col_str2n($col)
     {
         return PHPExcel_Cell::columnIndexFromString($col);
     }
     // Узнать уровень вложенности строки
     function get_level($worksheet, $row)
     {
         return $worksheet->getRowDimension($row)->getOutlineLevel();
     }
     $objPHPExcel = PHPExcel_IOFactory::load(DOCROOT . "/price.xls");
     $structure = array("name" => array("index" => "A", "type" => "chars", "title" => "Наименование", "ordering" => 1), "ed_izm" => array("index" => "N", "type" => "select", "title" => "Единица измерения", "ordering" => 2), "price" => array("index" => "O", "type" => "price", "title" => "Цена", "ordering" => 3));
     $num_structure = array_values($structure);
     $categories = array(array("id" => 0, "level" => -1, "name" => "root"));
     $materials = array();
     $category_id_counter = 1;
     // Счётчик для id категории
     $parent_category_id = 0;
     // id родительской категории
     //echo '<table border>';
     //echo "<tr><td>Id категории<td>Уровень<td>id родительской категории<td>Название категории</tr>";
     // Проход по листам
     foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
         $worksheet_title = $worksheet->getTitle();
         $max_row = $worksheet->getHighestRow();
         // максимальная строка
         $max_col = $worksheet->getHighestColumn();
         // максимальный столбец (буква)
         $max_col = col_str2n($max_col);
         // максимальный столбец (цифра)
         //echo "<p>Максимальная строка: " . $max_row . "</p>";
         //echo "<p>Максимальный столбец: " . $max_col . " (" . col_n2str($max_col) . ")</p>";
         $start_row = 12;
         // С какой строки начинаем?
         // Перебор строк
         for ($row = $start_row; $row <= $max_row; $row++) {
             $level = get_level($worksheet, $row);
             // Уровень вложенности
             // Строка является заголовком?
             if (!get_cell_value($worksheet, $num_structure[1]["index"] . $row)) {
                 $current_cell = "A" . $row;
                 // Адрес ячейки
                 $value = get_cell_value($worksheet, $current_cell);
                 // Название категории
                 $categories[$category_id_counter] = array("id" => $category_id_counter, "level" => $level, "name" => $value);
                 // Поиск родителя
                 for ($i = $category_id_counter; $i >= 0; $i--) {
                     if ($categories[$i]["level"] == $level - 1) {
                         $parent_category_id = $categories[$i]["id"];
                         break;
                     }
                 }
                 //echo "<tr><td>" . $category_id_counter . "<td>" . $level . "<td>" . $parent_category_id . "<td>" . $value;
                 $categories[$category_id_counter]["parent"] = $parent_category_id;
                 $category_id_counter++;
             } else {
                 //echo '<tr><td colspan="4"><table style="width:100%;" border><tr>';
                 foreach ($structure as $name => $el) {
                     $current_cell = $el["index"] . $row;
                     // Адрес ячейки
                     $value = get_cell_value($worksheet, $current_cell);
                     $material_data[$name] = $value;
                     //echo '<td>' . $value;
                 }
                 //echo "</table>";
                 $category_id = $category_id_counter - 1;
                 $material_data["category_id"] = $category_id;
                 if (!isset($categories[$category_id]["materials"])) {
                     $categories[$category_id]["materials"] = array();
                 }
                 $categories[$category_id]["materials"][] = $material_data;
                 $materials[] = $material_data;
             }
         }
         //echo "</table>";
         //var_dump($categories);
         //var_dump($materials);
         //echo "<hr>";
     }
     $gid = 1218;
     // id группы
     $model_material = new Model_Material('groups');
     $model_base = new Model_Base();
     $group = $model_material->getGroup($gid);
     $categories[0]["db_id"] = $gid;
     $categories[0]["name"] = $group["name"];
     $parent_id = 0;
     $insertdata = array();
     $fieldset = $model_material->getFieldsSet($gid);
     //$insert_categories = array();
     $current_level = 0;
     while (true) {
         $search_level_status = false;
         foreach ($categories as $category_id => $category_data) {
             if ($category_data["level"] == $current_level) {
                 $search_level_status = true;
                 // Поиск родителя
                 for ($i = $category_id; $i >= 0; $i--) {
                     if ($categories[$i]["level"] == $current_level - 1) {
                         $parent_id = $categories[$i]["db_id"];
                         break;
                     }
                 }
                 $insert_group_id = $model_material->groupInsert($parent_id, $parent_id, array('name' => $category_data["name"]));
                 $group_params = array();
                 foreach ($structure as $name => $param) {
                     $param_data = array_merge($param, array("name" => $name, "gid" => $insert_group_id));
                     $model_material->addParam($param_data);
                 }
                 $category_data["db_id"] = $insert_group_id;
                 if (isset($category_data["materials"])) {
                     $fieldset = $model_material->getFieldsSet($insert_group_id);
                     //var_dump($fieldset);
                     // Проход по материалам
                     foreach ($category_data["materials"] as $material) {
                         //var_dump($material);
                         $insertdata = array();
                         $insertdata['title'] = Request::clearText($material["name"]);
                         $insertdata['url'] = Request::str2url($material["name"]);
                         $insertdata['description'] = Request::clearText($material["name"]);
                         // Проход по параметрам
                         foreach ($fieldset as $field) {
                             if (isset($structure[$field["name"]])) {
                                 $insertdata[$field["type"] . '_' . $field["id"]] = $material[$field["name"]];
                                 switch ($field["type"]) {
                                     case "files":
                                         $insertdata[$field["type"] . '_' . $field["id"]] = array($material[$field["name"]]);
                                         break;
                                     case "photoalbum":
                                         $insertdata[$field["type"] . '_' . $field["id"]] = array($material[$field["name"]]);
                                         break;
                                     case "select":
                                         $insertdata[$field["type"] . '_' . $field["id"]] = array($material[$field["name"]]);
                                         break;
                                 }
                                 // Наценка 30%
                                 /*if ($field["type"] == "price") {
                                 			$insertdata[$field["type"].'_'.$field["id"]] = $material[$field["name"]] * 1.3;
                                 		}*/
                             }
                         }
                         echo "<pre>";
                         var_dump($insertdata);
                         echo "</pre>";
                         $result = $model_material->newMaterial($insertdata, $insert_group_id, TRUE);
                     }
                 }
                 //var_dump($category_data);
                 echo "<hr>";
                 $categories[$category_id] = $category_data;
             }
         }
         if (!$search_level_status) {
             break;
         }
         $current_level++;
     }
 }
예제 #3
0
 public function action_editfields()
 {
     $groupId = intval($this->request->param('id'));
     $paramName = $this->request->param('param');
     $group = new Model_Material('groups');
     if (isset($_POST['delete_fields'])) {
         $result = $group->deleteParams($_POST['pid']);
     }
     if (isset($_POST['sort_fields']) && isset($_POST['params'])) {
         $group->sortParams($_POST['params'], $groupId);
         Controller::redirect('/admin/materials/' . $groupId . '/fields');
     }
     if (isset($_POST['saveParam'])) {
         $group->updateParam($_POST, $paramName, $groupId);
         Controller::redirect('/admin/materials/' . $groupId . '/fields');
     }
     if (isset($_POST['saveExcelSettings'])) {
         $group->updateExcelSettings($_POST, $groupId);
     }
     $groupData = $group->getGroup($groupId);
     $this->data['groups'] = $group->getTree();
     $this->data['groupParams'] = $group->getParams($groupId);
     $base = new Model_Base();
     $options = $base->getOptions();
     if (!$paramName) {
         $params = View::factory('admin/admParams', array('data' => $this->data['groupParams'], 'user' => $this->user, 'group' => $groupData, 'options' => $options));
     } else {
         $param_data = $group->getField($paramName, $groupId);
         $params = View::factory('admin/admParam', array('data' => $param_data, 'user' => $this->user, 'group' => $groupData, 'options' => $options));
     }
     $this->template->content = View::factory('admin/admMaterials', array('data' => $this->data, 'user' => $this->user, 'params' => $params));
 }
예제 #4
0
 public function action_index()
 {
     $group = new Model_Material('groups');
     $pagination = '';
     //Добавление группы
     if (isset($_POST['add_group'])) {
         $groupName = Arr::get($_POST, 'groupName', '');
         $parentId = Arr::get($_POST, 'parentId', '');
         $previousId = Arr::get($_POST, 'previousId', '');
         $res = $group->groupInsert($parentId, $previousId, array('name' => $groupName));
         if ($res) {
             Controller::redirect('admin/materials');
         } else {
             $data['errors'] = $group->getErrors();
         }
     }
     //Редактирование группы
     if (isset($_POST['save_group'])) {
         $groupName = Arr::get($_POST, 'groupName', '');
         $groupKeywords = Arr::get($_POST, 'groupKeywords', '');
         $groupDescription = Arr::get($_POST, 'groupDescription', '');
         $id = $this->request->param('id');
         $res = $group->groupUpdate($id, array('name' => $groupName, 'keywords' => $groupKeywords, 'description' => $groupDescription));
         if ($res) {
             Controller::redirect('admin/materials/' . $id);
         } else {
             $data['errors'] = $group->getErrors();
         }
     }
     //Добавление поля группы
     if (isset($_POST['add_field'])) {
         $groupId = $this->request->param('id');
         $paramTitle = Arr::get($_POST, 'field_title', '');
         $paramName = Arr::get($_POST, 'field_name', '');
         $paramType = Arr::get($_POST, 'field_type', '');
         $previousPos = Arr::get($_POST, 'previousPos', '0');
         $ordering = $previousPos + 1;
         $result = $group->addParam(array('gid' => $groupId, 'name' => $paramName, 'title' => $paramTitle, 'type' => $paramType, 'ordering' => $ordering));
         if (!$result) {
             $data['groupErrors'] = $group->getErrors();
         }
     }
     if (isset($_POST['change_group'])) {
         $oldGroup = Arr::get($_POST, 'old_group', '0');
         $newGroup = Arr::get($_POST, 'new_group', '0');
         $ids = Arr::get($_POST, 'check_name', NULL);
         $result = $group->changeGroup($oldGroup, $newGroup, $ids);
     }
     //Загрузка из Excell
     if (isset($_POST['load_xls'])) {
         $groupId = $this->request->param('id');
         $excel = new Model_Excel();
         $load = $excel->load_xls($_FILES, $groupId);
     }
     if (isset($_POST['delete_fields'])) {
         $groupId = $this->request->param('id');
         $paramId = Arr::get($_POST, 'pid', '');
         $result = $group->deleteParams($paramId);
     }
     //удаление отмеченных материалов
     if (isset($_POST['checked_del'])) {
         $gid = $this->request->param('id');
         $delArr = Arr::get($_POST, 'check_name', array());
         $group = new Model_Material('groups');
         foreach ($delArr as $del) {
             $group->deleteMaterial($del, $gid);
         }
     }
     //if(isset())
     $groupId = $this->request->param('id');
     $pageNum = str_replace('page', '', $this->request->param('page'));
     if ($groupId != NULL && $groupId != 'cart') {
         $data['thisGroup'] = $group->getGroup($groupId);
         $data['groupParams'] = $group->getParams($groupId);
         if (!$this->request->param('url')) {
             $q = Arr::get($_GET, 'q', '');
             $countMaterials = $group->getCountAdmMaterials($groupId, $q);
             $pagination = Pagination::factory(array('total_items' => $countMaterials));
             $pagination->current_page = $pageNum;
             if (isset($_GET['sort'])) {
                 $data['items'] = $group->getMaterials($groupId, $pagination->items_per_page, $pagination->offset, $q, array($_GET['sort']));
             } else {
                 $data['items'] = $group->getMaterials($groupId, $pagination->items_per_page, $pagination->offset, $q);
             }
         } else {
             if (isset($_POST['save_material'])) {
                 $res = $group->saveMaterial($_POST, $_FILES);
                 if ($res) {
                     Controller::redirect('admin/materials/' . $groupId);
                 } else {
                     $data['errors'] = $group->getErrors();
                 }
             }
             //Данные материала
             $materialId = $group->getMaterialIdByUrl($this->request->param('url'));
             $data['material'] = $group->getAdminMaterial($materialId);
             //комментарии
             $comments['data'] = $group->getComments($materialId, FALSE);
             //Поля
             $fieldset = array();
             $fields = $group->getFields2($data['material']['id']);
             foreach ($fields as $field) {
                 //генерируем код для каждого поля
                 //если поле - список выбора
                 if ($field['type'] == 'select') {
                     $values = $group->getSelectValues($field['id']);
                     $field['myValues'] = $values;
                 }
                 $fieldset[] = View::factory('admin/fields/' . $field['type'])->bind('data', $field)->render();
             }
             $data['fields'] = $fieldset;
         }
     } elseif ($groupId == 'cart') {
         $data['items'] = $group->getMaterials($groupId);
         $data['is_cart'] = TRUE;
     }
     $data['groups'] = $group->getTree();
     //
     $wpm['status'] = Cookie::get('wpm', FALSE);
     $wpm['folder'] = Cookie::get('wpm_folder', '');
     $folders = $this->getFolders();
     $pictures = $this->action_pictures($wpm['folder']);
     $comments['status'] = Cookie::get('comments', FALSE);
     $this->template->content = View::factory('admin/admMaterials', array('data' => $data, 'folders' => $folders, 'pictures' => $pictures, 'wpm' => $wpm, 'user' => $this->user, 'pagination' => $pagination));
     // $this->template->content = View::factory('admin/admMaterials', array('data'=> $data, 'user' => $this->user, 'pagination' => $pagination, 'comments' => $comments, 'pictures' => $pictures, 'wpm' => $wpm, ));
 }
예제 #5
0
파일: Excel.php 프로젝트: chernogolov/blank
 public function uploadFile($gid)
 {
     $material = new Model_Material('groups');
     $data = $material->getFullMaterials2($gid, 10000, 0);
     $phpexcel = new PHPExcel();
     // Создаём объект PHPExcel
     $page = $phpexcel->setActiveSheetIndex(0);
     // Делаем активной первую страницу и получаем её
     $letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ');
     $header = array('name' => 'Название');
     $fields = $material->getFieldsSet($gid);
     foreach ($fields as $field) {
         $header[$field['name']] = $field['title'];
     }
     $fields = $header;
     $header = array_values($fields);
     for ($i = 0; $i < count($header); ++$i) {
         $page->setCellValue($letters[$i] . "1", $header[$i]);
     }
     //echo '<pre>';
     $row = 2;
     foreach ($data as $item) {
         $col = 0;
         foreach ($fields as $key => $field) {
             if (isset($item[$key])) {
                 if (!is_array($item[$key])) {
                     $page->setCellValue($letters[$col] . $row, $item[$key]);
                 } else {
                     $str = '';
                     $s = 1;
                     foreach ($item[$key] as $val) {
                         $str .= Arr::get($val, 'value');
                         if ($s < count($item[$key])) {
                             $str .= ', ';
                         }
                         ++$s;
                     }
                     $page->setCellValue($letters[$col] . $row, $str);
                 }
             }
             ++$col;
         }
         ++$row;
     }
     //        echo '</pre>';
     $page->setTitle("Страница 1");
     // Заголовок делаем "Example"
     /* Начинаем готовиться к записи информации в xlsx-файл */
     $objWriter = PHPExcel_IOFactory::createWriter($phpexcel, 'Excel2007');
     /* Записываем в файл */
     $group = $material->getGroup($gid);
     $base = new Model_Base();
     $filename = $group['id'] . '_' . $base->str2url(Text::limit_chars($group['name'], 20)) . '_' . date("Y.m.d H-i-s");
     $objWriter->save(DOCROOT . "/img/user/export/" . $filename . ".xlsx");
     return array('Файл ' . $filename . ' успешно создан в директории <a href="/admin/files/export">/export/</a>');
 }
예제 #6
0
 public function action_index($options = array("catalog_id" => 4, "items_position_type" => "half"))
 {
     $this->setopt(array("name" => "catalog_id", "description" => "Ид каталога", "default" => $options["catalog_id"]));
     $this->setopt(array("name" => "items_position_type", "description" => "Способ отображения item'ов", "default" => $options["items_position_type"]));
     // --- tests ---------------------------------------------------------------
     $model_module = new Model_Module();
     $module = $model_module->get_module(176);
     $module->get_options();
     //$module->test(1382);
     $module->set(array("action" => "index"));
     // --- /tests --------------------------------------------------------------
     $model = array();
     $qdata = array();
     $param_array = array();
     $materials = new Model_Material('groups');
     $config = Kohana::$config->load('main')->site;
     $pageNum = intval(Arr::get($_GET, 'page', 0));
     $param = $this->getopt("catalog_id");
     //$param = $this->request->param('id');
     //PC::debug($pageNum);
     $params = explode('/', $param);
     $gid = $params[0];
     foreach ($params as $paramName) {
         if (preg_match("/page(\\d)/", $paramName)) {
             $pageNum = str_replace('page', '', $paramName);
         }
     }
     $template = $this->request->param('template');
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     //search for template
     $widget = new Model_Widget();
     $widgetData = $this->widget_data;
     if ($widgetData['template']) {
         $this->template = View::factory('widgets/' . $widgetData['template']);
     }
     $query = Arr::get($widgetData, 'query');
     if ($query != '') {
         $queries = explode('&', $query);
         foreach ($queries as $q) {
             $rr = explode('=', $q);
             if (!isset($param_array[$rr[0]])) {
                 $qdata[$rr[0]][] = $rr[1];
             }
         }
     }
     //counters
     $group = $materials->getGroup($gid);
     $material_count = $group['materials'];
     $search_string = Arr::get($param_array, 'art', NULL);
     //проверяем кодировку
     $res = mb_detect_encoding($search_string, array('UTF-8', 'Windows-1251'));
     if ($res != 'UTF-8') {
         $search_string = iconv($res, 'UTF-8', $search_string);
     }
     if (isset($param_array['go'])) {
         unset($param_array['go']);
     }
     if (isset($param_array['price'])) {
         $pricer = explode(';', $param_array['price']);
         $qdata['price_from'] = intval(Arr::get($pricer, 0) * 1000);
         $qdata['price_to'] = intval(Arr::get($pricer, 1) * 1000);
         unset($param_array['price']);
     }
     if (isset($param_array['sort'])) {
         $qdata['sort'] = addslashes($param_array['sort']);
     }
     $qparams = array_keys($param_array);
     //получаем доступные параметры
     $params = $materials->getFieldsSet($gid);
     foreach ($params as $param) {
         if ($param['for_filters'] == 1) {
             if (in_array($param['name'], $qparams)) {
                 switch ($param['type']) {
                     case 'select':
                         if (is_array($param_array[$param['name']])) {
                             $selvalues = $materials->getSelectValues($param['id']);
                             $vals = array_values($param_array[$param['name']]);
                             foreach ($selvalues as $value) {
                                 if (in_array($value->value, $vals)) {
                                     $qdata[$param['name']][] = $value->value;
                                 }
                             }
                         }
                         break;
                     case 'price':
                         $arr = explode(';', $param_array[$param['name']]);
                         $qdata[$param['name'] . '_from'] = intval(Arr::get($arr, 0));
                         $qdata[$param['name'] . '_to'] = intval(Arr::get($arr, 1));
                         break;
                     case 'chars':
                         $qdata[$param['name']] = addslashes($param_array[$param['name']]);
                         break;
                 }
             }
         }
     }
     //получаем данные для сортировки
     //$this->template->searchtext = $search_string;
     //$this->template->search_params = $param_array;
     // Сколько найдено материалов?
     $material_count = $materials->getCountFullMaterials2($gid, $search_string, $qdata);
     // Номер текущей страницы
     $current_page = 1;
     if (isset($_GET["page"])) {
         //if ($_GET["page"] !== 0)
         $current_page = $_GET["page"];
     }
     // Вывод всех материалов на одной странице
     $model["limit"]["text"] = "Показать все на странице";
     $model["limit"]["href"] = URL::query(array("limit" => false, "page" => 1));
     $material_limit = 24;
     if (isset($_GET["limit"])) {
         if (!$_GET["limit"]) {
             $model["limit"]["text"] = "Постраничное разделение";
             $model["limit"]["href"] = URL::query(array("limit" => true));
             $material_limit = $material_count;
             //$current_page = 1;
         }
     } else {
         $material_limit = 24;
         // Материалов на странице
     }
     $max_page = ceil($material_count / $material_limit);
     // Максимальная страница
     $material_offset = $material_limit * ($current_page - 1);
     // Смещение материалов
     // страница существует
     if ($current_page <= $max_page) {
         $items = $materials->getFullMaterials2($gid, $material_limit, $material_offset, $search_string, $qdata);
     } else {
         $items = [];
     }
     // Хлебные крошки
     $this->load_module("breadcrumb", "/widgets/Breadcrumb/index");
     // --- Выбор способа отображения item'ов ---------------------------------------------------
     $model["items_position_type"] = Arr::get($_COOKIE, "items_position_type", $this->getopt("items_position_type"));
     $this->load_module("item_position", "/widgets/ItemPosition/index");
     // --- /Выбор способа отображения item'ов ---------------------------------------------------
     // --- Пагинация --------------------------------------------------------------------------
     $this->load_module("pagination", "/widgets/Pagination/index", array("current" => $current_page, "max" => $max_page, "count" => 5));
     // --- /Пагинация -------------------------------------------------------------------------
     // Для корзины
     echo '<script>var items = JSON.parse(\'' . json_encode($items) . '\');</script>';
     $model["items"] = $items;
     // Кол-во найденых материалов
     $model["material_count"] = $material_count;
     // Изменение модели
     foreach ($model["items"] as $item_id => $item) {
         $new_model = array();
         // id материала
         $new_model["id"] = $item_id;
         // Формат цены
         $new_model["price"] = number_format($item["price"], 0, '', ' ');
         // Формат старой цены
         if (isset($item['old_price'])) {
             $new_model["old_price"] = number_format($item["old_price"], 0, '', ' ');
         }
         // Изображение
         if (isset($item['photos'][0])) {
             $new_model["photo"] = Route::url('miniimg3', array('filename' => $item['photos'][0]['value']));
         } else {
             $new_model["photo"] = Route::url('miniimg3', array('filename' => '/img/noimg.png'));
         }
         // Акция
         if (isset($item["stock"])) {
             $new_model["stock"] = " " . $item["stock"][0]["value"];
         }
         //$new_model["stock"] = "new"; //test
         // Ссылка на материал
         $new_model["href"] = "/" . $item["node"] . $item["url"] . ".html";
         // --- Обрезаем длинные поля --------------------------------------------------------
         // Название
         $new_model["name"] = $item["name"];
         if (strlen($item["name"]) > 80) {
             $new_model["name"] = Text::limit_chars($item["name"], 77);
         }
         // Описание
         $new_model["description"] = $item["description"];
         if (strlen($item["description"]) > 80) {
             $new_model["description"] = Text::limit_chars($item["description"], 77);
         }
         // --- /Обрезаем длинные поля -------------------------------------------------------
         $model["items"][$item_id] = array_merge($model["items"][$item_id], $new_model);
     }
     if ($material_count == 0) {
         $Menu = new Controller_Widgets_Menu($this->request, $this->response);
         $Menu->action_graph(array("parent_id" => Arr::get($GLOBALS, 'categoryId')));
         $this->body($Menu->get_body());
         /*$this->load_module("graph_menu", "/widgets/Graph_Menu/index", array(
         			"parent_id" => Arr::get($GLOBALS, 'categoryId'),
         		));*/
     } else {
         $this->set_template("/widgets/w_catalog.php", "twig")->render($model)->body();
     }
 }