@@ -110,6 +110,9 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | + /** |
|
| 114 | + * @return string |
|
| 115 | + */ |
|
| 113 | 116 | function getValue() {
|
| 114 | 117 | if (!is_null($this->setValue)) return $this->setValue; |
| 115 | 118 | if (isset($_REQUEST[$this->form . "_" . $this->name])) {
|
@@ -173,6 +176,9 @@ discard block |
||
| 173 | 176 | } |
| 174 | 177 | } |
| 175 | 178 | |
| 179 | + /** |
|
| 180 | + * @param boolean $submit |
|
| 181 | + */ |
|
| 176 | 182 | function doProcess($submit) {
|
| 177 | 183 | if ($submit) {
|
| 178 | 184 | $value = $this->getValue(); |
@@ -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 | |
@@ -92,6 +92,9 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | + /** |
|
| 96 | + * @param string $s |
|
| 97 | + */ |
|
| 95 | 98 | function parseSnip($s) {
|
| 96 | 99 | //save root tags |
| 97 | 100 | $roots = $this->root; |
@@ -229,6 +232,9 @@ discard block |
||
| 229 | 232 | |
| 230 | 233 | } |
| 231 | 234 | |
| 235 | + /** |
|
| 236 | + * @param integer $indent |
|
| 237 | + */ |
|
| 232 | 238 | function consumeBlock($indent) {
|
| 233 | 239 | $out = array(); |
| 234 | 240 | $m = array(); |
@@ -243,6 +249,9 @@ discard block |
||
| 243 | 249 | return $out; |
| 244 | 250 | } |
| 245 | 251 | |
| 252 | + /** |
|
| 253 | + * @param integer $indent |
|
| 254 | + */ |
|
| 246 | 255 | function indentLevel($indent) {
|
| 247 | 256 | if (!isset($this->indents)) $this->indents = array(); |
| 248 | 257 | if (!count($this->indents)) {
|
@@ -108,22 +108,25 @@ discard block |
||
| 108 | 108 | $revSnip = array(); |
| 109 | 109 | /** @var Tag $roots */ |
| 110 | 110 | $roots = array(); |
| 111 | - foreach ($this->root as $snip) |
|
| 112 | - if ($snip instanceOf Tag\Snippet) {
|
|
| 111 | + foreach ($this->root as $snip) { |
|
| 112 | + if ($snip instanceOf Tag\Snippet) {
|
|
| 113 | 113 | if ($snip->getType() == "append") {
|
| 114 | - array_unshift($revSnip, $snip); |
|
| 114 | + array_unshift($revSnip, $snip); |
|
| 115 | + } |
|
| 115 | 116 | } else {
|
| 116 | 117 | $fwdSnip[] = $snip; |
| 117 | 118 | } |
| 118 | 119 | } else {
|
| 119 | 120 | $roots[] = $snip; |
| 120 | 121 | } |
| 121 | - foreach ($fwdSnip as $snip) |
|
| 122 | - foreach ($roots as $root) |
|
| 123 | - $snip->apply($root); |
|
| 124 | - foreach ($revSnip as $snip) |
|
| 125 | - foreach ($roots as $root) |
|
| 126 | - $snip->apply($root); |
|
| 122 | + foreach ($fwdSnip as $snip) { |
|
| 123 | + foreach ($roots as $root) |
|
| 124 | + $snip->apply($root); |
|
| 125 | + } |
|
| 126 | + foreach ($revSnip as $snip) { |
|
| 127 | + foreach ($roots as $root) |
|
| 128 | + $snip->apply($root); |
|
| 129 | + } |
|
| 127 | 130 | $this->root = $roots; |
| 128 | 131 | } |
| 129 | 132 | |
@@ -143,9 +146,11 @@ discard block |
||
| 143 | 146 | $heir = array(); |
| 144 | 147 | while ($this->lineNo < $this->lineCount) {
|
| 145 | 148 | $line = $this->lines[$this->lineNo]; |
| 146 | - if (trim($line)) if (preg_match(self::REGEX_PARSE_LINE, $line, $m)) {
|
|
| 149 | + if (trim($line)) { |
|
| 150 | + if (preg_match(self::REGEX_PARSE_LINE, $line, $m)) {
|
|
| 147 | 151 | if (FALSE !== strpos($m[1], "\t")) |
| 148 | - throw new ParseError("Tabs are not supported in templates at this time");
|
|
| 152 | + throw new ParseError("Tabs are not supported in templates at this time"); |
|
| 153 | + } |
|
| 149 | 154 | $indent = strlen($m[1]); |
| 150 | 155 | $tag = isset($m[2]) ? $tag = $m[2] : ""; |
| 151 | 156 | $classid = isset($m[3]) ? $m[3] : ""; |
@@ -157,13 +162,13 @@ discard block |
||
| 157 | 162 | unset($m[0]); |
| 158 | 163 | switch (strlen($code) ? $code[0] : ($textcode ? $textcode : "")) {
|
| 159 | 164 | case "|": //Control Tag |
| 160 | - if ($code == "|snippet") |
|
| 161 | - $hTag = new Tag\Snippet($text); |
|
| 162 | - elseif ($code == "|form") |
|
| 163 | - $hTag = new Tag\Form($text); |
|
| 164 | - elseif ($code == "|formhint") |
|
| 165 | - $hTag = new Tag\FormHint($text); |
|
| 166 | - elseif ($code == "|else") {
|
|
| 165 | + if ($code == "|snippet") { |
|
| 166 | + $hTag = new Tag\Snippet($text); |
|
| 167 | + } elseif ($code == "|form") { |
|
| 168 | + $hTag = new Tag\Form($text); |
|
| 169 | + } elseif ($code == "|formhint") { |
|
| 170 | + $hTag = new Tag\FormHint($text); |
|
| 171 | + } elseif ($code == "|else") {
|
|
| 167 | 172 | $hTag = new Tag\Control(substr($code, 1), $heir[$i - 1]); |
| 168 | 173 | $hTag->setVar($text); |
| 169 | 174 | } else {
|
@@ -174,8 +179,9 @@ discard block |
||
| 174 | 179 | case ":": //Filter Tag |
| 175 | 180 | $hTag = new Tag\Filter(substr($code, 1)); |
| 176 | 181 | $hTag->addContent($text, Text::TOKEN_CODE); |
| 177 | - foreach ($this->consumeBlock($indent) as $l) |
|
| 178 | - $hTag->addContent($l, Text::TOKEN_CODE); |
|
| 182 | + foreach ($this->consumeBlock($indent) as $l) { |
|
| 183 | + $hTag->addContent($l, Text::TOKEN_CODE); |
|
| 184 | + } |
|
| 179 | 185 | break; |
| 180 | 186 | case "_": //String Tag |
| 181 | 187 | case "__": //Unescape String Tag |
@@ -186,8 +192,9 @@ discard block |
||
| 186 | 192 | case "//": // Non Printed Comment |
| 187 | 193 | $hTag = new Tag\Comment($textcode); |
| 188 | 194 | $hTag->addContent($text); |
| 189 | - foreach ($this->consumeBlock($indent) as $l) |
|
| 190 | - $hTag->addContent($l, Text::TOKEN_CODE); |
|
| 195 | + foreach ($this->consumeBlock($indent) as $l) { |
|
| 196 | + $hTag->addContent($l, Text::TOKEN_CODE); |
|
| 197 | + } |
|
| 191 | 198 | break; |
| 192 | 199 | default: |
| 193 | 200 | $attr = array(); |
@@ -198,33 +205,43 @@ discard block |
||
| 198 | 205 | } |
| 199 | 206 | $class = array(); $id = ""; $ref = ""; |
| 200 | 207 | preg_match_all('/[#\.!][a-zA-Z0-9\-\_]+/m', $classid, $cid);
|
| 201 | - if (isset($cid[0])) foreach ($cid[0] as $s) {
|
|
| 202 | - if ($s[0] == "#") $id = substr($s, 1); |
|
| 203 | - if ($s[0] == ".") $class[] = substr($s, 1); |
|
| 204 | - if ($s[0] == "!") $ref = substr($s, 1); |
|
| 208 | + if (isset($cid[0])) { |
|
| 209 | + foreach ($cid[0] as $s) {
|
|
| 210 | + if ($s[0] == "#") $id = substr($s, 1); |
|
| 211 | + } |
|
| 212 | + if ($s[0] == ".") { |
|
| 213 | + $class[] = substr($s, 1); |
|
| 214 | + } |
|
| 215 | + if ($s[0] == "!") { |
|
| 216 | + $ref = substr($s, 1); |
|
| 217 | + } |
|
| 205 | 218 | } |
| 206 | - if($ref) |
|
| 207 | - $hTag = new Tag\DynHtml($tag, $class, $attr, $id, $ref); |
|
| 208 | - else |
|
| 209 | - $hTag = new Tag\Html($tag, $class, $attr, $id); |
|
| 219 | + if($ref) { |
|
| 220 | + $hTag = new Tag\DynHtml($tag, $class, $attr, $id, $ref); |
|
| 221 | + } else { |
|
| 222 | + $hTag = new Tag\Html($tag, $class, $attr, $id); |
|
| 223 | + } |
|
| 210 | 224 | $hTag->addContent($text); |
| 211 | 225 | break; |
| 212 | 226 | } |
| 213 | 227 | $heir[$i] = $hTag; |
| 214 | - if ($i > 0) |
|
| 215 | - $heir[$i - 1]->addChild($hTag); |
|
| 216 | - else |
|
| 217 | - $this->root[] = $hTag; |
|
| 218 | - } else |
|
| 219 | - throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/" . preg_last_error());
|
|
| 228 | + if ($i > 0) { |
|
| 229 | + $heir[$i - 1]->addChild($hTag); |
|
| 230 | + } else { |
|
| 231 | + $this->root[] = $hTag; |
|
| 232 | + } |
|
| 233 | + } else { |
|
| 234 | + throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/" . preg_last_error()); |
|
| 235 | + } |
|
| 220 | 236 | $this->lineNo++; |
| 221 | 237 | } |
| 222 | 238 | } |
| 223 | 239 | |
| 224 | 240 | function output() {
|
| 225 | 241 | $out = "<?php\nuse Seufert\\Hamle;\n?>"; |
| 226 | - foreach ($this->root as $tag) |
|
| 227 | - $out .= $tag->render(); |
|
| 242 | + foreach ($this->root as $tag) { |
|
| 243 | + $out .= $tag->render(); |
|
| 244 | + } |
|
| 228 | 245 | return $out; |
| 229 | 246 | |
| 230 | 247 | } |
@@ -236,15 +253,18 @@ discard block |
||
| 236 | 253 | (!trim($this->lines[$this->lineNo + 1]) || |
| 237 | 254 | preg_match('/^(\s){' . $indent . '}((\s)+[^\s].*)$/',
|
| 238 | 255 | $this->lines[$this->lineNo + 1], $m))) {
|
| 239 | - if (trim($this->lines[$this->lineNo + 1])) |
|
| 240 | - $out[] = $m[2]; |
|
| 256 | + if (trim($this->lines[$this->lineNo + 1])) { |
|
| 257 | + $out[] = $m[2]; |
|
| 258 | + } |
|
| 241 | 259 | $this->lineNo++; |
| 242 | 260 | } |
| 243 | 261 | return $out; |
| 244 | 262 | } |
| 245 | 263 | |
| 246 | 264 | function indentLevel($indent) {
|
| 247 | - if (!isset($this->indents)) $this->indents = array(); |
|
| 265 | + if (!isset($this->indents)) { |
|
| 266 | + $this->indents = array(); |
|
| 267 | + } |
|
| 248 | 268 | if (!count($this->indents)) {
|
| 249 | 269 | $this->indents = array(0 => $indent); |
| 250 | 270 | // Key = indent level, Value = Depth in spaces |
@@ -17,6 +17,9 @@ |
||
| 17 | 17 | /** @var Model[] Assoc array of Models by Scope Name */ |
| 18 | 18 | static $namedScopes = array(); |
| 19 | 19 | |
| 20 | + /** |
|
| 21 | + * @param Model $model |
|
| 22 | + */ |
|
| 20 | 23 | static function add($model, $name = null) {
|
| 21 | 24 | if (!$model instanceOf Model) |
| 22 | 25 | throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface");
|
@@ -18,12 +18,14 @@ discard block |
||
| 18 | 18 | static $namedScopes = array(); |
| 19 | 19 | |
| 20 | 20 | static function add($model, $name = null) {
|
| 21 | - if (!$model instanceOf Model) |
|
| 22 | - throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface");
|
|
| 23 | - if ($name) |
|
| 24 | - self::$namedScopes[$name] = $model; |
|
| 25 | - else |
|
| 26 | - self::$scopes[] = $model; |
|
| 21 | + if (!$model instanceOf Model) { |
|
| 22 | + throw new Unsupported("Unsupported Model (".get_class($model)."), Needs to implement hamleModel Interface"); |
|
| 23 | + } |
|
| 24 | + if ($name) { |
|
| 25 | + self::$namedScopes[$name] = $model; |
|
| 26 | + } else { |
|
| 27 | + self::$scopes[] = $model; |
|
| 28 | + } |
|
| 27 | 29 | } |
| 28 | 30 | |
| 29 | 31 | static function done() {
|
@@ -41,15 +43,21 @@ discard block |
||
| 41 | 43 | */ |
| 42 | 44 | static function get($id = 0) {
|
| 43 | 45 | if (0 == $id) {
|
| 44 | - if ($scope = end(self::$scopes)) |
|
| 45 | - return $scope; |
|
| 46 | + if ($scope = end(self::$scopes)) { |
|
| 47 | + return $scope; |
|
| 48 | + } |
|
| 46 | 49 | throw new OutOfScope("Unable to find Scope ($id)");
|
| 47 | 50 | } |
| 48 | 51 | $key = $id - 1; |
| 49 | - if ($id < 0) $key = count(self::$scopes) + $id - 1; |
|
| 50 | - if ($id == 0) $key = count(self::$scopes) - 1; |
|
| 51 | - if (!isset(self::$scopes[$key])) |
|
| 52 | - throw new OutOfScope("Unable to find Scope ($id) or $key");
|
|
| 52 | + if ($id < 0) { |
|
| 53 | + $key = count(self::$scopes) + $id - 1; |
|
| 54 | + } |
|
| 55 | + if ($id == 0) { |
|
| 56 | + $key = count(self::$scopes) - 1; |
|
| 57 | + } |
|
| 58 | + if (!isset(self::$scopes[$key])) { |
|
| 59 | + throw new OutOfScope("Unable to find Scope ($id) or $key"); |
|
| 60 | + } |
|
| 53 | 61 | return self::$scopes[$key]; |
| 54 | 62 | } |
| 55 | 63 | |
@@ -64,8 +72,9 @@ discard block |
||
| 64 | 72 | if ($name && isset(self::$namedScopes[$name])) {
|
| 65 | 73 | self::$namedScopes[$name]->rewind(); |
| 66 | 74 | return self::$namedScopes[$name]; |
| 67 | - } else |
|
| 68 | - throw new RunTime("Unable to find scope ($name)");
|
|
| 75 | + } else { |
|
| 76 | + throw new RunTime("Unable to find scope ($name)"); |
|
| 77 | + } |
|
| 69 | 78 | } |
| 70 | 79 | |
| 71 | 80 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * Open the default model when only an ID is specified in the template |
| 50 | 50 | * |
| 51 | - * @param mixed $id Identifier when no type is passed |
|
| 52 | - * @param array $sort |
|
| 51 | + * @param string $id Identifier when no type is passed |
|
| 52 | + * @param integer $sort |
|
| 53 | 53 | * @param int $limit Results Limit |
| 54 | 54 | * @param int $offset Results Offset |
| 55 | 55 | * @return Model Instance of model class that implements hamleModel |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * Open a specific model type with id |
| 61 | 61 | * |
| 62 | 62 | * @param array[] $typeId Type ID array [type=>[id]] or [page=>[3]] |
| 63 | - * @param array $sort |
|
| 63 | + * @param integer $sort |
|
| 64 | 64 | * @param int $limit Results Limit |
| 65 | 65 | * @param int $offset Results Offset |
| 66 | 66 | * @return Model |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * Return Iterator containing results from search of tags |
| 77 | 77 | * |
| 78 | 78 | * @param array[] $typeTags Type Tag Array [type=>[tag1,tag2],type2=>[]] |
| 79 | - * @param array $sort |
|
| 79 | + * @param integer $sort |
|
| 80 | 80 | * @param int $limit Results Limit |
| 81 | 81 | * @param int $offset Results Limit |
| 82 | 82 | * @return Model Instance of Iterable model class |
@@ -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 | |
@@ -30,6 +30,9 @@ |
||
| 30 | 30 | class Comment extends Tag { |
| 31 | 31 | protected $commentstyle; |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param string $type |
|
| 35 | + */ |
|
| 33 | 36 | function __construct($type) { |
| 34 | 37 | if ($type == "/") |
| 35 | 38 | $this->commentstyle = "HTML"; |
@@ -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 | |
@@ -33,6 +33,10 @@ |
||
| 33 | 33 | protected $varname; |
| 34 | 34 | protected $baseType; |
| 35 | 35 | |
| 36 | + /** |
|
| 37 | + * @param string $tag |
|
| 38 | + * @param string $id |
|
| 39 | + */ |
|
| 36 | 40 | function __construct($tag, $class, $param, $id, $ref) { |
| 37 | 41 | parent::__construct($tag, $class, $param, $id); |
| 38 | 42 | $this->source[] = $ref; |
@@ -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) ? "/>" : ">"; |
@@ -38,6 +38,9 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | protected $filter; |
| 40 | 40 | |
| 41 | + /** |
|
| 42 | + * @param string $tag |
|
| 43 | + */ |
|
| 41 | 44 | function __construct($tag) { |
| 42 | 45 | parent::__construct(); |
| 43 | 46 | $this->type = ucfirst(strtolower($tag)); |
@@ -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) { |
@@ -38,6 +38,9 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | protected $form; |
| 40 | 40 | |
| 41 | + /** |
|
| 42 | + * @param string $param |
|
| 43 | + */ |
|
| 41 | 44 | function __construct($param) { |
| 42 | 45 | parent::__construct(); |
| 43 | 46 | $param = explode(' ', $param); |
@@ -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) { |
@@ -30,6 +30,9 @@ |
||
| 30 | 30 | class Snippet extends Hamle\Tag { |
| 31 | 31 | protected $path; |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param string $params |
|
| 35 | + */ |
|
| 33 | 36 | function __construct($params) { |
| 34 | 37 | parent::__construct(); |
| 35 | 38 | if (!preg_match('/^(append|content|prepend|replace)(?: (.*))?$/', $params, $m)) |
@@ -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 |