@@ -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 | |
@@ -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 | } |
@@ -54,10 +54,11 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | static function popInstance() {
|
| 56 | 56 | array_pop(self::$hamleList); |
| 57 | - if (self::$hamleList) |
|
| 58 | - self::$hamle = self::$hamleList[count(self::$hamleList) - 1]; |
|
| 59 | - else |
|
| 60 | - self::$hamle = NULL; |
|
| 57 | + if (self::$hamleList) { |
|
| 58 | + self::$hamle = self::$hamleList[count(self::$hamleList) - 1]; |
|
| 59 | + } else { |
|
| 60 | + self::$hamle = NULL; |
|
| 61 | + } |
|
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | /** |
@@ -113,7 +114,9 @@ discard block |
||
| 113 | 114 | */ |
| 114 | 115 | static function modelId($id, $sort = [], $limit = 0, $offset = 0) {
|
| 115 | 116 | $o = self::$hamle->setup->getModelDefault($id, $sort, $limit, $offset); |
| 116 | - if (!$o instanceOf Model) throw new RunTime("Application must return instance of hamleModel");
|
|
| 117 | + if (!$o instanceOf Model) { |
|
| 118 | + throw new RunTime("Application must return instance of hamleModel"); |
|
| 119 | + } |
|
| 117 | 120 | return $o; |
| 118 | 121 | } |
| 119 | 122 | |
@@ -39,17 +39,25 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function __construct($s) { |
| 41 | 41 | $m = array(); |
| 42 | - if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
|
| 43 | - throw new ParseError("Unable to read \$ sub func in '$s'"); |
|
| 44 | - if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT; |
|
| 45 | - elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD; |
|
| 46 | - else $this->dir = Hamle\Hamle::REL_ANY; |
|
| 42 | + if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) { |
|
| 43 | + throw new ParseError("Unable to read \$ sub func in '$s'"); |
|
| 44 | + } |
|
| 45 | + if ($m[1] == "<") { |
|
| 46 | + $this->dir = Hamle\Hamle::REL_PARENT; |
|
| 47 | + } elseif ($m[1] == ">") { |
|
| 48 | + $this->dir = Hamle\Hamle::REL_CHILD; |
|
| 49 | + } else { |
|
| 50 | + $this->dir = Hamle\Hamle::REL_ANY; |
|
| 51 | + } |
|
| 47 | 52 | $this->sortlimit = $this->attSortLimit($m[2]); |
| 48 | 53 | $this->filt = $this->attIdTag($m[2]); |
| 49 | 54 | $this->grouptype = $this->attGroupType($m[2]); |
| 50 | - if ($this->filt['id']) throw new ParseError("Unable to select by id"); |
|
| 51 | - if (trim($m[3])) |
|
| 52 | - $this->sub = new FuncSub($m[3]); |
|
| 55 | + if ($this->filt['id']) { |
|
| 56 | + throw new ParseError("Unable to select by id"); |
|
| 57 | + } |
|
| 58 | + if (trim($m[3])) { |
|
| 59 | + $this->sub = new FuncSub($m[3]); |
|
| 60 | + } |
|
| 53 | 61 | } |
| 54 | 62 | |
| 55 | 63 | /** |
@@ -69,13 +77,15 @@ discard block |
||
| 69 | 77 | $model = $parent->hamleRel($this->dir, $this->filt['tag'], $this->sortlimit['sort'], |
| 70 | 78 | $this->sortlimit['limit'], $this->sortlimit['offset']); |
| 71 | 79 | if(!$model->valid()) { |
| 72 | - if(!$parent instanceof Hamle\WriteModel) |
|
| 73 | - throw new \Exception('Cant create model, ' . get_class($parent) . ' must implement Hamle\\WriteModel.'); |
|
| 80 | + if(!$parent instanceof Hamle\WriteModel) { |
|
| 81 | + throw new \Exception('Cant create model, ' . get_class($parent) . ' must implement Hamle\\WriteModel.'); |
|
| 82 | + } |
|
| 74 | 83 | $model = $parent->current()->hamleCreateRel($this->dir, $this->filt['tag'], $this->sortlimit['sort'], |
| 75 | 84 | $this->sortlimit['limit'], $this->sortlimit['offset']); |
| 76 | 85 | } |
| 77 | - if($this->sub) |
|
| 78 | - return $this->sub->getOrCreateModel($model)->current(); |
|
| 86 | + if($this->sub) { |
|
| 87 | + return $this->sub->getOrCreateModel($model)->current(); |
|
| 88 | + } |
|
| 79 | 89 | return $model->current(); |
| 80 | 90 | } |
| 81 | 91 | |
@@ -44,8 +44,9 @@ discard block |
||
| 44 | 44 | if(preg_match("/^([a-z]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) { |
| 45 | 45 | $this->filter = $m[1]; |
| 46 | 46 | $this->vars = isset($m['vars']) && strlen($m['vars']) ? explode(',', $m['vars']) : []; |
| 47 | - foreach($this->vars as $k=>$v) |
|
| 48 | - $this->vars[$k] = str_replace(",",',',$v); |
|
| 47 | + foreach($this->vars as $k=>$v) { |
|
| 48 | + $this->vars[$k] = str_replace(",",',',$v); |
|
| 49 | + } |
|
| 49 | 50 | if(isset($m['chained']) && strlen($m['chained'])) { |
| 50 | 51 | $this->chained = new Filter($m['chained'],$what); |
| 51 | 52 | } |
@@ -58,31 +59,36 @@ discard block |
||
| 58 | 59 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
| 59 | 60 | } |
| 60 | 61 | $mapFilter = ['json'=>'json_encode']; |
| 61 | - if(isset($mapFilter[$this->filter])) |
|
| 62 | - $this->filter = $mapFilter[$this->filter]; |
|
| 62 | + if(isset($mapFilter[$this->filter])) { |
|
| 63 | + $this->filter = $mapFilter[$this->filter]; |
|
| 64 | + } |
|
| 63 | 65 | $this->what = $what; |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | function toHTML($escape = false) { |
| 67 | - if($escape) |
|
| 68 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 69 | + if($escape) { |
|
| 70 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 71 | + } |
|
| 69 | 72 | return "<?=" . $this->toPHP() . "?>"; |
| 70 | 73 | } |
| 71 | 74 | |
| 72 | 75 | function toPHPpre() { |
| 73 | 76 | $pre = ''; |
| 74 | - if($this->chained) |
|
| 75 | - $pre = $this->chained->toPHPpre(); |
|
| 77 | + if($this->chained) { |
|
| 78 | + $pre = $this->chained->toPHPpre(); |
|
| 79 | + } |
|
| 76 | 80 | return "$pre{$this->filter}("; |
| 77 | 81 | } |
| 78 | 82 | |
| 79 | 83 | function toPHPpost() { |
| 80 | 84 | $post = ''; |
| 81 | - if($this->chained) |
|
| 82 | - $post = $this->chained->toPHPpost(); |
|
| 85 | + if($this->chained) { |
|
| 86 | + $post = $this->chained->toPHPpost(); |
|
| 87 | + } |
|
| 83 | 88 | $o = ''; |
| 84 | - foreach($this->vars as $v) |
|
| 85 | - $o .= ','.$this->varToCode($v); |
|
| 89 | + foreach($this->vars as $v) { |
|
| 90 | + $o .= ','.$this->varToCode($v); |
|
| 91 | + } |
|
| 86 | 92 | return "$o)$post"; |
| 87 | 93 | } |
| 88 | 94 | |
@@ -97,8 +103,9 @@ discard block |
||
| 97 | 103 | static function itersplit($v, $sep = ",") { |
| 98 | 104 | $o = []; |
| 99 | 105 | foreach(explode($sep, $v) as $k=>$i) { |
| 100 | - if($i) |
|
| 101 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 106 | + if($i) { |
|
| 107 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 108 | + } |
|
| 102 | 109 | } |
| 103 | 110 | return new WrapArray($o); |
| 104 | 111 | } |