From d679a45f73764ffa77dafdb6ef4ac5653df11de2 Mon Sep 17 00:00:00 2001 From: Mike Churchward Date: Wed, 11 Jan 2017 10:11:37 -0500 Subject: [PATCH] MDL-57590 mod_forum: fixed search form with forumid and actionurl. --- mod/forum/classes/output/big_search_form.php | 4 +++ mod/forum/templates/big_search_form.mustache | 33 ++++++++++++++++++- .../mod_forum/big_search_form.mustache | 33 ++++++++++++++++++- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/mod/forum/classes/output/big_search_form.php b/mod/forum/classes/output/big_search_form.php index 6a983d6e2cf98..e2bd7cee46f94 100644 --- a/mod/forum/classes/output/big_search_form.php +++ b/mod/forum/classes/output/big_search_form.php @@ -53,6 +53,8 @@ class big_search_form implements renderable, templatable { public $subject; public $user; public $words; + /** @var string The URL of the search form. */ + public $actionurl; /** * Constructor. @@ -65,6 +67,7 @@ public function __construct($course) { $this->course = $course; $this->scripturl = new moodle_url('/mod/forum/forum.js'); $this->showfullwords = $DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres'; + $this->actionurl = new moodle_url('/mod/forum/search.php'); $forumoptions = ['' => get_string('allforums', 'forum')] + forum_menu_list($course); $this->forumoptions = array_map(function($option) use ($forumoptions) { @@ -161,6 +164,7 @@ public function export_for_template(renderer_base $output) { $data->subject = $this->subject; $data->user = $this->user; $data->showfullwords = $this->showfullwords; + $data->actionurl = $this->actionurl->out(false); $datefrom = $this->datefrom; if (empty($datefrom)) { diff --git a/mod/forum/templates/big_search_form.mustache b/mod/forum/templates/big_search_form.mustache index 373694edc799a..ffdc3886a8c65 100644 --- a/mod/forum/templates/big_search_form.mustache +++ b/mod/forum/templates/big_search_form.mustache @@ -15,7 +15,38 @@ along with Moodle. If not, see . }} {{! + @template mod_forum/big_search_form + Big search form. + + Example context (json): + { + "scripturl": "https://example.com/mod/forum/forum.js", + "actionurl": "https://example.com/mod/forum/search.php", + "courseid": "2", + "words": "apples", + "phrase": "Lorem ipsum dolor", + "notwords": "Not these words", + "showfullwords": [ + { + "fullwords": "Exactly" + } + ], + "datefromchecked": 1, + "datetochecked": "", + "forumoptions": [ + { + "name": "Forum One", + "value": "23" + }, + { + "name": "Forum Two", + "value": "34" + } + ], + "subject": "Help me please", + "user": "Helpy McUser" + } }}