From 7e3cda3a39a34d56bab03cd8760caaa7215a7dd2 Mon Sep 17 00:00:00 2001 From: "M@dD3n" Date: Mon, 2 Oct 2017 11:50:22 +0300 Subject: [PATCH] Fixes --- class/class.paginations.php | 5 +++-- functions/func.parserequest.php | 29 ++++++++++++++++++----------- inc/sitemap.php | 7 +++---- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/class/class.paginations.php b/class/class.paginations.php index 65e71aa..285bf58 100644 --- a/class/class.paginations.php +++ b/class/class.paginations.php @@ -91,7 +91,7 @@ if ($curent_page - 1 == 1) { $search = array('[link]', '[page]', '[name]'); - $replace = array($template_label, $curent_page, $pagination_prev_label); + $replace = array($template_label, $curent_page-1, $pagination_prev_label); $link = str_replace($search, $replace, $pagination_link_template); @@ -100,6 +100,7 @@ // Если больше 2х else { + $search = array('[link]', '[page]', '[name]'); $replace = array($template_label, $curent_page - 1, $pagination_prev_label); @@ -181,7 +182,7 @@ // Если пришел внешний контейнер для if ($pagination_box_ext != '') $pagination = sprintf($pagination_box_ext, $pagination); - else if (pagination_box != '') + else if ($pagination_box != '') $pagination = sprintf($pagination_box, $pagination); } diff --git a/functions/func.parserequest.php b/functions/func.parserequest.php index 251cc6d..583664f 100755 --- a/functions/func.parserequest.php +++ b/functions/func.parserequest.php @@ -370,7 +370,7 @@ function showrequestelement($mixed, $template = '', $tparams = '') // Возвращаем поле из БД документа $item = preg_replace_callback('/\[tag:doc:([a-zA-Z0-9-_]+)\]/u', - function ($match) + function ($match) use ($row) { return isset($row->{$match[1]}) ? $row->{$match[1]} @@ -570,28 +570,35 @@ function request_parse($id, $params = array()) { foreach($params['SORT'] as $fid => $sort) { - $fid = (int)get_field_num($request->rubric_id, $fid); - - if ((int)$fid <= 0) - continue; + if (is_numeric($fid)) + $fid = (int)get_field_num($request->rubric_id, $fid); - $sort = strtolower($sort); + if ((int)$fid > 0) + { + $sort = strtolower($sort); - $request_join[$fid] = ""; + $request_join[$fid] = ""; - $asc_desc = strpos(strtolower($sort),'asc') !== false ? 'ASC' : 'DESC'; + $asc_desc = strpos(strtolower($sort),'asc') !== false ? 'ASC' : 'DESC'; - $request_order['field-'.$fid] = "t$fid.field_value " . $asc_desc; + $request_order['field-'.$fid] = "t$fid.field_value " . $asc_desc; - $request_order_fields[] = $fid; + $request_order_fields[] = $fid; + } + else + { + $asc_desc = strpos(strtolower($sort),'asc') !== false ? 'ASC' : 'DESC'; + $request_order[$param] = "$fid " . $asc_desc; + } } } // Сортировка по полю из настроек (только если не передана другая в параметрах) elseif ($request->request_order_by_nat) { $fid = (int)$request->request_order_by_nat; + // Добавляем с учётом переменной $t из условий, чтобы не выбирать те же таблиы заново - это оптимизирует время - $request_join[$fid] = ""; + $request_join[$fid] = ""; $request_order['field-' . $fid] = "t$fid.field_value " . $request->request_asc_desc; $request_order_fields[] = $fid; diff --git a/inc/sitemap.php b/inc/sitemap.php index 11675c0..6fee20d 100644 --- a/inc/sitemap.php +++ b/inc/sitemap.php @@ -31,8 +31,7 @@ require_once (BASE_DIR . '/inc/init.php'); - if (! defined('ABS_PATH')) - define ('ABS_PATH', str_ireplace(BASE_DIR,'/',str_replace("\\", "/", dirname(dirname(__FILE__))))); + $abs_path = str_ireplace(BASE_DIR, '/', str_replace("\\", "/", dirname(dirname(__FILE__)))); if (isset ($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { @@ -92,8 +91,8 @@ echo ''; $res = $AVE_DB->Query($sql); while ($row = $res->FetchAssocArray()): - $document_alias = ABS_PATH . $row['document_alias'] . URL_SUFF; - $document_alias = $domain . str_ireplace(ABS_PATH . '/' . URL_SUFF, '/', $document_alias); + $document_alias = $abs_path . $row['document_alias'] . URL_SUFF; + $document_alias = $domain . str_ireplace($abs_path . '/' . URL_SUFF, '/', $document_alias); $date = $row["document_changed"] ? date("Y-m-d", $row["document_changed"]) : date("Y-m-d"); ?>