<?php
/**
 * @version		$Id: json.php 115 2009-06-17 07:20:36Z eddieajau $
 * @copyright	Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
 * @license		GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
 * @link		http://www.theartofjoomla.com
 */

// no direct access
defined('_JEXEC') or die;

jimport('joomla.html.html');

/**
 * List form field type object
 *
 * @package		TAOJ.Quanta
 * @subpackage	com_quanta
 */
class JXFieldTypeJSON extends JXFieldType
{
   /**
	* Element name
	*
	* @access	protected
	* @var		string
	*/
	var	$_name = 'JSON';

	function fetchField($name, $value, &$node, $controlName)
	{
		$id		= str_replace(']', '', str_replace('[', '_', $controlName.'_'.$name));
		$rows	= $node->attributes('rows');
		$cols	= $node->attributes('cols');
		$class	= ($node->attributes('class') ? 'class="'.$node->attributes('class').'"' : 'class="text_area"');

		JHtml::addIncludePath(JPATH_COMPONENT.DS.'helpers'.DS.'html');

		$value	= JHtml::_('json.format', $value);

		return '<textarea name="'.$controlName.'['.$name.']" cols="'.$cols.'" rows="'.$rows.'" '.$class.' id="'.$id.'" >'.htmlspecialchars($value).'</textarea>';
	}
}