Inheritance: extends Kohana_Kostache_Layout
コード例 #1
0
ファイル: 404.php プロジェクト: bosoy83/progtest
 public function __construct()
 {
     parent::__construct();
     // Регистрируем крошки
     $path[0]['title'] = 'Страница не найдена';
     $this->breadcrumbs = $this->prepare_table($path, 1);
 }
コード例 #2
0
ファイル: feedback.php プロジェクト: bosoy83/progtest
 public function __construct($template = NULL, array $partials = NULL)
 {
     parent::__construct($template, $partials);
     // Подключаем библиотеку PHPMailer
     require 'packages/PhpMailer/class.phpmailer.php';
     // Получаем параметры модуля
     $this->fos_email = $this->get_variable('fos_email');
 }
コード例 #3
0
ファイル: content.php プロジェクト: bosoy83/progtest
 public function __construct()
 {
     // Родительский конструктор
     parent::__construct();
     $sub_menu_arr = array();
     // Выбираем текущую секцию из базы
     $this->cur_content = Sprig::factory('content', array('url' => $this->page))->load();
     // Выкидываем 404 ошибку
     if (empty($this->cur_content->id)) {
         throw new HTTP_Exception_404('Раздел отсутствует');
     }
     // Определяем ID текущей категории, родительской и корневой
     $this->cur_content_id = $this->cur_content->id;
     $this->parent_id = $this->cur_content->parent->id;
     $this->root_id = Sprig::factory('content')->root(1)->id;
     // Формируем тайтлы и мета-тэги
     $this->title = $this->cur_content->meta_title;
     $this->description = $this->cur_content->meta_description;
     $this->keywords = $this->cur_content->meta_keywords;
     // Хлебные крошки
     $path = $this->select_path($this->cur_content_id);
     // Регистрируем хлебные крошки
     $this->breadcrumbs = $this->prepare_table($path, 1);
     // Находим в содержимом страницы вызовы других модулей
     if (preg_match_all('!\\[include module:([^:]+)(?:::(.+))?\\]!i', $this->cur_content->content, $modules_include_arr)) {
         // Метка, что на странице будет форма подачи заявки
         $this->is_service = TRUE;
         // Проходим по всем найденным подключенным модулям
         for ($i = 0; $i < count($modules_include_arr[1]); $i++) {
             // Создаем объект модуля
             $module = Sprig::factory('module', array('name' => $modules_include_arr[1][$i]))->load();
             if ($module->loaded()) {
                 // Костыль. Узнаем раздел с формой обратной связи
                 if ($module->mid == 5) {
                     $this->is_feedback = TRUE;
                 }
                 // Формируем имя представления, генерируем вывод и вставляем на страницу
                 $view_name = 'View_' . $modules_include_arr[1][$i] . '_' . (!empty($modules_include_arr[2][$i]) ? $modules_include_arr[2][$i] : 'index');
                 $view = new $view_name();
                 $this->cur_content->content = str_replace($modules_include_arr[0][$i], $view->render(), $this->cur_content->content);
             } else {
                 $this->cur_content->content = str_replace($modules_include_arr[0][$i], sprintf($this->include_unknow_module, $modules_include_arr[1][$i]), $this->cur_content->content);
             }
         }
     }
     // Регистрируем крошки
     $path[0]['title'] = $this->cur_content->name;
     $path[0]['url'] = '/content/' . $this->cur_content->url;
     // Для второго уровня вложенности показываем крошки
     if ($this->cur_content->lvl > 1) {
         $path[0]['title'] = $this->cur_content->parent->name;
         $path[0]['url'] = '/content/' . $this->cur_content->parent->url;
         $path[1]['title'] = $this->cur_content->name;
     }
     $this->breadcrumbs = $this->prepare_table($path, 1);
 }
コード例 #4
0
ファイル: email.php プロジェクト: rpa-design/kohana-email
 public function create_html_template()
 {
     // get the html email template
     $this->html_template = View_Layout::factory($this->htmlview_path);
     $this->html_template->set_layout($this->layout);
     // set textview params to template
     if (count($this->htmlview_params) > 0) {
         foreach ($this->htmlview_params as $key => $htmlview_param) {
             $this->html_template->set($key, $htmlview_param);
         }
     }
 }
