Xataface 2.0
Xataface Application Framework
actions/ajax_valuelist_append.php
Go to the documentation of this file.
00001 <?php
00002 import('Dataface/JSON.php');
00003 import('Dataface/ValuelistTool.php');
00004 
00005 class dataface_actions_ajax_valuelist_append {
00006 
00007         function handle(&$params){
00008                 $app =& Dataface_Application::getInstance();
00009                 
00010                 if ( !@$_POST['-valuelist'] ){
00011                         echo JSON::error("No valuelist specified.");
00012                         exit;
00013                 }
00014                 
00015                 $valuelist = $_POST['-valuelist'];
00016                 $query =& $app->getQuery();
00017                 
00018                 $table =& Dataface_Table::loadTable($query['-table']);
00019                 
00020                 
00021                 if ( !@$_POST['-value'] ){
00022                         echo JSON::error("No value was provided to be appended to the valuelist.");
00023                         exit;
00024                 }
00025                 
00026                 $value = $_POST['-value'];
00027                 if ( @$_POST['-key'] ){
00028                         $key = $_POST['-key'];
00029                 } else {
00030                         $key = null;
00031                 }       
00032                 
00033                 $vt =& Dataface_ValuelistTool::getInstance();
00034                 $res = $vt->addValueToValuelist($table, $valuelist, $value, $key, true);
00035                 if ( PEAR::isError($res) ){
00036                         echo JSON::error($res->getMessage());
00037                         exit;
00038                 }
00039                 echo JSON::json(array(
00040                         'success'=>1,
00041                         'value'=>array('key'=>$res['key'], 'value'=>$res['value'])
00042                         )
00043                 );
00044                 exit;
00045                 
00046                 
00047         }
00048 
00049 }
00050 
00051 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations