| <?php |
|
|
| namespace Kanboard\Helper; |
|
|
| use Kanboard\Core\Markdown; |
| use Kanboard\Core\Base; |
|
|
| |
| |
| |
| |
| |
| |
| class TextHelper extends Base |
| { |
| |
| |
| |
| |
| |
| |
| public function e($value) |
| { |
| return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8', false); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function implode($glue, array $list) |
| { |
| array_walk($list, function (&$value) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); }); |
| return implode($glue, $list); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function markdown($text, $isPublicLink = false) |
| { |
| $parser = new Markdown($this->container, $isPublicLink); |
| $parser->setMarkupEscaped(MARKDOWN_ESCAPE_HTML); |
| $parser->setBreaksEnabled(true); |
| return $parser->text($text ?: ''); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function bytes($size, $precision = 2) |
| { |
| if ($size == 0) { |
| return 0; |
| } |
|
|
| $base = log($size) / log(1024); |
| $suffixes = array('', 'k', 'M', 'G', 'T'); |
|
|
| return round(pow(1024, $base - floor($base)), $precision).$suffixes[(int)floor($base)]; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function contains($haystack, $needle) |
| { |
| return strpos($haystack, $needle) !== false; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| public function in($id, array $listing, $default_value = '?') |
| { |
| if (isset($listing[$id])) { |
| return $this->helper->text->e($listing[$id]); |
| } |
|
|
| return $default_value; |
| } |
| } |
|
|