Пример #1
0
/**
 * 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());
}
Пример #2
0
	/**
	 * 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();
	}
Пример #3
0
 /**
  * vBForum_Search_Type_SocialGroupMessage::listUi()
  *This function generates the search elements for a user to search for group messages
  *
  *
  * @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 $html: complete html for the search elements
  */
 public function listUi($prefs = null, $contenttypeid = null, $registers = null, $template_name = null)
 {
     global $vbulletin, $vbphrase, $show;
     if (!isset($template_name)) {
         $template_name = 'search_input_groupmessage';
     }
     if (!isset($contenttypeid)) {
         $contenttypeid = vB_Search_Core::get_instance()->get_contenttypeid('vBForum', 'SocialGroupMessage');
     }
     $messagegroupoptions = $this->showGroupOptions($prefs['messagegroupid']);
     if ($messagegroupoptions) {
         $show['search_messagegroupid'] = true;
     }
     $categoryoptions = $this->showCategoryOptions($prefs['categoryid']);
     if ($categoryoptions) {
         $show['search_categoryid'] = true;
     }
     $template = vB_Template::create($template_name);
     $template->register('securitytoken', $vbulletin->userinfo['securitytoken']);
     $template->register('contenttypeid', $contenttypeid);
     $template->register('search_messagegroup_options', $messagegroupoptions);
     $template->register('search_category_options', $categoryoptions);
     $this->setPrefs($template, $prefs, array('select' => array('searchdate', 'beforeafter', 'starteronly', 'messagegroupid', 'sortby'), 'cb' => array('nocache', 'exactname'), 'value' => array('query', 'searchuser'), 'rb' => array('showposts')));
     vB_Search_Searchtools::searchIntroRegisterHumanVerify($template);
     if (isset($registers) and is_array($registers)) {
         foreach ($registers as $key => $value) {
             $template->register($key, htmlspecialchars_uni($value));
         }
     }
     ($hook = vBulletinHook::fetch_hook('search_listui_complete')) ? eval($hook) : false;
     //clean up any changes to the show variable.
     unset($show['search_messagegroupid']);
     return $template->render();
 }
Пример #4
0
 /**
  * vBForum_Search_Type_Forum::listUi()
  * This prepares the HTML for the user to search for forums
  * 
  * @param  [type] $prefs         the array of user preferences
  * @param  [type] $contenttypeid added for PHP 5.4 strict standards compliance
  * @param  [type] $registers     added for PHP 5.4 strict standards compliance
  * @param  [type] $template_name added for PHP 5.4 strict standards compliance
  * @return $html: complete html for the search elements
  */
 public function listUi($prefs = null, $contenttypeid = null, $registers = null, $template_name = null)
 {
     global $vbulletin, $show;
     $template = vB_Template::create('search_input_forum');
     $template->register('securitytoken', $vbulletin->userinfo['securitytoken']);
     $template->register('contenttypeid', vB_Search_Core::get_instance()->get_contenttypeid('vBForum', 'Forum'));
     $template->register('show', $show);
     $this->setPrefs($template, $prefs, array('select' => array('titleonly', 'threadless', 'forumdateline', 'beforeafter', 'postless', 'sortby'), 'cb' => array('nocache'), 'value' => array('query', 'threadlimit', 'postlimit')));
     vB_Search_Searchtools::searchIntroRegisterHumanVerify($template);
     ($hook = vBulletinHook::fetch_hook('search_listui_complete')) ? eval($hook) : false;
     return $template->render();
 }
Пример #5
0
 /**
  * vBForum_Search_Type_SocialGroup::listUi()
  *This function generates the search elements for a user to search for groups
  * @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 $html: complete html for the search elements
  */
 public function listUi($prefs = null, $contenttypeid = null, $registers = null, $template_name = null)
 {
     global $vbulletin, $vbphrase;
     if (!isset($template_name)) {
         $template_name = 'search_input_socialgroup';
     }
     if (!isset($contenttypeid)) {
         $contenttypeid = vB_Search_Core::get_instance()->get_contenttypeid('vBForum', 'SocialGroup');
     }
     $template = vB_Template::create($template_name);
     $template->register('securitytoken', $vbulletin->userinfo['securitytoken']);
     $template->register('contenttypeid', $contenttypeid);
     $template->register('show', $show);
     // Get categories
     $categories = fetch_socialgroup_category_options();
     $category_options = '<option value="">' . $vbphrase['any_category'] . '</option>';
     if (!isset($prefs['cat'])) {
         $prefs['cat'] = array();
     }
     foreach ($categories as $key => $name) {
         $category_options .= "<option value=\"{$key}\"" . (in_array($key, $prefs['cat']) ? ' selected="selected" ' : '') . " >" . $name['title'] . "</option>\n";
     }
     $template->register('category_options', $category_options);
     $this->setPrefs($template, $prefs, array('select' => array('titleonly', 'messageless', 'discussionless', 'pictureless', 'memberless', 'group_filter_date_lteq_month', 'group_filter_date_gteq_month', 'sortby'), 'cb' => array('nocache'), 'value' => array('query', 'messagelimit', 'discussionlimit', 'picturelimit', 'memberlimit', 'group_filter_date_lteq_day', 'group_filter_date_lteq_year', 'group_filter_date_gteq_day', 'group_filter_date_gteq_year', 'memberlimit')));
     vB_Search_Searchtools::searchIntroRegisterHumanVerify($template);
     if (isset($registers) and is_array($registers)) {
         foreach ($registers as $key => $value) {
             $template->register($key, htmlspecialchars_uni($value));
         }
     }
     ($hook = vBulletinHook::fetch_hook('search_listui_complete')) ? eval($hook) : false;
     return $template->render();
 }
