ACC SHELL
<?php
//coded by Warden - http://warden.dharma.cz
/*
priklad vytvareni instance:
$listing = new c_Listing("aktivni link pro strankovani", "pocet zaznamu v jednom listu",
"list pro zobrazeni", "formatovani zacatku odkazu strankovani",
"formatovani konce odkazu strankovani", "sql dotaz pro vyber vsech zazkamu k vylistovani");
*/
//definice tridy c_Listing
class c_Listing {
var $url;
var $interval;
var $sql;
var $list;
var $before;
var $after;
var $numLists;
var $numRecords;
var $errName;
var $befError = "<div align=\"center\" style=\"color: maroon;\">";
var $aftError = "</div>";
//konstruktor...naplni promenne
function c_Listing($conUrl = "./index.php?", $conInterval = 10, $conList = 1, $conBefore = "", $conAfter = "", $conSql = ""){
$this->errName[1] = "P�i vol�n� konstruktotu nebyl zad�n SQL dotaz!<br>\n";
$this->errName[2] = "Nelze zobrazit listov�n�, chyba datab�ze(Query)!<br>\n";
$this->errName[3] = "Nelze zobrazit listov�n�, chyba datab�ze(Num_Rows)!<br>\n";
$this->url = $conUrl;
$this->interval = $conInterval;
$this->list = $conList;
$this->before = $conBefore;
$this->after = $conAfter;
if (Empty($conSql)){
$this->error(1);
}
else {
$this->sql = $conSql;
}
}
//vyber dat z databaze
function dbSelect(){
$listRecord = @MySQL_Query($this->sql);
if (!$listRecord){
$this->error(2);
}
$allRecords = @MySQL_Num_Rows($listRecord);
if (!$allRecords){
$allRecords = 0;
//$this->error(3);
}
$allLists = ceil($allRecords / $this->interval);
$this->numLists = $allLists;
$this->numRecords = $allRecords;
}
//zobrazi pouze seznam cisel listu
//napr.: 1 | 2 | 3
function listNumber(){
$this->dbSelect();
$end .= $this->before;
for ($i = 1; $i <= $this->numLists; $i++){
$isLink = 1;
$spacer = " | ";
if (Empty($this->list)){
$this->list = 1;
}
if ($i == $this->list){
$isLink = 0;
}
if ($i == $this->numLists){
$spacer = "";
}
if ($isLink == 0){
$end .= "<div class='carouselItem active'>".$i."</div> ";
}
if ($isLink == 1){
$end .= "<div class='carouselItem'><a href=\"".$this->url."&list=".$i."\" onFocus=\"blur()\">".$i."</a> </div>";
}
}
$end .= $this->after;
return $end;
}
//zobrazi seznam intervalu v zadanem rozsahu ($interval)
//napr.: 1-10 | 11-20 | 21-30
function listInterval(){
$this->dbSelect();
$end .= $this->before."<div>";
for ($i = 1; $i <= $this->numLists; $i++){
$isLink = 1;
$spacer = " | ";
$from = ($i*$this->interval)-($this->interval-1);
$to = $i*$this->interval;
if (Empty($this->list)){
$this->list = 1;
}
if ($i == $this->list){
$isLink = 0;
}
if ($i == $this->numLists){
$to = $this->numRecords;
$spacer = "";
}
if ($isLink == 0){
$end .= $from."-".$to." ".$spacer;
}
if ($isLink == 1){
$end .= "<a href=\"".$this->url."&list=".$i."\" onFocus=\"blur()\">".$from."-".$to."</a> ".$spacer;
}
}
/*$end .= "<form style='float: right;' method='get'>
Počet záznamů na stránce: <select name='na_stranku' onchange='this.form.submit()'>
<option value='5'".($_SESSION['na_stranku']==5?" selected='selected'":"").">5</option>
<option value='10'".($_SESSION['na_stranku']==10?" selected='selected'":"").">10</option>
<option value='25'".($_SESSION['na_stranku']==25?" selected='selected'":"").">25</option>
<option value='50'".($_SESSION['na_stranku']==50?" selected='selected'":"").">50</option>
<option value='50000'".($_SESSION['na_stranku']==50000?" selected='selected'":"").">vše</option>
</select>
</form>";*/
$end .= $this->after."</div>";
return $end;
}
//zobrazi aktivni odkaz pouze na dalsi cast intervalu (dopredu, dozadu)
//napr.: <<< << 11-20 >> >>>
function listPart(){
$this->dbSelect();
echo $this->before;
if (Empty($this->list)){
$this->list = 1;
}
$from = ($this->list*$this->interval)-($this->interval-1);
$to = $this->list*$this->interval;
$forward = "<a href=\"".$this->url."&list=1\" onFocus=\"blur()\"><<<</a> <a href=\"".$this->url."&list=".($this->list-1)."\" onFocus=\"blur()\"><<</a> ";
$backward = " <a href=\"".$this->url."&list=".($this->list+1)."\" onFocus=\"blur()\">>></a> <a href=\"".$this->url."&list=".$this->numLists."\" onFocus=\"blur()\">>>></a>";
if ($this->list == 1){
$forward = "";
}
if ($this->list == $this->numLists){
$to = $this->numRecords;
$backward = "";
}
echo $forward.$from."-".$to.$backward;
echo $this->after;
}
//vypisovani chybovych hlasek
function error($errNum = 0){
if ($errNum != 0){
echo $this->befError.$this->errName[$errNum].$this->aftError;
}
}
}
?>
ACC SHELL 2018