Joomla! Programmierung/Framework/JHtml/calendar

Aus Joomla! Dokumentation
Wechseln zu: Navigation, Suche

Gibt ein Kalender Input Feld aus.

Inhaltsverzeichnis

[Bearbeiten] Syntax

static calendar( $value, $name, $id, [$format], [$attribs] )
  • @return string HTML
  • @since Joomla 1.5
Parameter Datentyp Beschreibung Standardwert
$value string Der Wert des Inputfeldes (im Idealfall ein Datum).
$name string Der Name des Inputfeldes
$id string Die Id des Inputfeldes.
$format string Das Format des Datums %Y-%m-%d
$attribs array() Attribute des Inputfeldes, müssen als Array in der Form array('name' => 'wert') übergeben werden. null

[Bearbeiten] Beispiele

[Bearbeiten] Kalender Inputfeld ausgeben

$value = '2009-06-25';
$name = 'kalender';
$id = 'kalender';
 
echo JHtml::_('calendar', $value, $name, $id);

Ausgabe:

<input type="text" name="kalender" id="kalender" value="2009-06-25" />
<img class="calendar" src="/templates/system/images/calendar.png" alt="calendar" id="kalender_img" />
Ausgabe


[Bearbeiten] Siehe auch

[Bearbeiten] Quellcode

JHtml::calendar in Joomla! 2.5.4

Folder blue.png libraries

  • Folder red.png joomla
    • Folder green.png html
      • File php.png html.php
  1. public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
  2. {
  3. static $done;
  4.  
  5. if ($done === null)
  6. {
  7. $done = array();
  8. }
  9.  
  10. $readonly = isset($attribs['readonly']) && $attribs['readonly'] == 'readonly';
  11. $disabled = isset($attribs['disabled']) && $attribs['disabled'] == 'disabled';
  12. if (is_array($attribs))
  13. {
  14. $attribs = JArrayHelper::toString($attribs);
  15. }
  16.  
  17. if (!$readonly && !$disabled)
  18. {
  19. // Load the calendar behavior
  20. JHtml::_('behavior.calendar');
  21. JHtml::_('behavior.tooltip');
  22.  
  23. // Only display the triggers once for each control.
  24. if (!in_array($id, $done))
  25. {
  26. $document = JFactory::getDocument();
  27. $document
  28. ->addScriptDeclaration(
  29. 'window.addEvent(\'domready\', function() {Calendar.setup({
  30. // Id of the input field
  31. inputField: "' . $id . '",
  32. // Format of the input field
  33. ifFormat: "' . $format . '",
  34. // Trigger for the calendar (button ID)
  35. button: "' . $id . '_img",
  36. // Alignment (defaults to "Bl")
  37. align: "Tl",
  38. singleClick: true,
  39. firstDay: ' . JFactory::getLanguage()->getFirstDay() . '
  40. });});'
  41. );
  42. $done[] = $id;
  43. }
  44. return '<input type="text" title="' . (0 !== (int) $value ? JHtml::_('date', $value) : '') . '" name="' . $name . '" id="' . $id
  45. . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />'
  46. . JHtml::_('image', 'system/calendar.png', JText::_('JLIB_HTML_CALENDAR'), array('class' => 'calendar', 'id' => $id . '_img'), true);
  47. }
  48. else
  49. {
  50. return '<input type="text" title="' . (0 !== (int) $value ? JHtml::_('date', $value) : '')
  51. . '" value="' . (0 !== (int) $value ? JHtml::_('date', $value, JFactory::getDbo()->getDateFormat()) : '') . '" ' . $attribs
  52. . ' /><input type="hidden" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" />';
  53. }
  54. }
Meine Werkzeuge
Namensräume
Varianten
Aktionen
Navigation
Sonstiges
Team Navigation
Werkzeuge