@@ -38,7 +38,9 @@ |
||
| 38 | 38 | $s = DIRECTORY_SEPARATOR; |
| 39 | 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)) { |
|
| 42 | + include_once($path); |
|
| 43 | + } |
|
| 42 | 44 | } |
| 43 | 45 | },true,true); |
| 44 | 46 | |
@@ -34,14 +34,18 @@ |
||
| 34 | 34 | static function filterText($s) { |
| 35 | 35 | $as = explode("\n", $s); |
| 36 | 36 | $indent = -1; |
| 37 | - foreach ($as as $line) |
|
| 38 | - if (preg_match('/^(\s+).*$/', $line, $m)) { |
|
| 37 | + foreach ($as as $line) { |
|
| 38 | + if (preg_match('/^(\s+).*$/', $line, $m)) { |
|
| 39 | 39 | $lnInd = strlen($m[1]); |
| 40 | - if ($indent < 0) $indent = $lnInd; |
|
| 40 | + } |
|
| 41 | + if ($indent < 0) { |
|
| 42 | + $indent = $lnInd; |
|
| 43 | + } |
|
| 41 | 44 | $indent = min($indent, $lnInd); |
| 42 | 45 | } |
| 43 | - foreach ($as as $k => $v) |
|
| 44 | - $as[$k] = substr($v, $indent); |
|
| 46 | + foreach ($as as $k => $v) { |
|
| 47 | + $as[$k] = substr($v, $indent); |
|
| 48 | + } |
|
| 45 | 49 | $s = implode("\n", $as); |
| 46 | 50 | |
| 47 | 51 | require_once ME_DIR . "/lib/phpsass/SassParser.php"; |
@@ -60,11 +60,14 @@ |
||
| 60 | 60 | $out = "<" . $d['type'] . " "; |
| 61 | 61 | foreach ($d['opt'] as $k => $v) { |
| 62 | 62 | if (is_array($v)) { |
| 63 | - foreach ($v as $k2 => $v2) |
|
| 64 | - if ($v[$k2] instanceof Text) $v[$k2] = eval('return ' . $v[$k2]->toPHP() . ';'); |
|
| 63 | + foreach ($v as $k2 => $v2) { |
|
| 64 | + if ($v[$k2] instanceof Text) $v[$k2] = eval('return ' . $v[$k2]->toPHP() . ';'); |
|
| 65 | + } |
|
| 65 | 66 | $v = implode(" ", $v); |
| 66 | 67 | } |
| 67 | - if ($v instanceOf H\Text) $v = eval('return ' . $v->toPHP() . ';'); |
|
| 68 | + if ($v instanceOf H\Text) { |
|
| 69 | + $v = eval('return ' . $v->toPHP() . ';'); |
|
| 70 | + } |
|
| 68 | 71 | $out .= $k . "=\"" . htmlspecialchars($v) . "\" "; |
| 69 | 72 | } |
| 70 | 73 | $out .= in_array($d['type'], self::$selfCloseTags) ? "/>" : ">"; |
@@ -41,12 +41,15 @@ discard block |
||
| 41 | 41 | function __construct($param) { |
| 42 | 42 | parent::__construct(); |
| 43 | 43 | $param = explode(' ', $param); |
| 44 | - if (count($param) < 2) throw new ParseError("|form requires 2 arguments, form type, and instance"); |
|
| 44 | + if (count($param) < 2) { |
|
| 45 | + throw new ParseError("|form requires 2 arguments, form type, and instance"); |
|
| 46 | + } |
|
| 45 | 47 | $this->var = new H\Text($param[1]); |
| 46 | - if (preg_match('/^(.*)\((.*)\)/', $param[0], $m)) |
|
| 47 | - $this->form = new $m[1]($m[2]); |
|
| 48 | - else |
|
| 49 | - $this->form = new $param[0]; |
|
| 48 | + if (preg_match('/^(.*)\((.*)\)/', $param[0], $m)) { |
|
| 49 | + $this->form = new $m[1]($m[2]); |
|
| 50 | + } else { |
|
| 51 | + $this->form = new $param[0]; |
|
| 52 | + } |
|
| 50 | 53 | } |
| 51 | 54 | |
| 52 | 55 | function renderStTag() { |
@@ -58,32 +61,38 @@ discard block |
||
| 58 | 61 | } |
| 59 | 62 | $fields = $this->form->getFields(); |
| 60 | 63 | $labelTags = $this->find(array(array("type" => "label"))); |
| 61 | - foreach ($labelTags as $tag) |
|
| 62 | - if ($tag instanceOf Html) |
|
| 64 | + foreach ($labelTags as $tag) { |
|
| 65 | + if ($tag instanceOf Html) |
|
| 63 | 66 | foreach ($tag->source as $source) { |
| 64 | 67 | if(isset($fields[$source])) |
| 65 | 68 | $fields[$source]->getLabelAttStatic($tag->opt, $tag->type, $tag->content); |
| 66 | - else |
|
| 67 | - $tag->opt['style'] = "display:none;"; |
|
| 69 | + } |
|
| 70 | + else { |
|
| 71 | + $tag->opt['style'] = "display:none;"; |
|
| 72 | + } |
|
| 68 | 73 | } |
| 69 | 74 | $inputTags = $this->find(array(array("type" => "hint"))); |
| 70 | - foreach ($inputTags as $tag) |
|
| 71 | - if ($tag instanceOf Html) |
|
| 75 | + foreach ($inputTags as $tag) { |
|
| 76 | + if ($tag instanceOf Html) |
|
| 72 | 77 | foreach ($tag->source as $source) { |
| 73 | 78 | if(isset($fields[$source])) |
| 74 | 79 | $fields[$source]->getHintAttStatic($tag->opt, $tag->type, $tag->content); |
| 75 | - else |
|
| 76 | - $tag->opt['style'] = "display:none;"; |
|
| 80 | + } |
|
| 81 | + else { |
|
| 82 | + $tag->opt['style'] = "display:none;"; |
|
| 83 | + } |
|
| 77 | 84 | } |
| 78 | 85 | $inputTags = $this->find(array(array("type" => "input"))); |
| 79 | - foreach ($inputTags as $tag) |
|
| 80 | - if ($tag instanceOf Html) |
|
| 86 | + foreach ($inputTags as $tag) { |
|
| 87 | + if ($tag instanceOf Html) |
|
| 81 | 88 | foreach ($tag->source as $source) { |
| 82 | 89 | if(isset($fields[$source])) { |
| 83 | 90 | $fields[$source]->getInputAttStatic($tag->opt, $tag->type, $tag->content); |
| 91 | + } |
|
| 84 | 92 | unset($fields[$source]); |
| 85 | - } else |
|
| 86 | - $tag->opt['style'] = "display:none;"; |
|
| 93 | + } else { |
|
| 94 | + $tag->opt['style'] = "display:none;"; |
|
| 95 | + } |
|
| 87 | 96 | } |
| 88 | 97 | foreach ($fields as $n => $f) { |
| 89 | 98 | if (!$f instanceOf Button) { |
@@ -31,8 +31,9 @@ discard block |
||
| 31 | 31 | protected $commentstyle; |
| 32 | 32 | |
| 33 | 33 | function __construct($type) { |
| 34 | - if ($type == "/") |
|
| 35 | - $this->commentstyle = "HTML"; |
|
| 34 | + if ($type == "/") { |
|
| 35 | + $this->commentstyle = "HTML"; |
|
| 36 | + } |
|
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | function renderStTag() { |
@@ -40,11 +41,12 @@ discard block |
||
| 40 | 41 | } |
| 41 | 42 | |
| 42 | 43 | function renderContent($pad = "", $oneliner = false) { |
| 43 | - if ($this->commentstyle == "HTML") |
|
| 44 | - if (count($this->content) > 1) |
|
| 44 | + if ($this->commentstyle == "HTML") { |
|
| 45 | + if (count($this->content) > 1) |
|
| 45 | 46 | return $pad . " " . implode("\n$pad", $this->content) . "\n"; |
| 46 | - else |
|
| 47 | - return current($this->content); |
|
| 47 | + } else { |
|
| 48 | + return current($this->content); |
|
| 49 | + } |
|
| 48 | 50 | return ""; |
| 49 | 51 | } |
| 50 | 52 | |
@@ -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) {
|
@@ -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 |