3 * SkladovySystem - Storage management system compatible with LMS
4 * Copyright (C) 2011 Tomas Mudrunka
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.
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.
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/>.
20 require_once('sklad.conf.php');
21 set_include_path(DIR_LIB
.PATH_SEPARATOR
.get_include_path());
23 require_once('Sklad_LMS-fake.class.php');
24 require_once('HTTP_Auth.class.php');
25 require_once('Locale.class.php');
28 * Trida poskytuje vseobecne funkce pro generovani HTML kodu
30 * Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)!
33 * @author Tomas Mudrunka
38 foreach($row as $var) {
39 if(trim($var) == '') $var = ' ';
40 $html.="<td>$var</td>";
46 function table(&$table, $params='border=1') {
47 $html="<table $params>";
49 foreach($table as $row) {
51 $html.=$this->row(array_keys($row));
54 $html.=$this->row($row);
60 function link($title='n/a', $link='#void', $internal=true) {
61 if($internal) $link = $this->internal_url($link);
62 return "<a href='$link'>".T($title)."</a>";
65 function img($src='#void', $title='img') {
66 return "<img src='$src' alt='$title' title='$title' width=64 />";
69 function input($name=false, $value=false, $type='text', $placeholder=false, $options=false) {
70 $html = "<input type='$type' ";
71 if($name) $html.= "name='$name' ";
72 if(!is_bool($value)) {
73 if($type == 'submit') $value = T($value);
74 $html.= "value='$value' ";
76 if($options) $html.= "$options ";
77 if($placeholder) $html.= "placeholder='$placeholder' ";
82 function select($name, $selectbox, $default=false) {
83 //echo('<pre>'); print_r($selectbox);
84 $html = "<select name='$name'>";
87 $value=$default; $title=$selectbox[$value];
88 $html .= "<option value='$value'>$value :: $title</option>";
89 unset($selectbox[$value]);
91 foreach($selectbox as $value => $title) {
92 $html .= "<option value='$value'>$value :: $title</option>";
100 * Trida poskytuje podpurne funkce pro generovani HTML kodu specificke pro sklad
102 * Tato trida by nemela sama nic vypisovat (vyjma chybovych a debugovacich hlasek)!
104 * @package Sklad_HTML
105 * @author Tomas Mudrunka
107 class Sklad_HTML
extends HTML
{
108 function header($title='') {
110 $script = $_SERVER['SCRIPT_NAME'];
111 $search = htmlspecialchars(@trim
($_GET['q']));
112 $message = strip_tags(@trim
($_GET['message']),'<a><b><u><i>');
115 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
117 <h1><a href="$script/">SystémSklad</a><small>$title</small></h1>
119 <style type="text/css">
134 .menu, .menu * menu {
139 border: 1px solid orange;
144 .menu li:hover menu, .menu li:hover {
146 background-color: yellow;
153 <li><a href="?logout">Logout</a></li>
154 <li><a href="$script/">Home</a></li>
155 <li><a href="#">Assistants</a>
157 <li><a href="$script/assistant/stats">stats</a></li>
158 <li><a href="$script/assistant/store">store</a></li>
159 <li><a href="$script/assistant/store-single">store-single</a></li>
160 <li><a href="$script/assistant/dispose">dispose</a></li>
161 <li><a href="$script/assistant/sell">sell</a></li>
162 <li>↓↓ BETA ↓↓</li>
165 <li><a href="#">List</a>
167 <li><a href="$script/item">item</a></li>
168 <li><a href="$script/model">model</a></li>
169 <li><a href="$script/category">category</a></li>
170 <li><a href="$script/producer">producer</a></li>
171 <li><a href="$script/vendor">vendor</a></li>
172 <li><a href="$script/room">room</a></li>
173 <li><a href="$script/status">status</a></li>
176 <li><a href="#">New</a>
178 <li><a href="$script/item/new">item</a></li>
179 <li><a href="$script/model/new">model</a></li>
180 <li><a href="$script/category/new">category</a></li>
181 <li><a href="$script/producer/new">producer</a></li>
182 <li><a href="$script/vendor/new">vendor</a></li>
183 <li><a href="$script/room/new">room</a></li>
184 <li><a href="$script/status/new">status</a></li>
189 <div style="float: right;">
190 <form action="$script/assistant/go" method="GET" style="float: left;"><!-- TODO: Display only when go plugin available -->
191 <input type="text" name="q" placeholder="smart id..." />
192 <input type="submit" value="go" />
194 <form action="?" method="GET" style="float: left;">
195 <input type="text" name="q" placeholder="regexp..." value="$search" />
196 <input type="submit" value="filter" />
198 <!-- form action="$script/" method="GET">
199 <input type="text" name="q" placeholder="regexp..." value="$search" />
200 <input type="submit" value="search items" />
204 <hr style="clear: both;" />
205 <div style="background-color:#FFDDDD;">
206 <font color="red">$message</font>
211 function internal_url($link) {
212 return $_SERVER['SCRIPT_NAME'].'/'.$link;
215 function table_add_images(&$table) {
216 $image = array('model_id');
217 foreach($table as $id => $row) {
218 foreach($image as $column) if(isset($table[$id][$column])) {
219 $type = @array_shift
(preg_split('/_/', $column));
220 $src=URL_IMAGES
."/$type/".$table[$id][$column].'.jpg';
221 $table[$id][$type.'_image']=$this->img($src, $table[$id][$column]);
226 function table_collapse(&$table) {
228 'item_id' => 'item_id',
229 'model_id' => 'model_name',
230 'category_id' => 'category_name',
231 'producer_id' => 'producer_name',
232 'vendor_id' => 'vendor_name',
233 'room_id' => 'room_name',
234 'status_id' => 'status_name',
236 foreach($table as $id => $row) {
237 foreach($collapse as $link => $title)
238 if(isset($table[$id][$link]) && isset($row[$title])) {
239 $type = @array_shift
(preg_split('/_/', $link));
240 if($link != $title) unset($table[$id][$link]);
241 $table[$id][$title]=$this->link($row[$title], $type.'/'.$row[$link].'/');
246 function table_sort(&$table) {
247 $precedence = array('item_id', 'model_image', 'model_name','model_descript','category_name','status_name','room_name');
248 $table_sorted = array();
249 foreach($table as $id => $row) {
250 $table_sorted[$id] = array();
251 foreach($precedence as $column) if(isset($table[$id][$column])) {
252 $table_sorted[$id][T($column)]=$table[$id][$column];
253 unset($table[$id][$column]);
255 //$table_sorted[$id]=array_merge($table_sorted[$id],$table[$id]);
256 foreach($table[$id] as $key => $val) $table_sorted[$id][T($key)] = $val; //array_merge with T() translating
258 $table = $table_sorted;
261 function render_item_table($table) {
262 $this->table_add_images($table);
263 $this->table_collapse($table);
264 $this->table_sort($table);
265 return $this->table($table);
268 function render_insert_form($class, $columns, $selectbox=array(), $current=false, $hidecols=false, $action=false, $multi_insert=true) {
269 //echo('<pre>'); print_r($selectbox);
270 //echo('<pre>'); print_r($current);
272 if(is_array($current)) {
274 $current = array_shift($current);
277 if(!is_array($hidecols)) $hidecols = array('item_author', 'item_valid_from', 'item_valid_till'); //TODO Autodetect
279 $action = $action ?
" action='$action'" : false;
280 $html="<form$action method='POST'>";
281 if($multi_insert) $html.='<div name="input_set" style="float:left; border:1px solid grey;">';
282 //$html.=$this->input('table', $class, 'hidden');
283 foreach($columns as $column) {
284 $html.=T($class).':<b>'.T($column['Field']).'</b>: ';
285 $name="values[$class][".$column['Field'].'][]';
286 $val = $update && isset($current[$column['Field']]) ?
$current[$column['Field']] : false;
288 case (preg_match('/auto_increment/', $column['Extra']) ||
in_array($column['Field'], $hidecols)):
290 $html.=$this->input($name, $val, 'hidden');
291 $html.=$val.'(AUTO)';
293 case isset($selectbox[$column['Field']]):
294 $html.=$this->select($name,$selectbox[$column['Field']],$val);
297 $html.=$this->input($name, $val);
304 //TODO, move to separate JS file
307 <span name="input_set_next"></span><br style="clear:both" />
309 function duplicate_element(what, where) {
310 document.getElementsByName(where)[0].outerHTML =
311 document.getElementsByName(what)[0].outerHTML
312 + document.getElementsByName(where)[0].outerHTML;
315 <a href='#' onClick="duplicate_element('input_set', 'input_set_next')">+</a>
319 $btn = is_array($current) ?
'UPDATE' : 'INSERT'; //TODO: $current may be set even when inserting...
320 $html.=$this->input(false, $btn, 'submit');
327 * Trida poskytuje rozhrani k databazi skladu
330 * @author Tomas Mudrunka
332 class Sklad_DB
extends PDO
{
333 function __construct() {
334 $this->lms
= new Sklad_LMS();
337 DB_DSN
, DB_USER
, DB_PASS
,
338 array(PDO
::MYSQL_ATTR_INIT_COMMAND
=> "SET NAMES utf8") //Force UTF8 for MySQL
342 function escape($str) {
343 return preg_replace('(^.|.$)', '', $this->quote($str)); //TODO HACK
346 function build_query_select($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false, $order=false, $suffix_id='_id') {
349 'item' => array('model', 'category', 'producer', 'vendor', 'room', 'status'),
350 'model' => array('category', 'producer')
351 ); //TODO Autodetect using foreign keys?
352 $search_fields = array(
353 'item' => array('item_id','item_serial','model_name','model_barcode','model_descript','producer_name','vendor_name')
357 $class = $this->escape($class);
360 $sql="SELECT * FROM $class\n";
362 if(isset($join[$class])) foreach($join[$class] as $j) $sql .= "LEFT JOIN $j USING($j$suffix_id)\n";
365 $search = $this->quote($search);
366 if(!isset($search_fields[$class])) die(trigger_error(T("Can't search in $class table yet :-("))); //TODO: post_redirect_get
368 foreach($search_fields[$class] as $column) $sql_search .= "OR $column REGEXP $search ";
369 $where[] = "FALSE $sql_search";
370 } elseif($id) $where[] = "$class$suffix_id = $id";
371 if(!$history && $this->contains_history($class)) $where[] = $class.'_valid_till=0';
373 if($where) $sql .= 'WHERE ('.implode(') AND (', $where).")\n";
375 if(!$order) $order = $class.$suffix_id;
376 if($this->contains_history($class)) $order .= ",${class}_valid_from DESC";
377 $sql .= "ORDER BY $order\n";
380 $limit = $this->escape((int)$limit);
381 $offset = $this->escape((int)$offset);
382 $sql .= "LIMIT $offset,$limit\n";
388 function safe_query($sql, $fatal=true) {
389 $result = $this->query($sql);
391 $error = $this->errorInfo();
392 trigger_error("<font color=red><b>QUERY FAILED ($error[0],$error[1]): </b>$error[2]<br /><br /><b>QUERY:</b>\n<pre>$sql</pre></font>");
398 function translate_query_results($result) {
399 $translate_cols = array('status_name', 'item_valid_till'); //TODO: Hardcoded
400 foreach($result as $key => $row) {
401 foreach($translate_cols as $col) if(isset($result[$key][$col])){
402 $result[$key][$col] = T($result[$key][$col]);
408 function safe_query_fetch($sql, $fatal=true, $fetch_flags = PDO
::FETCH_ASSOC
, $translate=true) {
409 $result = $this->safe_query($sql, $fatal)->fetchAll($fetch_flags);
410 if($translate) $result = $this->translate_query_results($result);
415 function get_listing($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false, $indexed=array(), $suffix_id='_id') {
416 $sql = $this->build_query_select($class, $id, $limit, $offset, $where, $search, $history);
417 $result = $this->safe_query_fetch($sql);
418 if(!$result ||
!is_array($indexed)) return $result;
420 foreach($result as $key => $row) $indexed[$row[$class.$suffix_id]]=$row;
424 function get_columns($class) {
425 $class = $this->escape($class);
426 $sql = "SHOW COLUMNS FROM $class;";
427 return $this->safe_query_fetch($sql);
430 function columns_get_selectbox($columns, $class=false, $suffix_id='_id', $suffix_name='_name') {
432 foreach($columns as $column) {
433 if($column['Field'] == 'user_id') continue; //TODO HACK Blacklist: tabulka nemusi obsahovat *_name!!! momentalne se to tyka jen tabulky user (a item - u ty to nevadi)!
434 if($class && $column['Field'] == $class.$suffix_id) continue;
435 if(!preg_match('/'.$suffix_id.'$/', $column['Field'])) continue;
436 $table=preg_replace('/'.$suffix_id.'$/','',$column['Field']);
438 $history = $this->contains_history($table) ?
" WHERE ${table}_valid_till=0" : '';
439 $sql = "SELECT $table$suffix_id, $table$suffix_name FROM $table$history;"; //TODO use build_query_select()!!!
440 $result = $this->safe_query_fetch($sql, false);
441 if(!$result) continue;
442 foreach($result as $row) $selectbox[$table.$suffix_id][$row[$table.$suffix_id]]=$row[$table.$suffix_name];
444 //echo('<pre>'); print_r($selectbox);
445 return array_filter($selectbox, 'ksort');
448 function map_unique($key, $value, $select, $table) { //TODO: Guess $select and $table if not passed
449 $history = $this->contains_history($table) ?
" AND ${table}_valid_till=0" : '';
450 $value=$this->quote($value);
451 $sql = "SELECT $select FROM $table WHERE $key=$value$history LIMIT 1;"; //TODO use build_query_select()!!!
452 $result = $this->safe_query_fetch($sql);
453 if(isset($result[0][$select])) return $result[0][$select]; else die(trigger_error(T('Record not found!'))); //TODO post_redirect_get...
456 function contains_history($table) {
457 $history_tables = array('item'); //TODO Autodetect
458 return in_array($table, $history_tables);
461 function build_query_insert($table, $values, $replace=true, $suffix_id='_id') {
463 $history = $this->contains_history($table);
466 $table = $this->escape($table);
468 //Get list of POSTed columns
469 $columns_array = array_map(array($this,'escape'), array_keys($values[0]));
470 $columns = implode(',',$columns_array);
474 //echo('<pre>'); die(print_r($values));
477 $history_update=false; foreach($values as $row) if(is_numeric($row[$table.'_id'])) $history_update=true;
478 if($history_update) {
479 $sql .= "UPDATE $table";
480 $sql .= " SET ${table}_valid_till=NOW()";
481 $sql .= " WHERE ${table}_valid_till=0 AND (";
483 foreach($values as $row) {
484 $sql .= $or.' '.$table.'_id='.$row[$table.'_id'];
492 //Insert into table (columns)
493 $sql .= "INSERT INTO $table ($columns) VALUES ";
495 //Values (a,b,c),(d,e,f)
497 foreach($values as $row) {
498 $row_quoted = array_map(array($this,'quote'), $row); //Check
500 foreach($row as $column => $value) {
502 case $table.'_valid_from':
503 $row_quoted[$column] = 'NOW()';
505 case $table.'_valid_till':
506 $row_quoted[$column] = '0';
508 case $table.'_author':
509 $row_quoted[$column] = $this->lms
->get_authorized_user_id();
510 //die($this->lms->get_authorized_user_id().'=USER');
515 $sql .= $comma.'('.implode(',',$row_quoted).')';
521 foreach($columns_array as $col) {
522 if($col == $table.'_id' ||
$col == $table.'_valid_till') continue;
523 $on_duplicate[] = "$col=VALUES($col)";
525 $sql .= "\nON DUPLICATE KEY UPDATE ".implode(',', $on_duplicate);
533 function insert_or_update($table, $values, $replace=true) {
534 $sql = $this->build_query_insert($table, $values, $replace);
535 $this->safe_query($sql);
536 return $this->lastInsertId();
539 function insert_or_update_multitab($values, $replace=true) {
541 foreach($values as $table => $rows) $last = $this->insert_or_update($table, $rows, $replace);
545 function delete($table, $id, $suffix_id='_id') {
546 if($this->contains_history($table)) return false;
547 $key = $this->escape($table.$suffix_id);
548 $table = $this->escape($table);
549 $id = $this->quote($id);
550 return $this->safe_query("DELETE FROM $table WHERE $key = $id LIMIT 1;");
555 * Trida poskytuje high-level rozhrani k databazi skladu
557 * @package Sklad_DB_Abstract
558 * @author Tomas Mudrunka
560 class Sklad_DB_Abstract
extends Sklad_DB
{
565 * Trida implementuje uzivatelske rozhrani skladu
568 * $sklad = new Sklad_UI();
569 * $sklad->process_http_request();
572 * @author Tomas Mudrunka
575 function __construct() {
576 $this->db
= new Sklad_DB();
577 $this->html
= new Sklad_HTML();
580 function render_items($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false) {
581 return $this->html
->render_item_table($this->db
->get_listing($class, $id, $limit, $offset, $where, $search, $history, false));
584 function render_form_add($class) {
585 $columns = $this->db
->get_columns($class);
586 $selectbox = $this->db
->columns_get_selectbox($columns, $class);
587 return $this->html
->render_insert_form($class, $columns, $selectbox);
590 function render_form_edit($class, $id) {
591 $columns = $this->db
->get_columns($class);
592 $selectbox = $this->db
->columns_get_selectbox($columns, $class);
593 $current = $this->db
->get_listing($class, $id, 1);
594 return $this->html
->render_insert_form($class, $columns, $selectbox, $current);
597 function render_single_record_details($class, $id) {
599 $id_prev = $id - 1 > 0 ?
$id - 1 : 0;
600 $get = $_SERVER['QUERY_STRING'] != '' ?
'?'.$_SERVER['QUERY_STRING'] : '';
602 $html.= $this->html
->link('<<', "$class/$id_prev/");
604 $html.= $this->html
->link('>>', "$class/$id_next/");
606 $html.= $this->html
->link('edit', "$class/$id/edit/");
607 if($this->db
->contains_history($class)) $html.= ' ][ '.$this->html
->link('history', "$class/$id/history/");
611 function render_listing_navigation($class, $id, $limit, $offset) {
612 $offset_next = $offset +
$limit;
613 $offset_prev = $offset - $limit > 0 ?
$offset - $limit : 0;
614 $get = $_SERVER['QUERY_STRING'] != '' ?
'?'.$_SERVER['QUERY_STRING'] : '';
616 $html.= $this->html
->link('<<', "$class/$id/$limit/$offset_prev/$get");
618 $html.= $this->html
->link('>>', "$class/$id/$limit/$offset_next/$get");
620 $html.= $this->html
->link('new', "$class/new/$get");
624 function render_listing_extensions($class, $id, $limit, $offset, $edit=false) {
626 if(is_numeric($id)) {
627 $html.=$this->render_single_record_details($class, $id);
629 $html.=$this->render_listing_navigation($class, '*', $limit, $offset);
632 $html.= $this->render_form_edit($class, $id);
633 $action = $_SERVER['SCRIPT_NAME']."/$class/$id/delete";
634 $html.= "<form action='$action' method='POST'>";
635 $html.= $this->html
->input(false, 'DELETE', 'submit');
636 $html.= T('sure?').$this->html
->input('sure', false, 'checkbox');
638 $action = $_SERVER['SCRIPT_NAME']."/$class/$id/image";
639 $html.= "<form action='$action' method='POST' enctype='multipart/form-data'>";
640 $html.= $this->html
->input('image', false, 'file', false, 'size="30"');
641 $html.= $this->html
->input(false, 'IMAGE', 'submit');
647 function check_auth() {
648 new HTTP_Auth('SkladovejSystem', true, array($this->db
->lms
,'check_auth'));
651 function post_redirect_get($location, $message='', $error=false) {
652 $url_args = $message != '' ?
'?message='.urlencode(T($message)) : '';
653 $location = $this->html
->internal_url($location).$url_args;
654 header('Location: '.$location);
655 if($error) trigger_error($message);
656 $location=htmlspecialchars($location);
658 "<meta http-equiv='refresh' content='0; url=$location'>".
659 T($message)."<br />Location: <a href='$location'>$location</a>"
663 function safe_include($dir,$name,$vars=array(),$ext='.inc.php') {
664 if(preg_match('/[^a-zA-Z0-9-]/',$name)) $this->post_redirect_get('', 'SAFE INCLUDE: Securityfuck.', true);
665 $filename="$dir/$name$ext";
666 if(!is_file($filename)) $this->post_redirect_get('', 'SAFE INCLUDE: Fuckfound.', true);
667 foreach($vars as $var => $val) $
$var=$val;
670 $out=ob_get_contents();
675 function process_http_request_post($action=false, $class=false, $id=false, $force_redirect=false) {
676 if($_SERVER['REQUEST_METHOD'] != 'POST') return;
677 //echo('<pre>'); //DEBUG (maybe todo remove), HEADERS ALREADY SENT!!!!
681 /* Tenhle foreach() prekopiruje promenne
682 * z: $_POST['values'][$table][$column][$id];
683 * do: $values[$table][$id][$column]
685 if(isset($_POST['values'])) {
687 foreach($_POST['values'] as $table => $columns) {
688 foreach($columns as $column => $ids) {
689 foreach($ids as $id => $val) $values[$table][$id][$column] = $val;
692 //die(print_r($values));
695 if($action) switch($action) {
699 if(!isset($replace)) $replace = true;
700 $table = $class ?
$class : 'item';
701 //print_r($values); //debug
702 $last = $this->db
->insert_or_update_multitab($values, $replace);
703 $last = $force_redirect ?
$force_redirect."?last=$last" : "$table/$last/";
704 $next = "$table/new/";
705 $message = $force_redirect ?
'' : 'Hotovo. Další záznam přidáte '.$this->html
->link('zde', $next).'.';
706 $this->post_redirect_get($last, $message);
709 if(!isset($_POST['sure']) ||
!$_POST['sure']) $this->post_redirect_get("$class/$id/edit", 'Sure user expected :-)');
710 $this->db
->delete($class, $id) ||
$this->post_redirect_get("$class/$id/edit", "V tabulce $class jentak neco mazat nebudes chlapecku :-P");
711 $this->post_redirect_get("$class", "Neco (pravdepodobne /$class/$id) bylo asi smazano. Fnuk :'-(");
714 $image_classes = array('model'); //TODO, use this more widely across the code
715 if(!in_array($class, $image_classes)) $this->post_redirect_get("$class/$id/edit", "Nekdo nechce k DB Tride '$class' prirazovat obrazky!");
716 $image_destination = DIR_IMAGES
."/$class/$id.jpg";
717 if($_FILES['image']['name'] == '') $this->post_redirect_get("$class/$id/edit", 'Everything has to be called somehow!', true);
718 if(move_uploaded_file($_FILES['image']['tmp_name'], $image_destination)) {
719 chmod ($image_destination, 0664);
720 $this->post_redirect_get("$class/$id", 'Image has been upbloated successfully :)');
721 } else $this->post_redirect_get("$class/$id/edit", 'File upload failed :(', true);
724 $this->post_redirect_get('', 'Nothin\' to do here my cutie :-*');
731 function process_http_request() {
734 @ini_set
('magic_quotes_gpc' , 'off');
735 if(get_magic_quotes_gpc()) {
736 die(trigger_error("Error: magic_quotes_gpc needs to be disabled! F00K!"));
739 $PATH_INFO=@trim
($_SERVER[PATH_INFO
]);
740 if($_SERVER['REQUEST_METHOD'] != 'POST') echo $this->html
->header($PATH_INFO); //TODO tahle podminka naznacuje ze je v navrhu nejaka drobna nedomyslenost...
744 $PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
745 if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]='';
746 switch($PATH_CHUNKS[1]) {
748 die('Tell me why you cry');
750 case 'assistant': //assistant
751 $PATH_CHUNKS[3] = isset($PATH_CHUNKS[3]) ?
trim($PATH_CHUNKS[3]) : false;
752 $assistant_vars['SUBPATH'] = array_slice($PATH_CHUNKS, 3);
753 $assistant_vars['URL_INTERNAL'] = 'assistant/'.$PATH_CHUNKS[2];
754 $assistant_vars['URL'] = $_SERVER['SCRIPT_NAME'].'/'.$assistant_vars['URL_INTERNAL'];
755 echo $this->safe_include(DIR_ASSISTANTS
,$PATH_CHUNKS[2],$assistant_vars);
758 $search = (isset($_GET['q']) && trim($_GET['q']) != '') ?
trim($_GET['q']) : false;
759 $class = (isset($PATH_CHUNKS[1]) && $PATH_CHUNKS[1] != '') ?
$PATH_CHUNKS[1] : 'item';
760 if(!isset($PATH_CHUNKS[2])) $PATH_CHUNKS[2]='';
761 switch($PATH_CHUNKS[2]) {
763 $this->process_http_request_post($PATH_CHUNKS[2], $class);
764 echo $this->render_form_add($class);
767 $id = (isset($PATH_CHUNKS[2]) && is_numeric($PATH_CHUNKS[2]) ?
(int) $PATH_CHUNKS[2] : false);
768 if(!isset($PATH_CHUNKS[3])) $PATH_CHUNKS[3]='';
770 switch($PATH_CHUNKS[3]) {
771 case 'edit': //?/?/edit
772 case 'image': //?/?/image
773 case 'delete': //?/?/delete
774 $this->process_http_request_post($PATH_CHUNKS[3], $class, $id);
777 $history = $PATH_CHUNKS[3] == 'history' ?
true : false;
778 $limit = (int) (isset($PATH_CHUNKS[3]) ?
$PATH_CHUNKS[3] : '0');
779 $offset = (int) (isset($PATH_CHUNKS[4]) ?
$PATH_CHUNKS[4] : '0');
780 $where = false; //TODO get from URL
781 echo $this->render_items($class, $id, $limit, $offset, $where, $search, $history);
782 echo $this->render_listing_extensions($class, $id, $limit, $offset, $edit);
783 //print_r(array("<pre>",$_SERVER));
793 $sklad = new Sklad_UI();
794 $sklad->process_http_request();
This page took 0.886735 seconds and 4 git commands to generate.