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

https://gitlab.com/vitaliylukin91/lavka · PHP · 107 lines · 46 code · 13 blank · 48 comment · 4 complexity · 125fd3898eceee251263c87ef7020ff9 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Platform
  4. * @subpackage Form
  5. *
  6. * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE
  8. */
  9. defined('JPATH_PLATFORM') or die;
  10. /**
  11. * Form Field class for the Joomla Platform.
  12. * Provides spacer markup to be used in form layouts.
  13. *
  14. * @since 11.1
  15. */
  16. class JFormFieldSpacer extends JFormField
  17. {
  18. /**
  19. * The form field type.
  20. *
  21. * @var string
  22. * @since 11.1
  23. */
  24. protected $type = 'Spacer';
  25. /**
  26. * Method to get the field input markup for a spacer.
  27. * The spacer does not have accept input.
  28. *
  29. * @return string The field input markup.
  30. *
  31. * @since 11.1
  32. */
  33. protected function getInput()
  34. {
  35. return ' ';
  36. }
  37. /**
  38. * Method to get the field label markup for a spacer.
  39. * Use the label text or name from the XML element as the spacer or
  40. * Use a hr="true" to automatically generate plain hr markup
  41. *
  42. * @return string The field label markup.
  43. *
  44. * @since 11.1
  45. */
  46. protected function getLabel()
  47. {
  48. $html = array();
  49. $class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
  50. $html[] = '<span class="spacer">';
  51. $html[] = '<span class="before"></span>';
  52. $html[] = '<span' . $class . '>';
  53. if ((string) $this->element['hr'] == 'true')
  54. {
  55. $html[] = '<hr' . $class . ' />';
  56. }
  57. else
  58. {
  59. $label = '';
  60. // Get the label text from the XML element, defaulting to the element name.
  61. $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
  62. $text = $this->translateLabel ? JText::_($text) : $text;
  63. // Build the class for the label.
  64. $class = !empty($this->description) ? 'hasTooltip' : '';
  65. $class = $this->required == true ? $class . ' required' : $class;
  66. // Add the opening label tag and main attributes attributes.
  67. $label .= '<label id="' . $this->id . '-lbl" class="' . $class . '"';
  68. // If a description is specified, use it to build a tooltip.
  69. if (!empty($this->description))
  70. {
  71. JHtml::_('bootstrap.tooltip');
  72. $label .= ' title="' . JHtml::tooltipText(trim($text, ':'), JText::_($this->description), 0) . '"';
  73. }
  74. // Add the label text and closing tag.
  75. $label .= '>' . $text . '</label>';
  76. $html[] = $label;
  77. }
  78. $html[] = '</span>';
  79. $html[] = '<span class="after"></span>';
  80. $html[] = '</span>';
  81. return implode('', $html);
  82. }
  83. /**
  84. * Method to get the field title.
  85. *
  86. * @return string The field title.
  87. *
  88. * @since 11.1
  89. */
  90. protected function getTitle()
  91. {
  92. return $this->getLabel();
  93. }
  94. }