<?php
/* SVN FILE: $Id: ajax.php 5421 2007-07-09 04:58:57Z phpnut $ */
/**
* Helper for AJAX operations.
*
* Helps doing AJAX using the Prototype library.
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2005-2007, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs.view.helpers
* @since CakePHP(tm) v 0.10.0.1076
* @version $Revision: 5421 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2007-07-08 23:58:57 -0500 (Sun, 08 Jul 2007) $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* XmlHelper library.
*
* Helps doing XML
*
* @package cake
* @subpackage cake.cake.libs.view.helpers
*/
class XmlHelper extends Helper
{
var $helpers = array('Html', 'Javascript');
var $current_depth = 1;
var $max_depth = 20;
function renderArray($key,$value, $no_follow=array(),$max_depth = null)
{
$max_depth = ($max_depth === null) ? $this->max_depth : $max_depth;
$tab = '';
$txt = "$tab<$key>";
$this->current_depth++;
//Check for double arrays
if(is_array($value) && isset($value[0]) && is_array($value[0]) && !in_array($key,$no_follow))
{
foreach($value as $inner_value)
{
$new_key = Inflector::singularize($key);
$txt .= $this->renderArray($new_key,$inner_value,$no_follow,$max_depth);
}
}
//Check for single arrays
elseif(is_array($value) && !in_array($key,$no_follow) && $this->current_depth <= $max_depth)
{
foreach($value as $k=>$v)
{
$txt .= $tab.$this->renderArray($k,$v,$no_follow,$max_depth);
}
}
else
{
//Disregard errors because arrays might land here
$txt .= @htmlspecialchars($value);
}
$this->current_depth--;
$txt.= "</$key>\n";
return $txt;
}
function parseXML($xml)
{
$x = new DOMDocument();
$x->load($xml);
}
}
?>