1: <?php
2:
3: 4: 5: 6:
7:
8: namespace Nette\Templating;
9:
10: use Nette;
11: use Latte;
12: use Nette\Utils\Strings;
13:
14:
15: 16: 17:
18: class Helpers extends Latte\Runtime\Filters
19: {
20: private static $helpers = array(
21: 'normalize' => 'Nette\Utils\Strings::normalize',
22: 'toascii' => 'Nette\Utils\Strings::toAscii',
23: 'webalize' => 'Nette\Utils\Strings::webalize',
24: 'padleft' => 'Nette\Utils\Strings::padLeft',
25: 'padright' => 'Nette\Utils\Strings::padRight',
26: 'reverse' => 'Nette\Utils\Strings::reverse',
27: 'url' => 'rawurlencode',
28: );
29:
30:
31: 32: 33: 34: 35:
36: public static function loader($helper)
37: {
38: if (method_exists(__CLASS__, $helper)) {
39: return array(__CLASS__, $helper);
40: } elseif (isset(self::$helpers[$helper])) {
41: return self::$helpers[$helper];
42: }
43: }
44:
45:
46: 47: 48: 49: 50: 51: 52:
53: public static function modifyDate($time, $delta, $unit = NULL)
54: {
55: return $time == NULL
56: ? NULL
57: : Nette\Utils\DateTime::from($time)->modify($delta . $unit);
58: }
59:
60:
61: 62: 63: 64: 65:
66: public static function length($var)
67: {
68: return is_string($var) ? Strings::length($var) : count($var);
69: }
70:
71:
72: 73: 74: 75: 76:
77: public static function null()
78: {
79: return '';
80: }
81:
82:
83: public static function optimizePhp($source, $lineLength = 80)
84: {
85: return Latte\Helpers::optimizePhp($source, $lineLength);
86: }
87:
88: }
89: