PageRenderTime 87ms CodeModel.GetById 21ms RepoModel.GetById 3ms app.codeStats 0ms

/contentmanager/code/trunk/administrator/components/com_contentmanager/libraries/jxtended/form/fields/registry.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 77 lines | 33 code | 10 blank | 34 comment | 4 complexity | 32b1b8b367b82292c0a8f3394697b794 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: registry.php 160 2009-07-09 00:06:09Z eddieajau $
  4. * @package JXtended.Libraries
  5. * @subpackage Form
  6. * @copyright Copyright (C) 2008 - 2009 JXtended, LLC. All rights reserved.
  7. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
  8. * @link http://jxtended.com
  9. */
  10. defined('JPATH_BASE') or die;
  11. jximport2('jxtended.form.field');
  12. /**
  13. * JXtended Form Field Type Class for a registry input.
  14. *
  15. * @package JXtended.Libraries
  16. * @subpackage Form
  17. * @version 1.0
  18. */
  19. class JXFieldTypeRegistry extends JXFieldType
  20. {
  21. /**
  22. * Field type
  23. *
  24. * @access protected
  25. * @var string
  26. */
  27. var $_type = 'Registry';
  28. function fetchField($name, $value, &$node, $controlName)
  29. {
  30. if (is_string($value)) {
  31. $params = new JParameter($value);
  32. $values = $params->toArray();
  33. } else {
  34. $values = (array) $value;
  35. }
  36. $fields = array();
  37. if (!empty($node->param)) {
  38. foreach ($node->param as $param)
  39. {
  40. $fields[$param->attributes('name')] = $this->_getField($param, (!empty($values[$param->attributes('name')])) ? $values[$param->attributes('name')] : $param->attributes('default', null), $controlName.'['.$name.']');
  41. }
  42. }
  43. return $fields;
  44. }
  45. /**
  46. * Render a form field
  47. *
  48. * @access public
  49. * @param object $node An JXFormField object
  50. * @param mixed $value The field value
  51. * @param string $controlName The field control name
  52. * @return object Rendered Form Field object
  53. * @since 1.5
  54. */
  55. function _getField(&$node, $value, $controlName = 'jxform[params]')
  56. {
  57. // get the field type
  58. $type = $node->attributes('type');
  59. // load the field type object
  60. $field = &$this->_parent->loadFieldType($type);
  61. // field type could not be loaded -- just return some basic information
  62. if ($field === false) {
  63. $field = &$this->_parent->loadFieldType('text');
  64. }
  65. return $field->render($node, $value, $controlName);
  66. }
  67. }