Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 48 lines (42 sloc) 2.38 kB
6cb8749 @vrana New plugin: Edit calendar
authored
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 {
7578342 @vrana Comment
authored
11 /** @access protected */
544b562 @vrana Simplify variables
authored
12 var $prepend, $langPath;
6cb8749 @vrana New plugin: Edit calendar
authored
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
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
19 $this->prepend = $prepend;
20 $this->langPath = $langPath;
21 }
22
98a00ba @vrana Move init to head
authored
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
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'";
6b3e3c2 @vrana Remove unnecessary onload event
authored
39 return "<input id='fields-" . h($field["field"]) . "' value='" . h($value) . "'" . (+$field["length"] ? " maxlength='" . (+$field["length"]) . "'" : "") . "$attrs><script type='text/javascript'>jQuery('#fields-" . js_escape($field["field"]) . "')."
6cb8749 @vrana New plugin: Edit calendar
authored
40 . ($field["type"] == "time" ? "timepicker({ $timeFormat })"
41 : (ereg("time", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
42 : "datepicker({ $dateFormat })"
6b3e3c2 @vrana Remove unnecessary onload event
authored
43 )) . ";</script>";
6cb8749 @vrana New plugin: Edit calendar
authored
44 }
45 }
46
47 }
Something went wrong with that request. Please try again.