From 84b0f0df90442775b9122457648f06c9485df1f1 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 17 Jan 2015 17:11:51 -0500 Subject: Add project calendars (merge/refactoring of #490) --- app/Core/Helper.php | 90 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 8 deletions(-) (limited to 'app/Core/Helper.php') 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 ''; + return ''; } /** @@ -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.'&action='.$action; + $values = array( + 'controller' => $controller, + 'action' => $action, + ); if ($csrf) { $params['csrf_token'] = Security::getCSRFToken(); } - foreach ($params as $key => $value) { - $html .= '&'.$key.'='.$value; - } + $values += $params; - return $html; + return '?'.http_build_query($values, '', '&'); + } + + /** + * 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'), + )); + } } -- cgit v1.2.3