public function showSearchBox($q = false, $courseID = false, $searchInCourse = false, $showAllResults = false, $showOptions = true, $placeholderText = null)
 {
     global $SITE;
     //Begin form
     $r = html_writer::start_tag('form', array('action' => $this->block->getFullURL(), 'method' => 'get', 'class' => 'searchBlockForm'));
     if ($placeholderText === null) {
         $placeholderText = $this->str('search_input_text_page');
     }
     //Input box
     $r .= html_writer::empty_tag('input', array('type' => 'text', 'placeholder' => $placeholderText, 'value' => $q, 'class' => 'searchBlockInput', 'name' => 'q'));
     //Search Button
     $icon = html_writer::tag('i', '', array('class' => 'fa fa-search'));
     $r .= html_writer::tag('button', $icon . ' ' . $this->str('search'), array('class' => 'searchButton'));
     if ($showOptions) {
         $r .= html_writer::start_tag('div', array('class' => 'options'));
         $allowNoAccess = get_config('block_search', 'allow_no_access');
         $showOptionsTitle = $allowNoAccess || !empty($courseID);
         if ($showOptionsTitle) {
             $icon = html_writer::tag('i', '', array('class' => 'fa fa-cogs'));
             $r .= '<strong>' . $icon . ' ' . $this->str('search_options') . '</strong>';
         }
         //If courseID is in the URL, show options to search this course or everywhere
         if ($courseID) {
             // hidden courseID field
             $r .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'courseID', 'value' => $courseID));
             $inputParams = array('type' => 'radio', 'name' => 'searchInCourse', 'value' => 0);
             if (!$searchInCourse) {
                 $inputParams['checked'] = 'checked';
             }
             $r .= html_writer::tag('label', html_writer::empty_tag('input', $inputParams) . $this->str('search_all_of_site', $SITE->shortname));
             $inputParams = array('type' => 'radio', 'name' => 'searchInCourse', 'value' => 1);
             if ($searchInCourse) {
                 $inputParams['checked'] = 'checked';
             }
             $courseName = DataManager::getCourseName($courseID);
             $r .= html_writer::tag('label', html_writer::empty_tag('input', $inputParams) . $this->str('search_in_course', $courseName));
         }
         if ($allowNoAccess) {
             //"Show hidden results" button
             //We need to make this an array so 'checked' can only be added if necessary
             $checkboxAttributes = array('type' => 'checkbox', 'name' => 'showHiddenResults', 'value' => 1);
             if ($showAllResults) {
                 $checkboxAttributes['checked'] = 'checked';
             }
             $checkbox = html_writer::empty_tag('input', $checkboxAttributes);
             $r .= html_writer::tag('label', $checkbox . $this->str('include_hidden_results'));
         }
         $r .= html_writer::end_tag('div');
     } elseif ($courseID) {
         //If we're not showing the options, but have a courseID we still need to add that to the form
         $r .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'courseID', 'value' => $courseID));
     }
     $r .= html_writer::end_tag('form');
     return $r;
 }
 public function showSearchBox($q = false, $courseID = false, $searchInCourse = false, $showOptions = true, $placeholderText = null)
 {
     global $SITE;
     //Begin form
     $r = html_writer::start_tag('form', array('action' => $this->block->getFullURL(), 'method' => 'get', 'class' => 'searchBlockForm'));
     if ($placeholderText === null) {
         $placeholderText = $this->str('search_input_text_page');
     }
     //Input box
     $r .= html_writer::empty_tag('input', array('type' => 'text', 'placeholder' => $placeholderText, 'value' => $q, 'class' => 'searchBlockInput', 'name' => 'q'));
     //Search Button
     $icon = html_writer::tag('i', '', array('class' => 'fa fa-search'));
     $r .= html_writer::tag('button', $icon . ' ' . $this->str('search'), array('class' => 'searchButton'));
     if ($showOptions) {
         $r .= html_writer::start_tag('div', array('class' => 'options'));
         if (!empty($courseID)) {
             $icon = html_writer::tag('i', '', array('class' => 'fa fa-cogs'));
             $r .= '<strong>' . $icon . ' ' . $this->str('search_options') . '</strong>';
         }
         //If courseID is in the URL, show options to search this course or everywhere
         if ($courseID) {
             // hidden courseID field
             $r .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'courseID', 'value' => $courseID));
             $inputParams = array('type' => 'radio', 'name' => 'searchInCourse', 'value' => 0);
             if (!$searchInCourse) {
                 $inputParams['checked'] = 'checked';
             }
             $r .= html_writer::tag('label', html_writer::empty_tag('input', $inputParams) . $this->str('search_all_of_site', $SITE->shortname));
             $inputParams = array('type' => 'radio', 'name' => 'searchInCourse', 'value' => 1);
             if ($searchInCourse) {
                 $inputParams['checked'] = 'checked';
             }
             $courseName = DataManager::getCourseName($courseID);
             $r .= html_writer::tag('label', html_writer::empty_tag('input', $inputParams) . $this->str('search_in_course', $courseName));
         }
         $r .= html_writer::end_tag('div');
     } elseif ($courseID) {
         //If we're not showing the options, but have a courseID we still need to add that to the form
         $r .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'courseID', 'value' => $courseID));
     }
     $r .= html_writer::end_tag('form');
     return $r;
 }