@@ -39,8 +39,8 @@ |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | static function filterText($s) { |
| 42 | - return "/*<![CDATA[*/\n" . |
|
| 42 | + return "/*<![CDATA[*/\n". |
|
| 43 | 43 | /*preg_replace(HamlParser::MATCH_INTERPOLATION, '<?php echo \1; ?>', $text)*/ |
| 44 | - $s . "/*]]>*/"; |
|
| 44 | + $s."/*]]>*/"; |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -35,10 +35,10 @@ |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | function toPHP() { |
| 38 | - return '$form->getField(' . Text::varToCode($this->var) . ')->getValue()'; |
|
| 38 | + return '$form->getField('.Text::varToCode($this->var).')->getValue()'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function toHTML($escape = false) { |
| 42 | - return '<?=' . $this->toPHP() . '?>'; |
|
| 42 | + return '<?='.$this->toPHP().'?>'; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -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 |
@@ -38,17 +38,25 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | function __construct($s) { |
| 40 | 40 | $m = array(); |
| 41 | - if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
|
| 42 | - throw new ParseError("Unable to read \$ sub func in '$s'"); |
|
| 43 | - if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT; |
|
| 44 | - elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD; |
|
| 45 | - else $this->dir = Hamle\Hamle::REL_ANY; |
|
| 41 | + if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) { |
|
| 42 | + throw new ParseError("Unable to read \$ sub func in '$s'"); |
|
| 43 | + } |
|
| 44 | + if ($m[1] == "<") { |
|
| 45 | + $this->dir = Hamle\Hamle::REL_PARENT; |
|
| 46 | + } elseif ($m[1] == ">") { |
|
| 47 | + $this->dir = Hamle\Hamle::REL_CHILD; |
|
| 48 | + } else { |
|
| 49 | + $this->dir = Hamle\Hamle::REL_ANY; |
|
| 50 | + } |
|
| 46 | 51 | $this->sortlimit = $this->attSortLimit($m[2]); |
| 47 | 52 | $this->filt = $this->attIdTag($m[2]); |
| 48 | 53 | $this->grouptype = $this->attGroupType($m[2]); |
| 49 | - if ($this->filt['id']) throw new ParseError("Unable to select by id"); |
|
| 50 | - if (trim($m[3])) |
|
| 51 | - $this->sub = new FuncSub($m[3]); |
|
| 54 | + if ($this->filt['id']) { |
|
| 55 | + throw new ParseError("Unable to select by id"); |
|
| 56 | + } |
|
| 57 | + if (trim($m[3])) { |
|
| 58 | + $this->sub = new FuncSub($m[3]); |
|
| 59 | + } |
|
| 52 | 60 | } |
| 53 | 61 | |
| 54 | 62 | /** |
@@ -38,55 +38,55 @@ |
||
| 38 | 38 | protected $what; |
| 39 | 39 | |
| 40 | 40 | function __construct($s, Text $what) { |
| 41 | - if(preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
|
| 41 | + if (preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
|
| 42 | 42 | $this->filter = $m[1]; |
| 43 | 43 | $this->vars = isset($m[3]) ? explode(',', $m[3]) : []; |
| 44 | - foreach($this->vars as $k=>$v) |
|
| 45 | - $this->vars[$k] = str_replace(",",',',$v); |
|
| 44 | + foreach ($this->vars as $k=>$v) |
|
| 45 | + $this->vars[$k] = str_replace(",", ',', $v); |
|
| 46 | 46 | } else { |
| 47 | 47 | throw new ParseError("Unable to parse filter expression \"$s\""); |
| 48 | 48 | } |
| 49 | - if(!in_array($this->filter, ['itersplit', 'newlinebr', 'round', |
|
| 50 | - 'strtoupper', 'strtolower', 'ucfirst','replace', 'json'])) { |
|
| 49 | + if (!in_array($this->filter, ['itersplit', 'newlinebr', 'round', |
|
| 50 | + 'strtoupper', 'strtolower', 'ucfirst', 'replace', 'json'])) { |
|
| 51 | 51 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
| 52 | 52 | } |
| 53 | - if(in_array($this->filter,['itersplit','newlinebr', 'replace'])) { |
|
| 53 | + if (in_array($this->filter, ['itersplit', 'newlinebr', 'replace'])) { |
|
| 54 | 54 | $this->filter = "Seufert\\Hamle\\Text\\Filter::{$this->filter}"; |
| 55 | 55 | } |
| 56 | 56 | $mapFilter = ['json'=>'json_encode']; |
| 57 | - if(isset($mapFilter[$this->filter])) |
|
| 57 | + if (isset($mapFilter[$this->filter])) |
|
| 58 | 58 | $this->filter = $mapFilter[$this->filter]; |
| 59 | 59 | $this->what = $what; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | function toHTML($escape = false) { |
| 63 | - if($escape) |
|
| 64 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 65 | - return "<?=" . $this->toPHP() . "?>"; |
|
| 63 | + if ($escape) |
|
| 64 | + return "<?=htmlspecialchars(".$this->toPHP().")?>"; |
|
| 65 | + return "<?=".$this->toPHP()."?>"; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function toPHP() { |
| 69 | - $o = [$this->what->toPHPVar()] ; |
|
| 70 | - foreach($this->vars as $v) |
|
| 69 | + $o = [$this->what->toPHPVar()]; |
|
| 70 | + foreach ($this->vars as $v) |
|
| 71 | 71 | $o[] = $this->varToCode($v); |
| 72 | - return "{$this->filter}(" . implode(',',$o) . ")"; |
|
| 72 | + return "{$this->filter}(".implode(',', $o).")"; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | static function itersplit($v, $sep = ",") { |
| 76 | 76 | $o = []; |
| 77 | - foreach(explode($sep, $v) as $k=>$i) { |
|
| 78 | - if($i) |
|
| 79 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 77 | + foreach (explode($sep, $v) as $k=>$i) { |
|
| 78 | + if ($i) |
|
| 79 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k]; |
|
| 80 | 80 | } |
| 81 | 81 | return new WrapArray($o); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | static function newlinebr($v) { |
| 85 | - return str_replace("\n","<br />\n",$v); |
|
| 85 | + return str_replace("\n", "<br />\n", $v); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | static function replace($v, $src, $dst) { |
| 89 | - return str_replace($src,$dst,$v); |
|
| 89 | + return str_replace($src, $dst, $v); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | } |
| 93 | 93 | \ No newline at end of file |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | if(preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
| 42 | 42 | $this->filter = $m[1]; |
| 43 | 43 | $this->vars = isset($m[3]) ? explode(',', $m[3]) : []; |
| 44 | - foreach($this->vars as $k=>$v) |
|
| 45 | - $this->vars[$k] = str_replace(",",',',$v); |
|
| 44 | + foreach($this->vars as $k=>$v) { |
|
| 45 | + $this->vars[$k] = str_replace(",",',',$v); |
|
| 46 | + } |
|
| 46 | 47 | } else { |
| 47 | 48 | throw new ParseError("Unable to parse filter expression \"$s\""); |
| 48 | 49 | } |
@@ -54,29 +55,33 @@ discard block |
||
| 54 | 55 | $this->filter = "Seufert\\Hamle\\Text\\Filter::{$this->filter}"; |
| 55 | 56 | } |
| 56 | 57 | $mapFilter = ['json'=>'json_encode']; |
| 57 | - if(isset($mapFilter[$this->filter])) |
|
| 58 | - $this->filter = $mapFilter[$this->filter]; |
|
| 58 | + if(isset($mapFilter[$this->filter])) { |
|
| 59 | + $this->filter = $mapFilter[$this->filter]; |
|
| 60 | + } |
|
| 59 | 61 | $this->what = $what; |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | 64 | function toHTML($escape = false) { |
| 63 | - if($escape) |
|
| 64 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 65 | + if($escape) { |
|
| 66 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 67 | + } |
|
| 65 | 68 | return "<?=" . $this->toPHP() . "?>"; |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | 71 | function toPHP() { |
| 69 | 72 | $o = [$this->what->toPHPVar()] ; |
| 70 | - foreach($this->vars as $v) |
|
| 71 | - $o[] = $this->varToCode($v); |
|
| 73 | + foreach($this->vars as $v) { |
|
| 74 | + $o[] = $this->varToCode($v); |
|
| 75 | + } |
|
| 72 | 76 | return "{$this->filter}(" . implode(',',$o) . ")"; |
| 73 | 77 | } |
| 74 | 78 | |
| 75 | 79 | static function itersplit($v, $sep = ",") { |
| 76 | 80 | $o = []; |
| 77 | 81 | foreach(explode($sep, $v) as $k=>$i) { |
| 78 | - if($i) |
|
| 79 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 82 | + if($i) { |
|
| 83 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 84 | + } |
|
| 80 | 85 | } |
| 81 | 86 | return new WrapArray($o); |
| 82 | 87 | } |
@@ -37,6 +37,9 @@ |
||
| 37 | 37 | /** @var SimpleVar */ |
| 38 | 38 | protected $what; |
| 39 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $s |
|
| 42 | + */ |
|
| 40 | 43 | function __construct($s, Text $what) { |
| 41 | 44 | if(preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
| 42 | 45 | $this->filter = $m[1]; |
@@ -42,6 +42,6 @@ |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | function isClicked() { |
| 45 | - return isset($_REQUEST[$this->form . "_" . $this->name]); |
|
| 45 | + return isset($_REQUEST[$this->form."_".$this->name]); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |