|
<?php |
|
|
|
namespace Kanboard\Helper; |
|
|
|
use Kanboard\Core\Base; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AppHelper extends Base |
|
{ |
|
public function tooltipMarkdown($markdownText, $icon = 'fa-info-circle') |
|
{ |
|
return '<span class="tooltip"><i class="fa '.$icon.'"></i><script type="text/template"><div class="markdown">'.$this->helper->text->markdown($markdownText).'</div></script></span>'; |
|
} |
|
|
|
public function tooltipHTML($htmlText, $icon = 'fa-info-circle') |
|
{ |
|
return '<span class="tooltip"><i class="fa '.$icon.'"></i><script type="text/template"><div class="markdown">'.$htmlText.'</div></script></span>'; |
|
} |
|
|
|
public function tooltipLink($label, $link) |
|
{ |
|
return '<span class="tooltip" data-href="'.$link.'">'.$label.'</span>'; |
|
} |
|
|
|
public function getToken() |
|
{ |
|
return $this->token; |
|
} |
|
|
|
public function isAjax() |
|
{ |
|
return $this->request->isAjax(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function component($name, array $params = array()) |
|
{ |
|
return '<div class="js-'.$name.'" data-params=\''.json_encode($params, JSON_HEX_APOS).'\'></div>'; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function config($param, $default = '') |
|
{ |
|
return $this->configModel->get($param, $default); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function checkMenuSelection($controller, $action = '', $plugin = '') |
|
{ |
|
$result = strtolower($this->getRouterController()) === strtolower($controller); |
|
|
|
if ($result && $action !== '') { |
|
$result = strtolower($this->getRouterAction()) === strtolower($action); |
|
} |
|
|
|
if ($result && $plugin !== '') { |
|
$result = strtolower($this->getPluginName()) === strtolower($plugin); |
|
} |
|
|
|
return $result ? 'class="active"' : ''; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getPluginName() |
|
{ |
|
return $this->router->getPlugin(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getRouterController() |
|
{ |
|
return $this->router->getController(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getRouterAction() |
|
{ |
|
return $this->router->getAction(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function jsLang() |
|
{ |
|
return $this->languageModel->getJsLanguageCode(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getJsDateFormat() |
|
{ |
|
$format = $this->dateParser->getUserDateFormat(); |
|
$format = str_replace('m', 'mm', $format); |
|
$format = str_replace('Y', 'yy', $format); |
|
$format = str_replace('d', 'dd', $format); |
|
|
|
return $format; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getJsTimeFormat() |
|
{ |
|
$format = $this->dateParser->getUserTimeFormat(); |
|
$format = str_replace('H', 'HH', $format); |
|
$format = str_replace('i', 'mm', $format); |
|
$format = str_replace('g', 'h', $format); |
|
$format = str_replace('a', 'tt', $format); |
|
|
|
return $format; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getTimezone() |
|
{ |
|
return $this->timezoneModel->getCurrentTimezone(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function flashMessage() |
|
{ |
|
$success_message = $this->flash->getMessage('success'); |
|
$failure_message = $this->flash->getMessage('failure'); |
|
|
|
if (! empty($success_message)) { |
|
return '<div class="alert alert-success alert-fade-out">'.$this->helper->text->e($success_message).'</div>'; |
|
} |
|
|
|
if (! empty($failure_message)) { |
|
return '<div class="alert alert-error">'.$this->helper->text->e($failure_message).'</div>'; |
|
} |
|
|
|
return ''; |
|
} |
|
} |
|
|