PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 83 lines | 39 code | 9 blank | 35 comment | 4 complexity | 08834211717ff6da982ed14841f0b090 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: registrygroup.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 group input.
  14. *
  15. * @package JXtended.Libraries
  16. * @subpackage Form
  17. * @version 1.0
  18. */
  19. class JXFieldTypeRegistrygroup extends JXFieldType
  20. {
  21. /**
  22. * Field type
  23. *
  24. * @access protected
  25. * @var string
  26. */
  27. var $_type = 'Registrygroup';
  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->group)) {
  38. foreach ($node->group as $group)
  39. {
  40. foreach ($group->param as $param)
  41. {
  42. // Special cases
  43. $pName = $param->attributes('name');
  44. $value = (isset($values[$pName]) AND $values[$pName] !== '') ? $values[$pName] : $param->attributes('default', null);
  45. $prefix = $controlName.$name;
  46. $fields[$group->attributes('title')][$pName] = $this->_getField($param, $value, $prefix);
  47. }
  48. }
  49. }
  50. return $fields;
  51. }
  52. /**
  53. * Render a form field
  54. *
  55. * @access public
  56. * @param object $node An JXFormField object
  57. * @param mixed $value The field value
  58. * @param string $controlName The field control name
  59. * @return object Rendered Form Field object
  60. * @since 1.5
  61. */
  62. function _getField(&$node, $value, $controlName = 'jxform[params]')
  63. {
  64. // get the field type
  65. $type = $node->attributes('type');
  66. // load the field type object
  67. $field = &$this->_parent->loadFieldType($type);
  68. // field type could not be loaded -- just return some basic information
  69. if ($field === false) {
  70. $field = &$this->_parent->loadFieldType('text');
  71. }
  72. return $field->render($node, $value, $controlName);
  73. }
  74. }