@@ -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) { |
@@ -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 |
@@ -36,14 +36,18 @@ |
||
36 | 36 | function getInputAttDynamic(&$atts, &$type, &$content) { |
37 | 37 | parent::getInputAttDynamic($atts, $type, $content); |
38 | 38 | $atts['value'] = "ON"; |
39 | - if ($this->getValue()) |
|
40 | - $atts['checked'] = "checked"; |
|
39 | + if ($this->getValue()) { |
|
40 | + $atts['checked'] = "checked"; |
|
41 | + } |
|
41 | 42 | } |
42 | 43 | |
43 | 44 | function getValue() { |
44 | - if (!is_null($this->setValue)) return $this->setValue; |
|
45 | - if (isset($_REQUEST[$this->form . "__submit"])) |
|
46 | - return isset($_REQUEST[$this->form . "_" . $this->name]); |
|
45 | + if (!is_null($this->setValue)) { |
|
46 | + return $this->setValue; |
|
47 | + } |
|
48 | + if (isset($_REQUEST[$this->form . "__submit"])) { |
|
49 | + return isset($_REQUEST[$this->form . "_" . $this->name]); |
|
50 | + } |
|
47 | 51 | return $this->opt['default']; |
48 | 52 | } |
49 | 53 | } |
50 | 54 | \ No newline at end of file |
@@ -41,7 +41,9 @@ discard block |
||
41 | 41 | public function cachePath($f) { |
42 | 42 | $s = DIRECTORY_SEPARATOR; |
43 | 43 | $dir = implode($s,[__DIR__,"..","..","cache",""]); |
44 | - if(!is_dir($dir)) mkdir($dir); |
|
44 | + if(!is_dir($dir)) { |
|
45 | + mkdir($dir); |
|
46 | + } |
|
45 | 47 | return $dir.$f; |
46 | 48 | } |
47 | 49 | |
@@ -67,8 +69,9 @@ discard block |
||
67 | 69 | * @throws Exception\RunTime |
68 | 70 | */ |
69 | 71 | public function getModelTypeID($typeId, $sort = [], $limit = 0, $offset = 0) { |
70 | - if(count($typeId) > 1) |
|
71 | - throw new Exception\RunTime("Unable to open more than one ID at a time"); |
|
72 | + if(count($typeId) > 1) { |
|
73 | + throw new Exception\RunTime("Unable to open more than one ID at a time"); |
|
74 | + } |
|
72 | 75 | return new Model\Zero(); |
73 | 76 | } |
74 | 77 |
@@ -35,8 +35,9 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | function hamleGet($key) { |
38 | - if (!isset($this->data[$this->pos][$key])) |
|
39 | - return "Missing Key [$key]"; |
|
38 | + if (!isset($this->data[$this->pos][$key])) { |
|
39 | + return "Missing Key [$key]"; |
|
40 | + } |
|
40 | 41 | return $this->data[$this->pos][$key]; |
41 | 42 | } |
42 | 43 |
@@ -18,12 +18,14 @@ discard block |
||
18 | 18 | static $namedScopes = array(); |
19 | 19 | |
20 | 20 | static function add($model, $name = null) { |
21 | - if (!$model instanceOf Model) |
|
22 | - throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface"); |
|
23 | - if ($name) |
|
24 | - self::$namedScopes[$name] = $model; |
|
25 | - else |
|
26 | - self::$scopes[] = $model; |
|
21 | + if (!$model instanceOf Model) { |
|
22 | + throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface"); |
|
23 | + } |
|
24 | + if ($name) { |
|
25 | + self::$namedScopes[$name] = $model; |
|
26 | + } else { |
|
27 | + self::$scopes[] = $model; |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | static function done() { |
@@ -41,15 +43,21 @@ discard block |
||
41 | 43 | */ |
42 | 44 | static function get($id = 0) { |
43 | 45 | if (0 == $id) { |
44 | - if ($scope = end(self::$scopes)) |
|
45 | - return $scope; |
|
46 | + if ($scope = end(self::$scopes)) { |
|
47 | + return $scope; |
|
48 | + } |
|
46 | 49 | throw new OutOfScope("Unable to find Scope ($id)"); |
47 | 50 | } |
48 | 51 | $key = $id - 1; |
49 | - if ($id < 0) $key = count(self::$scopes) + $id - 1; |
|
50 | - if ($id == 0) $key = count(self::$scopes) - 1; |
|
51 | - if (!isset(self::$scopes[$key])) |
|
52 | - throw new OutOfScope("Unable to find Scope ($id) or $key"); |
|
52 | + if ($id < 0) { |
|
53 | + $key = count(self::$scopes) + $id - 1; |
|
54 | + } |
|
55 | + if ($id == 0) { |
|
56 | + $key = count(self::$scopes) - 1; |
|
57 | + } |
|
58 | + if (!isset(self::$scopes[$key])) { |
|
59 | + throw new OutOfScope("Unable to find Scope ($id) or $key"); |
|
60 | + } |
|
53 | 61 | return self::$scopes[$key]; |
54 | 62 | } |
55 | 63 | |
@@ -67,8 +75,9 @@ discard block |
||
67 | 75 | self::$namedScopes[$name]->rewind(); |
68 | 76 | return self::$namedScopes[$name]; |
69 | 77 | } else |
70 | - if(self::$returnZeroOnNoScope) |
|
71 | - return new Model\Zero(); |
|
78 | + if(self::$returnZeroOnNoScope) { |
|
79 | + return new Model\Zero(); |
|
80 | + } |
|
72 | 81 | throw new RunTime("Unable to find scope ($name)"); |
73 | 82 | } |
74 | 83 |
@@ -44,8 +44,9 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | function toHTML($escape = false) { |
47 | - if($escape) |
|
48 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
47 | + if($escape) { |
|
48 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
49 | + } |
|
49 | 50 | return "<?=" . $this->toPHP() . "?>"; |
50 | 51 | } |
51 | 52 | |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | */ |
68 | 69 | function setValue($value) { |
69 | 70 | $model = $this->getOrCreateModel(); |
70 | - if(!$model instanceof WriteModel) |
|
71 | - throw new \RuntimeException('Can only write to model that implements WriteModel'); |
|
71 | + if(!$model instanceof WriteModel) { |
|
72 | + throw new \RuntimeException('Can only write to model that implements WriteModel'); |
|
73 | + } |
|
72 | 74 | $model->hamleSet($this->var, $value); |
73 | 75 | return $model; |
74 | 76 | } |