Back to index

moin  1.9.0~rc2
basexml.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
00004  * Copyright (C) 2003-2009 Frederico Caldeira Knabben
00005  *
00006  * == BEGIN LICENSE ==
00007  *
00008  * Licensed under the terms of any of the following licenses at your
00009  * choice:
00010  *
00011  *  - GNU General Public License Version 2 or later (the "GPL")
00012  *    http://www.gnu.org/licenses/gpl.html
00013  *
00014  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
00015  *    http://www.gnu.org/licenses/lgpl.html
00016  *
00017  *  - Mozilla Public License Version 1.1 or later (the "MPL")
00018  *    http://www.mozilla.org/MPL/MPL-1.1.html
00019  *
00020  * == END LICENSE ==
00021  *
00022  * These functions define the base of the XML response sent by the PHP
00023  * connector.
00024  */
00025 
00026 function SetXmlHeaders()
00027 {
00028        ob_end_clean() ;
00029 
00030        // Prevent the browser from caching the result.
00031        // Date in the past
00032        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ;
00033        // always modified
00034        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ;
00035        // HTTP/1.1
00036        header('Cache-Control: no-store, no-cache, must-revalidate') ;
00037        header('Cache-Control: post-check=0, pre-check=0', false) ;
00038        // HTTP/1.0
00039        header('Pragma: no-cache') ;
00040 
00041        // Set the response format.
00042        header( 'Content-Type: text/xml; charset=utf-8' ) ;
00043 }
00044 
00045 function CreateXmlHeader( $command, $resourceType, $currentFolder )
00046 {
00047        SetXmlHeaders() ;
00048 
00049        // Create the XML document header.
00050        echo '<?xml version="1.0" encoding="utf-8" ?>' ;
00051 
00052        // Create the main "Connector" node.
00053        echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">' ;
00054 
00055        // Add the current folder node.
00056        echo '<CurrentFolder path="' . ConvertToXmlAttribute( $currentFolder ) . '" url="' . ConvertToXmlAttribute( GetUrlFromPath( $resourceType, $currentFolder, $command ) ) . '" />' ;
00057 
00058        $GLOBALS['HeaderSent'] = true ;
00059 }
00060 
00061 function CreateXmlFooter()
00062 {
00063        echo '</Connector>' ;
00064 }
00065 
00066 function SendError( $number, $text )
00067 {
00068        if ( $_GET['Command'] == 'FileUpload' )
00069               SendUploadResults( $number, "", "", $text ) ;
00070 
00071        if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] )
00072        {
00073               SendErrorNode( $number, $text ) ;
00074               CreateXmlFooter() ;
00075        }
00076        else
00077        {
00078               SetXmlHeaders() ;
00079 
00080               // Create the XML document header
00081               echo '<?xml version="1.0" encoding="utf-8" ?>' ;
00082 
00083               echo '<Connector>' ;
00084 
00085               SendErrorNode( $number, $text ) ;
00086 
00087               echo '</Connector>' ;
00088        }
00089        exit ;
00090 }
00091 
00092 function SendErrorNode(  $number, $text )
00093 {
00094        if ($text)
00095               echo '<Error number="' . $number . '" text="' . htmlspecialchars( $text ) . '" />' ;
00096        else
00097               echo '<Error number="' . $number . '" />' ;
00098 }
00099 ?>