Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 48 lines (43 sloc) 2.424 kb
6cb87499 »
2011-02-18 New plugin: Edit calendar
1 <?php
2
3 /** Display jQuery UI Timepicker for each date and datetime field
091a4d04 »
2012-06-30 Link to documentation
4 * @link http://www.adminer.org/plugins/#use
6cb87499 »
2011-02-18 New plugin: Edit calendar
5 * @uses jQuery-Timepicker, http://trentrichardson.com/examples/timepicker/
6 * @uses jQuery UI: core, widget, mouse, slider, datepicker
7 * @author Jakub Vrana, http://www.vrana.cz/
8 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
9 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
10 */
11 class AdminerEditCalendar {
75783421 »
2011-08-11 Comment
12 /** @access protected */
544b562c »
2011-02-18 Simplify variables
13 var $prepend, $langPath;
6cb87499 »
2011-02-18 New plugin: Edit calendar
14
15 /**
16 * @param string text to append before first calendar usage
17 * @param string path to language file, %s stands for language code
18 */
98a00bac »
2011-06-10 Move init to head
19 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") {
6cb87499 »
2011-02-18 New plugin: Edit calendar
20 $this->prepend = $prepend;
21 $this->langPath = $langPath;
22 }
23
98a00bac »
2011-06-10 Move init to head
24 function head() {
25 echo $this->prepend;
26 if ($this->langPath && function_exists('get_lang')) { // since Adminer 3.2.0
27 $lang = get_lang();
28 $lang = ($lang == "zh" ? "zh-CN" : ($lang == "zh-tw" ? "zh-TW" : $lang));
29 if ($lang != "en" && file_exists(sprintf($this->langPath, $lang))) {
30 printf("<script type='text/javascript' src='$this->langPath'></script>\n", $lang);
31 echo "<script type='text/javascript'>jQuery(function () { jQuery.timepicker.setDefaults(jQuery.datepicker.regional['$lang']); });</script>\n";
32 }
33 }
34 }
35
6cb87499 »
2011-02-18 New plugin: Edit calendar
36 function editInput($table, $field, $attrs, $value) {
37 if (ereg("date|time", $field["type"])) {
38 $dateFormat = "changeYear: true, dateFormat: 'yy-mm-dd'"; //! yy-mm-dd regional
39 $timeFormat = "showSecond: true, timeFormat: 'hh:mm:ss'";
6b3e3c25 »
2011-09-13 Remove unnecessary onload event
40 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"]) . "')."
6cb87499 »
2011-02-18 New plugin: Edit calendar
41 . ($field["type"] == "time" ? "timepicker({ $timeFormat })"
42 : (ereg("time", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
43 : "datepicker({ $dateFormat })"
6b3e3c25 »
2011-09-13 Remove unnecessary onload event
44 )) . ";</script>";
6cb87499 »
2011-02-18 New plugin: Edit calendar
45 }
46 }
47
48 }
Something went wrong with that request. Please try again.