/administrator/components/com_menus/models/fields/menutype.php

https://bitbucket.org/eternaware/joomus · PHP · 77 lines · 37 code · 11 blank · 29 comment · 1 complexity · 5a6fd44f94ee14f696e5939a8cfa9f4b MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Administrator
  4. * @subpackage com_menus
  5. *
  6. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('JPATH_BASE') or die;
  10. JFormHelper::loadFieldClass('list');
  11. /**
  12. * Form Field class for the Joomla Framework.
  13. *
  14. * @package Joomla.Administrator
  15. * @subpackage com_menus
  16. * @since 1.6
  17. */
  18. class JFormFieldMenutype extends JFormFieldList
  19. {
  20. /**
  21. * The form field type.
  22. *
  23. * @var string
  24. * @since 1.6
  25. */
  26. protected $type = 'menutype';
  27. /**
  28. * Method to get the field input markup.
  29. *
  30. * @return string The field input markup.
  31. * @since 1.6
  32. */
  33. protected function getInput()
  34. {
  35. $html = array();
  36. $recordId = (int) $this->form->getValue('id');
  37. $size = ($v = $this->element['size']) ? ' size="'.$v.'"' : '';
  38. $class = ($v = $this->element['class']) ? ' class="'.$v.'"' : 'class="text_area"';
  39. // Get a reverse lookup of the base link URL to Title
  40. $model = JModelLegacy::getInstance('menutypes', 'menusModel');
  41. $rlu = $model->getReverseLookup();
  42. switch ($this->value)
  43. {
  44. case 'url':
  45. $value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
  46. break;
  47. case 'alias':
  48. $value = JText::_('COM_MENUS_TYPE_ALIAS');
  49. break;
  50. case 'separator':
  51. $value = JText::_('COM_MENUS_TYPE_SEPARATOR');
  52. break;
  53. default:
  54. $link = $this->form->getValue('link');
  55. // Clean the link back to the option, view and layout
  56. $value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
  57. break;
  58. }
  59. // Load the javascript and css
  60. JHtml::_('behavior.framework');
  61. JHtml::_('behavior.modal');
  62. $html[] = '<span class="input-append"><input type="text" readonly="readonly" disabled="disabled" value="'.$value.'"'.$size.$class.' /><a class="btn btn-primary" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\''.JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId='.$recordId).'\'})"><i class="icon-list icon-white"></i> '.JText::_('JSELECT').'</a></span>';
  63. $html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" value="'.htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
  64. return implode("\n", $html);
  65. }
  66. }