summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2015-07-12 13:45:47 +0200
committerPhilip Häusler <msquare@notrademark.de>2015-07-12 13:45:47 +0200
commit53737666c64a5670d661ece071f5b913e45f195a (patch)
tree0895fa57e17a80830827037ef51d636c98dab498 /includes
parent993d6a4f591607e998a65b105c964c546a04e285 (diff)
add bootstrap datepicker
Diffstat (limited to 'includes')
-rw-r--r--includes/helper/internationalization_helper.php14
-rw-r--r--includes/sys_template.php29
2 files changed, 43 insertions, 0 deletions
diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php
index 836bbc6a..a8fdd0f0 100644
--- a/includes/helper/internationalization_helper.php
+++ b/includes/helper/internationalization_helper.php
@@ -7,6 +7,20 @@ $locales = array(
$default_locale = 'en_US.UTF-8';
/**
+ * Return currently active locale
+ */
+function locale() {
+ return $_SESSION['locale'];
+}
+
+/**
+ * Returns two letter language code from currently active locale
+ */
+function locale_short() {
+ return substr(locale(), 0, 2);
+}
+
+/**
* Initializes gettext for internationalization and updates the sessions locale to use for translation.
*/
function gettext_init() {
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 1c3b38b1..452e3a82 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -123,6 +123,35 @@ function form_spinner($name, $label, $value) {
}
/**
+ * Render a bootstrap datepicker
+ *
+ * @param string $name
+ * Name of the parameter
+ * @param string $label
+ * Label
+ * @param int $value
+ * Unix Timestamp
+ * @return HTML
+ */
+function form_date($name, $label, $value) {
+ $id = $name . '-date';
+ $value = is_numeric($value) ? date('Y-m-d', $value) : '';
+ return form_element($label, '
+ <div class="input-group date" id="' . $id . '">
+ <input type="text" class="form-control" value="' . $value . '"><span class="input-group-addon">' . glyph('th') . '</span>
+ </div>
+ <script type="text/javascript">
+ $(function(){
+ $("#' . $id . '").datepicker({
+ language: "' . locale_short() . '",
+ format: "yyyy-mm-dd"
+ });
+ });
+ </script>
+ ', $id);
+}
+
+/**
* Rendert eine Liste von Checkboxen für ein Formular
*
* @param