@@ -110,6 +110,9 @@ discard block |
||
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | + /** |
|
114 | + * @return string |
|
115 | + */ |
|
113 | 116 | function getValue() { |
114 | 117 | if (!is_null($this->setValue)) return $this->setValue; |
115 | 118 | if (isset($_REQUEST[$this->form . "_" . $this->name])) { |
@@ -173,6 +176,9 @@ discard block |
||
173 | 176 | } |
174 | 177 | } |
175 | 178 | |
179 | + /** |
|
180 | + * @param boolean $submit |
|
181 | + */ |
|
176 | 182 | function doProcess($submit) { |
177 | 183 | if ($submit) { |
178 | 184 | $value = $this->getValue(); |
@@ -112,19 +112,19 @@ discard block |
||
112 | 112 | |
113 | 113 | function getValue() { |
114 | 114 | if (!is_null($this->setValue)) return $this->setValue; |
115 | - if (isset($_REQUEST[$this->form . "_" . $this->name])) { |
|
115 | + if (isset($_REQUEST[$this->form."_".$this->name])) { |
|
116 | 116 | if (get_magic_quotes_runtime()) |
117 | - return stripslashes($_REQUEST[$this->form . "_" . $this->name]); |
|
117 | + return stripslashes($_REQUEST[$this->form."_".$this->name]); |
|
118 | 118 | else |
119 | - return $_REQUEST[$this->form . "_" . $this->name]; |
|
119 | + return $_REQUEST[$this->form."_".$this->name]; |
|
120 | 120 | } |
121 | 121 | return $this->opt['default']; |
122 | 122 | } |
123 | 123 | |
124 | 124 | function getInputAttStatic(&$atts, &$type, &$content) { |
125 | - $atts['id'] = $atts['name'] = $this->form . "_" . $this->name; |
|
125 | + $atts['id'] = $atts['name'] = $this->form."_".$this->name; |
|
126 | 126 | $atts['type'] = "text"; |
127 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
127 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | function getInputAttDynamic(&$atts, &$type, &$content) { |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | function getLabelAttStatic(&$atts, &$type, &$content) { |
145 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
146 | - $atts["for"] = $this->form . "_" . $this->name; |
|
145 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
146 | + $atts["for"] = $this->form."_".$this->name; |
|
147 | 147 | $content = array($this->opt['label']); |
148 | 148 | } |
149 | 149 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | function getHintAttStatic(&$atts, &$type, &$content) { |
154 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
154 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
155 | 155 | $atts['class'][] = "hamleFormHint"; |
156 | 156 | } |
157 | 157 |
@@ -17,6 +17,9 @@ |
||
17 | 17 | /** @var Model[] Assoc array of Models by Scope Name */ |
18 | 18 | static $namedScopes = array(); |
19 | 19 | |
20 | + /** |
|
21 | + * @param Model $model |
|
22 | + */ |
|
20 | 23 | static function add($model, $name = null) { |
21 | 24 | if (!$model instanceOf Model) |
22 | 25 | throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface"); |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * Open the default model when only an ID is specified in the template |
50 | 50 | * |
51 | - * @param mixed $id Identifier when no type is passed |
|
52 | - * @param array $sort |
|
51 | + * @param string $id Identifier when no type is passed |
|
52 | + * @param integer $sort |
|
53 | 53 | * @param int $limit Results Limit |
54 | 54 | * @param int $offset Results Offset |
55 | 55 | * @return Model Instance of model class that implements hamleModel |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * Open a specific model type with id |
61 | 61 | * |
62 | 62 | * @param array[] $typeId Type ID array [type=>[id]] or [page=>[3]] |
63 | - * @param array $sort |
|
63 | + * @param integer $sort |
|
64 | 64 | * @param int $limit Results Limit |
65 | 65 | * @param int $offset Results Offset |
66 | 66 | * @return Model |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * Return Iterator containing results from search of tags |
77 | 77 | * |
78 | 78 | * @param array[] $typeTags Type Tag Array [type=>[tag1,tag2],type2=>[]] |
79 | - * @param array $sort |
|
79 | + * @param integer $sort |
|
80 | 80 | * @param int $limit Results Limit |
81 | 81 | * @param int $offset Results Limit |
82 | 82 | * @return Model Instance of Iterable model class |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function cachePath($f) { |
42 | 42 | $s = DIRECTORY_SEPARATOR; |
43 | - $dir = implode($s,[__DIR__,"..","..","cache",""]); |
|
44 | - if(!is_dir($dir)) mkdir($dir); |
|
43 | + $dir = implode($s, [__DIR__, "..", "..", "cache", ""]); |
|
44 | + if (!is_dir($dir)) mkdir($dir); |
|
45 | 45 | return $dir.$f; |
46 | 46 | } |
47 | 47 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @throws Exception\RunTime |
68 | 68 | */ |
69 | 69 | public function getModelTypeID($typeId, $sort = [], $limit = 0, $offset = 0) { |
70 | - if(count($typeId) > 1) |
|
70 | + if (count($typeId) > 1) |
|
71 | 71 | throw new Exception\RunTime("Unable to open more than one ID at a time"); |
72 | 72 | return new Model\Zero(); |
73 | 73 | } |
@@ -13,6 +13,9 @@ |
||
13 | 13 | protected $s; |
14 | 14 | protected $type; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $s |
|
18 | + */ |
|
16 | 19 | function __construct($s, $type = self::TOKEN_HTML) { |
17 | 20 | $this->s = str_replace('\\$', "$", $s); |
18 | 21 | $this->type = $type; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | static function decodeClassId($s) { |
47 | 47 | $out = $m = array(); |
48 | - if(preg_match('/^[a-zA-Z0-9\_]+/', $s, $m)) |
|
48 | + if (preg_match('/^[a-zA-Z0-9\_]+/', $s, $m)) |
|
49 | 49 | $out['type'] = $m[0]; |
50 | 50 | preg_match_all('/[#\.][a-zA-Z0-9\-\_]+/m', $s, $m); |
51 | 51 | if (isset($m[0])) foreach ($m[0] as $s) { |
@@ -13,6 +13,9 @@ |
||
13 | 13 | protected $s; |
14 | 14 | protected $type; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $s |
|
18 | + */ |
|
16 | 19 | function __construct($s, $type = self::TOKEN_HTML) { |
17 | 20 | $this->s = str_replace('\\$', "$", $s); |
18 | 21 | $this->type = $type; |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | |
36 | 36 | function __construct($s, $mode = self::TOKEN_CONTROL) { |
37 | 37 | $m = array(); |
38 | - if(preg_match('/^(.*) '.self::REGEX_COMP_OPER.' (.*)$/', $s, $m)) { |
|
39 | - $this->param1 = new Text($m[1],Text::TOKEN_HTML); |
|
40 | - $this->param2 = new Text($m[3],Text::TOKEN_HTML); |
|
38 | + if (preg_match('/^(.*) '.self::REGEX_COMP_OPER.' (.*)$/', $s, $m)) { |
|
39 | + $this->param1 = new Text($m[1], Text::TOKEN_HTML); |
|
40 | + $this->param2 = new Text($m[3], Text::TOKEN_HTML); |
|
41 | 41 | $this->operator = $m[2]; |
42 | 42 | } else |
43 | - $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
43 | + $this->param1 = new Text($s, Text::TOKEN_HTML); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // function __construct(String $p1, String $p2, $operator) { |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | // $this->operator = $operator; |
50 | 50 | // } |
51 | 51 | function toPHP() { |
52 | - if(!$this->param2) return $this->param1->toPHP(); |
|
52 | + if (!$this->param2) return $this->param1->toPHP(); |
|
53 | 53 | $p1 = $this->param1->toPHP(); |
54 | 54 | $p2 = $this->param2->toPHP(); |
55 | - switch($this->operator) { |
|
55 | + switch ($this->operator) { |
|
56 | 56 | case "equals": |
57 | 57 | case "equal": |
58 | 58 | return $p1." == ".$p2; |
@@ -13,6 +13,9 @@ |
||
13 | 13 | protected $s; |
14 | 14 | protected $type; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $s |
|
18 | + */ |
|
16 | 19 | function __construct($s, $type = self::TOKEN_HTML) { |
17 | 20 | $this->s = str_replace('\\$', "$", $s); |
18 | 21 | $this->type = $type; |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | protected $filter; |
35 | 35 | |
36 | 36 | function __construct($s) { |
37 | - if(FALSE !== $pos = strpos($s,'|')) { |
|
38 | - $this->filter = new Filter(substr($s, $pos+1), $this); |
|
39 | - $s = substr($s,0,$pos); |
|
37 | + if (FALSE !== $pos = strpos($s, '|')) { |
|
38 | + $this->filter = new Filter(substr($s, $pos + 1), $this); |
|
39 | + $s = substr($s, 0, $pos); |
|
40 | 40 | } |
41 | 41 | $s = explode("->", $s); |
42 | - if(count($s) == 1) $s = explode("-!",$s[0]); |
|
42 | + if (count($s) == 1) $s = explode("-!", $s[0]); |
|
43 | 43 | if (!$s[0]) throw new ParseError("Unable to parse Complex Expression"); |
44 | 44 | if ($s[0][1] == "(") |
45 | 45 | $this->func = new Text\Func($s[0]); |
@@ -52,19 +52,19 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | function toHTML($escape = false) { |
55 | - if($escape) |
|
56 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
57 | - return "<?=" . $this->toPHP() . "?>"; |
|
55 | + if ($escape) |
|
56 | + return "<?=htmlspecialchars(".$this->toPHP().")?>"; |
|
57 | + return "<?=".$this->toPHP()."?>"; |
|
58 | 58 | } |
59 | 59 | function toPHP() { |
60 | - return $this->filter?$this->filter->toPHP():$this->toPHPVar(); |
|
60 | + return $this->filter ? $this->filter->toPHP() : $this->toPHPVar(); |
|
61 | 61 | } |
62 | 62 | function toPHPVar() { |
63 | 63 | if ($this->sel) { |
64 | 64 | $sel = array(); |
65 | 65 | foreach ($this->sel as $s) |
66 | 66 | $sel[] = "hamleGet('$s')"; |
67 | - return $this->func->toPHP() . "->" . implode('->', $sel); |
|
67 | + return $this->func->toPHP()."->".implode('->', $sel); |
|
68 | 68 | } else |
69 | 69 | return $this->func->toPHP(); |
70 | 70 | } |
@@ -13,6 +13,9 @@ |
||
13 | 13 | protected $s; |
14 | 14 | protected $type; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $s |
|
18 | + */ |
|
16 | 19 | function __construct($s, $type = self::TOKEN_HTML) { |
17 | 20 | $this->s = str_replace('\\$', "$", $s); |
18 | 21 | $this->type = $type; |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | protected $what; |
39 | 39 | |
40 | 40 | function __construct($s, Text $what) { |
41 | - if(preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
|
41 | + if (preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
|
42 | 42 | $this->filter = $m[1]; |
43 | 43 | $this->vars = isset($m[3]) ? explode(',', $m[3]) : []; |
44 | 44 | } else { |
45 | 45 | throw new ParseError("Unable to parse filter expression \"$s\""); |
46 | 46 | } |
47 | - if(!in_array($this->filter, ['itersplit', 'newlinebr', 'round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
|
47 | + if (!in_array($this->filter, ['itersplit', 'newlinebr', 'round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
|
48 | 48 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
49 | 49 | } |
50 | - switch($this->filter) { |
|
50 | + switch ($this->filter) { |
|
51 | 51 | case "itersplit": |
52 | 52 | $this->filter = "Seufert\\Hamle\\Text\\Filter::iterSplit"; |
53 | 53 | break; |
@@ -59,29 +59,29 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | function toHTML($escape = false) { |
62 | - if($escape) |
|
63 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
64 | - return "<?=" . $this->toPHP() . "?>"; |
|
62 | + if ($escape) |
|
63 | + return "<?=htmlspecialchars(".$this->toPHP().")?>"; |
|
64 | + return "<?=".$this->toPHP()."?>"; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | function toPHP() { |
68 | - $o = [$this->what->toPHPVar()] ; |
|
69 | - foreach($this->vars as $v) |
|
68 | + $o = [$this->what->toPHPVar()]; |
|
69 | + foreach ($this->vars as $v) |
|
70 | 70 | $o[] = $this->varToCode($v); |
71 | - return "{$this->filter}(" . implode(',',$o) . ")"; |
|
71 | + return "{$this->filter}(".implode(',', $o).")"; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | static function iterSplit($v, $sep = ",") { |
75 | 75 | $o = []; |
76 | - foreach(explode($sep, $v) as $k=>$i) { |
|
77 | - if($i) |
|
78 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
76 | + foreach (explode($sep, $v) as $k=>$i) { |
|
77 | + if ($i) |
|
78 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k]; |
|
79 | 79 | } |
80 | 80 | return new WrapArray($o); |
81 | 81 | } |
82 | 82 | |
83 | 83 | static function newlineBr($v) { |
84 | - return str_replace("\n","<br />\n",$v); |
|
84 | + return str_replace("\n", "<br />\n", $v); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | } |
88 | 88 | \ No newline at end of file |
@@ -34,11 +34,11 @@ |
||
34 | 34 | * @param string $class Class name to be autoloaded |
35 | 35 | */ |
36 | 36 | spl_autoload_register(function($class) { |
37 | - if(strpos($class, "Seufert\\Hamle\\") === 0) { |
|
37 | + if (strpos($class, "Seufert\\Hamle\\") === 0) { |
|
38 | 38 | $s = DIRECTORY_SEPARATOR; |
39 | - $class = str_replace("\\",$s,substr($class,14)); |
|
39 | + $class = str_replace("\\", $s, substr($class, 14)); |
|
40 | 40 | $path = __DIR__.$s."hamle".$s."$class.php"; |
41 | - if(is_file($path)) include_once($path); |
|
41 | + if (is_file($path)) include_once($path); |
|
42 | 42 | } |
43 | -},true,true); |
|
43 | +},true, true); |
|
44 | 44 |