Pasek_stron_PHP.txt

(6 KB) Pobierz
<html>Kodowanie: Windows-1250, koniec wiersza CR+LF, test: za矿虫 g隃l?ja燅
Autor: Adam Sawicki, http://regedit.gamedev.pl, sawickiap@poczta.onet.pl
Data: 21.01.2009, J陑yk programowania: PHP5


// Wypisuje na wyj渃iu akapit z paskiem do prze彻czania stron
// $a_sUrlTemplate ma zawiera?znacznik {Page} do zamiany na numer strony.
// Strony s?indeksowane od 0 do $a_iPageCount-1, ale dla u縴tkownika pokazuj?
// si?od 1 do $a_iPageCount.

function WritePageBar($a_iCurrentPage, $a_iPageCount, $a_sUrlTemplate)
{
	print("<p>Strony: ");
	
	if ($a_iPageCount <= 0)
		print(" [1]");
	elseif ($a_iCurrentPage < 0 or $a_iCurrentPage >= $a_iPageCount)
		print(" [".($a_iCurrentPage+1)."]");
	else
	{
		// Poprzednia (strza砮czka)
		if ($a_iCurrentPage > 0)
		{
			$sUrl = str_replace('{Page}', $a_iCurrentPage-1, $a_sUrlTemplate);
			print(" <a href=%22javascript:if(confirm(%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22  \n\nThis file was not retrieved by Teleport Ultra, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?%27))window.location=%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22%27%22 tppabs="http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22"><img src="ArrowL.png" tppabs="http://asawicki.info/Download/Code/ArrowL.png" width="10" height="9" alt="&gt;"></a>");
		}
	
		// Pierwsza
		if ($a_iCurrentPage == 0)
			print(" [1]");
		else
		{
			$sUrl = str_replace('{Page}', 0, $a_sUrlTemplate);
			print(" <a href=%22javascript:if(confirm(%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22  \n\nThis file was not retrieved by Teleport Ultra, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?%27))window.location=%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22%27%22 tppabs="http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22">1</a>");
		}
		
		// Kropeczki
		if ($a_iCurrentPage > 3)
			print(" ...");
	
		// Strony poprzednie
		if ($a_iCurrentPage > 2)
		{
			$sUrl = str_replace('{Page}', $a_iCurrentPage-2, $a_sUrlTemplate);
			print(" <a href=%22javascript:if(confirm(%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22  \n\nThis file was not retrieved by Teleport Ultra, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?%27))window.location=%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22%27%22 tppabs="http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22">".($a_iCurrentPage-1)."</a>");
		}
		if ($a_iCurrentPage > 1)
		{
			$sUrl = str_replace('{Page}', $a_iCurrentPage-1, $a_sUrlTemplate);
			print(" <a href=%22javascript:if(confirm(%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22  \n\nThis file was not retrieved by Teleport Ultra, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?%27))window.location=%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22%27%22 tppabs="http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22">".$a_iCurrentPage."</a>");
		}
		
		// Strona bie抗ca
		if ($a_iCurrentPage > 0 and $a_iCurrentPage < $a_iPageCount-1)
			print(" [".($a_iCurrentPage+1)."]");
		
		// Strony nast阷ne
		if ($a_iCurrentPage < $a_iPageCount-2)
		{
			$sUrl = str_replace('{Page}', $a_iCurrentPage+1, $a_sUrlTemplate);
			print(" <a href=%22javascript:if(confirm(%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22  \n\nThis file was not retrieved by Teleport Ultra, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?%27))window.location=%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22%27%22 tppabs="http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22">".($a_iCurrentPage+2)."</a>");
		}
		if ($a_iCurrentPage < $a_iPageCount-3)
		{
			$sUrl = str_replace('{Page}', $a_iCurrentPage+2, $a_sUrlTemplate);
			print(" <a href=%22javascript:if(confirm(%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22  \n\nThis file was not retrieved by Teleport Ultra, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?%27))window.location=%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22%27%22 tppabs="http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22">".($a_iCurrentPage+3)."</a>");
		}
	
		// Kropeczki
		if ($a_iCurrentPage < $a_iPageCount - 4)
			print(" ...");
	
		// Ostatnia
		if ($a_iPageCount > 1)
		{
			if ($a_iCurrentPage == $a_iPageCount-1)
				print(" [".$a_iPageCount."]");
			else
			{
				$sUrl = str_replace('{Page}', $a_iPageCount-1, $a_sUrlTemplate);
				print(" <a href=%22javascript:if(confirm(%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22  \n\nThis file was not retrieved by Teleport Ultra, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?%27))window.location=%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22%27%22 tppabs="http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22">".$a_iPageCount."</a>");
			}
		}
	
		// Nast阷na (strza砮czka)
		if ($a_iCurrentPage < $a_iPageCount-1)
		{
			$sUrl = str_replace('{Page}', $a_iCurrentPage+1, $a_sUrlTemplate);
			print(" <a href=%22javascript:if(confirm(%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22  \n\nThis file was not retrieved by Teleport Ultra, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon.  \n\nDo you want to open it from the server?%27))window.location=%27http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22%27%22 tppabs="http://asawicki.info/%22%22.htmlspecialchars($sUrl).%22/%22"><img src="ArrowR.png" tppabs="http://asawicki.info/Download/Code/ArrowR.png" width="10" height="9" alt="&gt;"></a>");
		}
	}
	print("</p>\n");
}

Zgłoś jeśli naruszono regulamin