Browse Source

Fixes

master
M@d D3n 4 years ago
parent
commit
4559cc3688
  1. 2
      class/class.debug.php
  2. 21
      class/class.rubs.php
  3. 9
      functions/func.documents.php
  4. 27
      functions/func.fields.php
  5. 21
      functions/func.parserequest.php
  6. 62
      functions/func.rubrics.php
  7. 1
      inc/init.php

2
class/class.debug.php

@ -1025,6 +1025,8 @@
$out .= 'Memory peak usage: ' . self::getStatistic('peak');
$out .= '<br>';
$out .= 'SQL Queries: ' . $AVE_DB->DBProfilesGet('count') . ' for ' . $AVE_DB->DBProfilesGet('time') . ' sec';
$out .= '<br>';
$out .= 'All SQL Queries: ' . count($AVE_DB->_query_list);
$out .= '</div>';
$out .= PHP_EOL;

21
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);
}
}
?>

9
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)

27
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)

21
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);

62
functions/func.rubrics.php

@ -0,0 +1,62 @@
<?php
/**
* Функция отдает время когда менялась рубрика или ее поля
*
* @param int $rubric_id
* @param int $var
*
* @return mixed
*/
function get_rubrics_changes ($rubric_id = null, $var = '')
{
global $AVE_DB;
$cache_file = BASE_DIR . '/tmp/cache/sql/rubrics/all/rubrics.cahnges';
// Если включен DEV MODE, то отключаем кеширование запросов
if (defined('DEV_MODE') and DEV_MODE)
$cache_file = null;
if (! is_dir(dirname($cache_file)))
mkdir(dirname($cache_file), 0766, true);
if (file_exists($cache_file))
{
$rubrics = unserialize(file_get_contents($cache_file));
}
else
{
$query = "
SELECT
Id,
rubric_changed,
rubric_changed_fields
FROM
" . PREFIX . "_rubrics
";
$sql = $AVE_DB->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;
}
}
?>

1
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'); // Второстепенные функции

Loading…
Cancel
Save