/libraries/fof/form/field/sql.php

https://github.com/elinw/joomla-cms · PHP · 97 lines · 47 code · 12 blank · 38 comment · 4 complexity · fc2a482d10bbbdd55034ee33a665535b MD5 · raw file

  1. <?php
  2. /**
  3. * @package FrameworkOnFramework
  4. * @copyright Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. */
  7. // Protect from unauthorized access
  8. defined('_JEXEC') or die;
  9. if (!class_exists('JFormFieldSql'))
  10. {
  11. require_once JPATH_LIBRARIES . '/joomla/form/fields/sql.php';
  12. }
  13. /**
  14. * Form Field class for FOF
  15. * Radio selection listGeneric list from an SQL statement
  16. *
  17. * @package FrameworkOnFramework
  18. * @since 2.0
  19. */
  20. class FOFFormFieldSql extends JFormFieldSql implements FOFFormField
  21. {
  22. protected $static;
  23. protected $repeatable;
  24. /**
  25. * Method to get certain otherwise inaccessible properties from the form field object.
  26. *
  27. * @param string $name The property name for which to the the value.
  28. *
  29. * @return mixed The property value or null.
  30. *
  31. * @since 2.0
  32. */
  33. public function __get($name)
  34. {
  35. switch ($name)
  36. {
  37. case 'static':
  38. if (empty($this->static))
  39. {
  40. $this->static = $this->getStatic();
  41. }
  42. return $this->static;
  43. break;
  44. case 'repeatable':
  45. if (empty($this->repeatable))
  46. {
  47. $this->repeatable = $this->getRepeatable();
  48. }
  49. return $this->static;
  50. break;
  51. default:
  52. return parent::__get($name);
  53. }
  54. }
  55. /**
  56. * Get the rendering of this field type for static display, e.g. in a single
  57. * item view (typically a "read" task).
  58. *
  59. * @since 2.0
  60. *
  61. * @return string The field HTML
  62. */
  63. public function getStatic()
  64. {
  65. $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
  66. return '<span id="' . $this->id . '" ' . $class . '>' .
  67. htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
  68. '</span>';
  69. }
  70. /**
  71. * Get the rendering of this field type for a repeatable (grid) display,
  72. * e.g. in a view listing many item (typically a "browse" task)
  73. *
  74. * @since 2.0
  75. *
  76. * @return string The field HTML
  77. */
  78. public function getRepeatable()
  79. {
  80. $class = $this->element['class'] ? (string) $this->element['class'] : '';
  81. return '<span class="' . $this->id . ' ' . $class . '">' .
  82. htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
  83. '</span>';
  84. }
  85. }