Орла
Области
Компаний
Пользователи
Галерея
Фиксированные новости
Орла
Отзывы о фирмах
Тарифы
Пользователи
Области
Банкоматы
Торговые точки
Доска объявлений
Курсы валют
Скидки
организации Орла
организации области
товары
сайты
сайты Орел
Данные
Разделы
Поиск
Поиск запросы
Статистика
Показы каталога организаций
Статистика клиенты
Пользователи
Сайты
Управление сайтом
Анкета
Аптеки
Афиша
Афиша новая
Баннеры
Бизнес >
Викторина
Голосование
Гость на сайте
Истории
Календарь событий
Каталоги >
Конкурс красоты
Конкурс аудио
Консультации
Меню
Новое на сайте
Новости >
Организации >
Программа ТВ
Публикации
Разделы сайта
Рассылка
Рестораны
Секрет фирмы >
Сервисы >
Ссылки
Тесты
Файловый менеджер
Форум
Фотогалерея
Обратная связь
Недвижимость
Новый год
Тексты
Пользователи
Юридический рейтинг
Отзывы на товары
Бан пользователей
Жалобы
Новые тесты
Коронавирус
Файловый менеджер
Имя файла
Restoran.php
Содержимое
<?php namespace app\restoran; use App; use app\core\helpers\ArrayHelper; use app\core\helpers\UrlHelper; use app\helpers\views\EntityRatingCssClass; /** * Класс для работы с ресторанами. * Class Restoran * @package app\restoran */ class Restoran { /** * @var \PDO */ private $_pdo; public function __construct() { $this->_pdo = App::getRestoranPdo(); } /** * Функция для получения комментариев к ресторану * @param $count * @return array */ public static function getFeedbackItems($count) { function getCommentGoodString($comment) { $pattern = '|[[\/\!]*?[^\[\]]*?]|si'; $replace = ''; $comment = preg_replace('%\[img[^\]]*\][^\[\]]*|\[/img[^\]]*\]%', '', $comment); return $comment; // $comment = preg_replace("/\*0([a-z]{1,10}\/[0-9]{1,3})\*/e","_mychat_('\\1',1)", $comment); // if (mb_strlen($comment) >= 100) { // $comment = mb_substr($comment, 0, mb_strpos( $comment, ' ', 100, 'UTF-8' ), 'UTF-8') . '...'; // } // return $comment; } function getSexClass($sex) { $array = ['it', 'men', 'women']; if (isset($array[$sex])) { return $array[$sex]; } return 'it'; } function getSexString($sex) { $array = ['оставило', 'оставил', 'оставила']; if (isset($array[$sex])) { return $array[$sex]; } return 'оставило'; } $pdo = App::getRestoranPdo(); $sth = $pdo->prepare(" SELECT restoran_comment.id as comment_id, restoran.registr, `restoran`.`name`, `id_restoran`, `id_user`, DATE_FORMAT(`restoran_comment`.`date`, '%d.%m.%Y') AS `date`, `comment`, `karma`, ( SELECT COUNT(id) as total FROM restoran_comment WHERE restoran_comment.id_restoran = restoran.id and (restoran_comment.status='3' or restoran_comment.status='4') ) as total_comments, restoran.restoran_url FROM `restoran`.`restoran`, `restoran`.`restoran_comment` WHERE (restoran.status='3' or restoran.status='4') and (restoran_comment.status='3' or restoran_comment.status='4') and `restoran`.`id`=`restoran_comment`.`id_restoran` ORDER BY `restoran_comment`.`date` DESC LIMIT 0, {$count} "); $sth->execute(); $feedbackRestoranItems = $sth->fetchAll(); // список пользователей $userIds = ArrayHelper::arrayColumn($feedbackRestoranItems, 'id_user'); $users = App::$user->getUsersByIds($userIds); foreach ($feedbackRestoranItems as $key => $item) { $user = null; if (isset($users[$item['id_user']])) { $user = $users[$item['id_user']]; } $feedbackRestoranItems[$key]['sex_class'] = $user == null ? 'it' : getSexClass($user['sex']); $feedbackRestoranItems[$key]['sex_string'] = $user == null ? 'оставило' : getSexString($user['sex']); $feedbackRestoranItems[$key]['user_name'] = $user == null ? null : $user['name']; $feedbackRestoranItems[$key]['comment'] = getCommentGoodString($item['comment']); $feedbackRestoranItems[$key]['class_name'] = EntityRatingCssClass::getName($item['karma']); } return $feedbackRestoranItems; } /** * Функция получения рейтинга ресторана по пятибальной шкале * @param $restoranId * @return float */ public function getRating($restoranId) { $pdo = \App::getRestoranPdo(); $comments = new Comments(); $sth = $pdo->prepare(' SELECT ROUND(IFNULL(SUM(ball), 0) / COUNT(id), 1) as rating FROM `restoran`.`restoran_vote_new` WHERE `id_restoran` = :restoran_id '); $sth->execute([ ':restoran_id' => $restoranId ]); $rating = $sth->fetch()['rating']; $commentsPlus = $comments->getCommentsTotalPlus($restoranId); $commentsMinus = $comments->getCommentsTotalMinus($restoranId); $weightComments = false; if ($commentsMinus != 0 || $commentsPlus != 0) { $weightComments = ($commentsPlus * 5 + $commentsMinus * 1)/ ($commentsPlus + $commentsMinus); } if ($weightComments !== false) { if ($rating > 0) { $rating = round(($rating + $weightComments) / 2, 1); } else { $rating = round($rating + $weightComments, 1); } } return $rating; } /** * Функция получения названия ресторана по его ID * @param $retoranId - номер ресторана * @return string|null */ public function getRestoranName($restoranId) { $sth = $this->_pdo ->prepare(' SELECT id, name FROM restoran WHERE id = :restoran_id '); $sth->execute([ ':restoran_id' => $restoranId ]); $data = $sth->fetch(); if (isset($data['name'])) { return $data['name']; } return null; } /** * Функция проверяет, существует ли такой ресторан или нет. * @param $restoranId * @return boolean */ public function isExist($restoranId) { $sth = $this->_pdo ->prepare(' SELECT COUNT(id) as total FROM `restoran` WHERE id = :restoran_id '); $sth->execute([ ':restoran_id' => $restoranId ]); return $sth->fetch()['total'] > 0; } public function getRestoran($restoranId) { $pdo = \App::getRestoranPdo(); $sth = $pdo->prepare(' SELECT `restoran`.*, `restoran_area`.`id` AS `id_area`, `restoran_area`.`name` AS `area_name` FROM `restoran`.`restoran`, `restoran`.`restoran_area` WHERE (`restoran`.status="3" or `restoran`.status="4") and `restoran`.`id_area`=`restoran_area`.`id` AND `restoran`.`id`=:restoran_id '); $sth->execute([ ':restoran_id' => $restoranId ]); $restoran = $sth->fetch(); if (isset($restoran['id'])) { $restoran['kitchen_array'] = (new Kitchen())->getKitchenByRestoranId($restoranId); $restoran['interes_array'] = (new Interes())->getInteresByRestoranId($restoranId); $restoran['music_array'] = (new Music())->getMusicByRestoranId($restoranId); $restoran['entertainment_array'] = (new Entertainment())->getEntertainmentByRestoranId($restoranId); $restoran['registr'] = 1; $restoran['site'] = UrlHelper::normalize($restoran['site']); $restoran['vk_url'] = UrlHelper::normalize($restoran['vk_url']); //$restoran['interes_array'] = return $restoran; } return null; } /** * Функция считает общее количество ресторанов. */ public function getTotal() { $pdo = \App::getRestoranPdo(); $sth = $pdo->prepare(' SELECT COUNT(id) as total FROM `restoran` WHERE status = 3 '); $sth->execute(); return $sth->fetch()['total']; } public static function getWorkHours($restoranId) { $pdo = \App::getRestoranPdo(); $sth = $pdo ->prepare(' SELECT id, work_hours FROM restoran WHERE id = :id '); $sth->execute([ ':id' => $restoranId ]); $data = $sth->fetch(); if (isset($data['work_hours'])) { return $data['work_hours']; } return null; } public static function getUrlById($id) { $pdo = \App::getRestoranPdo(); $sth = $pdo->prepare(' SELECT restoran_url FROM restoran WHERE id = :id '); $sth->execute([ ':id' => $id ]); $data = $sth->fetch(); if (isset($data['restoran_url'])) { return $data['restoran_url']; } return null; } public static function getIdByUrl($url) { $pdo = \App::getRestoranPdo(); $sth = $pdo->prepare(' SELECT id FROM restoran WHERE restoran_url = :restoran_url '); $sth->execute([ ':restoran_url' => $url ]); $data = $sth->fetch(); if (isset($data['id']) == true) { return $data['id']; } return null; } /** * Функция возвращает список платных ресторанов. * @return array */ public function getVipRestoranList() { $pdo = \App::getRestoranPdo(); $sth = $pdo->prepare(' SELECT id, name, restoran_url, img_index, logo FROM restoran WHERE registr = 1 AND (status = 3 OR status = 4) ORDER BY `restoran`.`registr` DESC, `restoran`.position DESC, `restoran`.`date` DESC, `restoran`.name ASC '); $sth->execute(); return $sth->fetchAll(); } /** * Функция возвращает полный URL к ресторану. * @param $restoranId * @return string */ public function getFullUrl($restoranId) { $url = static::getUrlById($restoranId); if ($url === null) { return null; } return '/restoran/' . $url . '.html'; } }
/app/restoran/
Имя
Дата
Размер
..
2026-10-01
entity
2019-01-18
filters
2019-01-18
forms
2017-01-30
repository
2019-01-18
request
2019-01-18
utils
2019-01-18
CommentImages.php
2017-08-17
2 кб.
Comments.php
2018-07-10
7 кб.
Entertainment.php
2016-12-22
1 кб.
Interes.php
2016-12-22
1 кб.
Kitchen.php
2016-12-22
1 кб.
Music.php
2016-12-22
982 байт
Panorams.php
2017-01-18
484 байт
Photos.php
2017-03-24
2 кб.
Restoran.php
2018-07-12
10 кб.
RestoranMenu.php
2017-07-20
3 кб.
RestoranNews.php
2017-09-11
6 кб.
RestoranReader.php
2022-02-25
8 кб.
RestoranReader.php~
2018-07-11
8 кб.
RestoranViews.php
2017-03-21
2 кб.
RestoranVote.php
2017-09-11
2 кб.
Video.php
2017-01-30
889 байт
/app/restoran
Загрузить файлы
Файл 1
Файл 2
Файл 3