コード例 #1
0
ファイル: functions.php プロジェクト: hungnv0789/vhtm
/**
* Ensures that the variables for a multi-page display are sane
*
* @param	integer	Total number of items to be displayed
* @param	integer	(ref) Current page number
* @param	integer	(ref) Desired number of results to show per-page
* @param	integer	Maximum allowable results to show per-page
* @param	integer	Default number of results to show per-page
*/
function sanitize_pageresults($numresults, &$page, &$perpage, $maxperpage = 20, $defaultperpage = 20)
{
	$perpage = fetch_perpage($perpage, $maxperpage, $defaultperpage);
	$numpages = ceil($numresults / $perpage);
	if ($numpages == 0)
	{
		$numpages = 1;
	}

	if ($page < 1)
	{
		$page = 1;
	}
	else if ($page > $numpages)
	{
		$page = $numpages;
	}
}
コード例 #2
0
ファイル: resultsview.php プロジェクト: hungnv0789/vhtm
	public function showpage($pagenumber, $perpage, $base, $navbits, $print_output = true)
	{
		global $vbulletin;
		global $show;
		$errors = array();
		($hook = vBulletinHook::fetch_hook('search_before_process')) ? eval($hook) : false;

		$perpage = fetch_perpage($perpage, $this->maxpagesize, $vbulletin->options['searchperpage']);
		$pagenumber = max(intval($pagenumber), 1);

		if (!$this->results)
		{
			eval(standard_error(fetch_error('searchnoresults', $displayCommon), '', false));
		}
		$page_results = $this->results->get_page($pagenumber, $perpage, $this->window);

		if (!$page_results)
		{
			eval(standard_error(fetch_error('searchnoresults', $displayCommon), '', false));
		}
		$criteria = $this->results->get_criteria();
		//When we have better template features, the display strings should be passed as
		//an array to the template and handled there.
		$this->template->register('criteriaDisplay', implode('; ', $criteria->get_display_strings()));
		$this->template->register('displayCommon', $criteria->get_common_words_string());

		$this->render_searchbits($page_results);
		$show['results'] = (bool) count($page_results);

		($hook = vBulletinHook::fetch_hook('search_complete')) ? eval($hook) : false;

		//figure searchtime -- time it took to run the search in seconds
		$this->template->register('searchtime', $this->results->get_searchtime());

		//"searchminutes" in the template is minutes since the search was generated.
		$sincegenerated = floor((TIMENOW - $this->results->get_dateline()) / 60);

		if ($sincegenerated >= 1)
		{
			$this->template->register('searchminutes', $sincegenerated);
			$show['generated'] = true;
		}

		$search['showposts'] = true;

		$pagenav = construct_window_page_nav($pagenumber, $this->window, $perpage,
			$this->results->get_confirmed_count(),	$base);

		$this->template->register('navbar', render_navbar_template(construct_navbits($navbits)));
		$this->template->register('base', $base);
		$startat = ($pagenumber-1) * $perpage;
		$this->template->register('first', $startat + 1);
		$this->template->register('last', $startat + count($page_results));
		$this->template->register('total', $this->results->get_confirmed_count());
		$this->template->register('search', $search);
		$this->template->register('pagenav', $pagenav);
		$this->template->register('show', $show);
		$this->template->register('search_back_url', $criteria->get_url());
		$this->template->register_page_templates();
		
		if ($print_output)
		{
			print_output($this->template->render());
		}
		else
		{
			return $this->template->render();
		}
	}