POST (handler+formular) upraveny tak, aby nabidli udrzitelny interface pro upravy...
authorThomas Mudrunka <tomas@mudrunka.cz>
Tue, 26 Jul 2011 00:58:10 +0000 (02:58 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Tue, 26 Jul 2011 00:59:54 +0000 (02:59 +0200)
index.php

index 15c19ec306b624495c72ef994cad98e67e29f5c8..8d6ff1460af8ab9350aea7d8cd06d3772ca7c5bd 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -181,7 +181,7 @@ EOF;
                //$html.=$this->input('table', $class, 'hidden');
                foreach($columns as $column)    {
                        $html.=$class.':<b>'.$column['Field'].'</b>: ';
-                       $name='value;'.$class.';'.$column['Field'].'[]';
+                       $name="values[$class][".$column['Field'].'][]';
                        $val = $update ? $current[$column['Field']] : false;
                        switch(true) {
                                case preg_match('/auto_increment/', $column['Extra']):
@@ -463,24 +463,19 @@ class Sklad_UI {
                //SephirPOST:
 
                /* Tenhle foreach() prekopiruje promenne
-                * z:           $_POST['value;$table;$column'][$id];
+                * z:           $_POST['values'][$table][$column][$id];
                 * do:  $values[$table][$id][$column]
                 */
-
-               $values=array();
-               foreach($_POST as $key => $value) {
-                       $name = preg_split('/;/',$key);
-                       if(isset($name[0])) switch($name[0]) {
-                               case 'value':
-                                       foreach($value as $id => $val) $values[$name[1]][$id][$name[2]]=$value[$id];
-                                       break;
-                               default:
-                                       break;
+               if(isset($_POST['values'])) {
+                       $values=array();
+                       foreach($_POST['values'] as $table => $columns) {
+                               foreach($columns as $column => $ids) {
+                                       foreach($ids as $id => $val) $values[$table][$id][$column] = $val;
+                               }
                        }
+                       //die(print_r($values));
                }
 
-               //die(print_r($values));
-
                if($action) switch($action) {
                        case 'new':
                        case 'edit':
@@ -493,8 +488,8 @@ class Sklad_UI {
                                break;
                        case 'delete':
                                if(!isset($_POST['sure']) || !$_POST['sure']) die(trigger_error('Sure user expected :-)'));
-                               //$this->db->delete($class, $id);
-                               die('Neco asi bylo smazano. Fnuk :\'-('); //TODO REDIRECT
+                               $this->db->delete($class, $id);
+                               die("Neco (pravdepodobne /$class/$id) bylo asi smazano. Fnuk :'-("); //TODO REDIRECT
                                break;
                        case 'image':
                                $image_classes = array('model'); //TODO, use this more widely across the code
This page took 0.142399 seconds and 4 git commands to generate.