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 | |
parent | f32507d423c46e8e9612b5239728e6c617e4cbcb (diff) |
Helper refactoring
Diffstat (limited to 'app/Helper')
-rw-r--r-- | app/Helper/AppHelper.php (renamed from app/Helper/App.php) | 8 | ||||
-rw-r--r-- | app/Helper/AssetHelperHelper.php (renamed from app/Helper/Asset.php) | 6 | ||||
-rw-r--r-- | app/Helper/BoardHelper.php (renamed from app/Helper/Board.php) | 4 | ||||
-rw-r--r-- | app/Helper/DateHelper.php (renamed from app/Helper/Dt.php) | 3 | ||||
-rw-r--r-- | app/Helper/FileHelper.php (renamed from app/Helper/File.php) | 4 | ||||
-rw-r--r-- | app/Helper/FormHelper.php (renamed from app/Helper/Form.php) | 20 | ||||
-rw-r--r-- | app/Helper/HookHelper.php (renamed from app/Helper/Hook.php) | 4 | ||||
-rw-r--r-- | app/Helper/LayoutHelper.php (renamed from app/Helper/Layout.php) | 2 | ||||
-rw-r--r-- | app/Helper/ModelHelper.php (renamed from app/Helper/Model.php) | 2 | ||||
-rw-r--r-- | app/Helper/SubtaskHelper.php (renamed from app/Helper/Subtask.php) | 6 | ||||
-rw-r--r-- | app/Helper/TaskHelper.php (renamed from app/Helper/Task.php) | 2 | ||||
-rw-r--r-- | app/Helper/TextHelper.php (renamed from app/Helper/Text.php) | 15 | ||||
-rw-r--r-- | app/Helper/UrlHelper.php (renamed from app/Helper/Url.php) | 4 | ||||
-rw-r--r-- | app/Helper/UserHelper.php (renamed from app/Helper/User.php) | 6 |
14 files changed, 55 insertions, 31 deletions
diff --git a/app/Helper/App.php b/app/Helper/AppHelper.php index 79afa5b9..e6f6412d 100644 --- a/app/Helper/App.php +++ b/app/Helper/AppHelper.php @@ -5,12 +5,12 @@ namespace Kanboard\Helper; use Kanboard\Core\Base; /** - * Application helpers + * Application Helper * * @package helper * @author Frederic Guillot */ -class App extends Base +class AppHelper extends Base { /** * Get config variable @@ -116,11 +116,11 @@ class App extends Base $failure_message = $this->flash->getMessage('failure'); if (! empty($success_message)) { - return '<div class="alert alert-success alert-fade-out">'.$this->helper->e($success_message).'</div>'; + 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->e($failure_message).'</div>'; + return '<div class="alert alert-error">'.$this->helper->text->e($failure_message).'</div>'; } return ''; diff --git a/app/Helper/Asset.php b/app/Helper/AssetHelperHelper.php index c4178e8c..7040a40a 100644 --- a/app/Helper/Asset.php +++ b/app/Helper/AssetHelperHelper.php @@ -2,13 +2,15 @@ namespace Kanboard\Helper; +use Kanboard\Core\Base; + /** - * Assets helpers + * Asset Helper * * @package helper * @author Frederic Guillot */ -class Asset extends \Kanboard\Core\Base +class AssetHelper extends Base { /** * Add a Javascript asset diff --git a/app/Helper/Board.php b/app/Helper/BoardHelper.php index 430d1858..a86a6c18 100644 --- a/app/Helper/Board.php +++ b/app/Helper/BoardHelper.php @@ -2,13 +2,15 @@ namespace Kanboard\Helper; +use Kanboard\Core\Base; + /** * Board Helper * * @package helper * @author Frederic Guillot */ -class Board extends \Kanboard\Core\Base +class BoardHelper extends Base { /** * Return true if tasks are collapsed diff --git a/app/Helper/Dt.php b/app/Helper/DateHelper.php index eb3f93b3..3844ce64 100644 --- a/app/Helper/Dt.php +++ b/app/Helper/DateHelper.php @@ -3,6 +3,7 @@ namespace Kanboard\Helper; use DateTime; +use Kanboard\Core\Base; /** * DateTime helpers @@ -10,7 +11,7 @@ use DateTime; * @package helper * @author Frederic Guillot */ -class Dt extends \Kanboard\Core\Base +class DateHelper extends Base { /** * Get formatted time diff --git a/app/Helper/File.php b/app/Helper/FileHelper.php index b493e64f..cabf371c 100644 --- a/app/Helper/File.php +++ b/app/Helper/FileHelper.php @@ -2,13 +2,15 @@ namespace Kanboard\Helper; +use Kanboard\Core\Base; + /** * File helpers * * @package helper * @author Frederic Guillot */ -class File extends \Kanboard\Core\Base +class FileHelper extends Base { /** * Get file icon diff --git a/app/Helper/Form.php b/app/Helper/FormHelper.php index bfd75ee3..161fd54c 100644 --- a/app/Helper/Form.php +++ b/app/Helper/FormHelper.php @@ -10,7 +10,7 @@ use Kanboard\Core\Base; * @package helper * @author Frederic Guillot */ -class Form extends Base +class FormHelper extends Base { /** * Hidden CSRF token field @@ -52,7 +52,7 @@ class Form extends Base $html = '<select name="'.$name.'" id="form-'.$name.'" class="'.$class.'" '.implode(' ', $attributes).'>'; foreach ($options as $id => $value) { - $html .= '<option value="'.$this->helper->e($id).'"'; + $html .= '<option value="'.$this->helper->text->e($id).'"'; if (isset($values->$name) && $id == $values->$name) { $html .= ' selected="selected"'; @@ -61,7 +61,7 @@ class Form extends Base $html .= ' selected="selected"'; } - $html .= '>'.$this->helper->e($value).'</option>'; + $html .= '>'.$this->helper->text->e($value).'</option>'; } $html .= '</select>'; @@ -103,7 +103,7 @@ class Form extends Base */ public function radio($name, $label, $value, $selected = false, $class = '') { - return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.$this->helper->e($value).'" '.($selected ? 'checked="checked"' : '').'> '.$this->helper->e($label).'</label>'; + return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.$this->helper->text->e($value).'" '.($selected ? 'checked="checked"' : '').'> '.$this->helper->text->e($label).'</label>'; } /** @@ -139,7 +139,7 @@ class Form extends Base */ public function checkbox($name, $label, $value, $checked = false, $class = '') { - return '<label><input type="checkbox" name="'.$name.'" class="'.$class.'" value="'.$this->helper->e($value).'" '.($checked ? 'checked="checked"' : '').'> '.$this->helper->e($label).'</label>'; + return '<label><input type="checkbox" name="'.$name.'" class="'.$class.'" value="'.$this->helper->text->e($value).'" '.($checked ? 'checked="checked"' : '').'> '.$this->helper->text->e($label).'</label>'; } /** @@ -153,7 +153,7 @@ class Form extends Base */ public function label($label, $name, array $attributes = array()) { - return '<label for="form-'.$name.'" '.implode(' ', $attributes).'>'.$this->helper->e($label).'</label>'; + return '<label for="form-'.$name.'" '.implode(' ', $attributes).'>'.$this->helper->text->e($label).'</label>'; } /** @@ -173,7 +173,7 @@ class Form extends Base $html = '<textarea name="'.$name.'" id="form-'.$name.'" class="'.$class.'" '; $html .= implode(' ', $attributes).'>'; - $html .= isset($values->$name) ? $this->helper->e($values->$name) : isset($values[$name]) ? $values[$name] : ''; + $html .= isset($values->$name) ? $this->helper->text->e($values->$name) : isset($values[$name]) ? $values[$name] : ''; $html .= '</textarea>'; $html .= $this->errorList($errors, $name); @@ -334,7 +334,7 @@ class Form extends Base $html .= '<ul class="form-errors">'; foreach ($errors[$name] as $error) { - $html .= '<li>'.$this->helper->e($error).'</li>'; + $html .= '<li>'.$this->helper->text->e($error).'</li>'; } $html .= '</ul>'; @@ -354,9 +354,9 @@ class Form extends Base private function formValue($values, $name) { if (isset($values->$name)) { - return 'value="'.$this->helper->e($values->$name).'"'; + return 'value="'.$this->helper->text->e($values->$name).'"'; } - return isset($values[$name]) ? 'value="'.$this->helper->e($values[$name]).'"' : ''; + return isset($values[$name]) ? 'value="'.$this->helper->text->e($values[$name]).'"' : ''; } } diff --git a/app/Helper/Hook.php b/app/Helper/HookHelper.php index 7b691949..e8abc875 100644 --- a/app/Helper/Hook.php +++ b/app/Helper/HookHelper.php @@ -2,13 +2,15 @@ namespace Kanboard\Helper; +use Kanboard\Core\Base; + /** * Template Hook helpers * * @package helper * @author Frederic Guillot */ -class Hook extends \Kanboard\Core\Base +class HookHelper extends Base { /** * Add assets JS or CSS diff --git a/app/Helper/Layout.php b/app/Helper/LayoutHelper.php index 3db23920..064c11ac 100644 --- a/app/Helper/Layout.php +++ b/app/Helper/LayoutHelper.php @@ -10,7 +10,7 @@ use Kanboard\Core\Base; * @package helper * @author Frederic Guillot */ -class Layout extends Base +class LayoutHelper extends Base { /** * Render a template without the layout if Ajax request diff --git a/app/Helper/Model.php b/app/Helper/ModelHelper.php index 68a52542..d49637c8 100644 --- a/app/Helper/Model.php +++ b/app/Helper/ModelHelper.php @@ -10,7 +10,7 @@ use Kanboard\Core\Base; * @package helper * @author Frederic Guillot */ -class Model extends Base +class ModelHelper extends Base { /** * Remove keys from an array diff --git a/app/Helper/Subtask.php b/app/Helper/SubtaskHelper.php index 1784a2bf..afa3c14e 100644 --- a/app/Helper/Subtask.php +++ b/app/Helper/SubtaskHelper.php @@ -2,13 +2,15 @@ namespace Kanboard\Helper; +use Kanboard\Core\Base; + /** * Subtask helpers * * @package helper * @author Frederic Guillot */ -class Subtask extends \Kanboard\Core\Base +class SubtaskHelper extends Base { public function getTitle(array $subtask) { @@ -20,7 +22,7 @@ class Subtask extends \Kanboard\Core\Base $html = '<i class="fa fa-check-square-o fa-fw"></i>'; } - return $html.$this->helper->e($subtask['title']); + return $html.$this->helper->text->e($subtask['title']); } /** diff --git a/app/Helper/Task.php b/app/Helper/TaskHelper.php index 6058c099..4857d0ee 100644 --- a/app/Helper/Task.php +++ b/app/Helper/TaskHelper.php @@ -10,7 +10,7 @@ use Kanboard\Core\Base; * @package helper * @author Frederic Guillot */ -class Task extends Base +class TaskHelper extends Base { /** * Local cache for project columns diff --git a/app/Helper/Text.php b/app/Helper/TextHelper.php index 83f1e3f9..e5aefdcf 100644 --- a/app/Helper/Text.php +++ b/app/Helper/TextHelper.php @@ -11,9 +11,20 @@ use Kanboard\Core\Base; * @package helper * @author Frederic Guillot */ -class Text extends Base +class TextHelper extends Base { /** + * HTML escaping + * + * @param string $value Value to escape + * @return string + */ + public function e($value) + { + return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); + } + + /** * Markdown transformation * * @param string $text Markdown content @@ -88,7 +99,7 @@ class Text extends Base public function in($id, array $listing, $default_value = '?') { if (isset($listing[$id])) { - return $this->helper->e($listing[$id]); + return $this->helper->text->e($listing[$id]); } return $default_value; diff --git a/app/Helper/Url.php b/app/Helper/UrlHelper.php index 7de8a571..96c6735a 100644 --- a/app/Helper/Url.php +++ b/app/Helper/UrlHelper.php @@ -5,12 +5,12 @@ namespace Kanboard\Helper; use Kanboard\Core\Base; /** - * Url helpers + * Url Helper * * @package helper * @author Frederic Guillot */ -class Url extends Base +class UrlHelper extends Base { private $base = ''; private $directory = ''; diff --git a/app/Helper/User.php b/app/Helper/UserHelper.php index 29844dfb..cbdb4af8 100644 --- a/app/Helper/User.php +++ b/app/Helper/UserHelper.php @@ -2,13 +2,15 @@ namespace Kanboard\Helper; +use Kanboard\Core\Base; + /** * User helpers * * @package helper * @author Frederic Guillot */ -class User extends \Kanboard\Core\Base +class UserHelper extends Base { /** * Return true if the logged user as unread notifications @@ -168,7 +170,7 @@ class User extends \Kanboard\Core\Base public function avatar($email, $alt = '') { if (! empty($email) && $this->config->get('integration_gravatar') == 1) { - return '<img class="avatar" src="https://www.gravatar.com/avatar/'.md5(strtolower($email)).'?s=25" alt="'.$this->helper->e($alt).'" title="'.$this->helper->e($alt).'">'; + return '<img class="avatar" src="https://www.gravatar.com/avatar/'.md5(strtolower($email)).'?s=25" alt="'.$this->helper->text->e($alt).'" title="'.$this->helper->text->e($alt).'">'; } return ''; |