コード例 #5
0
ファイル: index.php プロジェクト: bosoy83/progtest
 public function __construct()
 {
     parent::__construct();
     // Выбираем горячие предложения из всех 4 каталогов
     // country
     $hot_countryO = Sprig::factory('catalog')->load(DB::select('*')->where('scope', '=', 1)->where('status', '=', 1)->where('hot_status', '=', 1)->order_by(NULL, 'RAND()'), NULL);
     for ($i = 0; $i < count($hot_countryO); $i++) {
         $this->hot_country[$i] = $hot_countryO[$i]->as_array();
         $this->hot_country_exists = TRUE;
         if ($i > 2) {
             $this->hot_country_over3 = TRUE;
         }
     }
     // city
     $hot_cityO = Sprig::factory('catalog')->load(DB::select('*')->where('scope', '=', 2)->where('status', '=', 1)->where('hot_status', '=', 1)->order_by(NULL, 'RAND()'), NULL);
     for ($i = 0; $i < count($hot_cityO); $i++) {
         $this->hot_city[$i] = $hot_cityO[$i]->as_array();
         $this->hot_city_exists = TRUE;
         if ($i > 2) {
             $this->hot_city_over3 = TRUE;
         }
     }
     // commercial
     $hot_commercialO = Sprig::factory('catalog')->load(DB::select('*')->where('scope', '=', 3)->where('status', '=', 1)->where('hot_status', '=', 1)->order_by(NULL, 'RAND()'), NULL);
     for ($i = 0; $i < count($hot_commercialO); $i++) {
         $this->hot_commercial[$i] = $hot_commercialO[$i]->as_array();
         $this->hot_commercial_exists = TRUE;
         if ($i > 2) {
             $this->hot_commercial_over3 = TRUE;
         }
     }
     // bisuness
     $hot_businessO = Sprig::factory('catalog')->load(DB::select('*')->where('scope', '=', 4)->where('status', '=', 1)->where('hot_status', '=', 1)->order_by(NULL, 'RAND()'), 1);
     $hot_business = $hot_businessO->as_array();
     if (!empty($hot_business['id'])) {
         $this->hot_business = $hot_business;
     }
     // Вытаскиваем мета-тэги и контент из страницы с вербальным путем index (пока как-то так)
     $this->index_page = Sprig::factory('content', array('url' => 'index'))->load();
     $this->index_text = $this->index_page->content;
     // Регистрируем мета-тэги
     $this->title = $this->index_page->meta_title;
     $this->description = $this->index_page->meta_description;
     $this->keywords = $this->index_page->meta_keywords;
 }
コード例 #6
0
ファイル: index.php プロジェクト: bosoy83/progtest
 public function __construct($template)
 {
     $this->_layout = $template;
     $this->domen = $_SERVER['HTTP_HOST'];
     parent::__construct($template);
 }
コード例 #7
0
ファイル: index.php プロジェクト: bosoy83/progtest
 public function __construct($template = NULL, array $partials = NULL, $alien_call = false)
 {
     parent::__construct($template, $partials, $alien_call);
 }
