pripraveno rozhrani pro redirecty po postu a zobrazovani (nejen) chybovych hlasek
[mirrors/SokoMan.git] / index.php
CommitLineData
cdfce7c2
TM
1<?php
2/*
3 * SkladovySystem - Storage management system compatible with LMS
78bf26a5 4 * Copyright (C) 2011 Tomas Mudrunka
cdfce7c2
TM
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20require_once('sklad.conf.php');
21require_once('Sklad_LMS-fake.class.php');
22require_once('HTTP_Auth.class.php');
23
78bf26a5
TM
24/**
25* Trida poskytuje podpurne funkce pro generovani HTML kodu specificke pro sklad
26*
fc5c5b8b
TM
27* Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)!
28*
78bf26a5
TM
29* @package Sklad_HTML
30* @author Tomas Mudrunka
31*/
cdfce7c2 32class Sklad_HTML {
fc5c5b8b 33 function header($title='') {
cdfce7c2
TM
34 $home = URL_HOME;
35 $script = $_SERVER['SCRIPT_NAME'];
d9384cb5
TM
36 $search = htmlspecialchars(@trim($_GET['q']));
37 $message = htmlspecialchars(@trim($_GET['message']));
fc5c5b8b 38 return <<<EOF
10562613 39<head>
40 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
41</head>
cdfce7c2
TM
42<h1><a href="$script/">SystémSklad</a><small>$title</small></h1>
43<div>
44 <menu>
45 <li><a href="?logout">Logout</a></li>
46 <li><a href="$script/">Home</a></li>
47 </menu>
48 <form action="?" method="GET">
49 <input type="text" name="q" placeholder="regexp..." value="$search" />
50 <input type="submit" value="filter" />
51 </form>
52 <!-- form action="$script/" method="GET">
53 <input type="text" name="q" placeholder="regexp..." value="$search" />
54 <input type="submit" value="search items" />
55 </form -->
56</div>
d9384cb5
TM
57<div style="background-color:#FFDDDD;">
58 <font color="red">$message</font>
59</div>
cdfce7c2
TM
60EOF;
61 }
62
fc5c5b8b
TM
63 function row($row) {
64 $html='<tr>';
cdfce7c2
TM
65 foreach($row as $var) {
66 if(trim($var) == '') $var = '&nbsp;';
fc5c5b8b 67 $html.="<td>$var</td>";
cdfce7c2 68 }
fc5c5b8b
TM
69 $html.='</tr>';
70 return $html;
cdfce7c2
TM
71 }
72
fc5c5b8b
TM
73 function table(&$table, $params='border=1') {
74 $html="<table $params>";
cdfce7c2
TM
75 $header=true;
76 foreach($table as $row) {
77 if($header) {
fc5c5b8b 78 $html.=$this->row(array_keys($row));
cdfce7c2
TM
79 $header=false;
80 }
fc5c5b8b 81 $html.=$this->row($row);
cdfce7c2 82 }
fc5c5b8b
TM
83 $html.='</table>';
84 return $html;
cdfce7c2
TM
85 }
86
d9384cb5
TM
87 function internal_url($link) {
88 return $_SERVER['SCRIPT_NAME'].'/'.$link;
89 }
90
cdfce7c2 91 function link($title='n/a', $link='#void', $internal=true) {
d9384cb5 92 if($internal) $link = $this->internal_url($link);
cdfce7c2
TM
93 return "<a href='$link'>$title</a>";
94 }
95
96 function img($src='#void', $title='img') {
97 return "<img src='$src' alt='$title' title='$title' width=64 />";
98 }
99
100 function table_add_images(&$table) {
101 $image = array('model_id');
102 foreach($table as $id => $row) {
103 foreach($image as $column) if(isset($table[$id][$column])) {
104 $type = @array_shift(preg_split('/_/', $column));
105 $src=URL_IMAGES."/$type/".$table[$id][$column].'.jpg';
106 $table[$id][$type.'_image']=$this->img($src, $table[$id][$column]);
107 }
108 }
109 }
110
111 function table_collapse(&$table) {
112 $collapse = array(
113 'item_id' => 'item_id',
114 'model_id' => 'model_name',
115 'category_id' => 'category_name',
116 'producer_id' => 'producer_name',
117 'vendor_id' => 'vendor_name',
118 'room_id' => 'room_name',
119 'status_id' => 'status_name',
120 );
121 foreach($table as $id => $row) {
122 foreach($collapse as $link => $title)
123 if(isset($table[$id][$link])) {
124 $type = @array_shift(preg_split('/_/', $link));
125 if($link != $title) unset($table[$id][$link]);
126 $table[$id][$title]=$this->link($row[$title], $type.'/'.$row[$link].'/');
127 }
128 }
129 }
130
131 function table_sort(&$table) {
132 $precedence = array('item_id', 'model_image', 'model_name','model_descript','category_name','status_name','room_name');
133 $table_sorted = array();
134 foreach($table as $id => $row) {
135 $table_sorted[$id] = array();
136 foreach($precedence as $column) if(isset($table[$id][$column])) {
137 $table_sorted[$id][$column]=$table[$id][$column];
138 unset($table[$id][$column]);
139 }
140 $table_sorted[$id]=array_merge($table_sorted[$id],$table[$id]);
141 }
142 $table = $table_sorted;
143 }
144
fc5c5b8b 145 function render_item_table($table) {
cdfce7c2
TM
146 $this->table_add_images($table);
147 $this->table_collapse($table);
148 $this->table_sort($table);
fc5c5b8b 149 return $this->table($table);
cdfce7c2
TM
150 }
151
152 function input($name=false, $value=false, $type='text', $placeholder=false, $options=false) {
153 $html = "<input type='$type' ";
154 if($name) $html.= "name='$name' ";
155 if(!is_bool($value)) $html.= "value='$value' ";
156 if($options) $html.= "$options ";
157 if($placeholder) $html.= "placeholder='$placeholder' ";
158 $html .= '/>';
159 return $html;
160 }
161
162 function select($name, $selectbox, $default=false) {
163 //echo('<pre>'); print_r($selectbox);
164 $html = "<select name='$name'>";
165
166 if($default) {
167 $value=$default; $title=$selectbox[$value];
168 $html .= "<option value='$value'>$value :: $title</option>";
169 unset($selectbox[$value]);
170 }
171 foreach($selectbox as $value => $title) {
172 $html .= "<option value='$value'>$value :: $title</option>";
173 }
174 $html .= "</select>";
175 return $html;
176 }
177
fc5c5b8b 178 function render_insert_form($class, $columns, $selectbox=array(), $current=false, $multi_insert=true) {
cdfce7c2
TM
179 //echo('<pre>'); print_r($selectbox);
180 //echo('<pre>'); print_r($current);
181 $update = false;
182 if(is_array($current)) {
183 $update = true;
184 $current = array_shift($current);
185 }
186
fc5c5b8b
TM
187 $html='<form method="POST">';
188 if($multi_insert) $html.='<div name="input_set" style="float:left; border:1px solid grey;">';
371a86f4 189 //$html.=$this->input('table', $class, 'hidden');
cdfce7c2 190 foreach($columns as $column) {
371a86f4 191 $html.=$class.':<b>'.$column['Field'].'</b>: ';
7d20381f 192 $name="values[$class][".$column['Field'].'][]';
e9cb8cea 193 $val = $update ? $current[$column['Field']] : false;
cdfce7c2
TM
194 switch(true) {
195 case preg_match('/auto_increment/', $column['Extra']):
e9cb8cea 196 if(!$val) $val = '';
fc5c5b8b
TM
197 $html.=$this->input($name, $val, 'hidden');
198 $html.=$val.'(AUTO)';
cdfce7c2
TM
199 break;
200 case isset($selectbox[$column['Field']]):
e9cb8cea 201 $html.=$this->select($name,$selectbox[$column['Field']],$val);
cdfce7c2
TM
202 break;
203 default:
fc5c5b8b 204 $html.=$this->input($name, $val);
cdfce7c2
TM
205 break;
206 }
fc5c5b8b 207 $html.='<br />';
cdfce7c2
TM
208 }
209
210 if($multi_insert) {
211 //TODO, move to separate JS file
fc5c5b8b 212 $html.=<<<EOF
cdfce7c2
TM
213 </div>
214 <span name="input_set_next"></span><br style="clear:both" />
215 <script>
216 function duplicate_element(what, where) {
217 document.getElementsByName(where)[0].outerHTML =
218 document.getElementsByName(what)[0].outerHTML
219 + document.getElementsByName(where)[0].outerHTML;
220 }
221 </script>
222 <a href='#' onClick="duplicate_element('input_set', 'input_set_next')">+</a>
223EOF;
224 }
225
226 $btn = is_array($current) ? 'UPDATE' : 'INSERT';
fc5c5b8b
TM
227 $html.=$this->input(false, $btn, 'submit');
228 $html.='</form>';
229 return $html;
cdfce7c2
TM
230 }
231}
232
78bf26a5
TM
233/**
234* Trida poskytuje rozhrani k databazi skladu
235*
236* @package Sklad_DB
237* @author Tomas Mudrunka
238*/
cdfce7c2
TM
239class Sklad_DB extends PDO {
240 function __construct() {
241 $this->lms = new Sklad_LMS();
242
243 parent::__construct(
244 DB_DSN, DB_USER, DB_PASS,
245 array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") //Force UTF8 for MySQL
246 );
247 }
248
249 function escape($str) {
250 return preg_replace('(^.|.$)', '', $this->quote($str)); //TODO HACK
251 }
252
253 function build_query_select($class, $id=false, $limit=false, $offset=0, $search=false, $id_suffix='_id') {
254 $class = $this->escape($class);
255 $join = array(
256 'item' => array('model', 'category', 'producer', 'vendor', 'room', 'status'),
257 'model' => array('category', 'producer')
258 );
259 $search_fields = array(
260 'item' => array('item_id','model_name','model_barcode','model_descript','producer_name','vendor_name')
261 );
262 $sql="SELECT * FROM $class\n";
263 if(isset($join[$class])) foreach($join[$class] as $j) $sql .= "LEFT JOIN $j USING($j$id_suffix)\n";
264 if($search) {
265 $search = $this->quote($search);
266 if(!isset($search_fields[$class])) {
267 trigger_error("Ve tride $class zatim vyhledavat nemozno :-(");
268 die();
269 }
270 $sql .= 'WHERE FALSE ';
271 foreach($search_fields[$class] as $column) $sql .= "OR $column REGEXP $search ";
272 } elseif($id) $sql .= "WHERE $class$id_suffix = $id\n";
273 if($limit) {
274 $limit = $this->escape((int)$limit);
275 $offset = $this->escape((int)$offset);
276 $sql .= "LIMIT $offset,$limit\n";
277 }
278 return $sql;
279 }
280
281 function safe_query($sql) {
282 $result = $this->query($sql);
283 if(!$result) {
284 trigger_error('<font color=red><b>QUERY FAILED:</b><pre>'.$sql.'</pre></font>');
285 die();
286 }
287 return $result;
288 }
289
290 function get_listing($class, $id=false, $limit=false, $offset=0, $search=false, $indexed=array(), $suffix_id='_id') {
291 $sql = $this->build_query_select($class, $id, $limit, $offset, $search);
292 $result = $this->safe_query($sql)->fetchAll(PDO::FETCH_ASSOC);
293 if(!$result || !is_array($indexed)) return $result;
294
295 foreach($result as $key => $row) $indexed[$row[$class.$suffix_id]]=$row;
296 return $indexed;
297 }
298
299 function get_columns($class) {
300 $class = $this->escape($class);
301 $sql = "SHOW COLUMNS FROM $class;";
302 return $this->safe_query($sql)->fetchAll(PDO::FETCH_ASSOC);
303 }
304
305 function columns_get_selectbox($columns, $class=false, $suffix_id='_id', $suffix_name='_name') {
306 $selectbox=array();
307 foreach($columns as $column) {
308 if($class && $column['Field'] == $class.$suffix_id) continue;
309 if(!preg_match('/'.$suffix_id.'$/', $column['Field'])) continue;
310 $table=preg_replace('/'.$suffix_id.'$/','',$column['Field']);
311 $sql = "SELECT $table$suffix_id, $table$suffix_name FROM $table;";
312 $result=$this->safe_query($sql)->fetchAll(PDO::FETCH_ASSOC);
313 foreach($result as $row) $selectbox[$table.$suffix_id][$row[$table.$suffix_id]]=$row[$table.$suffix_name];
314 }
315 //echo('<pre>'); print_r($selectbox);
316 return $selectbox;
317 }
318
319 function build_query_insert($table, $values, $replace=true, $suffix_id='_id') {
320 $table = $this->escape($table);
321
322 //Get list of POSTed columns
323 $columns = implode(',',array_map(array($this,'escape'), array_keys($values[0])));
324
325 //Insert into table (columns)
326 $sql = 'INSERT';
327 if($replace) $sql = 'REPLACE';
328 $sql .= " INTO $table ($columns) VALUES ";
329
330 //Values (a,b,c),(d,e,f)
331 $comma='';
332 foreach($values as $row) {
333 $sql .= $comma.'('.implode(',',array_map(array($this,'quote'), $row)).')';
334 $comma = ',';
335 }
336
337 //Terminate
338 $sql .= ';';
339 return $sql;
340 }
341
342 function insert_or_update($table, $values) {
343 $sql = $this->build_query_insert($table, $values);
344 $this->safe_query($sql);
345 return $this->lastInsertId();
346 }
347
371a86f4
TM
348 function insert_or_update_multitab($values) {
349 $last=false;
350 foreach($values as $table => $rows) $last = $this->insert_or_update($table, $rows);
351 return $last;
352 }
353
cdfce7c2
TM
354 function delete($table, $id, $suffix_id='_id') {
355 $key = $this->escape($table.$suffix_id);
356 $table = $this->escape($table);
357 $id = $this->quote($id);
358 return $this->safe_query("DELETE FROM $table WHERE $key = $id LIMIT 1;");
359 }
360}
361
78bf26a5
TM
362/**
363* Trida implementuje uzivatelske rozhrani skladu
364*
365* Example usage:
366* $sklad = new Sklad_UI();
367* $sklad->process_http_request();
368*
369* @package Sklad_UI
370* @author Tomas Mudrunka
371*/
cdfce7c2
TM
372class Sklad_UI {
373 function __construct() {
374 $this->db = new Sklad_DB();
375 $this->html = new Sklad_HTML();
376 }
377
a25f85f8
TM
378 function render_items($class, $id=false, $limit=false, $offset=0, $search=false) {
379 return $this->html->render_item_table($this->db->get_listing($class, $id, $limit, $offset, $search));
cdfce7c2
TM
380 }
381
a25f85f8 382 function render_form_add($class) {
cdfce7c2
TM
383 $columns = $this->db->get_columns($class);
384 $selectbox = $this->db->columns_get_selectbox($columns, $class);
a25f85f8 385 return $this->html->render_insert_form($class, $columns, $selectbox);
cdfce7c2
TM
386 }
387
a25f85f8 388 function render_form_edit($class, $id) {
cdfce7c2
TM
389 $columns = $this->db->get_columns($class);
390 $selectbox = $this->db->columns_get_selectbox($columns, $class);
391 $current = $this->db->get_listing($class, $id);
a25f85f8 392 return $this->html->render_insert_form($class, $columns, $selectbox, $current);
cdfce7c2
TM
393 }
394
a25f85f8 395 function render_single_record_details($class, $id) {
cdfce7c2
TM
396 $id_next = $id + 1;
397 $id_prev = $id - 1 > 0 ? $id - 1 : 0;
398 $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : '';
a25f85f8
TM
399 $html='';
400 $html.= $this->html->link('<<', "$class/$id_prev/");
401 $html.= '-';
402 $html.= $this->html->link('>>', "$class/$id_next/");
403 $html.= '<br />';
404 $html.= $this->html->link('edit', "$class/$id/edit/");
405 return $html;
cdfce7c2
TM
406 }
407
a25f85f8 408 function render_listing_navigation($class, $id, $limit, $offset) {
cdfce7c2
TM
409 $offset_next = $offset + $limit;
410 $offset_prev = $offset - $limit > 0 ? $offset - $limit : 0;
411 $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : '';
a25f85f8
TM
412 $html='';
413 $html.= $this->html->link('<<', "$class/$id/$limit/$offset_prev/$get");
414 $html.= '-';
415 $html.= $this->html->link('>>', "$class/$id/$limit/$offset_next/$get");
416 $html.= '<br />';
417 $html.= $this->html->link('new', "$class/new/$get");
418 return $html;
cdfce7c2
TM
419 }
420
a25f85f8
TM
421 function render_listing_extensions($class, $id, $limit, $offset, $edit=false) {
422 $html='';
cdfce7c2 423 if(is_numeric($id)) {
a25f85f8 424 $html.=$this->render_single_record_details($class, $id);
cdfce7c2 425 } else {
a25f85f8 426 $html.=$this->render_listing_navigation($class, '*', $limit, $offset);
cdfce7c2
TM
427 }
428 if($edit) {
a25f85f8
TM
429 $html.='<br />TODO UPDATE FORM!<br />';
430 $html.= $this->render_form_edit($class, $id);
cdfce7c2 431 $action = $_SERVER['SCRIPT_NAME']."/$class/$id/delete";
a25f85f8
TM
432 $html.= "<form action='$action' method='POST'>";
433 $html.= $this->html->input(false, 'DELETE', 'submit');
434 $html.= 'sure?'.$this->html->input('sure', false, 'checkbox');
435 $html.= '</form>';
cdfce7c2 436 $action = $_SERVER['SCRIPT_NAME']."/$class/$id/image";
a25f85f8
TM
437 $html.= "<form action='$action' method='POST' enctype='multipart/form-data'>";
438 $html.= $this->html->input('image', false, 'file', false, 'size="30"');
439 $html.= $this->html->input(false, 'IMAGE', 'submit');
440 $html.='</form>';
cdfce7c2 441 }
a25f85f8 442 return $html;
cdfce7c2
TM
443 }
444
445 function check_auth() {
446 new HTTP_Auth('SkladovejSystem', true, array($this->db->lms,'check_auth'));
447 }
448
d9384cb5 449 function post_redirect_get($last, $next) {
cdfce7c2 450 //header('Location: '.$_SERVER['REQUEST_URI']); //TODO redirect (need templating system or ob_start() first!!!)
d9384cb5
TM
451 header('Location: '.$this->html->internal_url($dest));
452 die("Redirect: $dest");
cdfce7c2
TM
453 }
454
623c65e2 455 function safe_include($dir,$name,$vars=array(),$ext='.inc.php') {
3e6c412e
TM
456 if(preg_match('/[^a-zA-Z0-9-]/',$name)) die(trigger_error('SAFE INCLUDE: Securityfuck.'));
457 $filename="$dir/$name$ext";
458 if(!is_file($filename)) die(trigger_error('SAFE INCLUDE: Fuckfound.'));
623c65e2 459 foreach($vars as $var => $val) $$var=$val;
3e6c412e
TM
460 ob_start();
461 include($filename);
462 $out=ob_get_contents();
463 ob_end_clean();
464 return $out;
465 }
466
cdfce7c2
TM
467 function process_http_request_post($action=false, $class=false, $id=false) {
468 if($_SERVER['REQUEST_METHOD'] != 'POST') return;
469 echo('<pre>'); //DEBUG (maybe todo remove)
470
471 //SephirPOST:
371a86f4
TM
472
473 /* Tenhle foreach() prekopiruje promenne
7d20381f 474 * z: $_POST['values'][$table][$column][$id];
371a86f4
TM
475 * do: $values[$table][$id][$column]
476 */
7d20381f
TM
477 if(isset($_POST['values'])) {
478 $values=array();
479 foreach($_POST['values'] as $table => $columns) {
480 foreach($columns as $column => $ids) {
481 foreach($ids as $id => $val) $values[$table][$id][$column] = $val;
482 }
cdfce7c2 483 }
7d20381f 484 //die(print_r($values));
cdfce7c2
TM
485 }
486
487 if($action) switch($action) {
488 case 'new':
489 case 'edit':
371a86f4
TM
490 //if(!isset($_POST['table'])) die(trigger_error("Jest nutno specifikovat tabulku voe!"));
491 //$table=$_POST['table'];
492 $table='item';
cdfce7c2 493 //print_r($values); //debug
371a86f4 494 $last = $this->db->insert_or_update_multitab($values);
d9384cb5
TM
495 $last = "$table/$last/";
496 $next = "$table/new/";
497 echo 'Hotovo. Poslední vložený záznam naleznete '.$this->html->link('zde', $last).'.<br />'.
498 'Další záznam přidáte '.$this->html->link('zde', $next).'.';
499 die();
cdfce7c2
TM
500 break;
501 case 'delete':
502 if(!isset($_POST['sure']) || !$_POST['sure']) die(trigger_error('Sure user expected :-)'));
7d20381f
TM
503 $this->db->delete($class, $id);
504 die("Neco (pravdepodobne /$class/$id) bylo asi smazano. Fnuk :'-("); //TODO REDIRECT
cdfce7c2
TM
505 break;
506 case 'image':
507 $image_classes = array('model'); //TODO, use this more widely across the code
508 if(!in_array($class, $image_classes)) die(trigger_error("Nekdo nechce k DB Tride '$class' prirazovat obrazky!"));
509 $image_destination = DIR_IMAGES."/$class/$id.jpg";
510 if($_FILES['image']['name'] == '') die(trigger_error('Kazde neco se musi nejak jmenovat!'));
511 if(move_uploaded_file($_FILES['image']['tmp_name'], $image_destination)) {
512 chmod ($image_destination, 0664);
513 die('Obrazek se naladoval :)'); //TODO REDIRECT
514 } else die(trigger_error('Soubor se nenahral :('));
515 break;
516 default:
517 trigger_error('Nothin\' to do here my cutie :-*');
518 break;
519 }
520
521 die('POSTed pyčo!');
522 }
523
524 function process_http_request() {
525 $this->check_auth();
526
527 @ini_set('magic_quotes_gpc' , 'off');
528 if(get_magic_quotes_gpc()) {
529 die(trigger_error("Error: magic_quotes_gpc needs to be disabled! F00K!"));
530 }
531
532 $PATH_INFO=@trim($_SERVER[PATH_INFO]);
fc5c5b8b 533 echo $this->html->header($PATH_INFO);
cdfce7c2
TM
534
535
536 //Sephirot:
537 $PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
538 if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]='';
539 switch($PATH_CHUNKS[1]) {
540 case 'test': //test
541 die('Tell me why you cry');
542 break;
3e6c412e 543 case 'assistant': //assistant
623c65e2
TM
544 $assistant_vars['step'] = isset($PATH_CHUNKS[3]) && is_numeric($PATH_CHUNKS[3]) ? trim($PATH_CHUNKS[3]) : false;
545 echo $this->safe_include(DIR_ASSISTANTS,$PATH_CHUNKS[2],$assistant_vars);
3e6c412e 546 break;
cdfce7c2
TM
547 default: //?
548 $search = (isset($_GET['q']) && trim($_GET['q']) != '') ? trim($_GET['q']) : false;
549 $class = (isset($PATH_CHUNKS[1]) && $PATH_CHUNKS[1] != '') ? $PATH_CHUNKS[1] : 'item';
550 if(!isset($PATH_CHUNKS[2])) $PATH_CHUNKS[2]='';
551 switch($PATH_CHUNKS[2]) {
552 case 'new': //?/new
553 $this->process_http_request_post($PATH_CHUNKS[2], $class);
a25f85f8 554 echo $this->render_form_add($class);
cdfce7c2
TM
555 break;
556 default: //?/?
557 $id = (isset($PATH_CHUNKS[2]) && is_numeric($PATH_CHUNKS[2]) ? (int) $PATH_CHUNKS[2] : false);
558 if(!isset($PATH_CHUNKS[3])) $PATH_CHUNKS[3]='';
559 $edit=false;
560 switch($PATH_CHUNKS[3]) {
561 case 'edit': //?/?/edit
562 case 'image': //?/image
563 case 'delete': //?/delete
564 $this->process_http_request_post($PATH_CHUNKS[3], $class, $id);
565 $edit=true;
566 default: //?/?/?
567 $limit = (int) (isset($PATH_CHUNKS[3]) ? $PATH_CHUNKS[3] : '0');
568 $offset = (int) (isset($PATH_CHUNKS[4]) ? $PATH_CHUNKS[4] : '0');
a25f85f8
TM
569 echo $this->render_items($class, $id, $limit, $offset, $search);
570 echo $this->render_listing_extensions($class, $id, $limit, $offset, $edit);
cdfce7c2
TM
571 //print_r(array("<pre>",$_SERVER));
572 break;
573 }
574 break;
575 }
576 break;
577 }
578 }
579}
580
581$sklad = new Sklad_UI();
582$sklad->process_http_request();
583
584echo("<hr/>");
This page took 0.528903 seconds and 4 git commands to generate.