summaryrefslogtreecommitdiff
path: root/app/Core/Helper.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-01-17 17:11:51 -0500
committerFrederic Guillot <fred@kanboard.net>2015-01-17 17:11:51 -0500
commit84b0f0df90442775b9122457648f06c9485df1f1 (patch)
tree5f0fb91ed9280bbf10bb60d69f3523cafc928f5c /app/Core/Helper.php
parent4b45b2aa3533309898670f1b13756dfdfce355a7 (diff)
Add project calendars (merge/refactoring of #490)
Diffstat (limited to 'app/Core/Helper.php')
-rw-r--r--app/Core/Helper.php90
1 files changed, 82 insertions, 8 deletions
diff --git a/app/Core/Helper.php b/app/Core/Helper.php
index e9fa1868..146cb2f8 100644
--- a/app/Core/Helper.php
+++ b/app/Core/Helper.php
@@ -104,9 +104,9 @@ class Helper
* @param string $filename Filename
* @return string
*/
- public function css($filename)
+ public function css($filename, $is_file = true)
{
- return '<link rel="stylesheet" href="'.$filename.'?'.filemtime($filename).'" media="screen">';
+ return '<link rel="stylesheet" href="'.$filename.($is_file ? '?'.filemtime($filename) : '').'" media="screen">';
}
/**
@@ -417,7 +417,7 @@ class Helper
}
/**
- * URL query string
+ * Generate controller/action url for templates
*
* u('task', 'show', array('task_id' => $task_id))
*
@@ -429,17 +429,40 @@ class Helper
*/
public function u($controller, $action, array $params = array(), $csrf = false)
{
- $html = '?controller='.$controller.'&amp;action='.$action;
+ $values = array(
+ 'controller' => $controller,
+ 'action' => $action,
+ );
if ($csrf) {
$params['csrf_token'] = Security::getCSRFToken();
}
- foreach ($params as $key => $value) {
- $html .= '&amp;'.$key.'='.$value;
- }
+ $values += $params;
- return $html;
+ return '?'.http_build_query($values, '', '&amp;');
+ }
+
+ /**
+ * Generate controller/action url
+ *
+ * l('task', 'show', array('task_id' => $task_id))
+ *
+ * @param string $controller Controller name
+ * @param string $action Action name
+ * @param array $params Url parameters
+ * @return string
+ */
+ public function url($controller, $action, array $params = array())
+ {
+ $values = array(
+ 'controller' => $controller,
+ 'action' => $action,
+ );
+
+ $values += $params;
+
+ return '?'.http_build_query($values, '');
}
/**
@@ -656,4 +679,55 @@ class Helper
return $default_value;
}
+
+ /**
+ * Get calendar translations
+ *
+ * @access public
+ * @return string
+ */
+ public function getCalendarTranslations()
+ {
+ return json_encode(array(
+ 'Today' => t('Today'),
+ 'Jan' => t('Jan'),
+ 'Feb' => t('Feb'),
+ 'Mar' => t('Mar'),
+ 'Apr' => t('Apr'),
+ 'May' => t('May'),
+ 'Jun' => t('Jun'),
+ 'Jul' => t('Jul'),
+ 'Aug' => t('Aug'),
+ 'Sep' => t('Sep'),
+ 'Oct' => t('Oct'),
+ 'Nov' => t('Nov'),
+ 'Dec' => t('Dec'),
+ 'January' => t('January'),
+ 'February' => t('February'),
+ 'March' => t('March'),
+ 'April' => t('April'),
+ 'May' => t('May'),
+ 'June' => t('June'),
+ 'July' => t('July'),
+ 'August' => t('August'),
+ 'September' => t('September'),
+ 'October' => t('October'),
+ 'November' => t('November'),
+ 'December' => t('December'),
+ 'Sunday' => t('Sunday'),
+ 'Monday' => t('Monday'),
+ 'Tuesday' => t('Tuesday'),
+ 'Wednesday' => t('Wednesday'),
+ 'Thursday' => t('Thursday'),
+ 'Friday' => t('Friday'),
+ 'Saturday' => t('Saturday'),
+ 'Sun' => t('Sun'),
+ 'Mon' => t('Mon'),
+ 'Tue' => t('Tue'),
+ 'Wed' => t('Wed'),
+ 'Thu' => t('Thu'),
+ 'Fri' => t('Fri'),
+ 'Sat' => t('Sat'),
+ ));
+ }
}