diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-03-04 20:10:34 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-03-04 20:10:34 -0500 |
commit | 8f3e2b2e5c62a6130f6c8867ab335fb4c1a32c5c (patch) | |
tree | ce28cdc2dba9c31560ef753ac1b4dc39d567b7a6 /app/Helper/AssetHelperHelper.php | |
parent | f32507d423c46e8e9612b5239728e6c617e4cbcb (diff) |
Helper refactoring
Diffstat (limited to 'app/Helper/AssetHelperHelper.php')
-rw-r--r-- | app/Helper/AssetHelperHelper.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/app/Helper/AssetHelperHelper.php b/app/Helper/AssetHelperHelper.php new file mode 100644 index 00000000..7040a40a --- /dev/null +++ b/app/Helper/AssetHelperHelper.php @@ -0,0 +1,64 @@ +<?php + +namespace Kanboard\Helper; + +use Kanboard\Core\Base; + +/** + * Asset Helper + * + * @package helper + * @author Frederic Guillot + */ +class AssetHelper extends Base +{ + /** + * Add a Javascript asset + * + * @param string $filename Filename + * @return string + */ + public function js($filename, $async = false) + { + return '<script '.($async ? 'async' : '').' type="text/javascript" src="'.$this->helper->url->dir().$filename.'?'.filemtime($filename).'"></script>'; + } + + /** + * Add a stylesheet asset + * + * @param string $filename Filename + * @param boolean $is_file Add file timestamp + * @param string $media Media + * @return string + */ + public function css($filename, $is_file = true, $media = 'screen') + { + return '<link rel="stylesheet" href="'.$this->helper->url->dir().$filename.($is_file ? '?'.filemtime($filename) : '').'" media="'.$media.'">'; + } + + /** + * Get custom css + * + * @access public + * @return string + */ + public function customCss() + { + if ($this->config->get('application_stylesheet')) { + return '<style>'.$this->config->get('application_stylesheet').'</style>'; + } + + return ''; + } + + /** + * Get CSS for task colors + * + * @access public + * @return string + */ + public function colorCss() + { + return '<style>'.$this->color->getCss().'</style>'; + } +} |