@@ -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) { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | foreach ($labelTags as $tag) |
| 62 | 62 | if ($tag instanceOf Html) |
| 63 | 63 | foreach ($tag->source as $source) { |
| 64 | - if(isset($fields[$source])) |
|
| 64 | + if (isset($fields[$source])) |
|
| 65 | 65 | $fields[$source]->getLabelAttStatic($tag->opt, $tag->type, $tag->content); |
| 66 | 66 | else |
| 67 | 67 | $tag->opt['style'] = "display:none;"; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | foreach ($inputTags as $tag) |
| 71 | 71 | if ($tag instanceOf Html) |
| 72 | 72 | foreach ($tag->source as $source) { |
| 73 | - if(isset($fields[$source])) |
|
| 73 | + if (isset($fields[$source])) |
|
| 74 | 74 | $fields[$source]->getHintAttStatic($tag->opt, $tag->type, $tag->content); |
| 75 | 75 | else |
| 76 | 76 | $tag->opt['style'] = "display:none;"; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | foreach ($inputTags as $tag) |
| 80 | 80 | if ($tag instanceOf Html) |
| 81 | 81 | foreach ($tag->source as $source) { |
| 82 | - if(isset($fields[$source])) { |
|
| 82 | + if (isset($fields[$source])) { |
|
| 83 | 83 | $fields[$source]->getInputAttStatic($tag->opt, $tag->type, $tag->content); |
| 84 | 84 | unset($fields[$source]); |
| 85 | 85 | } else |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | foreach ($fields as $n => $f) { |
| 89 | 89 | if (!$f instanceOf Button) { |
| 90 | - $this->addChild($label = new DynHtml("label", [],[],"",$n)); |
|
| 90 | + $this->addChild($label = new DynHtml("label", [], [], "", $n)); |
|
| 91 | 91 | $f->getLabelAttStatic($label->opt, $label->type, $label->content); |
| 92 | 92 | } |
| 93 | - $this->addChild($input = new DynHtml("input", [],[],"",$n)); |
|
| 93 | + $this->addChild($input = new DynHtml("input", [], [], "", $n)); |
|
| 94 | 94 | $f->getInputAttStatic($input->opt, $input->type, $input->content); |
| 95 | 95 | } |
| 96 | - return "<form " . implode(" ", $out) . "><?php \$form = " . $this->var->toPHP() . "; \$form->process(); ?>"; |
|
| 96 | + return "<form ".implode(" ", $out)."><?php \$form = ".$this->var->toPHP()."; \$form->process(); ?>"; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | function renderEnTag() { |
@@ -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,7 +42,7 @@ |
||
| 42 | 42 | function renderContent($pad = "", $oneliner = false) { |
| 43 | 43 | if ($this->commentstyle == "HTML") |
| 44 | 44 | if (count($this->content) > 1) |
| 45 | - return $pad . " " . implode("\n$pad", $this->content) . "\n"; |
|
| 45 | + return $pad." ".implode("\n$pad", $this->content)."\n"; |
|
| 46 | 46 | else |
| 47 | 47 | return current($this->content); |
| 48 | 48 | return ""; |
@@ -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) { |
@@ -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) { |
@@ -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 | } |
@@ -42,22 +42,22 @@ 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 | $this->source = array(); |
| 48 | 48 | $this->type = $tag ? $tag : "div"; |
| 49 | - if($class) { |
|
| 49 | + if ($class) { |
|
| 50 | 50 | if (isset($this->opt['class'])) |
| 51 | 51 | $this->opt['class'] = array_merge($this->opt['class'], $class); |
| 52 | 52 | else |
| 53 | 53 | $this->opt['class'] = $class; |
| 54 | 54 | } |
| 55 | - if($id) $this->opt['id'] = $id; |
|
| 55 | + if ($id) $this->opt['id'] = $id; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function renderStTag() { |
| 59 | 59 | $close = in_array($this->type, self::$selfCloseTags) ? " />" : ">"; |
| 60 | - return "<{$this->type}" . $this->optToTags() . $close; |
|
| 60 | + return "<{$this->type}".$this->optToTags().$close; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | function renderEnTag() { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | if (!$v instanceof H\Text) |
| 80 | 80 | $v = new H\Text($v); |
| 81 | 81 | $k = new H\Text($k); |
| 82 | - $out[] = " " . $k->toHTML() . "=\"" . $v->toHTMLAtt() . "\""; |
|
| 82 | + $out[] = " ".$k->toHTML()."=\"".$v->toHTMLAtt()."\""; |
|
| 83 | 83 | } |
| 84 | 84 | return implode("", $out); |
| 85 | 85 | } |
@@ -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) {
|
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $this->setup(); |
| 55 | 55 | $fields = $this->_fields; |
| 56 | 56 | $this->_fields = array(); |
| 57 | - foreach($fields as $v) {
|
|
| 57 | + foreach ($fields as $v) {
|
|
| 58 | 58 | $this->_fields[$v->name] = $v; |
| 59 | 59 | $v->form($this->_name); |
| 60 | 60 | } |
@@ -64,23 +64,23 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | function process() {
|
| 66 | 66 | $clicked = ""; |
| 67 | - foreach($this->_fields as $f) |
|
| 68 | - if($f instanceOf Field\Button) |
|
| 69 | - if($f->isClicked()) |
|
| 67 | + foreach ($this->_fields as $f) |
|
| 68 | + if ($f instanceOf Field\Button) |
|
| 69 | + if ($f->isClicked()) |
|
| 70 | 70 | $clicked = $f; |
| 71 | - foreach($this->_fields as $f) |
|
| 72 | - $f->doProcess($clicked?true:false); |
|
| 73 | - if($clicked) |
|
| 71 | + foreach ($this->_fields as $f) |
|
| 72 | + $f->doProcess($clicked ? true : false); |
|
| 73 | + if ($clicked) |
|
| 74 | 74 | try {
|
| 75 | 75 | $this->onSubmit($clicked); |
| 76 | - } catch(Exception\FormInvalid $e) {
|
|
| 76 | + } catch (Exception\FormInvalid $e) {
|
|
| 77 | 77 | $this->hint = $e->getMessage(); |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function isValid() {
|
| 82 | 82 | $valid = true; |
| 83 | - foreach($this->_fields as $f) |
|
| 83 | + foreach ($this->_fields as $f) |
|
| 84 | 84 | $valid = $f->valid && $valid; |
| 85 | 85 | return $valid; |
| 86 | 86 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | return $this->_fields; |
| 96 | 96 | } |
| 97 | 97 | function getField($n) {
|
| 98 | - if(!isset($this->_fields[$n])) |
|
| 98 | + if (!isset($this->_fields[$n])) |
|
| 99 | 99 | throw new Exception\NoKey("unable to find form field ($n)");
|
| 100 | 100 | return $this->_fields[$n]; |
| 101 | 101 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | function getHTMLProp() {
|
| 107 | - return array('action'=>'','method'=>'post','name'=>$this->_name,
|
|
| 107 | + return array('action'=>'', 'method'=>'post', 'name'=>$this->_name,
|
|
| 108 | 108 | 'enctype'=>'multipart/form-data'); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -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() { |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function __construct($s) { |
| 40 | 40 | $m = array(); |
| 41 | - if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
|
| 41 | + if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL.'+)(.*)$/', $s, $m)) |
|
| 42 | 42 | throw new ParseError("Unable to read \$ sub func in '$s'"); |
| 43 | 43 | if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT; |
| 44 | 44 | elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD; |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | * @return string |
| 57 | 57 | */ |
| 58 | 58 | function toPHP() { |
| 59 | - $limit = Hamle\Text::varToCode($this->sortlimit['sort']) . "," . |
|
| 60 | - $this->sortlimit['limit'] . "," . $this->sortlimit['offset'] . "," . |
|
| 59 | + $limit = Hamle\Text::varToCode($this->sortlimit['sort']).",". |
|
| 60 | + $this->sortlimit['limit'].",".$this->sortlimit['offset'].",". |
|
| 61 | 61 | $this->grouptype['grouptype']; |
| 62 | - $sub = $this->sub ? "->" . $this->sub->toPHP() : ""; |
|
| 63 | - return "hamleRel(" . $this->dir . "," . |
|
| 64 | - Hamle\Text::varToCode($this->filt['tag']) . ",$limit)$sub"; |
|
| 62 | + $sub = $this->sub ? "->".$this->sub->toPHP() : ""; |
|
| 63 | + return "hamleRel(".$this->dir.",". |
|
| 64 | + Hamle\Text::varToCode($this->filt['tag']).",$limit)$sub"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | \ No newline at end of file |
@@ -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) { |
@@ -41,9 +41,9 @@ |
||
| 41 | 41 | |
| 42 | 42 | function toPHP() { |
| 43 | 43 | if (is_numeric($this->scope)) |
| 44 | - return "Hamle\\Scope::get(" . Text::varToCode($this->scope) . ")"; |
|
| 44 | + return "Hamle\\Scope::get(".Text::varToCode($this->scope).")"; |
|
| 45 | 45 | else |
| 46 | - return "Hamle\\Scope::getName(" . Text::varToCode($this->scope) . ")"; |
|
| 46 | + return "Hamle\\Scope::getName(".Text::varToCode($this->scope).")"; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | 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 | |
@@ -33,25 +33,25 @@ |
||
| 33 | 33 | protected $filter; |
| 34 | 34 | |
| 35 | 35 | function __construct($s) { |
| 36 | - if(FALSE !== $pos = strpos($s,'|')) { |
|
| 37 | - $this->var = substr($s,1,$pos-1); |
|
| 38 | - $this->filter = new Filter(substr($s, $pos+1), $this); |
|
| 36 | + if (FALSE !== $pos = strpos($s, '|')) { |
|
| 37 | + $this->var = substr($s, 1, $pos - 1); |
|
| 38 | + $this->filter = new Filter(substr($s, $pos + 1), $this); |
|
| 39 | 39 | } else { |
| 40 | 40 | $this->var = substr($s, 1); |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | function toHTML($escape = false) { |
| 45 | - if($escape) |
|
| 46 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 47 | - return "<?=" . $this->toPHP() . "?>"; |
|
| 45 | + if ($escape) |
|
| 46 | + return "<?=htmlspecialchars(".$this->toPHP().")?>"; |
|
| 47 | + return "<?=".$this->toPHP()."?>"; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | function toPHP() { |
| 51 | - return $this->filter?$this->filter->toPHP():$this->toPHPVar(); |
|
| 51 | + return $this->filter ? $this->filter->toPHP() : $this->toPHPVar(); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | function toPHPVar() { |
| 55 | - return "Hamle\\Scope::get()->hamleGet(" . Text::varToCode($this->var) . ")"; |
|
| 55 | + return "Hamle\\Scope::get()->hamleGet(".Text::varToCode($this->var).")"; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |