From 3ad27cd8c2a4731026748f422a243e89b2518783 Mon Sep 17 00:00:00 2001 From: Moc Date: Thu, 30 Nov 2023 21:41:32 +0100 Subject: [PATCH] #5123 - FAQ make AaQ field required and add min char limit Needs additional fix in form_handler to support minlength attribute for textarea --- e107_plugins/faqs/admin_config.php | 1 + e107_plugins/faqs/faqs_shortcodes.php | 8 +++++++- e107_plugins/faqs/languages/English/English_admin.php | 1 + e107_plugins/faqs/plugin.xml | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/e107_plugins/faqs/admin_config.php b/e107_plugins/faqs/admin_config.php index 2c9b50565..cb80cd4f4 100644 --- a/e107_plugins/faqs/admin_config.php +++ b/e107_plugins/faqs/admin_config.php @@ -238,6 +238,7 @@ class faq_main_ui extends e_admin_ui 'submit_question' => array('title'=> LANA_FAQ_PREF_2, 'tab'=>1, 'type'=>'userclass' ), 'submit_question_limit' => array('title'=> LANA_FAQ_PREF_4, 'tab'=>1, 'type'=>'number', 'data'=>'int', 'help'=>LANA_FAQ_PREF_HELP_1), 'submit_question_char_limit'=> array('title'=> LANA_FAQ_PREF_5, 'tab'=>1, 'type'=>'number', 'data'=>'int', 'help'=>LANA_FAQ_PREF_HELP_1, 'writeParms'=>array('max'=>255, 'default'=>255)), + 'submit_question_char_min'=> array('title'=> LANA_FAQ_PREF_24, 'tab'=>1, 'type'=>'number', 'data'=>'int', 'help'=>LANA_FAQ_PREF_HELP_1, 'writeParms'=> array('default'=> 20)), 'submit_question_language' => array('title'=> LANA_FAQ_PREF_6, 'tab'=>1, 'type'=>'dropdown' ), 'submit_question_acknowledgement'=> array('title'=> LANA_FAQ_PREF_7, 'tab'=>1, 'type'=>'textarea', 'help'=>LANA_FAQ_PREF_HELP_2), //new display tab diff --git a/e107_plugins/faqs/faqs_shortcodes.php b/e107_plugins/faqs/faqs_shortcodes.php index c1f44f294..0371da21a 100644 --- a/e107_plugins/faqs/faqs_shortcodes.php +++ b/e107_plugins/faqs/faqs_shortcodes.php @@ -30,6 +30,7 @@ class faqs_shortcodes extends e_shortcode private $share = false; private $datestamp = false; private $questionCharLimit = 255; + private $questionCharMin = 20; public $pref; public $tag; public $category; @@ -55,6 +56,11 @@ class faqs_shortcodes extends e_shortcode $this->questionCharLimit = intval($pref['submit_question_char_limit']); } + if(!empty($pref['submit_question_char_min'])) + { + $this->questionCharMin = intval($pref['submit_question_char_min']); + } + } // Simply FAQ count when needed. @@ -331,7 +337,7 @@ class faqs_shortcodes extends e_shortcode { $text .= $frm->open('faq-ask-question','post'); //TODO LAN ie. [x] character limit. - $text .= "
".$frm->textarea('ask_a_question','',3, 80 ,array('maxlength' =>$this->questionCharLimit, 'size' =>'xxlarge', 'placeholder' =>LAN_FAQS_012, 'wrap' =>'soft'))." + $text .= "
".$frm->textarea('ask_a_question','',3, 80 ,array('required' => true, 'maxlength' => $this->questionCharLimit, 'minlength' => $this->questionCharMinLimit, 'size' =>'xxlarge', 'placeholder' =>LAN_FAQS_012, 'wrap' =>'soft'))."
".$this->questionCharLimit." ".LAN_FAQS_013."
".$frm->submit('submit_a_question',LAN_SUBMIT)."
"; $text .= $frm->close(); diff --git a/e107_plugins/faqs/languages/English/English_admin.php b/e107_plugins/faqs/languages/English/English_admin.php index 8168f5e05..2aaa1ffd9 100644 --- a/e107_plugins/faqs/languages/English/English_admin.php +++ b/e107_plugins/faqs/languages/English/English_admin.php @@ -40,6 +40,7 @@ define("LANA_FAQ_PREF_20", "Ascending by Date"); define("LANA_FAQ_PREF_21", "Descending by Date"); define("LANA_FAQ_PREF_22", "Manage Questions"); define("LANA_FAQ_PREF_23", "Manage Categories"); +define("LANA_FAQ_PREF_24", "Ask a Question: character min length"); define("LANA_FAQ_PREF_HELP_1", "0 = no limit"); define("LANA_FAQ_PREF_HELP_2", "Leave blank to use default"); diff --git a/e107_plugins/faqs/plugin.xml b/e107_plugins/faqs/plugin.xml index 93bac6b30..c91b54898 100644 --- a/e107_plugins/faqs/plugin.xml +++ b/e107_plugins/faqs/plugin.xml @@ -21,6 +21,8 @@ 255 255 3 + 255 + 20 0 1 1