Zed. The source code to build a world.

api_helpers.php

API helper functions

Zed. The immensity of stars. The HyperShip. The people.

(c) 2010, Dereckson, some rights reserved. Released under BSD license.

This file provides a functions to output the API message in several formats.

The supported formats are preview (PHP dump), XML, PHP serialize and json.

The XML outputs code uses the following codes: - http://www.thedeveloperday.com/xml-beautifier-tool/ - http://snipplr.com/view/3491/convert-php-array-to-xml-or-simple-xml-object-if-you-wish/

Tags
subpackage

API

author

Sébastien Santoro aka Dereckson dereckson@espace-win.org

copyright

2010 Sébastien Santoro aka Dereckson

license

http://www.opensource.org/licenses/bsd-license.php BSD

version
0.1
link
http://scherzo.dereckson.be/doc/zed
link
http://zed.dereckson.be/
filesource

Table of Contents

Functions

toXml()  : string
The main function for converting to an XML document.
api_output()  : mixed
Outputs API reply, printing it in the specified format.

Functions

toXml()

The main function for converting to an XML document.

toXml(mixed $data[, string $rootNodeName = 'data' ][, SimpleXMLElement $xml = null ][, string $unknownNodeName = 'unknownNode' ]) : string

Pass in a multidimensional array and this recursively loops through and builds up an XML document.

Parameters
$data : mixed
$rootNodeName : string = 'data'

What you want the root node to be — defaults to data.

$xml : SimpleXMLElement = null

Should only be used recursively

$unknownNodeName : string = 'unknownNode'

Name to give to unknown (numeric) keys

Return values
string

XML

api_output()

Outputs API reply, printing it in the specified format.

api_output(mixed $reply, string $xmlRoot[, string $xmlChildren = "item" ]) : mixed

The format will be read form $_REQUEST['format'].

Parameters
$reply : mixed

the reply to format

$xmlRoot : string

the XML root element name (optional, default value is 'data').

$xmlChildren : string = "item"

the XML children elements name (optional, will be deducted from the context if omitted, or, if not possible, will be unknownNode)


        
On this page

Search results