commit | author | age
|
175a52
|
1 |
<?php |
JK |
2 |
class gotowe { |
|
3 |
static $pola = array('autor', 'tytul', 'wydanie', 'miejsce', 'rok', 'wydawnictwo', 'jezyk', 'ISBN', 'ISSN'); |
|
4 |
static $nastrone = 25; |
|
5 |
static $add = ''; |
|
6 |
static $default = FALSE; |
|
7 |
|
|
8 |
static function sort($by=NULL, $strona=NULL) { |
|
9 |
if($strona === NULL) { |
|
10 |
$strona = 0; |
|
11 |
} |
|
12 |
|
|
13 |
if($by === NULL) { |
|
14 |
if(!self::$default) { |
|
15 |
$by = $_GET['sort']; |
|
16 |
} |
|
17 |
|
|
18 |
$ord = $_GET['ord']; |
|
19 |
} |
|
20 |
elseif($by == 'default' && self::$default) { |
|
21 |
$ord = self::invert_sort($_GET['ord']); |
|
22 |
} |
|
23 |
elseif($_GET['sort'] == $by && $_GET['ord'] == 'asc') { |
|
24 |
$ord = 'desc'; |
|
25 |
} |
|
26 |
else |
|
27 |
{ |
|
28 |
$ord = 'asc'; |
|
29 |
} |
|
30 |
|
|
31 |
return $_SERVER['PHP_SELF'].'?'.self::$add.'strona='.$strona.'&sort='.$by.'&ord='.$ord; |
|
32 |
} |
|
33 |
|
|
34 |
static function add($what, $size=50) { |
|
35 |
if($_GET[$what]!='') { |
|
36 |
self::$add .= $what.'='.urlencode(substr($_GET[$what], 0, $size)).'&'; |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
static function invert_sort($ord) { |
|
41 |
$ord = strtolower($ord); |
|
42 |
if($ord != 'asc') { |
|
43 |
$ord = 'asc'; |
|
44 |
} |
|
45 |
else |
|
46 |
{ |
|
47 |
$ord = 'desc'; |
|
48 |
} |
|
49 |
return $ord; |
|
50 |
} |
|
51 |
|
|
52 |
static function informacje($kod, $dane=NULL) { |
|
53 |
if(is_null($dane)) { |
|
54 |
$dane = ksiazki::szukaj_KOD($kod); |
|
55 |
} |
|
56 |
|
|
57 |
if($dane['wycofana']) { |
|
58 |
$class = 'wyc'; |
388202
|
59 |
$info = '<p>Książka wycofana</p>'; |
175a52
|
60 |
} |
JK |
61 |
else |
|
62 |
{ |
|
63 |
if(!pozycz::pozyczona($dane['id'])) { |
|
64 |
$class = 'norm'; |
|
65 |
$info = ' |
|
66 |
|
388202
|
67 |
<p>Książka w dostępna</p> |
175a52
|
68 |
|
JK |
69 |
'; |
|
70 |
} |
|
71 |
else |
|
72 |
{ |
|
73 |
$class = 'poz'; |
|
74 |
$info = ' |
|
75 |
|
388202
|
76 |
<p>Książka wypożyczona</p> |
175a52
|
77 |
|
JK |
78 |
'; |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
// Okładka |
|
83 |
$cover = ksiazki::okladka($dane['id'], $dane['ISBN']); |
|
84 |
|
|
85 |
echo '<div class="'.$class.'" id="book"> |
|
86 |
'.($cover ? '<a href="cover.php?KOD='.$dane['id'].'&ISBN='.$dane['ISBN'].'"><img src="'.$cover.'" alt="Okładka" /></a> |
|
87 |
' : '').'<h4>'.$dane['tytul'].'</h4> |
|
88 |
<h5>'.$dane['autor'].($dane['regal'] ? ' <span>('.$dane['regal'].($dane['polka'] ? '/'.$dane['polka'] : '').($dane['rzad'] ? '/'.$dane['rzad'] : '').')</span>' : '').'</h5> |
|
89 |
'.($dane['wydanie'] ? '<p>Wydanie '.$dane['wydanie'].'</p>' : '').' |
|
90 |
<p>'.($dane['wydawnictwo'] ? $dane['wydawnictwo'].'<br /> |
|
91 |
' : '').$dane['miejsce'].' '.$dane['rok'].($dane['ISBN'] ? '<br /> |
|
92 |
ISBN-13: '.$dane['ISBN'] : '').(substr($dane['ISBN'], 0, 3) == '978' ? '<br /> |
|
93 |
ISBN-10: '.convert::ISBN13_to_ISBN10($dane['ISBN']) : '').($dane['ISSN'] ? '<br /> |
|
94 |
ISSN-13: '.$dane['ISSN'].'<br /> |
|
95 |
ISSN-10: '.convert::ISSN13_to_ISSN8($dane['ISSN']) : '').'</p> |
|
96 |
'.$info.' |
|
97 |
</div>'; |
|
98 |
} |
|
99 |
|
|
100 |
static function lista() { |
|
101 |
if(!in_array($_GET['sort'], array('id', 'autor', 'tytul', 'miejsce', 'rok', 'wydawnictwo'))) { |
|
102 |
$_GET['sort'] = 'tytul'; |
|
103 |
self::$default = TRUE; |
|
104 |
} |
|
105 |
if($_GET['ord'] != 'desc') { |
|
106 |
$_GET['ord'] = 'asc'; |
|
107 |
} |
|
108 |
if(!ctype_digit($_GET['strona'])) { |
|
109 |
$_GET['strona'] = 0; |
|
110 |
} |
|
111 |
|
|
112 |
if($_GET['id']) { |
|
113 |
self::add('id', 13); |
|
114 |
} |
|
115 |
else |
|
116 |
{ |
|
117 |
self::add('tytul'); |
|
118 |
self::add('autor'); |
|
119 |
self::add('wydanie', 25); |
|
120 |
self::add('miejsce'); |
|
121 |
self::add('rok', 4); |
|
122 |
self::add('wydawnictwo'); |
|
123 |
} |
|
124 |
|
|
125 |
if(self::$default) { |
|
126 |
$sort = array('revelance' => self::invert_sort($_GET['ord']), $_GET['sort'] => $_GET['ord']); |
|
127 |
} |
|
128 |
else |
|
129 |
{ |
|
130 |
$sort = array($_GET['sort'] => $_GET['ord']); |
|
131 |
} |
|
132 |
|
|
133 |
list($num, $ksiazki, $revelance) = ksiazki::szukaj_info($_GET, $sort, $_GET['strona']*self::$nastrone, self::$nastrone); |
|
134 |
|
|
135 |
if($num==0) { |
bc710e
|
136 |
errorclass::add('Brak książek spełniających podane kryteria'); |
175a52
|
137 |
} |
JK |
138 |
elseif($num==1 AND !$revelance) { |
|
139 |
self::informacje(NULL, $ksiazki[0]); |
|
140 |
return TRUE; |
|
141 |
} |
|
142 |
|
|
143 |
echo '<table class="width"> |
|
144 |
<tr> <th>Okł.</th> <th> <b><a href="'.self::sort('id').'">Kod</a></b> <br /> Wyd. </th> <th> <a href="'.self::sort('autor').'">Autor</a> <br /> <b><a href="'.self::sort('tytul').'">Tytuł</a></b> </th> <th> <a href="'.self::sort('miejsce').'">Miejsce</a>, <a href="'.self::sort('rok').'">rok</a> <br /> <a href="'.self::sort('wydawnictwo').'">Wydawnictwo</a> </th>'.($revelance ? ' <th><a href="'.self::sort('default').'">Trafność</a></th>' : '').' <th> Wypożyczenie <br /> Opcje </th> </tr> |
|
145 |
'; |
|
146 |
|
|
147 |
foreach($ksiazki as $ksiazka) { |
|
148 |
if($ksiazka['wycofana']) { |
|
149 |
$info = 'Książka wycofana'; |
|
150 |
$class = 'wyc'; |
|
151 |
} |
|
152 |
else |
|
153 |
{ |
|
154 |
if($ksiazka['do']!==NULL OR $ksiazka['od']===NULL) { |
|
155 |
$class = 'norm'; |
|
156 |
$info = 'Książka w bibliotece'; |
|
157 |
} |
|
158 |
else |
|
159 |
{ |
|
160 |
$class = 'poz'; |
388202
|
161 |
$info = 'Książka wypożyczona'; |
175a52
|
162 |
$pozycz = TRUE; |
JK |
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
$cover = ksiazki::okladka($ksiazka['id'], $ksiazka['ISBN']); |
|
167 |
|
|
168 |
echo '<tr'.($class ? ' class="'.$class.'"' : '').'> |
|
169 |
<td> |
|
170 |
'.($cover ? '<a href="cover.php?KOD='.$ksiazka['id'].'&ISBN='.$ksiazka['ISBN'].'"><img src="'.$cover.'" alt="Okładka" /></a>' : '').' |
|
171 |
</td> |
|
172 |
<td> |
|
173 |
<b>'.$ksiazka['id'].'</b> <br /> |
|
174 |
'.($ksiazka['wydanie'] ? 'W. '.$ksiazka['wydanie'] : '').' |
|
175 |
</td> |
|
176 |
<td> |
|
177 |
'.$ksiazka['autor']. |
|
178 |
($ksiazka['regal'] ? ' <span>('.$ksiazka['regal']. |
|
179 |
($ksiazka['polka'] ? '/'.$ksiazka['polka'] : ''). |
|
180 |
($ksiazka['rzad'] ? '/'.$ksiazka['rzad'] : ''). |
|
181 |
')</span>' : '').' <br /> |
|
182 |
<b>'.$ksiazka['tytul'].'</b> </td> |
|
183 |
<td> |
|
184 |
'.$ksiazka['miejsce'].' '.$ksiazka['rok'].' <br /> |
|
185 |
'.$ksiazka['wydawnictwo'].' |
|
186 |
</td>'.($revelance ? ' |
|
187 |
<td>'.min(100, (int)($ksiazka['revelance']*10)).'% </td>' : '').' |
|
188 |
<td class="n"> |
|
189 |
'.$info.' <br /> |
388202
|
190 |
<a href="info.php?kod='.$ksiazka['id'].'">Więcej...</a> |
175a52
|
191 |
</td> |
JK |
192 |
</tr> |
|
193 |
'; |
|
194 |
} |
|
195 |
|
|
196 |
echo '</table> |
|
197 |
|
|
198 |
'; |
|
199 |
self::strony($num); |
|
200 |
} |
|
201 |
|
|
202 |
static function strony($elementow) { |
|
203 |
$stron = ceil($elementow / self::$nastrone) - 1; |
|
204 |
|
|
205 |
echo '<p class="paginator"> '; |
|
206 |
for($strona=0; $strona<=$stron; $strona++) { |
|
207 |
if($strona == $_GET['strona']) { |
|
208 |
echo '<b>[ '.($strona+1).' ]</b> '; |
|
209 |
} |
|
210 |
else |
|
211 |
{ |
|
212 |
echo '<a href="'.self::sort(NULL, $strona).'">[ '.($strona+1).' ]</a> '; |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
echo '</p>'; |
|
217 |
} |
|
218 |
} |
532779
|
219 |
?> |