/administrator/components/com_menus/models/fields/menutype.php
PHP | 77 lines | 37 code | 11 blank | 29 comment | 1 complexity | 5a6fd44f94ee14f696e5939a8cfa9f4b MD5 | raw file
Possible License(s): LGPL-2.1
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 10defined('JPATH_BASE') or die; 11 12JFormHelper::loadFieldClass('list'); 13 14/** 15 * Form Field class for the Joomla Framework. 16 * 17 * @package Joomla.Administrator 18 * @subpackage com_menus 19 * @since 1.6 20 */ 21class JFormFieldMenutype extends JFormFieldList 22{ 23 /** 24 * The form field type. 25 * 26 * @var string 27 * @since 1.6 28 */ 29 protected $type = 'menutype'; 30 31 /** 32 * Method to get the field input markup. 33 * 34 * @return string The field input markup. 35 * @since 1.6 36 */ 37 protected function getInput() 38 { 39 $html = array(); 40 $recordId = (int) $this->form->getValue('id'); 41 $size = ($v = $this->element['size']) ? ' size="'.$v.'"' : ''; 42 $class = ($v = $this->element['class']) ? ' class="'.$v.'"' : 'class="text_area"'; 43 44 // Get a reverse lookup of the base link URL to Title 45 $model = JModelLegacy::getInstance('menutypes', 'menusModel'); 46 $rlu = $model->getReverseLookup(); 47 48 switch ($this->value) 49 { 50 case 'url': 51 $value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL'); 52 break; 53 54 case 'alias': 55 $value = JText::_('COM_MENUS_TYPE_ALIAS'); 56 break; 57 58 case 'separator': 59 $value = JText::_('COM_MENUS_TYPE_SEPARATOR'); 60 break; 61 62 default: 63 $link = $this->form->getValue('link'); 64 // Clean the link back to the option, view and layout 65 $value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link))); 66 break; 67 } 68 // Load the javascript and css 69 JHtml::_('behavior.framework'); 70 JHtml::_('behavior.modal'); 71 72 $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>'; 73 $html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" value="'.htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />'; 74 75 return implode("\n", $html); 76 } 77}