phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] [18567] add support for RFC4627 json requests and upd


From: Dave Hall
Subject: [Phpgroupware-cvs] [18567] add support for RFC4627 json requests and update header
Date: Sun, 01 Jun 2008 04:38:32 +0000

Revision: 18567
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18567
Author:   skwashd
Date:     2008-06-01 04:38:31 +0000 (Sun, 01 Jun 2008)

Log Message:
-----------
add support for RFC4627 json requests and update header

Modified Paths:
--------------
    trunk/phpgroupware/index.php

Modified: trunk/phpgroupware/index.php
===================================================================
--- trunk/phpgroupware/index.php        2008-06-01 04:12:22 UTC (rev 18566)
+++ trunk/phpgroupware/index.php        2008-06-01 04:38:31 UTC (rev 18567)
@@ -2,13 +2,29 @@
        /**
        * phpGroupWare
        *
-       * phpgroupware base
-       * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @author Dave Hall <address@hidden>
+       * @author Others <unknown>
+       * @copyright Copyright (C) 2000-2008 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package phpgroupware
        * @version $Id$
        */
 
+       /*
+          This program is free software: you can redistribute it and/or modify
+          it under the terms of the GNU General Public License as published by
+          the Free Software Foundation, either version 3 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU General Public License for more details.
+
+          You should have received a copy of the GNU General Public License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
        $phpgw_info = array();
        if (!file_exists('header.inc.php'))
        {
@@ -80,9 +96,12 @@
                && $GLOBALS[$class]->public_functions[$method] )
 
        {
-               if ( isset($_GET['phpgw_return_as']) && 
$_GET['phpgw_return_as'] == 'json' )
+               if ( phpgw::get_var('X-Requested-With', 'string', 'SERVER') == 
'XMLHttpRequest'
+                        // deprecated
+                       || phpgw::get_var('phpgw_return_as', 'string', 'GET') 
== 'json' )
                {
-                       Header('Content-Type: text/javascript');
+                       // comply with RFC 4627
+                       header('Content-Type: application/json'); 
                        $return_data = $GLOBALS[$class]->$method();
                        echo json_encode($return_data);
                        $GLOBALS['phpgw_info']['flags']['nofooter'] = true;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]