Пример #6
0
 /**
  * vBForum_Search_Type_VisitorMessage::listUi()
  * This function composes the html to display the user interface for this
  * search type
  *
  * @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 $html: complete html for the search elements
  */
 public function listUi($prefs = null, $contenttypeid = null, $registers = null, $template_name = null)
 {
     global $vbulletin, $vbphrase;
     if (!isset($template_name)) {
         $template_name = 'search_input_visitormessage';
     }
     if (!isset($contenttypeid)) {
         $contenttypeid = vB_Search_Core::get_instance()->get_contenttypeid('vBForum', 'VisitorMessage');
     }
     $template = vB_Template::create($template_name);
     $template->register('securitytoken', $vbulletin->userinfo['securitytoken']);
     $template->register('class', $this->get_display_name());
     $template->register('contenttypeid', $contenttypeid);
     $prefsettings = array('select' => array('searchdate', 'beforeafter', 'starteronly', 'sortby'), 'cb' => array('nocache', 'exactname'), 'value' => array('query', 'searchuser'));
     $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));
         }
     }
     ($hook = vBulletinHook::fetch_hook('search_listui_complete')) ? eval($hook) : false;
     return $template->render();
 }
Пример #7
0
 /**
  * vBForum_Search_Type_Post::listUi()
  *This function generates the search elements for the user to search for posts
  * @param mixed $prefs : the array of user preferences / propogated form values.
  * @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.
  * @return $html: complete html for the search elements
  */
 public function listUi($prefs = null, $contenttypeid = null, $registers = null, $template_name = null)
 {
     global $vbulletin, $vbphrase;
     if (!isset($template_name)) {
         $template_name = 'search_input_post';
     }
     if (!isset($contenttypeid)) {
         $contenttypeid = $this->get_contenttypeid();
     }
     $template = vB_Template::create($template_name);
     if ($prefs['searchthreadid']) {
         if ($thread = vB_Legacy_Thread::create_from_id($prefs['searchthreadid'])) {
             $template->register('thread_title', $thread->get_field('title'));
         }
     }
     $template->register('securitytoken', $vbulletin->userinfo['securitytoken']);
     $template->register('contenttypeid', $contenttypeid);
     $template->register('search_forum_options', $this->showForumOptions($prefs['forumchoice']));
     $prefix_selected = array('anythread' => (empty($prefs['prefixchoice']) or in_array('', $prefs['prefixchoice'])) ? 'selected="selected"' : '', 'anyprefix' => ($prefs['prefixchoice'] and in_array('-2', $prefs['prefixchoice'])) ? 'selected="selected"' : '', 'none' => ($prefs['prefixchoice'] and in_array('-1', $prefs['prefixchoice'])) ? 'selected="selected"' : '');
     $template->register('prefix_selected', $prefix_selected);
     $template->register('search_prefix_options', vB_Search_Searchtools::getPrefixOptions($prefs['prefixchoice'], false));
     $this->setPrefs($template, $prefs, array('select' => array('sortby', 'order', 'forumchoice', 'prefixchoice', 'titleonly', 'starteronly', 'searchdate', 'beforeafter'), 'cb' => array('childforums', 'exactname', 'nocache'), 'value' => array('query', 'searchuser', 'tag', 'searchthreadid'), 'rb' => array('showposts')));
     vB_Search_Searchtools::searchIntroRegisterHumanVerify($template);
     if (isset($registers) and is_array($registers)) {
         foreach ($registers as $key => $value) {
             $template->register($key, htmlspecialchars_uni($value));
         }
     }
     ($hook = vBulletinHook::fetch_hook('search_listui_complete')) ? eval($hook) : false;
     return $template->render();
 }
Пример #8
0
	/**
	 * This function composes the html to display the user interface for this
	 * search type
	 *
	 * @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 $html: complete html for the search elements
	 */
	public function listUi($prefs = null, $contenttypeid = null, $registers = null,
		$template_name = null)
	{
		global $vbulletin, $vbphrase;


		if (! isset($template_name))
		{
			$template_name = 'search_input_default';
		}

		if (! isset($contenttypeid))
		{
			$contenttypeid = vB_Types::instance()->getContentTypeID('vBCms_Article');
		}

		$template = vB_Template::create($template_name);
		$template->register('securitytoken', $vbulletin->userinfo['securitytoken']);
		$template->register('class', $this->get_display_name());
		$template->register('contenttypeid',$contenttypeid);

		$prefsettings = array(
			'select'=> array('searchdate', 'beforeafter', 'titleonly', 'sortby', 'sortorder'),
			'cb' => array('exactname'),
		 	'value' => array('query', 'searchuser'));
		$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();
	}
Пример #9
0
	public function listUi($prefs)
	{
		$phrase = new vB_Legacy_Phrase();
		$phrase->add_phrase_groups(array('vbblogglobal', 'vbblogcat'));

		global $vbulletin;
		$template = vB_Template::create('search_input_blogcomment');
		$template->register('securitytoken', $vbulletin->userinfo['securitytoken']);
		$template->register('contenttypeid', $this->get_contenttypeid());

		$prefsettings = array(
			'select'=> array('searchdate', 'beforeafter', 'sortby',
				'titleonly', 'sortorder', 'starteronly'),
			'cb' => array('nocache', 'exactname'),
		 	'value' => array('query', 'searchuser')
		);

		$this->setPrefs($template, $prefs, $prefsettings);
		vB_Search_Searchtools::searchIntroRegisterHumanVerify($template);
		return $template->render();	}