PageRenderTime 22ms CodeModel.GetById 19ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/libraries/joomla/form/fields/spacer.php

https://bitbucket.org/eternaware/joomus
PHP | 111 lines | 49 code | 12 blank | 50 comment | 4 complexity | 412ab1f71d20cab06c12edb6ff50f90b MD5 | raw file
Possible License(s): LGPL-2.1
  1<?php
  2/**
  3 * @package     Joomla.Platform
  4 * @subpackage  Form
  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
  8 */
  9
 10defined('JPATH_PLATFORM') or die;
 11
 12/**
 13 * Form Field class for the Joomla Platform.
 14 * Provides spacer markup to be used in form layouts.
 15 *
 16 * @package     Joomla.Platform
 17 * @subpackage  Form
 18 * @since       11.1
 19 */
 20class JFormFieldSpacer extends JFormField
 21{
 22	/**
 23	 * The form field type.
 24	 *
 25	 * @var    string
 26	 * @since  11.1
 27	 */
 28	protected $type = 'Spacer';
 29
 30	/**
 31	 * Method to get the field input markup for a spacer.
 32	 * The spacer does not have accept input.
 33	 *
 34	 * @return  string  The field input markup.
 35	 *
 36	 * @since   11.1
 37	 */
 38	protected function getInput()
 39	{
 40		return ' ';
 41	}
 42
 43	/**
 44	 * Method to get the field label markup for a spacer.
 45	 * Use the label text or name from the XML element as the spacer or
 46	 * Use a hr="true" to automatically generate plain hr markup
 47	 *
 48	 * @return  string  The field label markup.
 49	 *
 50	 * @since   11.1
 51	 */
 52	protected function getLabel()
 53	{
 54		$html = array();
 55		$class = $this->element['class'] ? (string) $this->element['class'] : '';
 56
 57		$html[] = '<span class="spacer">';
 58		$html[] = '<span class="before"></span>';
 59		$html[] = '<span class="' . $class . '">';
 60		if ((string) $this->element['hr'] == 'true')
 61		{
 62			$html[] = '<hr class="' . $class . '" />';
 63		}
 64		else
 65		{
 66			$label = '';
 67
 68			// Get the label text from the XML element, defaulting to the element name.
 69			$text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
 70			$text = $this->translateLabel ? JText::_($text) : $text;
 71
 72			// Build the class for the label.
 73			$class = !empty($this->description) ? 'hasTip' : '';
 74			$class = $this->required == true ? $class . ' required' : $class;
 75
 76			// Add the opening label tag and main attributes attributes.
 77			$label .= '<label id="' . $this->id . '-lbl" class="' . $class . '"';
 78
 79			// If a description is specified, use it to build a tooltip.
 80			if (!empty($this->description))
 81			{
 82				$label .= ' title="'
 83					. htmlspecialchars(
 84					trim($text, ':') . '::' . ($this->translateDescription ? JText::_($this->description) : $this->description),
 85					ENT_COMPAT, 'UTF-8'
 86				) . '"';
 87			}
 88
 89			// Add the label text and closing tag.
 90			$label .= '>' . $text . '</label>';
 91			$html[] = $label;
 92		}
 93		$html[] = '</span>';
 94		$html[] = '<span class="after"></span>';
 95		$html[] = '</span>';
 96
 97		return implode('', $html);
 98	}
 99
100	/**
101	 * Method to get the field title.
102	 *
103	 * @return  string  The field title.
104	 *
105	 * @since   11.1
106	 */
107	protected function getTitle()
108	{
109		return $this->getLabel();
110	}
111}