Xataface 2.0
Xataface Application Framework
actions/disabled/update_grid.php
Go to the documentation of this file.
00001 <?php
00002 import('Dataface/dhtmlxGrid/activegrid.php');
00003 
00019 class dataface_actions_update_grid {
00020 
00021         function handle(&$params){
00022                 if ( isset($_POST['--cleargrids']) and $_POST['--cleargrids'] == 1) Dataface_dhtmlXGrid_activegrid::clearGrids();
00023                 $cells = @$_REQUEST['cells'];
00024                 
00025                 
00026                 
00027                 
00028                 $gridid = @$_REQUEST['-gridid'];
00029                 $rowid = @$_REQUEST['-rowid'];
00030 
00031 
00032                 $grid = Dataface_dhtmlXGrid_activegrid::getGrid($gridid);
00033                 if ( !is_object($grid) ){
00034 
00035                         echo $this->error('Could not find grid with id "'.$gridid.'"');
00036                         exit;
00037                 }
00038                 
00039                 if ( !is_array($cells) ){
00040                         echo $this->notice('No cells were submitted to be updated.');
00041                         exit;
00042                 }
00043                 //$cells = array_map('trim',$cells);
00044                 foreach (array_keys($cells) as $key){
00045                         $cells[$key] = trim($cells[$key], "\x7f..\xff\x0..\x1f");
00046                 }
00047                 print_r($cells);
00048                 
00049                 $res = $grid->setRowValues($rowid, $cells);
00050                 if ( PEAR::isError($res) ){
00051                         echo $this->error($res->getMessage());
00052                 }
00053                 $grid->update();
00054                 $grid2 = Dataface_dhtmlXGrid_activegrid::getGrid($gridid);
00055                 echo $this->json(array('success'=>1));
00056                 exit;
00057                 
00058                 
00059         }
00060         
00061         function notice($msg){
00062                 return $this->json(array('notice'=>$msg, 'success'=>0));
00063         }
00064         
00065         function warning($msg){
00066                 return $this->json(array('warning'=>$msg, 'success'=>0));
00067         }
00068         
00069         function error($msg){
00070                 return $this->json(array('error'=>$msg, 'success'=>0));
00071         }
00072         
00073         function json($arr){
00074                 if ( is_array($arr) ){
00075                         $out = array();
00076                         foreach ( $arr as $key=>$val){
00077                                 $out[] = "'".addslashes($key)."': {$this->json($val)}";
00078                         }
00079                         return "{".implode(', ', $out)."}";
00080                 } else if ( is_int($arr) || is_float($arr) ){
00081                         return $arr;
00082                 } else if ( is_bool($arr) ){
00083                         return ( $arr?'1':'0');
00084                 } else {
00085                         return "'".addslashes($arr)."'";
00086                 }
00087         }
00088 
00089 }
00090 
00091 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations