Пример #1
0
 public function action_index()
 {
     $base = new Model_Base();
     $pageNum = 0;
     $param = $this->request->param('id');
     $filters = $base->safeArrAssoc($_GET);
     $params = explode('/', $param);
     $gid = $params[0];
     foreach ($params as $paramName) {
         if (preg_match("/page(\\d)/", $paramName)) {
             $pageNum = str_replace('page', '', $paramName);
         }
     }
     $marker = array_pop($params);
     $catalog = new Model_Material('groups');
     //смотрим шаблон для виджета
     $widget = new Model_Widget();
     $template = $widget->getTempalte('catalog2', $gid);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     // $categoryName = $catalog->getCategoryNameByCatalog();
     //получить содержимое папки
     // $count = $catalog->getCountMaterials($param);
     $count = $catalog->getCountMaterials($gid);
     $pagination = Pagination::factory(array('total_items' => $count));
     $pagination->current_page = $pageNum;
     $data = $catalog->getFullMaterials($gid);
     $this->template->data = $data;
     $this->template->pagination = $pagination;
 }
Пример #2
0
 public function action_index()
 {
     $parentId = $this->request->param('id');
     $tree = new Model_Widgets_Menu('tree');
     //смотрим шаблон для виджета
     $widget = new Model_Widget();
     $template = $widget->getTempalte('menu', $parentId);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     //Получаем список меню
     $items = $tree->menuItems($parentId);
     if (isset($_GET['del_mid'])) {
         if (Cookie::get('userId')) {
             $userId = Cookie::get('userId');
             $cart = new Model_Widgets_Cart();
             $cart->delFromCart($userId, $_GET['del_mid']);
         }
     }
     if (Cookie::get('userId')) {
         $userId = Cookie::get('userId');
         $cart = new Model_Widgets_Cart();
         $cartCount = $cart->getCartCount($userId);
         $cartPrice = $cart->getCartPrice($userId);
         $cartData = "<h5>В корзине: <font> " . $cartCount . " </font> товаров</h5>\n            <h5>на сумму:&nbsp;&nbsp; <font> " . $cartPrice . " </font> рублей</h5>";
     } else {
         $cartData = '<h5>Ваша корзина пуста</h5>';
     }
     $this->template->cartData = $cartData;
     $this->template->menu = $items;
 }
Пример #3
0
 public function action_index()
 {
     echo "fsfsff";
     $parentId = $this->request->param('id');
     $tree = new Model_Widgets_Menu('tree');
     //смотрим шаблон для виджета
     $widget = new Model_Widget();
     $template = $widget->getTempalte('menu2', $parentId);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     //Получаем список меню
     $items = $tree->menuItems($parentId);
     $this->template->menu = $items;
 }
Пример #4
0
 public function action_index()
 {
     $materialId = $this->request->param('id');
     $materials = new Model_Material('groups');
     //get widget template
     $widget = new Model_Widget();
     $template = $widget->getTempalte('files', $materialId);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     //get data
     $data = $materials->getMaterial($materialId);
     $fields = $materials->getFields2($materialId, TRUE);
     $this->template->material = $data;
     $this->template->fields = $fields;
 }
Пример #5
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;
 }
Пример #6
0
 public function action_index()
 {
     $materials = new Model_Material('group');
     $gid = $this->request->param('id');
     $template = $this->request->param('template');
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     //смотрим шаблон для виджета
     $widget = new Model_Widget();
     $template = $widget->getTempalte('top', $gid);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     $data = $materials->getRandomMaterials($gid, 4, time());
     $this->template->data = $data;
 }
Пример #7
0
 public function action_index()
 {
     $errors = array();
     $materialId = $this->request->param('id');
     $materials = new Model_Material('group');
     //смотрим шаблон для виджета
     $widget = new Model_Widget();
     $template = $widget->getTempalte('polls', $materialId);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     $name = 'polls_' . $materialId;
     $voted = FALSE;
     //Cookie::delete($name);
     if (Cookie::get($name)) {
         $voted = TRUE;
     } else {
         if (isset($_POST['save_polls'])) {
             $polls = new Model_Polls();
             //сохраняем результаты голосования
             $result = $polls->vote($_POST['save_polls'], $_POST['answer']);
             if ($result) {
                 //создаем куки по данному опросу
                 if (!Cookie::set($name, 'voted', Date::YEAR)) {
                     $errors[] = 'Вероятно в Вашем браузере отключены Cookie.';
                 } else {
                     $voted = TRUE;
                 }
             }
         }
     }
     $data = $materials->getMaterial($materialId);
     $fields = $materials->getFields2($materialId, TRUE);
     $fields2 = $materials->getFields2($materialId, FALSE);
     $this->template->data = $data;
     $this->template->fields = $fields;
     $this->template->fields2 = $fields2;
     $this->template->voted = $voted;
     //Получаем список меню
 }
Пример #8
0
 public function action_index()
 {
     //смотрим шаблон для виджета
     $id = $this->request->param('id');
     $widget = new Model_Widget();
     $template = $widget->getTempalte('callback', $id);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     if (isset($_POST['callback-order'])) {
         if (Captcha::valid(Arr::get($_POST, 'comm-captcha'))) {
             $base = new Model_Base();
             $options = $base->getOptions();
             $vData = $_POST;
             $validation = Validation::factory($vData);
             $validation->rule('cb-name', 'not_empty');
             $validation->rule('cb-name', 'min_length', array(':value', '2'));
             $validation->rule('cb-name', 'max_length', array(':value', '250'));
             $validation->rule('cb-phone', 'not_empty');
             $validation->rule('cb-phone', 'phone');
             $validation->rule('cb-phone', 'min_length', array(':value', '6'));
             $validation->rule('cb-phone', 'max_length', array(':value', '15'));
             if (!$validation->check()) {
                 $this->errors = $validation->errors('callbackErrors');
             } else {
                 $name = Arr::get($_POST, 'cb-name', '');
                 $phone = Arr::get($_POST, 'cb-phone', '');
                 //отправляем письмо
                 $config = Kohana::$config->load('email');
                 Email::connect($config);
                 $to = $config['options']['callback_email'];
                 //$to = '*****@*****.**';
                 $subject = 'Поступила заявка с сайта ' . $options['sitename'] . ' от ' . $name . '';
                 $from = $config['options']['username'];
                 $message = '<h2>Новая заявка</h2>';
                 $message .= 'Отправитель: <b>' . $name . ', </b><br>';
                 $message .= 'Тел: <b>' . $phone . ', </b><br>';
                 $message .= '<em>Отправлено: ' . date("G:i:s M j Y") . '</em>';
                 Email::send($to, $from, $subject, $message, $html = TRUE);
                 if (count($this->errors) > 0) {
                     $base = new Model_Base();
                     $options = $base->getOptions();
                     $to = $options['admin_email'];
                     $subject = 'Ошибки на сайте ' . $options['sitename'];
                     $from = $config['options']['username'];
                     foreach ($this->errors as $error) {
                         $message = '<h2>Ошибка</h2>';
                         $message .= $error;
                         $message .= ' <em>Отправлено: ' . date("G:i:s M j Y") . '</em>';
                     }
                     Email::send($to, $from, $subject, $message, $html = TRUE);
                 } else {
                     $this->messages[] = 'Спасибо! Ваш вопрос успешно отправлен.';
                 }
             }
         } else {
             $this->errors['captcha'] = "Код введен неверно";
         }
     }
     $captcha_image = Captcha::instance()->render();
     $this->template->captcha = $captcha_image;
     $this->template->errors = $this->errors;
     $this->template->messages = $this->messages;
 }