original_string: public function search_box($id = false) {
          global $CFG;
  
          // Accessing $CFG directly as using \core_search::is_global_search_enabled would
          // result in an extra included file for each site, even the ones where global search
          // is disabled.
          if (empty($CFG->enableglobalsearch) || !has_capability('moodle/search:query', context_system::instance())) {
              return '';
          }
  
          if ($id == false) {
              $id = uniqid();
          } else {
              // Needs to be cleaned, we use it for the input id.
              $id = clean_param($id, PARAM_ALPHANUMEXT);
          }
  
          // JS to animate the form.
          $this->page->requires->js_call_amd('core/search-input', 'init', array($id));
  
          $searchicon = html_writer::tag('div', $this->pix_icon('a/search', get_string('search', 'search'), 'moodle'),
              array('role' => 'button', 'tabindex' => 0));
          $formattrs = array('class' => 'search-input-form', 'action' => $CFG->wwwroot . '/search/index.php');
          $inputattrs = array('type' => 'text', 'name' => 'q', 'placeholder' => get_string('search', 'search'),
              'size' => 13, 'tabindex' => -1, 'id' => 'id_q_' . $id, 'class' => 'form-control');
  
          $contents = html_writer::tag('label', get_string('enteryoursearchquery', 'search'),
              array('for' => 'id_q_' . $id, 'class' => 'accesshide')) . html_writer::tag('input', '', $inputattrs);
          if ($this->page->context && $this->page->context->contextlevel !== CONTEXT_SYSTEM) {
              $contents .= html_writer::empty_tag('input', ['type' => 'hidden',
                      'name' => 'context', 'value' => $this->page->context->id]);
          }
          $searchinput = html_writer::tag('form', $contents, $formattrs);
  
          return html_writer::tag('div', $searchicon . $searchinput, array('class' => 'search-input-wrapper nav-link', 'id' => $id));
      }
code: public function search_box($id = false) {
          global $CFG;
  
          // Accessing $CFG directly as using \core_search::is_global_search_enabled would
          // result in an extra included file for each site, even the ones where global search
          // is disabled.
          if (empty($CFG->enableglobalsearch) || !has_capability('moodle/search:query', context_system::instance())) {
              return '';
          }
  
          if ($id == false) {
              $id = uniqid();
          } else {
              // Needs to be cleaned, we use it for the input id.
              $id = clean_param($id, PARAM_ALPHANUMEXT);
          }
  
          // JS to animate the form.
          $this->page->requires->js_call_amd('core/search-input', 'init', array($id));
  
          $searchicon = html_writer::tag('div', $this->pix_icon('a/search', get_string('search', 'search'), 'moodle'),
              array('role' => 'button', 'tabindex' => 0));
          $formattrs = array('class' => 'search-input-form', 'action' => $CFG->wwwroot . '/search/index.php');
          $inputattrs = array('type' => 'text', 'name' => 'q', 'placeholder' => get_string('search', 'search'),
              'size' => 13, 'tabindex' => -1, 'id' => 'id_q_' . $id, 'class' => 'form-control');
  
          $contents = html_writer::tag('label', get_string('enteryoursearchquery', 'search'),
              array('for' => 'id_q_' . $id, 'class' => 'accesshide')) . html_writer::tag('input', '', $inputattrs);
          if ($this->page->context && $this->page->context->contextlevel !== CONTEXT_SYSTEM) {
              $contents .= html_writer::empty_tag('input', ['type' => 'hidden',
                      'name' => 'context', 'value' => $this->page->context->id]);
          }
          $searchinput = html_writer::tag('form', $contents, $formattrs);
  
          return html_writer::tag('div', $searchicon . $searchinput, array('class' => 'search-input-wrapper nav-link', 'id' => $id));
      }
code_tokens: public function search_box ( $ id = false ) { global $ CFG ; // Accessing $CFG directly as using \core_search::is_global_search_enabled would // result in an extra included file for each site, even the ones where global search // is disabled. if ( empty ( $ CFG -> enableglobalsearch ) || ! has_capability ( 'moodle/search:query' , context_system :: instance ( ) ) ) { return '' ; } if ( $ id == false ) { $ id = uniqid ( ) ; } else { // Needs to be cleaned, we use it for the input id. $ id = clean_param ( $ id , PARAM_ALPHANUMEXT ) ; } // JS to animate the form. $ this -> page -> requires -> js_call_amd ( 'core/search-input' , 'init' , array ( $ id ) ) ; $ searchicon = html_writer :: tag ( 'div' , $ this -> pix_icon ( 'a/search' , get_string ( 'search' , 'search' ) , 'moodle' ) , array ( 'role' => 'button' , 'tabindex' => 0 ) ) ; $ formattrs = array ( 'class' => 'search-input-form' , 'action' => $ CFG -> wwwroot . '/search/index.php' ) ; $ inputattrs = array ( 'type' => 'text' , 'name' => 'q' , 'placeholder' => get_string ( 'search' , 'search' ) , 'size' => 13 , 'tabindex' => - 1 , 'id' => 'id_q_' . $ id , 'class' => 'form-control' ) ; $ contents = html_writer :: tag ( 'label' , get_string ( 'enteryoursearchquery' , 'search' ) , array ( 'for' => 'id_q_' . $ id , 'class' => 'accesshide' ) ) . html_writer :: tag ( 'input' , '' , $ inputattrs ) ; if ( $ this -> page -> context && $ this -> page -> context -> contextlevel !== CONTEXT_SYSTEM ) { $ contents .= html_writer :: empty_tag ( 'input' , [ 'type' => 'hidden' , 'name' => 'context' , 'value' => $ this -> page -> context -> id ] ) ; } $ searchinput = html_writer :: tag ( 'form' , $ contents , $ formattrs ) ; return html_writer :: tag ( 'div' , $ searchicon . $ searchinput , array ( 'class' => 'search-input-wrapper nav-link' , 'id' => $ id ) ) ; }
docstring: Returns a search box.
  
  @param  string $id     The search box wrapper div id, defaults to an autogenerated one.
  @return string         HTML with the search form hidden by default.
docstring_tokens: Returns a search box .