/contentmanager/code/trunk/administrator/components/com_contentmanager/libraries/jxtended/form/fields/registry.php
PHP | 77 lines | 33 code | 10 blank | 34 comment | 4 complexity | 32b1b8b367b82292c0a8f3394697b794 MD5 | raw file
- <?php
- /**
- * @version $Id: registry.php 160 2009-07-09 00:06:09Z eddieajau $
- * @package JXtended.Libraries
- * @subpackage Form
- * @copyright Copyright (C) 2008 - 2009 JXtended, LLC. All rights reserved.
- * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
- * @link http://jxtended.com
- */
- defined('JPATH_BASE') or die;
- jximport2('jxtended.form.field');
- /**
- * JXtended Form Field Type Class for a registry input.
- *
- * @package JXtended.Libraries
- * @subpackage Form
- * @version 1.0
- */
- class JXFieldTypeRegistry extends JXFieldType
- {
- /**
- * Field type
- *
- * @access protected
- * @var string
- */
- var $_type = 'Registry';
- function fetchField($name, $value, &$node, $controlName)
- {
- if (is_string($value)) {
- $params = new JParameter($value);
- $values = $params->toArray();
- } else {
- $values = (array) $value;
- }
- $fields = array();
- if (!empty($node->param)) {
- foreach ($node->param as $param)
- {
- $fields[$param->attributes('name')] = $this->_getField($param, (!empty($values[$param->attributes('name')])) ? $values[$param->attributes('name')] : $param->attributes('default', null), $controlName.'['.$name.']');
- }
- }
- return $fields;
- }
- /**
- * Render a form field
- *
- * @access public
- * @param object $node An JXFormField object
- * @param mixed $value The field value
- * @param string $controlName The field control name
- * @return object Rendered Form Field object
- * @since 1.5
- */
- function _getField(&$node, $value, $controlName = 'jxform[params]')
- {
- // get the field type
- $type = $node->attributes('type');
- // load the field type object
- $field = &$this->_parent->loadFieldType($type);
- // field type could not be loaded -- just return some basic information
- if ($field === false) {
- $field = &$this->_parent->loadFieldType('text');
- }
- return $field->render($node, $value, $controlName);
- }
- }