Skip to content
Newer
Older
100644 48 lines (42 sloc) 2.34 KB
6cb8749 @vrana New plugin: Edit calendar
authored Feb 18, 2011
1 <?php
2
3 /** Display jQuery UI Timepicker for each date and datetime field
4 * @uses jQuery-Timepicker, http://trentrichardson.com/examples/timepicker/
5 * @uses jQuery UI: core, widget, mouse, slider, datepicker
6 * @author Jakub Vrana, http://www.vrana.cz/
7 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
8 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
9 */
10 class AdminerEditCalendar {
e6b5202 @vrana Properties @access
authored Jun 10, 2011
11 /** @var string @access protected */
544b562 @vrana Simplify variables
authored Feb 18, 2011
12 var $prepend, $langPath;
6cb8749 @vrana New plugin: Edit calendar
authored Feb 18, 2011
13
14 /**
15 * @param string text to append before first calendar usage
16 * @param string path to language file, %s stands for language code
17 */
98a00ba @vrana Move init to head
authored Jun 10, 2011
18 function AdminerEditCalendar($prepend = "<script type='text/javascript' src='jquery-ui/jquery.js'></script>\n<script type='text/javascript' src='jquery-ui/jquery-ui.js'></script>\n<script type='text/javascript' src='jquery-ui/jquery-ui-timepicker-addon.js'></script>\n<link rel='stylesheet' type='text/css' href='jquery-ui/jquery-ui.css'>\n", $langPath = "jquery-ui/i18n/jquery.ui.datepicker-%s.js") {
6cb8749 @vrana New plugin: Edit calendar
authored Feb 18, 2011
19 $this->prepend = $prepend;
20 $this->langPath = $langPath;
21 }
22
98a00ba @vrana Move init to head
authored Jun 10, 2011
23 function head() {
24 echo $this->prepend;
25 if ($this->langPath && function_exists('get_lang')) { // since Adminer 3.2.0
26 $lang = get_lang();
27 $lang = ($lang == "zh" ? "zh-CN" : ($lang == "zh-tw" ? "zh-TW" : $lang));
28 if ($lang != "en" && file_exists(sprintf($this->langPath, $lang))) {
29 printf("<script type='text/javascript' src='$this->langPath'></script>\n", $lang);
30 echo "<script type='text/javascript'>jQuery(function () { jQuery.timepicker.setDefaults(jQuery.datepicker.regional['$lang']); });</script>\n";
31 }
32 }
33 }
34
6cb8749 @vrana New plugin: Edit calendar
authored Feb 18, 2011
35 function editInput($table, $field, $attrs, $value) {
36 if (ereg("date|time", $field["type"])) {
37 $dateFormat = "changeYear: true, dateFormat: 'yy-mm-dd'"; //! yy-mm-dd regional
38 $timeFormat = "showSecond: true, timeFormat: 'hh:mm:ss'";
39 return "<input id='fields-" . h($field["field"]) . "' value='" . h($value) . "'" . ($maxlength ? " maxlength='$maxlength'" : "") . "$attrs><script type='text/javascript'>jQuery(function () { jQuery('#fields-" . js_escape($field["field"]) . "')."
40 . ($field["type"] == "time" ? "timepicker({ $timeFormat })"
41 : (ereg("time", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
42 : "datepicker({ $dateFormat })"
43 )) . "; });</script>";
44 }
45 }
46
47 }
Something went wrong with that request. Please try again.