diff --git a/class/class.debug.php b/class/class.debug.php
index 373b9da..a497367 100644
--- a/class/class.debug.php
+++ b/class/class.debug.php
@@ -1025,6 +1025,8 @@
$out .= 'Memory peak usage: ' . self::getStatistic('peak');
$out .= '
';
$out .= 'SQL Queries: ' . $AVE_DB->DBProfilesGet('count') . ' for ' . $AVE_DB->DBProfilesGet('time') . ' sec';
+ $out .= '
';
+ $out .= 'All SQL Queries: ' . count($AVE_DB->_query_list);
$out .= '';
$out .= PHP_EOL;
diff --git a/class/class.rubs.php b/class/class.rubs.php
index 43cbd18..1e98017 100755
--- a/class/class.rubs.php
+++ b/class/class.rubs.php
@@ -293,6 +293,7 @@
}
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
$message = $AVE_Template->get_config_vars('RUBRIK_REP_QUICKSAVE_T');
$header = $AVE_Template->get_config_vars('RUBRIK_REP_QUICKSAVE_H');
@@ -526,6 +527,7 @@
// Удалить КЕШ
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
// Удалить файлы шаблонов
$this->clearTemplates($rubric_id);
@@ -950,6 +952,7 @@
// Очищаем кэш рубрики
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
if ($sql->_result === false)
{
@@ -996,6 +999,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
if ($sql->_result === false)
{
@@ -1108,6 +1112,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
$message = $AVE_Template->get_config_vars('RUBRIK_FILDS_SAVED');
$header = $AVE_Template->get_config_vars('RUBRIK_FILDS_SUCCESS');
@@ -1313,6 +1318,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
if ($sql === false)
{
@@ -1403,6 +1409,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
$message = $AVE_Template->get_config_vars('RUBRIC_SAVED_PERMS');
$header = $AVE_Template->get_config_vars('RUBRIC_SUCCESS');
@@ -1646,6 +1653,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
if ($sql === false)
{
@@ -2154,6 +2162,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
if ($sql === false)
{
@@ -2222,6 +2231,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
// Сохраняем системное сообщение в журнал
reportLog($AVE_Template->get_config_vars('RUBRIC_TMPLS_LOG_DEL') . ' - ' . stripslashes(htmlspecialchars($this->rubricNameByIdGet($rubric_id)->rubric_title, ENT_QUOTES)) . ' (Id шаблона: '.$rubric_id.')');
@@ -2352,7 +2362,7 @@
a.rubric_id
");
- $rubrics = array();
+ $rubrics = [];
while ($row = $sql->FetchRow())
{
@@ -2497,6 +2507,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
$message = 'Шаблон успешнно сохранен';
$header = 'Выполнено';
@@ -2549,6 +2560,7 @@
");
$AVE_DB->clearCache('rub_' . $rubric_id);
+ $this->clearChanges();
header('Location:' . get_referer_link());
exit;
@@ -2559,5 +2571,12 @@
{
}
+
+
+ function clearChanges()
+ {
+ $cache_file = BASE_DIR . '/tmp/cache/sql/rubrics/all/rubrics.cahnges';
+ unlink($cache_file);
+ }
}
?>
\ No newline at end of file
diff --git a/functions/func.documents.php b/functions/func.documents.php
index 824e991..da2729c 100644
--- a/functions/func.documents.php
+++ b/functions/func.documents.php
@@ -129,11 +129,14 @@
$sql = "
SELECT
# DOCUMENT = $doc_id
- *
+ doc.*
FROM
- " . PREFIX . "_documents
+ " . PREFIX . "_documents AS doc
+ LEFT JOIN
+ " . PREFIX . "_rubrics AS rub
+ ON rub.Id = doc.rubric_id
WHERE
- Id = '" . $doc_id . "'
+ doc.Id = '" . $doc_id . "'
";
$cache_time = (defined('CACHE_DOC_FILE') && CACHE_DOC_FILE)
diff --git a/functions/func.fields.php b/functions/func.fields.php
index bbd6ef6..7fcaa5d 100644
--- a/functions/func.fields.php
+++ b/functions/func.fields.php
@@ -427,6 +427,24 @@
if (! is_numeric($document_id))
return false;
+ static $rubric_changed_fields = [];
+
+ if (! isset($AVE_Core) || $AVE_Core->curentdoc->Id != $document_id)
+ {
+ if (! isset($rubric_changed_fields[$document_id]))
+ $rubric_id = get_document($document_id, 'rubric_id');
+ $rubric_changed_fields[$document_id] = get_rubrics_changes($rubric_id, 'rubric_changed_fields');
+
+ $cache_time = $rubric_changed_fields[$document_id];
+ }
+ else
+ {
+ $cache_time = $AVE_Core->curentdoc->rubric_changed_fields;
+ }
+
+ if ($cache_time == 0)
+ $cache_time = -1;
+
if (! isset($document_fields[$document_id]))
{
$document_fields[$document_id] = false;
@@ -462,7 +480,7 @@
# DOC FIELDS = $document_id
";
- $cache_id = (int)$AVE_Core->curentdoc->Id;
+ $cache_id = (int)$document_id;
$cache_id = 'documents/' . (floor($cache_id / 1000)) . '/' . $cache_id;
$cache_file = md5($query) . '.fields';
@@ -477,12 +495,9 @@
// Получаем время создания файла
$file_time = filemtime($cache_dir . $cache_file);
- // Получаем время для проверки
- $cache_time = $AVE_Core->curentdoc->rubric_changed_fields;
-
// Сравниваем временные метки
- if (! $cache_time || $cache_time > $file_time)
- unlink ($cache_dir . $cache_file);
+ if (! $cache_time || $cache_time > $file_time || $cache_time == 0)
+ unlink($cache_dir . $cache_file);
}
$cache_time = (defined('CACHE_DOC_FILE') && CACHE_DOC_FILE)
diff --git a/functions/func.parserequest.php b/functions/func.parserequest.php
index e3fb1f8..257a41f 100755
--- a/functions/func.parserequest.php
+++ b/functions/func.parserequest.php
@@ -74,6 +74,8 @@
condition_position ASC;
";
+ $request_settings = request_get_settings($id);
+
$sql_ak = $AVE_DB->Query($sql, -1, 'rqc_' . $id, true, '.conditions');
// Обрабатываем выпадающие списки
@@ -111,6 +113,24 @@
$numeric = [];
+ if (! defined('ACP'))
+ {
+ $query = "
+ SELECT
+ Id,
+ rubric_field_numeric
+ FROM
+ " . PREFIX . "_rubric_fields
+ WHERE
+ rubric_id = '". $request_settings->rubric_id."'
+ ";
+
+ $sql = $AVE_DB->Query($query);
+
+ while ($row = $sql->FetchAssocArray())
+ $numeric[$row['Id']] = $row['rubric_field_numeric'];
+ }
+
while ($row_ak = $sql_ak->FetchRow())
{
// id поля рубрики
@@ -1053,6 +1073,7 @@
$GLOBALS['block_generate']['REQUESTS'][$id]['ELEMENTS'][$item_num] = Debug::endTime('ELEMENT_' . $item_num);
+ $item = str_replace('[tag:item_num]', $item_num, $item);
$item = '<'.'?php $item_num='.var_export($item_num,1).'; $last_item='.var_export($last_item,1).'?'.'>'.$item;
$item = '<'.'?php $req_item_id = ' . $row->Id . '; ?>' . $item;
$item = str_replace('[tag:if_first]', '<'.'?php if(isset($item_num) && $item_num===1) { ?'.'>', $item);
diff --git a/functions/func.rubrics.php b/functions/func.rubrics.php
new file mode 100644
index 0000000..bb34c1e
--- /dev/null
+++ b/functions/func.rubrics.php
@@ -0,0 +1,62 @@
+Query($query);
+
+ $rubrics = [];
+
+ while ($row = $sql->FetchAssocArray())
+ $rubrics[$row['Id']] = $row;
+
+ if ($cache_file)
+ file_put_contents($cache_file, serialize($rubrics));
+ }
+
+ if ($rubric_id > 0)
+ {
+ if (! empty($var))
+ return $rubrics[$rubric_id][$var];
+ else
+ return $rubrics[$rubric_id];
+ }
+ else
+ {
+ return $rubrics;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/inc/init.php b/inc/init.php
index 5e0ccf1..782be20 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -199,6 +199,7 @@
require_once (BASE_DIR . '/functions/func.breadcrumbs.php'); // Хлебные крошки
require_once (BASE_DIR . '/functions/func.common.php'); // Основные функции
require_once (BASE_DIR . '/functions/func.locale.php'); // Языковые функции
+ require_once (BASE_DIR . '/functions/func.rubrics.php'); // Функции по работе с рубриками
require_once (BASE_DIR . '/functions/func.documents.php'); // Функции по работе с документами
require_once (BASE_DIR . '/functions/func.fields.php'); // Функции по работе с полями
require_once (BASE_DIR . '/functions/func.helpers.php'); // Второстепенные функции