PageRenderTime 43ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 66 lines | 36 code | 9 blank | 21 comment | 1 complexity | 8c50e494c5e1bc87d7c4b480103c7469 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: combo.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. jimport('joomla.html.html');
  12. jximport2('jxtended.form.field');
  13. /**
  14. * JXtended Form Field Type Class for a combobox list.
  15. *
  16. * @package JXtended.Libraries
  17. * @subpackage Form
  18. * @version 1.0
  19. */
  20. class JXFieldTypeCombo extends JXFieldType
  21. {
  22. /**
  23. * Field type
  24. *
  25. * @access protected
  26. * @var string
  27. */
  28. var $_type = 'Combo';
  29. function _getOptions(&$node)
  30. {
  31. $options = array ();
  32. foreach ($node->children() as $option)
  33. {
  34. $val = $option->attributes('value');
  35. $text = $option->data();
  36. $options[] = JHTML::_('select.option', $val, JText::_($text));
  37. }
  38. return $options;
  39. }
  40. function fetchField($name, $value, &$node, $controlName)
  41. {
  42. $id = str_replace(']', '', str_replace('[', '_', $controlName.'_'.$name));
  43. $size = ($node->attributes('size') ? ' size="'.$node->attributes('size').'"' : '');
  44. $readonly = ($node->attributes('readonly') == 'true' ? ' readonly="readonly"' : '');
  45. $onchange = ($node->attributes('onchange') ? ' onchange="'.$node->attributes('onchange').'"' : '');
  46. $class = ($node->attributes('class') ? 'class="'.$node->attributes('class').'"' : 'class="combobox"');
  47. $options = $this->_getOptions($node);
  48. $html = '<input type="text" name="'.$controlName.'['.$name.']" id="'.$id.'" value="'.htmlspecialchars($value).'" '.$class.$size.$readonly.$onchange.' />';
  49. $html .= '<ul id="combobox-'.$id.'" style="display:none;">';
  50. foreach ($options as $option) {
  51. $html .= '<li>'.$option->text.'</li>';
  52. }
  53. $html .= '</ul>';
  54. JHTML::_('behavior.combobox');
  55. return $html;
  56. }
  57. }