From b577ccf73994e7900c0852dd54aa74178d42deda Mon Sep 17 00:00:00 2001 From: Repellent Date: Tue, 17 Mar 2026 21:32:33 +0500 Subject: [PATCH] update ver 3.31 --- README.md | 4 +++- class/faq.php | 34 ++++++++++++++++++++++++++---- info.php | 2 +- module.php | 4 ++-- templates/admin_faq_edit.tpl | 2 +- templates/admin_quest_edit.tpl | 12 +++++------ templates/show_faq.tpl | 38 ++++++++++++++++------------------ 7 files changed, 61 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index b1fc330..3866dbc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ### faq -### Вопрос | ответ v1.26.1 +### Вопрос | ответ v3.31 ### Модуль создания раширенной справочной системы на основе тегов. @@ -8,6 +8,8 @@ ### Changelog: +17.03.2026 - версия 3.31 + 04.09.2019 - версия 1.26.1 26.11.2015 - версия 1.0.1 \ No newline at end of file diff --git a/class/faq.php b/class/faq.php index 3510c5a..4993ae3 100644 --- a/class/faq.php +++ b/class/faq.php @@ -58,7 +58,7 @@ class Faq $AVE_DB->Query("DELETE FROM " . PREFIX . "_module_faq WHERE id = '" . $_GET['fid'] . "'"); $AVE_DB->Query("DELETE FROM " . PREFIX . "_module_faq_quest WHERE faq_id = '" . $_GET['fid'] . "'"); - $AVE_Template->clear_cache($tpl_dir . 'show_faq.tpl', $_GET['fid']); + self::_clearFaqCache(); } header("Location:index.php?do=modules&action=modedit&mod=faq&moduleaction=1&cp=" . SESSION); @@ -80,7 +80,7 @@ class Faq { $AVE_DB->Query("UPDATE " . PREFIX . "_module_faq SET faq_title = '" . mb_substr($faq_title, 0, 100) . "', faq_description = '" . mb_substr($_POST['faq_description'][$id], 0, 255) . "' WHERE id = '" . $id . "'"); - $AVE_Template->clear_cache($tpl_dir . 'show_faq.tpl', $id); + self::_clearFaqCache(); } } @@ -204,7 +204,7 @@ class Faq } } - $AVE_Template->clear_cache($tpl_dir . 'show_faq.tpl', $_POST['fid']); + self::_clearFaqCache(); header("Location:index.php?do=modules&action=modedit&mod=faq&moduleaction=questlist&fid=" . $_POST['fid'] . "&cp=" . SESSION); exit; @@ -229,7 +229,7 @@ class Faq $AVE_DB->Query("DELETE FROM " . PREFIX . "_module_faq_quest WHERE faq_id = '" . $_GET['fid'] . "' AND id = '" . $_GET['id'] . "'"); - $AVE_Template->clear_cache($tpl_dir . 'show_faq.tpl', $_GET['fid']); + self::_clearFaqCache(); header("Location:index.php?do=modules&action=modedit&mod=faq&moduleaction=questlist&fid=" . $_GET['fid'] . "&cp=" . SESSION); exit; @@ -253,6 +253,32 @@ class Faq $AVE_Template->assign($faq); $AVE_Template->assign('questions', $questions); } + + /** + * Очистка кэша модуля FAQ + */ + private static function _clearFaqCache() + { + global $AVE_Template; + + $cache_dir = $AVE_Template->getCacheDir(); + + if (is_dir($cache_dir)) { + $files = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($cache_dir, RecursiveDirectoryIterator::SKIP_DOTS), + RecursiveIteratorIterator::CHILD_FIRST + ); + + foreach ($files as $fileinfo) { + + if ($fileinfo->isFile() && strpos($fileinfo->getFilename(), 'show_faq') !== false) { + @unlink($fileinfo->getRealPath()); + } + } + } + + $AVE_Template->clearCompiledTemplate('show_faq.tpl'); + } } ?> diff --git a/info.php b/info.php index 4995393..154047a 100644 --- a/info.php +++ b/info.php @@ -4,7 +4,7 @@ $module = array( 'ModuleSysName' => 'faq', - 'ModuleVersion' => '1.26.1', + 'ModuleVersion' => '3.31', 'ModuleAutor' => 'Freeon', 'ModuleCopyright' => '© 2007-' . date('Y') . ' AVE.cms', 'ModuleStatus' => 1, diff --git a/module.php b/module.php index 89a4133..53d5cf4 100644 --- a/module.php +++ b/module.php @@ -25,11 +25,11 @@ function mod_faq($id) $tpl_dir = BASE_DIR . '/modules/faq/templates/'; // Путь к шаблону модуля - // Если нету в кеше, то начинаем обрабатывать + // Если нет в кеше, то начинаем обрабатывать if (!$AVE_Template->is_cached($tpl_dir . 'show_faq.tpl', $id)) { // Проверяем, есть ли папка для кеша, если нет (первый раз) — создаем - if (!is_dir($AVE_Template->cache_dir)) + if (!is_dir($AVE_Template->getCacheDir())) { $oldumask = umask(0); @mkdir($AVE_Template->cache_dir, 0777); diff --git a/templates/admin_faq_edit.tpl b/templates/admin_faq_edit.tpl index 57dccc5..3c942a3 100644 --- a/templates/admin_faq_edit.tpl +++ b/templates/admin_faq_edit.tpl @@ -20,7 +20,7 @@
-
{if $smarty.request.id != ''}{#FAQ_EDIT_RUB#}{else}{#FAQ_EDIT_RUB#}{/if}
+
{if isset($smarty.request.id) && $smarty.request.id != ''}{#FAQ_EDIT_RUB#}{else}{#FAQ_EDIT_RUB#}{/if}
diff --git a/templates/admin_quest_edit.tpl b/templates/admin_quest_edit.tpl index 7cc9a45..69c0877 100644 --- a/templates/admin_quest_edit.tpl +++ b/templates/admin_quest_edit.tpl @@ -24,7 +24,7 @@
-
{if $smarty.request.id != ''}{#FAQ_EDIT_RUB#}{else}{#FAQ_EDIT_RUB#}{/if}
+
{if ($smarty.request.id|default:'') != ''}{#FAQ_EDIT_RUB#}{else}{#FAQ_EDIT_RUB#}{/if}
@@ -38,9 +38,9 @@
- {if $smarty.session.use_editor == 0} + {if ($smarty.session.use_editor|default:0) == 0} {$faq_quest} - {elseif $smarty.session.use_editor == 1} + {elseif ($smarty.session.use_editor|default:0) == 1} {/if}
@@ -54,9 +54,9 @@
- {if $smarty.session.use_editor == 0} + {if ($smarty.session.use_editor|default:0) == 0} {$faq_answer} - {elseif $smarty.session.use_editor == 1} + {elseif ($smarty.session.use_editor|default:0) == 1} {/if}
@@ -72,4 +72,4 @@ -
+
\ No newline at end of file diff --git a/templates/show_faq.tpl b/templates/show_faq.tpl index 55cf54c..e1328f8 100644 --- a/templates/show_faq.tpl +++ b/templates/show_faq.tpl @@ -1,24 +1,22 @@

{$faq_title}

{if $questions} -
-{foreach from=$questions item=question} -

{$question->faq_quest}

-
-

{$question->faq_quest}

- {$question->faq_answer} -
-{/foreach} -
-{literal} - -{/literal} +
+ {foreach from=$questions item=question name=faq} +
+

+ +

+
+
+ {$question->faq_answer} +
+
+
+ {/foreach} +
+{else} +
{#FAQ_NO_QUESTIONS#}
{/if}