public static function get() { $functions = array(); /** * Get one or couple entities. * If get one entity of the UsersModel, we also get user statistic * * @param $modelName * @param array $id * @return array * @throws Exception */ $functions['fetch'] = function ($modelName, $id = array()) { $Register = Register::getInstance(); try { $model = $Register['ModManager']->getModelInstance($modelName); // get collection of entities if (is_array($id) && count($id)) { $id = array_map(function ($n) { $n = intval($n); if ($n < 1) { throw new Exception('Only integer value might send as ID.'); } return $n; }, $id); $ids = implode(", ", $id); $result = $model->getCollection(array("`id` IN ({$ids})")); // get one entity } else { if (is_numeric($id)) { $id = intval($id); if ($id < 1) { throw new Exception('Only integer value might send as ID.'); } $result = $model->getById($id); if ($result && strtolower($modelName) == 'users') { $stat = $model->getFullUserStatistic($id); $result->setStatistic($stat); } } } } catch (Exception $e) { throw new Exception($e->getMessage()); } return !empty($result) ? $result : array(); }; /** * Format date. * If date_format == 'atm-format', just call AtmGetSimpleDate. * * @param $date string * @param $format string * @return string */ $functions['AtmGetDate'] = function ($date, $format = false) { return AtmDateTime::getDate($date, $format); }; /** * Return date formatted as(example) - "3 seconds before" * * @param $date string * @return string */ $functions['AtmGetSimpleDate'] = function ($date) { return AtmDateTime::getSimpleDate($date); }; /** * Check access according with ACL rules. * * @param $params array * @return bool */ $functions['checkAccess'] = function ($params = array()) { if (isset($params) && is_array($params)) { $Register = Register::getInstance(); return $Register['ACL']->turn($params, false); } return false; }; $functions['get_url'] = function ($url, $notRoot = false, $useLang = true) { return get_url($url, $notRoot, $useLang); }; /** * Return URl to the user avatar * or default image if avatar image is not exists. * * @param null $id_user * @param null $email_user * @return string */ $functions['getAvatar'] = function ($id_user = null, $email_user = null) { $def = get_url('/template/' . getTemplateName() . '/img/noavatar.png', false, false); if (isset($id_user) && $id_user > 0) { if (is_file(ROOT . '/sys/avatars/' . $id_user . '.jpg')) { return get_url('/sys/avatars/' . $id_user . '.jpg', false, false); } else { $Register = Register::getInstance(); $Viewer = $Register['Viewer']; if (Config::read('use_gravatar', 'users') && $Viewer->customFunctionExists('getGravatar')) { if (!isset($email_user)) { $usersModel = $Register['ModManager']->getModelInstance('Users'); $user = $usersModel->getById($id_user); if ($user) { $email_user = $user->getEmail(); } else { return $def; } } return $Viewer->runCustomFunction('getGravatar', array($email_user)); } else { return $def; } } } else { return $def; } }; /** * Get either a Gravatar URL or complete image tag for a specified email address. * * @param string $email The email address * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] * @return String containing either just a URL or a complete image tag */ $functions['getGravatar'] = function ($email, $s = 120, $d = 'mm', $r = 'g') { $url = 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . ".png?s={$s}&d={$d}&r={$r}"; return $url; }; $functions['getOrderLink'] = function ($params) { if (!$params || !is_array($params) || count($params) < 2) { return ''; } $order = !empty($_GET['order']) ? strtolower(trim($_GET['order'])) : ''; $new_order = strtolower($params[0]); $active = $order === $new_order; $asc = $active && isset($_GET['asc']); $url = $_SERVER['REQUEST_URI']; $url = preg_replace('#(order=[^&]*[&]?)|(asc=[^&]*[&]?)#i', '', $url); if (substr($url, -1) !== '&' && substr($url, -1) !== '?') { $url .= !strstr($url, '?') ? '?' : '&'; } return '<a href="' . $url . 'order=' . $new_order . ($asc ? '' : '&asc=1') . '">' . $params[1] . ($active ? ' ' . ($asc ? '↑' : '↓') : '') . '</a>'; }; /** * Checks is an user online or not. * * @param $user_id int */ $functions['CheckUserOnline'] = function ($user_id) { $users = getOnlineUsers(); return array_key_exists($user_id, $users); }; /** * Returns user rank img such as Stars or Progressbar * * @param $rating int */ $functions['getUserRatingImg'] = function ($rating) { $Register = Register::getInstance(); $settingsModel = $Register['ModManager']->getModelInstance('UsersSettings'); $rating_settings = $settingsModel->getCollection(array('type' => 'rating')); $rating_settings = count($rating_settings) > 0 ? $rating_settings[0]->getValues() : ''; $rank = getUserRating($rating, $rating_settings); return $rank['img']; }; $custom_functions = self::loadCustomTemplateFunctions(); if (is_array($custom_functions)) { $functions = array_merge($functions, $custom_functions); } return $functions; }
public function statistics($type = false, $id = false) { if ($type && !$id) { $type = false; } $Register = Register::getInstance(); $this->pageTitle = __('Shop') . ' / ' . __('Statistics'); $this->pageNav = __('Shop') . ' / ' . __('Statistics'); $content = ''; if (!$type) { $deliveryModel = $Register['ModManager']->getModelInstance('shopDeliveryTypes'); $ordersProductsModel = $Register['ModManager']->getModelInstance('shopOrdersProducts'); $ordersModel = $Register['ModManager']->getModelInstance('shopOrders'); list($date1, $date2) = $this->getDateRange('orders-by-dates'); $data = $ordersModel->getCollection(array("a.date BETWEEN '{$date1}' AND '{$date2}'"), array('joins' => array(array('table' => 'shop_orders', 'alias' => 'b', 'cond' => array("a.id = b.id", "a.status = 'process'"), 'type' => 'LEFT'), array('table' => 'shop_orders', 'alias' => 'c', 'cond' => array("a.id = c.id", "a.status = 'complete'"), 'type' => 'LEFT'), array('table' => 'shop_orders', 'alias' => 'd', 'cond' => array("a.id = d.id", "a.status = 'delivery'"), 'type' => 'LEFT')), 'fields' => array('a.date', 'COUNT( a.id ) AS all_cnt', 'COUNT( b.id ) AS process_cnt', 'COUNT( c.id ) AS complete_cnt', 'COUNT( d.id ) AS delivery_cnt'), 'alias' => 'a', 'group' => 'a.date', 'order' => 'a.date DESC')); $orders_st_date = array(0 => array(), 1 => array(), 2 => array(), 3 => array()); $orders_st_date_ticks = array(); if (!empty($data)) { foreach ($data as $k => $row) { $row = $row->asArray(); $orders_st_date[0][$k] = intval($row['all_cnt']); // all $orders_st_date[1][$k] = intval($row['process_cnt']); // process $orders_st_date[2][$k] = intval($row['delivery_cnt']); // delivery $orders_st_date[3][$k] = intval($row['complete_cnt']); // complete $orders_st_date_ticks[$k] = AtmDateTime::getDate($row['date'], "Y/m/d"); } } list($date1, $date2) = $this->getDateRange('top-products'); $data = $ordersProductsModel->getCollection(array("order_id IN (SELECT id FROM shop_orders WHERE date BETWEEN '{$date1}' AND '{$date2}')"), array('joins' => array(array('table' => 'shop_products', 'alias' => 'b', 'cond' => array("a.product_id = b.id"), 'type' => '')), 'fields' => array('a.product_id', 'b.title', 'COUNT(a.id) as cnt'), 'alias' => 'a', 'group' => 'a.product_id', 'order' => '`quantity` DESC', 'limit' => 30)); $top_products = array(); $top_products_ticks = array(); if (!empty($data)) { foreach ($data as $k => $row) { $row = $row->asArray(); $top_products[$k] = intval($row['quantity']); $top_products_ticks[$k] = h($row['title']); } } list($date1, $date2) = $this->getDateRange('orders-total'); $data = $ordersModel->getCollection(array("date BETWEEN '{$date1}' AND '{$date2}'"), array('fields' => array("DATE_FORMAT(date, '%Y-%m-%d') AS date", 'SUM(total) AS total'), 'group' => 'date', 'order' => 'date ASC')); $orders_total = array(); $orders_total_ticks = array(); $dateObj = new DateTime($date1); $prev_date = (string) $dateObj->modify('-1 day')->format('Y-m-d'); if (!empty($data)) { foreach ($data as $k => $row) { $row = $row->asArray(); $check_date = (string) $dateObj->modify('+1 day')->format('Y-m-d'); while ($check_date < $row['date']) { $orders_total[] = array($check_date, 0); $orders_total_ticks[] = $check_date; $check_date = (string) $dateObj->modify('+1 day')->format('Y-m-d'); } $orders_total[] = array($row['date'], intval($row['total'])); $orders_total_ticks[] = $row['date']; $check_date = $row['date']; } } $delivery_types = array(); $d_data = $deliveryModel->getCollection(array(), array('fileds' => array('id', 'title'))); if ($d_data) { foreach ($d_data as $r) { $r = $r->asArray(); $delivery_types[] = h($r['title']); } } list($date1, $date2) = $this->getDateRange('delivery-types'); $data = $ordersModel->getCollection(array("date BETWEEN '{$date1}' AND '{$date2}'"), array('joins' => array(array('table' => 'shop_delivery_types', 'type' => 'LEFT', 'alias' => 'b', 'cond' => array('a.delivery_type_id = b.id'))), 'fields' => array("DATE_FORMAT(a.date, '%Y-%m-%d') AS date", 'COUNT(a.delivery_type_id) as cnt', 'b.title'), 'alias' => 'a', 'group' => 'a.date, a.delivery_type_id', 'order' => 'a.date ASC')); $deliveries = array_fill(0, count($delivery_types), array()); $deliveries_ticks = array(); $dateObj = new DateTime($date1); $prev_date = (string) $dateObj->modify('-1 day')->format('Y-m-d'); if (!empty($data)) { foreach ($data as $k => $row) { $row = $row->asArray(); $d_type_key = array_search(h($row['title']), $delivery_types); if ($d_type_key === false) { $delivery_types[] = 'Unknown'; } } foreach ($data as $k => $row) { $row = $row->asArray(); if (empty($row['title'])) { $row['title'] = 'Unknown'; } $d_type_key = array_search(h($row['title']), $delivery_types); $check_date = (string) $dateObj->modify('+1 day')->format('Y-m-d'); while ($check_date < $row['date']) { $deliveries = array_map(function ($n) use($deliveries_ticks) { if (!array_key_exists(count($deliveries_ticks), $n)) { $n[count($deliveries_ticks)] = 0; } return $n; }, $deliveries); $deliveries[$d_type_key][count($deliveries_ticks)] = 0; $deliveries_ticks[] = $check_date; $check_date = (string) $dateObj->modify('+1 day')->format('Y-m-d'); } $date_key = array_search($row['date'], $deliveries_ticks); if ($date_key === false) { $date_key = count($deliveries_ticks); } $deliveries = array_map(function ($n) use($deliveries_ticks) { if (!array_key_exists(count($deliveries_ticks), $n)) { $n[count($deliveries_ticks)] = 0; } return $n; }, $deliveries); $deliveries[$d_type_key][$date_key] = intval($row['cnt']); if (!in_array($row['date'], $deliveries_ticks)) { $deliveries_ticks[] = $row['date']; } $check_date = $row['date']; } } } //pr($deliveries_ticks); pr($deliveries); die(); ob_start(); ?> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/jqplot/graphlib.js"></script> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/jqplot/plugins/jqplot.canvasTextRenderer.min.js"></script> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js"></script> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/jqplot/plugins/jqplot.barRenderer.min.js"></script> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/jqplot/plugins/jqplot.dateAxisRenderer.min.js"></script> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/jqplot/plugins/jqplot.pointLabels.min.js"></script> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/jqplot/plugins/jqplot.highlighter.min.js"></script> <!--<script type="text/javascript" src="/sys/js/jqplot_plugins/jqplot.bubbleRenderer.min.js"></script>--> <link href="/sys/js/jqplot/style.css" type="text/css" rel="stylesheet"> <script type="text/javascript" src="<?php echo WWW_ROOT; ?> /sys/js/datepicker/datepicker.js"></script> <link type="text/css" rel="StyleSheet" href="<?php echo WWW_ROOT; ?> /sys/js/datepicker/datepicker.css" /> <script type="text/javascript"> $(document).ready(function(){ $('.tcal').datetimepicker({ timepicker:false, format:'Y/m/d', closeOnDateSelect: true }); }); </script> <?php $content .= ob_get_clean(); if ($type === 'product') { $content .= $this->getProductStatistics($id); } if (!$type) { ob_start(); ?> <div class="list"> <div class="title"><?php echo __('Orders'); ?> </div> <div class="level1"> <div class="head"> <div class="title"><?php echo __('Orders by dates'); ?> </div> <?php echo $this->getDateRangeSelector('orders-by-dates'); ?> </div> <div class="graph-wrapper"><div class="graph-container" id="chart1"></div></div> <div class="title"><?php echo __('Top products'); ?> <?php echo $this->getDateRangeSelector('top-products'); ?> <div class="descr"><?php echo __('Top products by period'); ?> </div> </div> <div class="graph-wrapper"><div class="graph-container" id="chart2"></div></div> <div class="title"><?php echo __('Orders total summ'); ?> <?php echo $this->getDateRangeSelector('orders-total'); ?> <div class="descr"><?php echo __('Orders total summ per day'); ?> </div> </div> <div class="graph-wrapper"><div class="graph-container" id="chart4"></div></div> <div class="title"><?php echo __('Delivery'); ?> <?php echo $this->getDateRangeSelector('delivery-types'); ?> <div class="descr"><?php echo __('Deivery types by days'); ?> </div> </div> <div class="graph-wrapper"><div class="graph-container" id="chart5"></div></div> </div> </div> <script type="text/javascript"> $(document).ready(function(){ try { plot1 = $.jqplot('chart1', <?php echo json_encode($orders_st_date); ?> , { stackSeries: false, captureRightClick: true, seriesDefaults:{ renderer:$.jqplot.BarRenderer, rendererOptions: { /*barMargin: 20,*/ highlightMouseDown: true }, pointLabels: {show: true, stackedValue: false} }, axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: <?php echo json_encode($orders_st_date_ticks); ?> }, yaxis: { padMin: 0, tickOptions: {formatString: '%d'} } }, legend: { show: true, location: 'e', placement: 'inside', labels: ['total', 'process', 'delivery', 'complete'] } }); } catch (e) { $('#chart1').html('No Data Available'); } try { plot2 = $.jqplot('chart2', [<?php echo json_encode($top_products); ?> ], { stackSeries: false, captureRightClick: true, seriesDefaults:{ renderer:$.jqplot.BarRenderer, rendererOptions: { barMargin: 20, varyBarColor: true, highlightMouseDown: true }, pointLabels: {show: true, stackedValue: false} }, axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: <?php echo json_encode($top_products_ticks); ?> }, yaxis: { padMin: 0, min: 0, tickOptions: {formatString: '%d'} } } }); } catch (e) { $('#chart2').html('No Data Available'); } try { plot4 = $.jqplot('chart4', [<?php echo json_encode($orders_total); ?> ], { seriesDefaults:{ pointLabels: {show: true, stackedValue: false} }, axes: { xaxis: { renderer: $.jqplot.DateAxisRenderer, tickRenderer: $.jqplot.CanvasAxisTickRenderer , tickOptions: {angle: 30, fontSize: '10px'}, autoscale:true, ticks: <?php echo json_encode($orders_total_ticks); ?> }, yaxis: { autoscale:true, padMin: 0, min: 0, tickOptions: {formatString: '%d'} } }, highlighter: { show: true, sizeAdjust: 7.5, formatString: 'On %s was made orders for %s total' }, series: [ { lineWidth:2, fill: true, fillAndStroke: true, color:'#4bb2c5', fillColor: '#4bb2c5', fillAlpha: 0.3, label:'Orders total', markerOptions: { style:'circle'} } ] }); } catch (e) { $('#chart4').html('No Data Available'); } try { plot5 = $.jqplot('chart5', <?php echo json_encode($deliveries); ?> , { stackSeries: false, captureRightClick: true, seriesDefaults:{ renderer:$.jqplot.BarRenderer, rendererOptions: { highlightMouseDown: true }, pointLabels: {show: true, stackedValue: false} }, axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer, tickRenderer: $.jqplot.CanvasAxisTickRenderer , tickOptions: {angle: 30, fontSize: '10px'}, ticks: <?php echo json_encode($deliveries_ticks); ?> }, yaxis: { padMin: 0, tickOptions: {formatString: '%d'} } }, legend: { show: true, location: 'e', placement: 'inside', labels: <?php echo json_encode($delivery_types); ?> } }); } catch (e) { $('#chart5').html('No Data Available'); } }); </script> <?php $content .= ob_get_clean(); } return $content; }
/** * Return posts list */ public function view_theme($id_theme = null) { $id_theme = (int) $id_theme; if (empty($id_theme) || $id_theme < 1) { redirect('/forum/'); } $themeModel = $this->Register['ModManager']->getModelInstance('Themes'); $themeModel->bindModel('forum'); $themeModel->bindModel('poll'); $theme = $themeModel->getById($id_theme); if (!$theme->getForum()) { return $this->showInfoMessage(__('Can not find forum'), '/forum/'); } //turn access $this->ACL->turn(array('forum', 'view_themes')); // Check access to this forum. May be locked by pass or posts count $this->__checkForumAccess($theme->getForum()); $id_forum = $theme->getId_forum(); $this->__checkThemeAccess($theme); if ($this->cached && $this->Cache->check($this->cacheKey)) { $source = $this->Cache->read($this->cacheKey); } else { // Если запрошенной темы не существует - возвращаемся на форум if (empty($theme)) { return $this->showInfoMessage(__('Topic not found'), '/forum/'); } // Заголовок страницы (содержимое тега title) $this->addToPageMetaContext('entity_title', h($theme->getTitle())); $this->addToPageMetaContext('category_title', h($theme->getForum()->getTitle())); $markers = array(); $markers['navigation'] = get_link(__('Forums list'), '/forum/') . __('Separator') . get_link($theme->getForum()->getTitle(), '/forum/view_forum/' . $id_forum) . __('Separator') . get_link($theme->getTitle(), '/forum/view_theme/' . $id_theme); if (!empty($description)) { $markers['navigation'] .= ' (' . $theme->getDescription() . ')'; } // Page nav $postsModelName = $this->Register['ModManager']->getModelName('Posts'); $postsModel = new $postsModelName(); $total = $postsModel->getTotal(array('cond' => array('id_theme' => $id_theme))); if ($total === 0) { $this->__delete_theme($id_theme); return $this->showInfoMessage(__('Topic not found'), '/forum/view_forum/' . $id_forum); } list($pages, $page) = pagination($total, $this->Register['Config']->read('posts_per_page', 'forum'), '/forum/view_theme/' . $id_theme); $markers['pagination'] = $pages; $this->addToPageMetaContext('page', $page); // SELECT posts $postsModel->bindModel('author'); $postsModel->bindModel('editor'); $postsModel->bindModel('attacheslist'); $posts = $postsModel->getCollection(array('id_theme' => $id_theme), array('order' => 'time ASC, id ASC', 'page' => $page, 'limit' => $this->Register['Config']->read('posts_per_page', 'forum'))); // Ссылка "Ответить" (если тема закрыта - выводим сообщение "Тема закрыта") if ($theme->getLocked() == 0) { $markers['add_link'] = get_link(get_img('/template/' . $this->Register['Config']->read('template') . '/img/reply.png', array('alt' => __('Answer'), 'title' => __('Answer'))), '/forum/view_theme/' . $id_theme . '#sendForm'); } else { $markers['add_link'] = ''; // __('Theme is locked') $markers['closed_theme'] = true; } if (!$this->ACL->turn(array('forum', 'add_posts', $theme->getId_forum()), false)) { $markers['add_link'] = ''; } $markers['meta'] = ''; $this->_globalize($markers); $post_num = ($page - 1) * $this->Register['Config']->read('posts_per_page', 'forum'); //serialize rating settings $settingsModelName = $this->Register['ModManager']->getModelName('UsersSettings'); $settingsModel = new $settingsModelName(); $rating_settings = $settingsModel->getCollection(array('type' => 'rating')); $rating_settings = count($rating_settings) > 0 ? $rating_settings[0]->getValues() : ''; $usersModel = $this->Register['ModManager']->getModelInstance('Users'); $first_top = false; if ($page > 1 && $theme->getFirst_top() == '1') { $post = $postsModel->getCollection(array('id_theme' => $id_theme), array('order' => 'time ASC, id ASC', 'limit' => 1)); if (is_array($post) && count($post) == 1) { $posts = array_merge($post, $posts); $first_top = true; } } foreach ($posts as $post) { // Если автор сообщения (поста) - зарегистрированный пользователь $postAuthor = $post->getAuthor(); if ($post->getId_author()) { // Аватар if (is_file(ROOT . '/sys/avatars/' . $post->getId_author() . '.jpg')) { $postAuthor->setAvatar(get_url('/sys/avatars/' . $post->getId_author() . '.jpg')); } else { $postAuthor->setAvatar(get_url('/sys/img/noavatar.png')); } // Статус пользователя $status = $this->ACL->get_group_info(); $user_status = array_key_exists($postAuthor->getStatus(), $status) ? $status[$postAuthor->getStatus()] : $status[0]; $postAuthor->setStatus_title($user_status['title']); // Рейтинг пользователя (по количеству сообщений) $rating = $postAuthor->getPosts(); $rank_star = getUserRating($rating, $rating_settings); $postAuthor->setRank($rank_star['rank']); if ($postAuthor->getState()) { $postAuthor->setRank($postAuthor->getState()); } $postAuthor->setUser_rank(get_img('/sys/img/' . $rank_star['img'])); // Если автор сообщения сейчас "на сайте" $users_on_line = getOnlineUsers(); if (isset($users_on_line) && isset($users_on_line[$post->getId_author()])) { $postAuthor->setStatus_on(__('Online')); } else { $postAuthor->setStatus_on(__('Offline')); } // Если пользователь заблокирован if ($postAuthor->getBlocked()) { $postAuthor->setStatus_on('<span class="statusBlock">' . __('Banned') . '</span>'); } // Если автор сообщения - незарегистрированный пользователь } else { $postAuthor->setAvatar(get_url('/sys/img/noavatar.png')); $postAuthor->setName(__('Guest')); } $message = $this->Textarier->parseBBCodes($post->getMessage(), $post); $post->setMessage($message); $signature = $postAuthor->getSignature() ? $this->Textarier->getSignature($postAuthor->getSignature(), $postAuthor->getStatus()) : ''; $postAuthor->setSignature($signature); // If author is authorized user. $email = ''; $privat_message = ''; $author_site = ''; $user_profile = ''; $icon_params = array('class' => 'user-details'); if ($post->getId_author()) { $user_profile = ' ' . get_link(get_img('/sys/img/icon_profile.gif', array('alt' => __('View profile'), 'title' => __('View profile'))), getProfileUrl($post->getId_author()), $icon_params); if (isset($_SESSION['user'])) { $email = ' ' . get_link(get_img('/sys/img/icon_email.gif', array('alt' => __('Send mail'), 'title' => __('Send mail'))), '/users/send_mail_form/' . $post->getId_author(), $icon_params); $privat_message = ' ' . get_link(get_img('/sys/img/icon_pm.gif', array('alt' => __('PM'), 'title' => __('PM'))), '/users/pm_send_form/' . $post->getId_author(), $icon_params); } $author_site = $post->getAuthor()->getUrl() ? ' ' . get_link(get_img('/sys/img/icon_www.gif', array('alt' => __('Author site'), 'title' => __('Author site'))), h($post->getAuthor()->getUrl()), array_merge($icon_params, array('target' => '_blank')), true) : ''; } $post->getAuthor()->setAuthor_site($author_site); $post->getAuthor()->setProfile_url($user_profile); $post->getAuthor()->setEmail_url($email); $post->getAuthor()->setPm_url($privat_message); // Если сообщение редактировалось... if ($post->getId_editor()) { if ($post->getId_author() && $post->getId_author() == $post->getId_editor()) { $editor = __('Edit by author') . ' ' . AtmDateTime::getDate($post->getEdittime()); } else { $status_info = $this->ACL->get_user_group($post->getEditor()->getStatus()); $editor = __('Edited') . $post->getEditor()->getName() . '(' . $status_info['title'] . ') ' . AtmDateTime::getDate($post->getEdittime()); } } else { $editor = ''; } $post->setEditor_info($editor); //edit and delete links $edit_link = ''; $delete_link = ''; if (!empty($_SESSION['user'])) { if ($this->ACL->turn(array('forum', 'edit_posts', $theme->getId_forum()), false) || !empty($_SESSION['user']['id']) && $post->getId_author() == $_SESSION['user']['id'] && $this->ACL->turn(array('forum', 'edit_mine_posts', $theme->getId_forum()), false)) { $edit_link = get_link('', '/forum/edit_post_form/' . $post->getId(), array('class' => 'fps-edit')); } if ($this->ACL->turn(array('forum', 'delete_posts', $theme->getId_forum()), false) || !empty($_SESSION['user']['id']) && $post->getId_author() == $_SESSION['user']['id'] && $this->ACL->turn(array('forum', 'delete_mine_posts', $theme->getId_forum()), false)) { $delete_link = get_link('', '/forum/delete_post/' . $post->getId(), array('class' => 'fps-delete', 'onClick' => "return confirm('" . __('Are you sure') . "')")); } } $on_top = get_link('', '#top', array('class' => 'fps-up'), true); $post->setOn_top_link($on_top); $post->setEdit_link($edit_link); $post->setDelete_link($delete_link); //message number if ($first_top) { $post->setPost_number(1); $first_top = false; } else { $post_num++; $post->setPost_number($post_num); } $post_number_url = 'http://' . $_SERVER['HTTP_HOST'] . get_url('/' . $this->module . '/view_post/' . $post->getId(), true); $post->setPost_number_url($post_number_url); //set tags for cache $this->setCacheTag(array('post_id_' . $post->getId(), 'user_id_' . $post->getId_author())); } $this->setCacheTag('theme_id_' . $id_theme); // Polls render $polls = $theme->getPoll(); if (!empty($polls[0])) { $theme->setPoll($this->_renderPoll($polls[0])); } else { $theme->setPoll(''); } $markers = array('reply_form' => $this->add_post_form($theme)); $this->_globalize($markers); $source = $this->render('posts_list.html', array('posts' => $posts, 'theme' => $theme)); //write into cache if ($this->cached) { $this->Cache->write($source, $this->cacheKey, $this->cacheTags); } } // Если страницу темы запросил зарегистрированный пользователь, значит он ее просмотрит if (isset($_SESSION['user']) and isset($_SESSION['newThemes'])) { if (count($_SESSION['newThemes']) > 0) { if (in_array($id_theme, $_SESSION['newThemes'])) { unset($_SESSION['newThemes'][$id_theme]); } } else { unset($_SESSION['newThemes']); } } $theme->setViews($theme->getViews() + 1); $theme->save(); $_SESSION['VIEW_PAGE'] = 'theme' . $id_theme; //clean cache $this->Cache->clean(CACHE_MATCHING_TAG, array('action_viev_forum', 'theme_id_' . $id_theme)); return $this->_view($source); }