/** * vB_Search_Type::makeSearch() * If we have a new search type this will create a search interface for it. * This assumes we have written search and index controllers * * @param mixed $prefs : the array of user preferences * @param mixed $contenttypeid : the content type for which we are going to * search * @param array registers : any additional elements to be registered. These are * just passed to the template * @param string $template_name : name of the template to use for display. We have * a default template. * @param boolean $groupable : a flag to tell whether the interface should display * grouping option(s). * @return the html for the user interfacae */ public function listUi($prefs = null, $contenttypeid = null, $registers = null, $template_name = null) { global $vbulletin, $vbphrase; if (is_null($contenttypeid)) { $contenttypeid = vb_Search_Core::get_instance()->get_contenttypeid('vBForum', 'Post'); } if (isset($template_name)) { $template = vB_Template::create($template_name); } else if ($this->can_group()) { $template = vB_Template::create('search_input_default_groupable'); } else { $template = vB_Template::create('search_input_default'); } $template->register('securitytoken', $vbulletin->userinfo['securitytoken']); $template->register('class', $this->class); $template->register('contenttypeid', $this->get_contenttypeid()); $prefsettings = array( 'select'=> array('searchdate', 'beforeafter', 'starteronly', 'sortby', 'titleonly', 'order'), 'cb' => array('nocache', 'exactname'), 'value' => array('query', 'searchuser', 'tag')); $this->setPrefs($template, $prefs, $prefsettings); vB_Search_Searchtools::searchIntroRegisterHumanVerify($template); if (isset($registers) and is_array($registers) ) { foreach($registers as $key => $value) { $template->register($key, htmlspecialchars_uni($value)); } } return $template->render(); }
/** * Display the main search form. * * @param vB_Legacy_Current_User $user The current user for the board. * @param array $globals The array of "global" GPC items and their type defaults * @param array $navbits The navbit array * @param array $errors A list of errors to display, used for redisplaying the form on error * @param array $searchterms A map of form fields posted by the user. Used to propogate the * the form when processing fails. */ function do_intro($user, $globals, $navbits, $search_type, $errors = array(), $searchterms = array()) { global $vbulletin, $vbphrase, $prefs, $searchforumids, $show; if ($vbulletin->GPC['search_type'] OR intval($vbulletin->GPC['searchthreadid']) OR (isset($vbulletin->GPC['searchfromtype']) and strlen($vbulletin->GPC['searchfromtype']) > 6)) { $template = vB_Template::create('search_common_select_type'); } else { $template = vB_Template::create('search_common'); // we only need the list of content types if we're doing the generic $template->register('type_options', vB_Search_Searchtools::get_type_options()); if (!$prefs['type']) $prefs['type'] = array(); $template->register('selectedtypes', $prefs['type']); } search_intro_register_prefs($template, $prefs); vB_Search_Searchtools::searchIntroRegisterHumanVerify($template); //actually render any errors. search_intro_register_errors($template, $errors); $show['errors'] = !empty($errors); $show['tag_option'] = $vbulletin->options['threadtagging']; //check to see if we have a preferred type $defaulttype = null; if ($prefs['type']) { if (is_array($prefs['type'])) { $defaulttype = $prefs['type'][0]; } else { $defaulttype = $prefs['type']; } } if ($vbulletin->GPC['contenttypeid']) { $defaulttype = $vbulletin->GPC['contenttypeid']; } //If we have nothing else, let's show Posts if ($defaulttype == null) { $defaulttype = vB_Search_Core::get_instance()->get_contenttypeid('vBForum', 'Post'); } //If we have the common type, set to the default if ($search_type instanceof vBForum_Search_Type_Common) { unset($search_type); $search_type = vb_Search_Core::get_instance()->get_search_type_from_id($defaulttype); $prefs = vB_Search_Searchtools::searchIntroFetchPrefs($user, $defaulttype); } if ($vbulletin->GPC['search_type'] ) { $template->register('input_search_types', vB_Search_Searchtools::listSearchable('vb_search_params', 'search.php', $prefs, $defaulttype)); if (intval($vbulletin->GPC['contenttypeid']) OR $defaulttype) { $template->register('search_ui', $search_type->listUi($prefs, intval($vbulletin->GPC['contenttypeid']) ? $vbulletin->GPC['contenttypeid'] : $defaulttype)); } } else if (isset($vbulletin->GPC['searchfromtype']) AND strlen($vbulletin->GPC['searchfromtype']) > 6) { $template->register('input_search_types', vB_Search_Searchtools::listSearchable('vb_search_params', 'search.php', $prefs, $defaulttype)); $search_type = explode(':', $vbulletin->GPC['searchfromtype'], 2); if (count($search_type) == 2) { $search_type = vb_Search_Core::get_instance()->get_search_type($search_type[0], $search_type[1]); } else if (intval($vbulletin->GPC['contenttypeid'])) { $search_type = vb_Search_Core::get_instance()->get_search_type_from_id($vbulletin->GPC['contenttypeid']); } if (isset($search_type)) { $template->register('search_ui', $search_type->listUi($prefs, $search_type->get_contenttypeid())); } } $template->register('sessionhash', $sessionhash); search_intro_register_tagcloud($template); if ($vbulletin->debug) { $show['nocache'] = true; } // unlink the 'search' part of the navbits array_pop($navbits); $navbits[''] = $vbphrase['advanced_search']; ($hook = vBulletinHook::fetch_hook('search_intro')) ? eval($hook) : false; //finish off search ($hook = vBulletinHook::fetch_hook('search_complete')) ? eval($hook) : false; $template->register('show', $show); $template->register('navbar', render_navbar_template(construct_navbits($navbits))); $template->register_page_templates(); print_output($template->render()); }