コード例 #8
0
ファイル: index.php プロジェクト: bosoy83/progtest
 public function __construct($template = NULL, array $partials = NULL, $alien_call = FALSE)
 {
     // Категория и страница для каталога
     $this->cat_id = Request::current()->param('cat_id');
     $this->page = Request::current()->param('page');
     $this->page = !empty($this->page) ? $this->page : 1;
     // Фильтры
     $this->city = Request::current()->param('city');
     $this->rooms = Request::current()->param('rooms');
     $this->floor_compare = Request::current()->param('floor_compare');
     $this->floor = Request::current()->param('floor');
     $this->floors_1 = Request::current()->param('floors_1');
     $this->floors_2 = Request::current()->param('floors_2');
     $this->price_1 = Request::current()->param('price_1');
     $this->price_2 = Request::current()->param('price_2');
     $this->square_1 = Request::current()->param('square_1');
     $this->square_2 = Request::current()->param('square_2');
     // Регистрируем метку, что включен фильтр
     if (!empty($this->city) or !empty($this->rooms) or !empty($this->floor) or !empty($this->floors_1) or !empty($this->floors_2) or !empty($this->price_1) or !empty($this->price_2) or !empty($this->square_1) or !empty($this->square_2)) {
         $this->filter_works = TRUE;
     }
     // Создаем объект текущей категории (товара)
     $this->cur_category = Sprig::factory('catalog', array('id' => $this->cat_id))->load();
     // Создаем метку о текущем типе недвижимости
     if (!empty($this->scope_types_arr[$this->cur_category->scope])) {
         $this->{$this->scope_types_arr[$this->cur_category->scope]} = TRUE;
     }
     // Выкидываем 404 ошибку
     if (!empty($this->cat_id) and !$this->cur_category->loaded()) {
         throw new HTTP_Exception_404('Раздел каталога отсутствует');
     }
     // Получаем всех родителей категории
     $this->parent = $this->cur_category->parent;
     $this->grandparent = $this->parent->parent;
     $this->parents = $this->cur_category->parents;
     $count_perants = count($this->parents);
     $lvl_var = 'lvl' . $count_perants;
     $this->{$lvl_var} = TRUE;
     // Если мы не в разделе готового бизнеса - определяем табы фильтров
     if ($this->cur_category->scope != 4) {
         // Если мы в подкатегории недвижимости, берем на уровень выше
         $category_root = $this->cur_category->lvl == 1 ? $this->parent : $this->cur_category;
         $query_filter = DB::select('*')->where('scope', '=', $category_root->scope)->where('status', '=', 1)->where('lvl', '!=', 2)->where('lft', '>=', $category_root->lft)->where('rgt', '<=', $category_root->rgt)->order_by('lvl', 'ASC')->order_by('ord', 'ASC');
         $filtersO = Sprig::factory('catalog')->load($query_filter, NULL);
         // Массивы для уникальных значений
         $rooms = $cities = array();
         for ($i = 0; $i < count($filtersO); $i++) {
             $this->filters_tabs[$i] = $filtersO[$i]->as_array();
             $this->filters_tabs[$i]['rooms'] = array();
             $this->filters_tabs[$i]['cities'] = array();
             $this->filters_tabs[$i]['floor_compare'] = $this->floor_compare_arr;
             // Если это таб Все
             if ($filtersO[$i]->id == $category_root->id) {
                 $this->filters_tabs[$i]['name'] = 'Все';
                 $this->filters_tabs[$i]['active'] = TRUE;
             }
             // Добавляем активности
             if ($filtersO[$i]->id == $this->cat_id) {
                 $this->filters_tabs[0]['active'] = FALSE;
                 $this->filters_tabs[$i]['active'] = TRUE;
                 // Уже выбранные фильтры
                 if (!empty($this->price_1)) {
                     $this->filters_tabs[$i]['def_filters']['price_1'] = $this->price_1;
                 }
                 if (!empty($this->price_2)) {
                     $this->filters_tabs[$i]['def_filters']['price_2'] = $this->price_2;
                 }
                 if (!empty($this->square_1)) {
                     $this->filters_tabs[$i]['def_filters']['square_1'] = $this->square_1;
                 }
                 if (!empty($this->square_2)) {
                     $this->filters_tabs[$i]['def_filters']['square_2'] = $this->square_2;
                 }
                 if (!empty($this->floors_1)) {
                     $this->filters_tabs[$i]['def_filters']['floors_1'] = $this->floors_1;
                 }
                 if (!empty($this->floors_2)) {
                     $this->filters_tabs[$i]['def_filters']['floors_2'] = $this->floors_2;
                 }
                 if (!empty($this->floor)) {
                     $this->filters_tabs[$i]['def_filters']['floor'] = $this->floor;
                 }
                 if (!empty($this->floor_compare)) {
                     $this->filters_tabs[$i]['floor_compare'][$this->floor_compare - 1]['active'] = 1;
                 }
             }
             // Выбираем мин. и максимальную цену
             $query_price_min = DB::select(DB::expr('MIN(price) as min_price'))->from('catalog')->where('scope', '=', $category_root->scope)->where('status', '=', 1)->where('lvl', '=', 2)->where('lft', '>', $filtersO[$i]->lft)->where('rgt', '<', $filtersO[$i]->rgt);
             $result_price_min = $query_price_min->execute();
             $this->filters_tabs[$i]['min_price'] = !empty($result_price_min[0]) ? $result_price_min[0]['min_price'] : $this->price_min;
             if (empty($this->filters_tabs[$i]['min_price'])) {
                 $this->filters_tabs[$i]['min_price'] = 1;
             }
             $query_price_max = DB::select(DB::expr('MAX(price) as max_price'))->from('catalog')->where('scope', '=', $category_root->scope)->where('status', '=', 1)->where('lvl', '=', 2)->where('lft', '>', $filtersO[$i]->lft)->where('rgt', '<', $filtersO[$i]->rgt);
             $result_price_max = $query_price_max->execute();
             $this->filters_tabs[$i]['max_price'] = !empty($result_price_max[0]) ? $result_price_max[0]['max_price'] : $this->price_max;
             if ($this->filters_tabs[$i]['min_price'] == $this->filters_tabs[$i]['max_price'] + 1) {
                 $this->filters_tabs[$i]['max_price'] += 1000;
             }
             // Комнаты и Города добавляем только для дочерных категорий
             // Для категории Все заполняем в последующем из дочерних
             if ($filtersO[$i]->id != $category_root->id) {
                 // Выбираем возможное количество комнат
                 $query_rooms = DB::select(DB::expr('DISTINCT rooms'))->from('catalog')->where('scope', '=', $category_root->scope)->where('status', '=', 1)->where('lvl', '=', 2)->where('lft', '>', $filtersO[$i]->lft)->where('rgt', '<', $filtersO[$i]->rgt)->order_by('rooms', 'ASC');
                 $result_rooms = $query_rooms->execute();
                 for ($r = 0; $r < count($result_rooms); $r++) {
                     $room = $result_rooms[$r]['rooms'];
                     if (empty($room)) {
                         continue;
                     }
                     $active = 0;
                     if ($filtersO[$i]->id == $this->cat_id and $this->rooms == $room) {
                         $active = 1;
                     }
                     $this->filters_tabs[$i]['rooms'][] = array('room' => $room, 'active' => $active);
                     if (empty($rooms[$room])) {
                         $active = 0;
                         if ($category_root->id == $this->cat_id and $this->rooms == $room) {
                             $active = 1;
                         }
                         $this->filters_tabs[0]['rooms'][] = array('room' => $room, 'active' => $active);
                     }
                     $rooms[$room] = 1;
                 }
                 // Выбираем возможное количество комнат
                 $query_cities = DB::select(DB::expr('DISTINCT city'))->from('catalog')->where('scope', '=', $category_root->scope)->where('status', '=', 1)->where('lvl', '=', 2)->where('lft', '>', $filtersO[$i]->lft)->where('rgt', '<', $filtersO[$i]->rgt)->order_by('city', 'ASC');
                 $result_cities = $query_cities->execute();
                 $city_decode = base64_decode($this->city);
                 for ($r = 0; $r < count($result_cities); $r++) {
                     $city = $result_cities[$r]['city'];
                     if (empty($city)) {
                         continue;
                     }
                     $active = 0;
                     if ($filtersO[$i]->id == $this->cat_id and $city_decode == $city) {
                         $active = 1;
                     }
                     $this->filters_tabs[$i]['cities'][] = array('city' => $city, 'active' => $active);
                     if (empty($cities[$city])) {
                         $active = 0;
                         if ($category_root->id == $this->cat_id and $this->rooms == $room) {
                             $active = 1;
                         }
                         $this->filters_tabs[0]['cities'][] = array('city' => $city, 'active' => $active);
                     }
                     $cities[$city] = 1;
                 }
             }
         }
         //            print_r($this->filters_tabs);
         //            exit;
     }
     // Уровень, на котором разсположены объекты
     $object_lvl = 2;
     // Для раздела Готовый бизнес этот уровень меньше не единицу
     if ($this->cur_category->scope == 4) {
         $object_lvl = 1;
     }
     // Запрос на выборку нужных объектов
     $query_products = DB::select('*')->where('scope', '=', $this->cur_category->scope)->where('status', '=', 1)->where('lvl', '=', $object_lvl)->where('lft', '>', $this->cur_category->lft)->where('rgt', '<', $this->cur_category->rgt)->order_by('ord', 'ASC');
     // Узнаем ID страницы каталога в структуре контента
     $this->catalog_page_structure = Sprig::factory('content', array('url' => 'catalog/' . $this->cur_category->scope))->load();
     // Регистрируем мета-тэги и текст на странице категории
     if (!empty($this->lvl0)) {
         $this->title = $this->catalog_page_structure->meta_title;
         $this->description = $this->catalog_page_structure->meta_description;
         $this->keywords = $this->catalog_page_structure->meta_keywords;
         $this->content = $this->catalog_page_structure->content;
     } else {
         $this->title = $this->cur_category->meta_title;
         $this->description = $this->cur_category->meta_description;
         $this->keywords = $this->cur_category->meta_keywords;
         $this->content = $this->cur_category->content;
     }
     // Хлебные крошки
     for ($i = 0; $i < count($this->parents); $i++) {
         if (empty($i)) {
             $path[0]['title'] = $this->catalog_page_structure->name;
             $path[0]['url'] = $this->catalog_page_structure->url;
         } else {
             $path[$i]['title'] = $this->parents[$i]->name;
             $path[$i]['url'] = 'catalog/' . $this->parents[$i]->id;
         }
     }
     $path[$i]['title'] = $this->cur_category->name;
     // Регистрируем хлебные крошки
     $this->breadcrumbs = $this->prepare_table($path, 1);
     // Если объект создается сторонним приложением для использования
     // определенных функция - конструктор надо освободить от выполнения
     // лишних операций
     if (!empty($alien_call)) {
         parent::__construct();
         return;
     }
     // Добавляем фильтры
     if (!empty($this->city)) {
         $query_products = $query_products->where('city', '=', base64_decode($this->city));
     }
     if (!empty($this->rooms)) {
         $query_products = $query_products->where('rooms', '=', $this->rooms);
     }
     if (!empty($this->floor) and !empty($this->floor_compare)) {
         switch ($this->floor_compare) {
             case 1:
                 $compare = '<=';
                 break;
             case 2:
                 $compare = '>=';
                 break;
             default:
                 $compare = '=';
         }
         $query_products = $query_products->where('floor', $compare, $this->floor);
     }
     if (!empty($this->floors_1)) {
         $query_products = $query_products->where('floors', '>=', $this->floors_1);
     }
     if (!empty($this->floors_2)) {
         $query_products = $query_products->where('floors', '<=', $this->floors_2);
     }
     if (!empty($this->price_1)) {
         $query_products = $query_products->where('price', '>=', $this->price_1);
     }
     if (!empty($this->price_2)) {
         $query_products = $query_products->where('price', '<=', $this->price_2);
     }
     if (!empty($this->square_1)) {
         $query_products = $query_products->where('square', '>=', $this->square_1);
     }
     if (!empty($this->square_2)) {
         $query_products = $query_products->where('square', '<=', $this->square_2);
     }
     // Добавляем назначенные фильтры
     // Создаем объект пагинатора с нужными парметрами
     $pagination = Pagination::factory(array('total_items' => $this->get_products_count($query_products), 'current_page' => array('source' => 'route', 'key' => 'page'), 'items_per_page' => $this->count_per_page, 'auto_hide' => true, 'view' => 'pagination/catalog'));
     $this->page_links = $pagination->render();
     // Высчитываем смещение для пагинации
     $offset = $this->count_per_page * ($this->page - 1);
     $query_products = $query_products->limit($this->count_per_page)->offset($offset);
     $productsO = Sprig::factory('catalog')->load($query_products, NULL);
     // Проходим по всем товарам на странице и формируем конечный массив
     for ($i = 0; $i < count($productsO); $i++) {
         $this->products[$i] = $productsO[$i]->as_array();
     }
     parent::__construct();
 }
コード例 #9
0
ファイル: card.php プロジェクト: vendo/billing
 /**
  * Var method overriding years() to pre-select a year
  *
  * @return array
  */
 public function months($month = NULL)
 {
     return parent::months(isset($this->credit_card) ? $this->credit_card->month : NULL);
 }