Skip to content

Commit

Permalink
#5123 - FAQ make AaQ field required and add min char limit
Browse files Browse the repository at this point in the history
Needs additional fix in form_handler to support minlength attribute for textarea
  • Loading branch information
Moc committed Nov 30, 2023
1 parent 05727b8 commit 3ad27cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions e107_plugins/faqs/admin_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion e107_plugins/faqs/faqs_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -55,6 +56,11 @@ public function __construct()
$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.
Expand Down Expand Up @@ -331,7 +337,7 @@ function sc_faq_submit_question($parms=null)
{
$text .= $frm->open('faq-ask-question','post');
//TODO LAN ie. [x] character limit.
$text .= "<div>".$frm->textarea('ask_a_question','',3, 80 ,array('maxlength' =>$this->questionCharLimit, 'size' =>'xxlarge', 'placeholder' =>LAN_FAQS_012, 'wrap' =>'soft'))."
$text .= "<div>".$frm->textarea('ask_a_question','',3, 80 ,array('required' => true, 'maxlength' => $this->questionCharLimit, 'minlength' => $this->questionCharMinLimit, 'size' =>'xxlarge', 'placeholder' =>LAN_FAQS_012, 'wrap' =>'soft'))."
<div class='faq-char-limit'><small>".$this->questionCharLimit." ".LAN_FAQS_013."</small></div>".$frm->submit('submit_a_question',LAN_SUBMIT)."</div>";

$text .= $frm->close();
Expand Down
1 change: 1 addition & 0 deletions e107_plugins/faqs/languages/English/English_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
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");
Expand Down
2 changes: 2 additions & 0 deletions e107_plugins/faqs/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<pref name="add_faq">255</pref>
<pref name="submit_question">255</pref>
<pref name="submit_question_limit">3</pref>
<pref name="submit_question_char_limit">255</pref>
<pref name="submit_question_char_min">20</pref>
<pref name="classic_look">0</pref>
<pref name="display_social">1</pref>
<pref name="display_datestamp">1</pref>
Expand Down

0 comments on commit 3ad27cd

Please sign in to comment.