[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] FAQs: restore comment toggle behavior and align title length validation
Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69c835e955f18_3b18f31c764@gitlab-sidekiq-low-urgency-cpu-bound-v2-566f8746dd-27w8l.mail> |
Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
e70aaaf3 by Olivier Kango at 2026-03-28T20:04:00+00:00
[FIX] FAQs: restore comment toggle behavior and align title length validation
---
* [FIX] restore docblock for MAX_FAQ_TITLE_LENGTH constant
* tiki-view_faq: replace legacy comments block with comment_toggle pattern
* Improve comment button
* [FIX] FAQs: use shared title length constant instead of FAQ-specific schema lookup
* FIX] FAQ comments: restore toggle behavior and fix AJAX post form template
See merge request tikiwiki/tiki!9786
- - - - -
3 changed files:
- lib/faqs/faqlib.php
- templates/tiki-view_faq.tpl
- tiki-list_faqs.php
Changes:
=====================================
lib/faqs/faqlib.php
=====================================
@@ -13,34 +13,11 @@
class FaqLib extends TikiLib
{
/**
- * Fallback limit of the title field of the tiki_faqs table.
+ * Maximum length of the title field of the tiki_faqs table.
+ * Should match the varchar length defined in the DB schema.
*/
public const MAX_FAQ_TITLE_LENGTH = 200;
- /**
- * Reads the FAQ title length directly from DB schema to avoid hardcoded usage.
- * Falls back to MAX_FAQ_TITLE_LENGTH if schema lookup fails.
- */
- public function getFaqTitleMaxLength(): int
- {
- static $cachedLength = null;
-
- if ($cachedLength !== null) {
- return $cachedLength;
- }
-
- $column = $this->fetchAll("SHOW COLUMNS FROM `tiki_faqs` LIKE 'title'");
- $type = is_array($column) ? ($column[0]['Type'] ?? '') : '';
-
- if (preg_match('/^varchar\((\d+)\)/i', $type, $matches)) {
- $cachedLength = (int) $matches[1];
- return $cachedLength;
- }
-
- $cachedLength = self::MAX_FAQ_TITLE_LENGTH;
- return $cachedLength;
- }
-
/**
* @param $offset
* @param $maxRecords
=====================================
templates/tiki-view_faq.tpl
=====================================
@@ -60,15 +60,6 @@
{if $faq_info.canSuggest eq 'y' and $tiki_p_suggest_faq eq 'y'}
{button href="javascript:flip('faqsugg');" _flip_id="faqsugg" _text="{tr}Add Suggestion{/tr}"}
{/if}
-
- {if $prefs.feature_faq_comments == 'y'
- && (($tiki_p_read_comments == 'y'
- && $comments_count != 0)
- || $tiki_p_post_comments == 'y'
- || $tiki_p_edit_comments == 'y')
- }
- {include file='comments_button.tpl'}
- {/if}
</div>
{if $faq_info.canSuggest eq 'y' and $tiki_p_suggest_faq eq 'y'}
@@ -133,14 +124,15 @@
</footer>
{/if}
-{if $prefs.feature_faq_comments == 'y'
-&& ($tiki_p_read_comments == 'y'
-|| $tiki_p_post_comments == 'y'
-|| $tiki_p_edit_comments == 'y')}
- <div id="comment-container" class="my-3 mx-0" data-bs-target="{service controller=comment action=list type=faq objectId=$faqId}"></div>
- {jq}
- var id = '#comment-container';
- $(id).comment_load($(id).data('bs-target'));
- $(document).on("ajaxComplete", function(){$(id).tiki_popover();});
- {/jq}
+{if $prefs.feature_faq_comments == 'y' && !empty($faqId)
+ && ($tiki_p_read_comments == 'y'
+ || $tiki_p_post_comments == 'y'
+ || $tiki_p_edit_comments == 'y')}
+ <div id="page-bar" class="btn-group">
+ <span class="button btn-primary"><a id="comment-toggle" href="{service controller=comment action=list type=faq objectId=$faqId}#comment-container">{tr}Comments{/tr}</a></span>
+ {jq}
+ $('#comment-toggle').comment_toggle();
+ {/jq}
+ </div>
+ <div id="comment-container" class="my-3 mx-0"></div>
{/if}
=====================================
tiki-list_faqs.php
=====================================
@@ -32,7 +32,7 @@ $auto_query_args = ['offset', 'find', 'sort_mode', 'faqId'];
$access->check_feature('feature_faqs');
$access->check_permission('tiki_p_view_faqs');
//get_strings tra('Admin FAQs')
-$maxFaqTitleLength = $faqlib->getFaqTitleMaxLength();
+$maxFaqTitleLength = FaqLib::MAX_FAQ_TITLE_LENGTH;
$smarty->assign('MAX_FAQ_TITLE_LENGTH', $maxFaqTitleLength);
if (! isset($_REQUEST["faqId"])) {
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e70aaaf34f33661bb4ef6d54a5a3498aebd910cd
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e70aaaf34f33661bb4ef6d54a5a3498aebd910cd
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs