@@ -42,8 +42,9 @@ |
||
42 | 42 | parent::__construct(); |
43 | 43 | $this->type = ucfirst(strtolower($tag)); |
44 | 44 | $this->filter = "\\Seufert\\Hamle\\Filter\\{$this->type}"; |
45 | - if (!class_exists($this->filter)) |
|
46 | - Throw new ParseError("Unable to fild filter $tag"); |
|
45 | + if (!class_exists($this->filter)) { |
|
46 | + Throw new ParseError("Unable to fild filter $tag"); |
|
47 | + } |
|
47 | 48 | } |
48 | 49 | |
49 | 50 | function renderContent($pad = "", $oneliner = false) { |
@@ -42,17 +42,21 @@ discard block |
||
42 | 42 | function __construct($tag, $class = array(), $attr = array(), $id = "") { |
43 | 43 | parent::__construct(); |
44 | 44 | $this->opt = $attr; |
45 | - if(isset($attr['class']) && !is_array($attr['class'])) |
|
46 | - $this->opt['class'] = $attr['class']?explode(" ",$attr['class']):array(); |
|
45 | + if(isset($attr['class']) && !is_array($attr['class'])) { |
|
46 | + $this->opt['class'] = $attr['class']?explode(" ",$attr['class']):array(); |
|
47 | + } |
|
47 | 48 | $this->source = array(); |
48 | 49 | $this->type = $tag ? $tag : "div"; |
49 | 50 | if($class) { |
50 | - if (isset($this->opt['class'])) |
|
51 | - $this->opt['class'] = array_merge($this->opt['class'], $class); |
|
52 | - else |
|
53 | - $this->opt['class'] = $class; |
|
51 | + if (isset($this->opt['class'])) { |
|
52 | + $this->opt['class'] = array_merge($this->opt['class'], $class); |
|
53 | + } else { |
|
54 | + $this->opt['class'] = $class; |
|
55 | + } |
|
56 | + } |
|
57 | + if($id) { |
|
58 | + $this->opt['id'] = $id; |
|
54 | 59 | } |
55 | - if($id) $this->opt['id'] = $id; |
|
56 | 60 | } |
57 | 61 | |
58 | 62 | function renderStTag() { |
@@ -61,8 +65,9 @@ discard block |
||
61 | 65 | } |
62 | 66 | |
63 | 67 | function renderEnTag() { |
64 | - if (in_array($this->type, self::$selfCloseTags)) |
|
65 | - return ""; |
|
68 | + if (in_array($this->type, self::$selfCloseTags)) { |
|
69 | + return ""; |
|
70 | + } |
|
66 | 71 | return "</{$this->type}>"; |
67 | 72 | } |
68 | 73 | |
@@ -74,10 +79,15 @@ discard block |
||
74 | 79 | function optToTags() { |
75 | 80 | $out = array(); |
76 | 81 | foreach ($this->opt as $k => $v) { |
77 | - if ($k == "class" && !$v) continue; |
|
78 | - if (is_array($v)) $v = implode(" ", $v); |
|
79 | - if (!$v instanceof H\Text) |
|
80 | - $v = new H\Text($v); |
|
82 | + if ($k == "class" && !$v) { |
|
83 | + continue; |
|
84 | + } |
|
85 | + if (is_array($v)) { |
|
86 | + $v = implode(" ", $v); |
|
87 | + } |
|
88 | + if (!$v instanceof H\Text) { |
|
89 | + $v = new H\Text($v); |
|
90 | + } |
|
81 | 91 | $k = new H\Text($k); |
82 | 92 | $out[] = " " . $k->toHTML() . "=\"" . $v->toHTMLAtt() . "\""; |
83 | 93 | } |
@@ -64,15 +64,18 @@ discard block |
||
64 | 64 | |
65 | 65 | function process() { |
66 | 66 | $clicked = ""; |
67 | - foreach($this->_fields as $f) |
|
68 | - if($f instanceOf Field\Button) |
|
67 | + foreach($this->_fields as $f) { |
|
68 | + if($f instanceOf Field\Button) |
|
69 | 69 | if($f->isClicked()) |
70 | - $clicked = $f; |
|
71 | - foreach($this->_fields as $f) |
|
72 | - $f->doProcess($clicked?true:false); |
|
73 | - if($clicked) |
|
74 | - try { |
|
75 | - $this->onSubmit($clicked); |
|
70 | + $clicked = $f; |
|
71 | + } |
|
72 | + foreach($this->_fields as $f) { |
|
73 | + $f->doProcess($clicked?true:false); |
|
74 | + } |
|
75 | + if($clicked) { |
|
76 | + try { |
|
77 | + $this->onSubmit($clicked); |
|
78 | + } |
|
76 | 79 | } catch(Exception\FormInvalid $e) { |
77 | 80 | $this->hint = $e->getMessage(); |
78 | 81 | } |
@@ -80,8 +83,9 @@ discard block |
||
80 | 83 | |
81 | 84 | function isValid() { |
82 | 85 | $valid = true; |
83 | - foreach($this->_fields as $f) |
|
84 | - $valid = $f->valid && $valid; |
|
86 | + foreach($this->_fields as $f) { |
|
87 | + $valid = $f->valid && $valid; |
|
88 | + } |
|
85 | 89 | return $valid; |
86 | 90 | } |
87 | 91 | /** |
@@ -95,8 +99,9 @@ discard block |
||
95 | 99 | return $this->_fields; |
96 | 100 | } |
97 | 101 | function getField($n) { |
98 | - if(!isset($this->_fields[$n])) |
|
99 | - throw new Exception\NoKey("unable to find form field ($n)"); |
|
102 | + if(!isset($this->_fields[$n])) { |
|
103 | + throw new Exception\NoKey("unable to find form field ($n)"); |
|
104 | + } |
|
100 | 105 | return $this->_fields[$n]; |
101 | 106 | } |
102 | 107 | function __get($n) { |
@@ -33,17 +33,25 @@ |
||
33 | 33 | |
34 | 34 | function __construct($s) { |
35 | 35 | $m = array(); |
36 | - if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
|
37 | - throw new ParseError("Unable to read \$ sub func in '$s'"); |
|
38 | - if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT; |
|
39 | - elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD; |
|
40 | - else $this->dir = Hamle\Hamle::REL_ANY; |
|
36 | + if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) { |
|
37 | + throw new ParseError("Unable to read \$ sub func in '$s'"); |
|
38 | + } |
|
39 | + if ($m[1] == "<") { |
|
40 | + $this->dir = Hamle\Hamle::REL_PARENT; |
|
41 | + } elseif ($m[1] == ">") { |
|
42 | + $this->dir = Hamle\Hamle::REL_CHILD; |
|
43 | + } else { |
|
44 | + $this->dir = Hamle\Hamle::REL_ANY; |
|
45 | + } |
|
41 | 46 | $this->sortlimit = $this->attSortLimit($m[2]); |
42 | 47 | $this->filt = $this->attIdTag($m[2]); |
43 | 48 | $this->grouptype = $this->attGroupType($m[2]); |
44 | - if ($this->filt['id']) throw new ParseError("Unable to select by id"); |
|
45 | - if (trim($m[3])) |
|
46 | - $this->sub = new FuncSub($m[3]); |
|
49 | + if ($this->filt['id']) { |
|
50 | + throw new ParseError("Unable to select by id"); |
|
51 | + } |
|
52 | + if (trim($m[3])) { |
|
53 | + $this->sub = new FuncSub($m[3]); |
|
54 | + } |
|
47 | 55 | } |
48 | 56 | |
49 | 57 | function toPHP() { |
@@ -34,16 +34,18 @@ |
||
34 | 34 | function __construct($s) { |
35 | 35 | $m = array(); |
36 | 36 | //var_dump($s); |
37 | - if (!preg_match('/\$\[(-?[0-9]+|[a-zA-Z][a-zA-Z0-9]+)\]/', $s, $m)) |
|
38 | - throw new ParseError("Unable to match scope ($s)"); |
|
37 | + if (!preg_match('/\$\[(-?[0-9]+|[a-zA-Z][a-zA-Z0-9]+)\]/', $s, $m)) { |
|
38 | + throw new ParseError("Unable to match scope ($s)"); |
|
39 | + } |
|
39 | 40 | $this->scope = $m[1]; |
40 | 41 | } |
41 | 42 | |
42 | 43 | function toPHP() { |
43 | - if (is_numeric($this->scope)) |
|
44 | - return "Hamle\\Scope::get(" . Text::varToCode($this->scope) . ")"; |
|
45 | - else |
|
46 | - return "Hamle\\Scope::getName(" . Text::varToCode($this->scope) . ")"; |
|
44 | + if (is_numeric($this->scope)) { |
|
45 | + return "Hamle\\Scope::get(" . Text::varToCode($this->scope) . ")"; |
|
46 | + } else { |
|
47 | + return "Hamle\\Scope::getName(" . Text::varToCode($this->scope) . ")"; |
|
48 | + } |
|
47 | 49 | } |
48 | 50 | |
49 | 51 | function toHTML($escape = false) { |
@@ -42,8 +42,9 @@ |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | function toHTML($escape = false) { |
45 | - if($escape) |
|
46 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
45 | + if($escape) { |
|
46 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
47 | + } |
|
47 | 48 | return "<?=" . $this->toPHP() . "?>"; |
48 | 49 | } |
49 | 50 |
@@ -23,8 +23,9 @@ |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | function toHTML($escape = false) { |
26 | - if ($this->type == self::TOKEN_CODE) |
|
27 | - return $this->s; |
|
26 | + if ($this->type == self::TOKEN_CODE) { |
|
27 | + return $this->s; |
|
28 | + } |
|
28 | 29 | return htmlspecialchars($this->s); |
29 | 30 | } |
30 | 31 | } |
31 | 32 | \ No newline at end of file |
@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | $this->param1 = new Text($m[1],Text::TOKEN_HTML); |
40 | 40 | $this->param2 = new Text($m[3],Text::TOKEN_HTML); |
41 | 41 | $this->operator = $m[2]; |
42 | - } else |
|
43 | - $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
42 | + } else { |
|
43 | + $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
44 | + } |
|
44 | 45 | } |
45 | 46 | |
46 | 47 | // function __construct(String $p1, String $p2, $operator) { |
@@ -49,7 +50,9 @@ discard block |
||
49 | 50 | // $this->operator = $operator; |
50 | 51 | // } |
51 | 52 | function toPHP() { |
52 | - if(!$this->param2) return $this->param1->toPHP(); |
|
53 | + if(!$this->param2) { |
|
54 | + return $this->param1->toPHP(); |
|
55 | + } |
|
53 | 56 | $p1 = $this->param1->toPHP(); |
54 | 57 | $p2 = $this->param2->toPHP(); |
55 | 58 | switch($this->operator) { |
@@ -31,7 +31,8 @@ |
||
31 | 31 | function __construct($s) { |
32 | 32 | $s = explode("->", $s, 2); |
33 | 33 | $this->key = $s[0]; |
34 | - if (count($s) > 1) |
|
35 | - $this->sel = $s[1]; |
|
34 | + if (count($s) > 1) { |
|
35 | + $this->sel = $s[1]; |
|
36 | + } |
|
36 | 37 | } |
37 | 38 | } |
38 | 39 | \ No newline at end of file |