Esempio n. 1
0
 /**
  * Handle HTTP responses made with $_REQUEST['req'] = json (when <a ... data-cmd="gpajax">)
  * Sends JSON object to client
  *
  */
 static function Response()
 {
     global $page;
     if (!is_array($page->ajaxReplace)) {
         die;
     }
     if (!isset($_REQUEST['jsoncallback'])) {
         die('Invalid Request: jsoncallback not set');
     }
     //gadgets may be using gpajax/json request/responses
     gpOutput::TemplateSettings();
     gpOutput::PrepGadgetContent();
     echo gpAjax::Callback($_REQUEST['jsoncallback']);
     echo '([';
     //output content
     if (!empty($_REQUEST['gpx_content'])) {
         switch ($_REQUEST['gpx_content']) {
             case 'gpabox':
                 gpAjax::JsonDo('admin_box_data', '', $page->contentBuffer);
                 break;
         }
     } elseif (in_array('#gpx_content', $page->ajaxReplace)) {
         $replace_id = '#gpx_content';
         if (isset($_GET['gpreqarea'])) {
             $replace_id = '#' . $_GET['gpreqarea'];
         }
         ob_start();
         $page->GetGpxContent(true);
         $content = ob_get_clean();
         gpAjax::JsonDo('replace', $replace_id, $content);
     }
     //other areas
     foreach ($page->ajaxReplace as $arguments) {
         if (is_array($arguments)) {
             $arguments += array(0 => '', 1 => '', 2 => '');
             gpAjax::JsonDo($arguments[0], $arguments[1], $arguments[2]);
         }
     }
     //always send messages
     ob_start();
     echo GetMessages(false);
     $content = ob_get_clean();
     if (!empty($content)) {
         gpAjax::JsonDo('messages', '', $content);
     }
     echo ']);';
     die;
 }
Esempio n. 2
0
 /**
  * Save UI values for the current user
  *
  */
 function SaveGPUI()
 {
     global $gpAdmin;
     gpsession::SetGPUI();
     includeFile('tool/ajax.php');
     //send response so an error is not thrown
     echo gpAjax::Callback($_REQUEST['jsoncallback']) . '([]);';
     die;
     //for debugging
     die('debug: ' . showArray($_POST) . 'result: ' . showArray($gpAdmin));
 }