From 8966b75e3030a1af648e666f9c92b97b1984ed04 Mon Sep 17 00:00:00 2001 From: Alan <@> Date: Mon, 16 Feb 2026 21:36:34 +0300 Subject: [PATCH] add repairs design files --- .htaccess | 4 + design/atomic/html/repairs.tpl | 50 +++++++ design/atomic/html/repairs_post.tpl | 148 +++++++++++++++++++ view/RepairsView.php | 218 ++++++++++++++++++++++++++++ 4 files changed, 420 insertions(+) create mode 100644 design/atomic/html/repairs.tpl create mode 100644 design/atomic/html/repairs_post.tpl create mode 100644 view/RepairsView.php diff --git a/.htaccess b/.htaccess index 019e626..dadf503 100644 --- a/.htaccess +++ b/.htaccess @@ -651,6 +651,10 @@ RewriteRule ^nashi-raboty/([^/]+)/([^/]+)/filter-([^/]+)/?$ index.php?module= # Услуги RewriteRule ^tuning-centr/(.+)?$ index.php?module=ServiceView&page_url=$1 [L,QSA] +# Автосервис +RewriteRule ^repairs/([^/]+)/?$ index.php?module=RepairsView&url=$1 [L,QSA] +RewriteRule ^repairs/?$ index.php?module=RepairsView [L,QSA] + # Страницы RewriteRule ^pages/.+/([^/]+)/?$ index.php?module=PageView&page_url=$1 [L,QSA] RewriteRule ^pages/([^/]+)/?$ index.php?module=PageView&page_url=$1 [L,QSA] diff --git a/design/atomic/html/repairs.tpl b/design/atomic/html/repairs.tpl new file mode 100644 index 0000000..1a2d88e --- /dev/null +++ b/design/atomic/html/repairs.tpl @@ -0,0 +1,50 @@ +{* Список записей блога *} + + + + +

{$page->header}

+{$page->body} +{include file='pagination.tpl'} + +{* + +
+ {foreach $posts as $post} +
+
+ {if $post->image}
{$post->name|escape}
{/if} +
{$post->date|date|date_format:"%e %m %Y":"":"rus"} {$post->name|escape}
+
{$post->annotation}
+
+
+ {/foreach} +
*} + + + + +
+ {foreach $posts as $post} + +
+
{$post->date|date|date_format:"%e %m %Y":"":"rus"} + + {if $post->image} + {$post->name|escape} + {else} + {$post->name|escape} + {/if} + + + {$post->name|escape}
{$post->annotation}
+
+
+ {/foreach} +
+ + +{include file='pagination.tpl'} \ No newline at end of file diff --git a/design/atomic/html/repairs_post.tpl b/design/atomic/html/repairs_post.tpl new file mode 100644 index 0000000..fa05e26 --- /dev/null +++ b/design/atomic/html/repairs_post.tpl @@ -0,0 +1,148 @@ +{* Страница отдельной записи блога *} + + + + +

{$post->name|escape}

+

{$post->date|date|date_format:"%e %m %Y":"":"rus"}

+ + +{*if $post->image} +
+{$post->name|escape} +
+{/if*} + +{$post->text} + + + + + + +
+ {foreach from=$repair_photos item=ph} +
+ + + +
+ {/foreach} +
+ + {if $repair_photos || $prev_post || $next_post}

{/if} + + + +
+
+ {if $prev_post} + + +
+ ← {$prev_post->name} +
+ + {/if} +
+ {if $next_post} +
+ +
+ {$next_post->name} +
 → +
+ {/if} +
+ + + +
+ +

Комментарии

+ + {if $comments} + + + + {else} +

+ Пока нет комментариев +

+ {/if} + + + + + + + + + + + +
+ Написать комментарий + {if $error} +
+ {if $error=='captcha'} + Неверно введена капча + {elseif $error=='empty_name'} + Введите имя + {elseif $error=='empty_comment'} + Введите комментарий + {/if} +
+ {/if} + + + + + + + + + +

