PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/libraries/joomla/form/fields/media.php

https://github.com/joebushi/joomla
PHP | 72 lines | 42 code | 8 blank | 22 comment | 3 complexity | 1ee594dce41618e2dcba20be48723cf0 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. */
  7. defined('JPATH_BASE') or die;
  8. jimport('joomla.form.formfield');
  9. /**
  10. * Form Field class for the Joomla Framework.
  11. *
  12. * @package Joomla.Framework
  13. * @subpackage Form
  14. * @since 1.6
  15. */
  16. class JFormFieldMedia extends JFormField
  17. {
  18. /**
  19. * The field type.
  20. *
  21. * @var string
  22. */
  23. protected $type = 'Media';
  24. /**
  25. * Method to get the field input.
  26. *
  27. * @return string The field input.
  28. */
  29. protected function _getInput()
  30. {
  31. static $init = false;
  32. $html = '';
  33. $onchange = (string)$this->_element->attributes()->onchange ? $this->_replacePrefix((string)$this->_element->attributes()->onchange) : '';
  34. if (!$init) {
  35. JHtml::_('behavior.modal');
  36. $js = "
  37. function jInsertFieldValue(value,id) {
  38. var old_id = document.getElementById(id).value;
  39. if (old_id != id)
  40. {
  41. document.getElementById(id).value = value;
  42. ".$onchange."
  43. }
  44. }";
  45. $doc = &JFactory::getDocument();
  46. $doc->addScriptDeclaration($js);
  47. $init = true;
  48. }
  49. $link = (string)$this->_element->attributes()->link.$this->inputId;
  50. $size = (string)$this->_element->attributes()->size ? ' size="'.$this->_element->attributes()->size.'"' : '';
  51. $class = (string)$this->_element->attributes()->class ? ' class="'.$this->_element->attributes()->class.'"' : '';
  52. $html .= '<div style="float: left;">';
  53. $html .= '<input type="text" name="'.$this->inputName.'" id="'.$this->inputId.'" value="'.htmlspecialchars($this->value).'"'.$class.$size.' />';
  54. $html .= '</div>';
  55. $html .= '<div class="button2-left">';
  56. $html .= '<div class="blank">';
  57. $html .= '<a class="modal" title="'.JText::_('SELECT').'" href="'.$link.'" rel="{handler: \'iframe\', size: {x: 650, y: 375}}">';
  58. $html .= JText::_('SELECT');
  59. $html .= '</a>';
  60. $html .= '</div>';
  61. $html .= '</div>';
  62. return $html;
  63. }
  64. }