@@ -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 | |
@@ -66,7 +66,9 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function __call($name, $valarray) {
|
| 69 | - if (count($valarray) < 1) return $this->__get($name); |
|
| 69 | + if (count($valarray) < 1) { |
|
| 70 | + return $this->__get($name); |
|
| 71 | + } |
|
| 70 | 72 | $val = count($valarray) == 1 ? current($valarray) : $valarray; |
| 71 | 73 | switch ($name) {
|
| 72 | 74 | case "name": |
@@ -111,12 +113,15 @@ discard block |
||
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | function getValue() {
|
| 114 | - if (!is_null($this->setValue)) return $this->setValue; |
|
| 116 | + if (!is_null($this->setValue)) { |
|
| 117 | + return $this->setValue; |
|
| 118 | + } |
|
| 115 | 119 | if (isset($_REQUEST[$this->form . "_" . $this->name])) {
|
| 116 | - if (get_magic_quotes_runtime()) |
|
| 117 | - return stripslashes($_REQUEST[$this->form . "_" . $this->name]); |
|
| 118 | - else |
|
| 119 | - return $_REQUEST[$this->form . "_" . $this->name]; |
|
| 120 | + if (get_magic_quotes_runtime()) { |
|
| 121 | + return stripslashes($_REQUEST[$this->form . "_" . $this->name]); |
|
| 122 | + } else { |
|
| 123 | + return $_REQUEST[$this->form . "_" . $this->name]; |
|
| 124 | + } |
|
| 120 | 125 | } |
| 121 | 126 | return $this->opt['default']; |
| 122 | 127 | } |
@@ -133,12 +138,15 @@ discard block |
||
| 133 | 138 | if (!$this->valid) {
|
| 134 | 139 | $atts['class'][] = "hamleFormError"; |
| 135 | 140 | } |
| 136 | - if ($this->opt["disabled"]) |
|
| 137 | - $atts['disabled'] = "disabled"; |
|
| 138 | - if ($this->opt['required']) |
|
| 139 | - $atts['required'] = "required"; |
|
| 140 | - if ($this->opt['help']) |
|
| 141 | - $atts['title'] = $this->opt['help']; |
|
| 141 | + if ($this->opt["disabled"]) { |
|
| 142 | + $atts['disabled'] = "disabled"; |
|
| 143 | + } |
|
| 144 | + if ($this->opt['required']) { |
|
| 145 | + $atts['required'] = "required"; |
|
| 146 | + } |
|
| 147 | + if ($this->opt['help']) { |
|
| 148 | + $atts['title'] = $this->opt['help']; |
|
| 149 | + } |
|
| 142 | 150 | } |
| 143 | 151 | |
| 144 | 152 | function getLabelAttStatic(&$atts, &$type, &$content) {
|
@@ -176,10 +184,12 @@ discard block |
||
| 176 | 184 | function doProcess($submit) {
|
| 177 | 185 | if ($submit) {
|
| 178 | 186 | $value = $this->getValue(); |
| 179 | - if ($this->opt['required']) |
|
| 180 | - $this->valid = $this->valid && strlen($value); |
|
| 181 | - if ($this->opt['regex']) |
|
| 182 | - $this->valid = $this->valid && preg_match($this->opt['regex'], $value); |
|
| 187 | + if ($this->opt['required']) { |
|
| 188 | + $this->valid = $this->valid && strlen($value); |
|
| 189 | + } |
|
| 190 | + if ($this->opt['regex']) { |
|
| 191 | + $this->valid = $this->valid && preg_match($this->opt['regex'], $value); |
|
| 192 | + } |
|
| 183 | 193 | } |
| 184 | 194 | } |
| 185 | 195 | |
@@ -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) ? "/>" : ">"; |
@@ -43,8 +43,9 @@ |
||
| 43 | 43 | if ($this->escape) { |
| 44 | 44 | $parse = new H\Text($s, $strtype); |
| 45 | 45 | $this->content[] = $parse->toHTML(); |
| 46 | - } else |
|
| 47 | - $this->content[] = $s; |
|
| 46 | + } else { |
|
| 47 | + $this->content[] = $s; |
|
| 48 | + } |
|
| 48 | 49 | } |
| 49 | 50 | } |
| 50 | 51 | |
@@ -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 | |
@@ -32,25 +32,33 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | function __construct($params) { |
| 34 | 34 | parent::__construct(); |
| 35 | - if (!preg_match('/^(append|content|prepend|replace)(?: (.*))?$/', $params, $m)) |
|
| 36 | - throw new Hamle\Exception\ParseError("Unable to parse Snippet($params)"); |
|
| 35 | + if (!preg_match('/^(append|content|prepend|replace)(?: (.*))?$/', $params, $m)) { |
|
| 36 | + throw new Hamle\Exception\ParseError("Unable to parse Snippet($params)"); |
|
| 37 | + } |
|
| 37 | 38 | $this->type = $m[1]; |
| 38 | - if (isset($m[2])) |
|
| 39 | - $this->path = explode(" ", $m[2]); |
|
| 40 | - else |
|
| 41 | - $this->path = array(); |
|
| 42 | - foreach ($this->path as $k => $v) |
|
| 43 | - $this->path[$k] = self::decodeClassId($v); |
|
| 39 | + if (isset($m[2])) { |
|
| 40 | + $this->path = explode(" ", $m[2]); |
|
| 41 | + } else { |
|
| 42 | + $this->path = array(); |
|
| 43 | + } |
|
| 44 | + foreach ($this->path as $k => $v) { |
|
| 45 | + $this->path[$k] = self::decodeClassId($v); |
|
| 46 | + } |
|
| 44 | 47 | } |
| 45 | 48 | |
| 46 | 49 | static function decodeClassId($s) { |
| 47 | 50 | $out = $m = array(); |
| 48 | - if(preg_match('/^[a-zA-Z0-9\_]+/', $s, $m)) |
|
| 49 | - $out['type'] = $m[0]; |
|
| 51 | + if(preg_match('/^[a-zA-Z0-9\_]+/', $s, $m)) { |
|
| 52 | + $out['type'] = $m[0]; |
|
| 53 | + } |
|
| 50 | 54 | preg_match_all('/[#\.][a-zA-Z0-9\-\_]+/m', $s, $m); |
| 51 | - if (isset($m[0])) foreach ($m[0] as $s) { |
|
| 55 | + if (isset($m[0])) { |
|
| 56 | + foreach ($m[0] as $s) { |
|
| 52 | 57 | if ($s[0] == "#") $out['id'] = substr($s, 1); |
| 53 | - if ($s[0] == ".") $out['class'][] = substr($s, 1); |
|
| 58 | + } |
|
| 59 | + if ($s[0] == ".") { |
|
| 60 | + $out['class'][] = substr($s, 1); |
|
| 61 | + } |
|
| 54 | 62 | } |
| 55 | 63 | return $out; |
| 56 | 64 | } |
@@ -62,21 +70,24 @@ discard block |
||
| 62 | 70 | function addSnipContent($contentTag, &$tagArray = array(), $key = 0) { |
| 63 | 71 | if ($this->type == "content") { |
| 64 | 72 | $tagArray[$key] = $contentTag; |
| 65 | - } else |
|
| 66 | - parent::addSnipContent($contentTag, $tagArray, $key); |
|
| 73 | + } else { |
|
| 74 | + parent::addSnipContent($contentTag, $tagArray, $key); |
|
| 75 | + } |
|
| 67 | 76 | } |
| 68 | 77 | |
| 69 | 78 | function apply(Hamle\Tag $rootTag) { |
| 70 | 79 | if ($this->type == "append" or $this->type == "prepend") { |
| 71 | 80 | $matchTags = $rootTag->find($this->path); |
| 72 | - foreach ($matchTags as $tag) |
|
| 73 | - foreach ($this->tags as $t) { |
|
| 81 | + foreach ($matchTags as $tag) { |
|
| 82 | + foreach ($this->tags as $t) { |
|
| 74 | 83 | $tag->addChild($t, $this->type); |
| 84 | + } |
|
| 75 | 85 | } |
| 76 | 86 | } elseif ($this->type == "replace") { |
| 77 | 87 | $rootTag->replace($this->path, $this); |
| 78 | - } else |
|
| 79 | - throw new Hamle\Exception\ParseError("Cant Apply snippet to document '{$this->type}'"); |
|
| 88 | + } else { |
|
| 89 | + throw new Hamle\Exception\ParseError("Cant Apply snippet to document '{$this->type}'"); |
|
| 90 | + } |
|
| 80 | 91 | } |
| 81 | 92 | |
| 82 | 93 | } |
| 83 | 94 | \ No newline at end of file |
@@ -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) { |