public function __construct($template = NULL, array $partials = NULL) { parent::__construct($template, $partials); // Если есть POST данные - обновляем настройки if (!empty($_POST)) { $this->message_data = $this->update_settings($_POST); } // Загружаем настройки $this->catalog_content = $this->get_variable('catalog_content'); $this->catalog_meta_title = $this->get_variable('catalog_meta_title'); $this->catalog_meta_keywords = $this->get_variable('catalog_meta_keywords'); $this->catalog_meta_description = $this->get_variable('catalog_meta_description'); // Если настройик в системе нет - добавляем со значением по умолчанию if (empty($this->catalog_content)) { $this->catalog_content = $this->set_variable('catalog_content', 'Описание в каталоге', NULL, 0); } if (empty($this->catalog_meta_title)) { $this->catalog_meta_title = $this->set_variable('catalog_meta_title', 'Meta-title в каталоге', NULL, 0); } if (empty($this->catalog_meta_keywords)) { $this->catalog_meta_keywords = $this->set_variable('catalog_meta_keywords', 'Meta-keywords в каталоге', NULL, 0); } if (empty($this->catalog_meta_description)) { $this->catalog_meta_description = $this->set_variable('catalog_meta_description', 'Meta-description в каталоге', NULL, 0); } // Замены мнемоника пустого поля на пустое поле :) if ($this->catalog_content == 'empty') { $this->catalog_content = ''; } if ($this->catalog_meta_title == 'empty') { $this->catalog_meta_title = ''; } if ($this->catalog_meta_keywords == 'empty') { $this->catalog_meta_keywords = ''; } if ($this->catalog_meta_description == 'empty') { $this->catalog_meta_description = ''; } }
public function __construct($template = NULL, array $partials = NULL) { parent::__construct($template, $partials); // Подключаем библиотку WideImage require_once 'packages/wideimage/WideImage.php'; // Если был сабмит админ.формы - узнаем действие и вызываем нужный метод if (!empty($_POST['action']) and !empty($_POST['ord'])) { switch ($_POST['action']) { case 'status': $this->message_data = $this->update_status($_POST['work_id'], $_POST['status'][$_POST['work_id']]); break; case 'order': $this->message_data = $this->update_ord($_POST['ord']); break; case 'delete': $this->message_data = $this->delete($_POST['work_id']); break; case 'create_category': $this->message_data = $this->create_category($_POST); break; case 'update_category': $this->message_data = $this->update_category($_POST); break; case 'create_object': case 'update_object': $this->message_data = $this->create_object($_POST, $_FILES); } } unset($_POST); // Создаем объект текущей категории $this->cur_category = Sprig::factory('catalog', array('id' => $this->id))->load(); // Создаем метку о текущем типе недвижимости if (!empty($this->scope_types_arr[$this->cur_category->scope])) { $this->{$this->scope_types_arr[$this->cur_category->scope]} = TRUE; } // Получаем всех родителей категории $parents = $this->cur_category->parents; // Если мы находимся в создании или редактировании категории // Для корректого определения УВ, в качестве текущей // категории используем родительскую $count_perants = count($parents); $lvl_var = 'lvl' . $count_perants; $this->{$lvl_var} = TRUE; // Узнаем, что мы добавляем в текущей категории - объекты или категории if (!empty($this->is_business)) { $this->is_object = TRUE; } else { if (!empty($this->lvl1)) { $this->is_object = TRUE; } else { $this->is_category = TRUE; } } if (!$parents[0]) { $this->root = $this->cur_category; } else { $this->root = Sprig::factory('catalog', array('id' => $parents[0]->id))->load(); } $this->title = sprintf($this->title, $this->root->name); // Получение родителя и прародителя $this->parent = $this->cur_category->parent; $this->grand_parent = $this->parent->parent; // Получение разделов-детей $this->childrens = $this->cur_category->children(); // Получаем количество детей $this->children_count = count($this->childrens); // Проходимся по всем детям for ($i = 0; $i < $this->children_count; $i++) { $this->childrens_arr[$i] = $this->childrens[$i]->as_array(); } // Сортируем массив дочерних категорий usort($this->childrens_arr, array('View_Layout', 'sort_func_ord_arr')); // Если текущая категория не равна корневой - получаем детей корневой директории if ($this->cur_category->id != $this->root->id) { $this->childrens_root = $this->root->children->as_array(); // Сортируем массив дочерних категорий usort($this->childrens_root, array('View_Layout', 'sort_func_ord')); } }