+ +
+ +
+
+ + +
+ + +{* Скрипт для листания через ctrl → *} +{* Ссылки на соседние страницы должны иметь id PrevLink и NextLink *} + + +{literal} + +{/literal} \ No newline at end of file diff --git a/view/RepairsView.php b/view/RepairsView.php new file mode 100644 index 0000000..02e319d --- /dev/null +++ b/view/RepairsView.php @@ -0,0 +1,218 @@ +request->get('url', 'string'); + + // Если указан адрес поста, + if(!empty($url)) + { + // Выводим пост + return $this->fetch_post($url); + } + else + { + // if($url) + return $this->fetch_blog($url); + //else + //return $this->fetchPage($url); + } + } + + function fetchPage($url) + { + if(!$url) $url = 'repairs'; + + $page = $this->pages->get_page($url); + + // Отображать скрытые страницы только админу + if(empty($page) || (!$page->visible && empty($_SESSION['admin']))) + return false; + + $this->design->assign('page', $page); + $this->design->assign('meta_title', $page->meta_title); + $this->design->assign('meta_keywords', $page->meta_keywords); + $this->design->assign('meta_description', $page->meta_description); + + //return + //return $this->design->fetch('page.tpl'); + return $this->fetch_blog($url); + } + + private function fetch_post($url) + { + + // Выбираем пост из базы + $post = $this->repairs->get_post($url); + + // Если не найден - ошибка + if(!$post || (!$post->visible && empty($_SESSION['admin']))) + return false; + + // Автозаполнение имени для формы комментария + if(!empty($this->user)) + $this->design->assign('comment_name', $this->user->name); + + + // Принимаем комментарий + if ($this->request->method('post') && $this->request->post('comment')) + { + $comment->name = $this->request->post('name'); + $comment->text = $this->request->post('text'); + $captcha_code = $this->request->post('captcha_code', 'string'); + + // Передадим комментарий обратно в шаблон - при ошибке нужно будет заполнить форму + $this->design->assign('comment_text', $comment->text); + $this->design->assign('comment_name', $comment->name); + + // Проверяем капчу и заполнение формы + if ($_SESSION['captcha_code'] != $captcha_code || empty($captcha_code)) + { + $this->design->assign('error', 'captcha'); + } + elseif (empty($comment->name)) + { + $this->design->assign('error', 'empty_name'); + } + elseif (empty($comment->text)) + { + $this->design->assign('error', 'empty_comment'); + } + else + { + // Создаем комментарий + $comment->object_id = $post->id; + $comment->type = 'repairs'; + $comment->ip = $_SERVER['REMOTE_ADDR']; + + // Если были одобренные комментарии от текущего ip, одобряем сразу + $this->db->query("SELECT 1 FROM __comments WHERE approved=1 AND ip=? LIMIT 1", $comment->ip); + if($this->db->num_rows()>0) + $comment->approved = 1; + + // Добавляем комментарий в базу + $comment_id = $this->comments->add_comment($comment); + + // Отправляем email + $this->notify->email_comment_admin($comment_id); + + // Приберем сохраненную капчу, иначе можно отключить загрузку рисунков и постить старую + unset($_SESSION['captcha_code']); + header('location: '.$_SERVER['REQUEST_URI'].'#comment_'.$comment_id); + } + } + + // Комментарии к посту + $comments = $this->comments->get_comments(array('type'=>'repairs', 'object_id'=>$post->id, 'approved'=>1, 'ip'=>$_SERVER['REMOTE_ADDR'])); + $this->design->assign('comments', $comments); + $this->design->assign('post', $post); + + //Страница родительского раздела + $page_url = trim($_SERVER['REQUEST_URI']); + $arr_page_url = explode('/', $page_url); + $parent_url = $arr_page_url[1]; + $this->page = $this->pages->get_page($parent_url); + $this->design->assign('page', $this->page); + + // Соседние записи + $this->design->assign('next_post', $this->repairs->get_next_post($post->id)); + $this->design->assign('prev_post', $this->repairs->get_prev_post($post->id)); + + $escapedName = htmlspecialchars($post->name); + + // Мета-теги + if(!$post->meta_title) $post->meta_title = $escapedName . ' - Услуги Автосервиса Atomic Garage'; + if(!$post->meta_description) $post->meta_description = $escapedName . ' в Atomic Garage - Услуги Автосервиса в Санкт-Петербурге.'; +// if(!$post->meta_keywords) $post->meta_keywords = mb_strtolower($escapedName, 'utf-8') . ', акции, скидки, товары, услуги, для автомобиля, авто, санкт-петербург, установка, ремонт, тюнинг центр, линзы, оптика, фары, фонари, птф, дхо'; + + + $this->design->assign('meta_title', $post->meta_title); + $this->design->assign('meta_keywords', $post->meta_keywords); + $this->design->assign('meta_description', $post->meta_description); + + + + $this->db->query("SELECT * FROM __repair_photo WHERE repair_id='" . $post->id . "' ORDER BY position, id DESC"); + $photos = $this->db->results(); + foreach($photos as $ph){ + $ph->image = Img::get('/files/post/' . $ph->img, array('width'=>400)); + $ph->bigImage = Img::get('/files/post/' . $ph->img, array('width'=>1200)); + } + $this->design->assign('repair_photos', $photos); + + + + return $this->design->fetch('repairs_post.tpl'); + } + + // Отображение списка постов + private function fetch_blog() + { + // Количество постов на 1 странице + $items_per_page = 20; + + $filter = array(); + + // Выбираем только видимые посты + $filter['visible'] = 1; + + // Текущая страница в постраничном выводе + $current_page = $this->request->get('page', 'integer'); + + // Если не задана, то равна 1 + $current_page = max(1, $current_page); + $this->design->assign('current_page_num', $current_page); + + // Вычисляем количество страниц + $posts_count = $this->repairs->count_posts($filter); + + // Показать все страницы сразу + if($this->request->get('page') == 'all') + $items_per_page = $posts_count; + + $pages_num = ceil($posts_count/$items_per_page); + $this->design->assign('total_pages_num', $pages_num); + + $filter['page'] = $current_page; + $filter['limit'] = $items_per_page; + + // Выбираем статьи из базы + $posts = $this->repairs->get_posts($filter); + if(empty($posts)) + return false; + + // Передаем в шаблон + $this->design->assign('posts', $posts); + + +// $this->page = $this->pages->get_page(); + $page = $this->pages->get_page('repairs'); + $this->design->assign('page', $this->page); + // Метатеги + if($this->page) + { + $this->design->assign('meta_title', $this->page->meta_title); + $this->design->assign('meta_keywords', $this->page->meta_keywords); + $this->design->assign('meta_description', $this->page->meta_description); + } + + $body = $this->design->fetch('repairs.tpl'); + + return $body; + } +} \ No newline at end of file