@@ -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) { |
@@ -34,11 +34,11 @@ |
||
34 | 34 | * @param string $class Class name to be autoloaded |
35 | 35 | */ |
36 | 36 | spl_autoload_register(function($class) { |
37 | - if(strpos($class, "Seufert\\Hamle\\") === 0) { |
|
37 | + if (strpos($class, "Seufert\\Hamle\\") === 0) { |
|
38 | 38 | $s = DIRECTORY_SEPARATOR; |
39 | - $class = str_replace("\\",$s,substr($class,14)); |
|
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)) include_once($path); |
|
42 | 42 | } |
43 | -},true,true); |
|
43 | +},true, true); |
|
44 | 44 |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function cachePath($f) { |
42 | 42 | $s = DIRECTORY_SEPARATOR; |
43 | - $dir = implode($s,[__DIR__,"..","..","cache",""]); |
|
44 | - if(!is_dir($dir)) mkdir($dir); |
|
43 | + $dir = implode($s, [__DIR__, "..", "..", "cache", ""]); |
|
44 | + if (!is_dir($dir)) mkdir($dir); |
|
45 | 45 | return $dir.$f; |
46 | 46 | } |
47 | 47 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @throws Exception\RunTime |
68 | 68 | */ |
69 | 69 | public function getModelTypeID($typeId, $sort = [], $limit = 0, $offset = 0) { |
70 | - if(count($typeId) > 1) |
|
70 | + if (count($typeId) > 1) |
|
71 | 71 | throw new Exception\RunTime("Unable to open more than one ID at a time"); |
72 | 72 | return new Model\Zero(); |
73 | 73 | } |
@@ -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 |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | |
64 | 64 | public $baseModel; |
65 | 65 | |
66 | - const REL_CHILD = 0x01; /* Child Relation */ |
|
66 | + const REL_CHILD = 0x01; /* Child Relation */ |
|
67 | 67 | const REL_PARENT = 0x02; /* Parent Relation */ |
68 | - const REL_ANY = 0x03; /* Unspecified or any relation */ |
|
68 | + const REL_ANY = 0x03; /* Unspecified or any relation */ |
|
69 | 69 | |
70 | - const SORT_NATURAL = 0x00; /* Sort in what ever order is 'default' */ |
|
71 | - const SORT_ASCENDING = 0x02; /* Sort Ascending */ |
|
70 | + const SORT_NATURAL = 0x00; /* Sort in what ever order is 'default' */ |
|
71 | + const SORT_ASCENDING = 0x02; /* Sort Ascending */ |
|
72 | 72 | const SORT_DESCENDING = 0x03; /* Sort Decending */ |
73 | - const SORT_RANDOM = 0x04; /* Sort Randomly */ |
|
73 | + const SORT_RANDOM = 0x04; /* Sort Randomly */ |
|
74 | 74 | /** |
75 | 75 | * Create new HAMLE Parser |
76 | 76 | * |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function __construct($baseModel, $setup = NULL) { |
83 | 83 | self::$me = $this; |
84 | - if(!$setup) |
|
84 | + if (!$setup) |
|
85 | 85 | $setup = new Setup(); |
86 | 86 | $this->parse = new Parse(); |
87 | - if(!$setup instanceOf Setup) |
|
87 | + if (!$setup instanceOf Setup) |
|
88 | 88 | throw new Exception\Unsupported("Unsupported Setup Helper was passed, it must extends hamleSetup"); |
89 | - if(!$baseModel instanceOf Model) |
|
89 | + if (!$baseModel instanceOf Model) |
|
90 | 90 | throw new Exception\Unsupported("Unsupported Model(".get_class($baseModel).") Type was passed, it must implement hamleModel"); |
91 | 91 | $this->setup = $setup; |
92 | 92 | $this->baseModel = $baseModel; |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | function initSnipFiles() { |
97 | - if($this->snipMod == 0) { |
|
97 | + if ($this->snipMod == 0) { |
|
98 | 98 | $this->snipFiles = $this->setup->snippetFiles(); |
99 | - foreach($this->snipFiles as $f) { |
|
99 | + foreach ($this->snipFiles as $f) { |
|
100 | 100 | if (!file_exists($f)) throw new Exception\NotFound("Unable to find Snippet File ($f)"); |
101 | 101 | $this->snipFiles = max($this->snipFiles, filemtime($f)); |
102 | 102 | } |
@@ -111,17 +111,17 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function load($hamleFile, \Closure $parseFunc = null) { |
113 | 113 | $template = $this->setup->templatePath($hamleFile); |
114 | - if(!file_exists($template)) |
|
114 | + if (!file_exists($template)) |
|
115 | 115 | throw new Exception\NotFound("Unable to find HAMLE Template ($template)"); |
116 | 116 | $this->cacheFile = $this->setup->cachePath( |
117 | - str_replace("/","-",$hamleFile).".php"); |
|
117 | + str_replace("/", "-", $hamleFile).".php"); |
|
118 | 118 | $this->setup->debugLog("Set cache file path to ({$this->cacheFile})"); |
119 | - $cacheFileAge = is_file($this->cacheFile)?filemtime($this->cacheFile):0; |
|
119 | + $cacheFileAge = is_file($this->cacheFile) ? filemtime($this->cacheFile) : 0; |
|
120 | 120 | $cacheDirty = !$this->cache || |
121 | 121 | $cacheFileAge < $this->snipMod || $cacheFileAge < filemtime($template); |
122 | - if($cacheDirty) { |
|
122 | + if ($cacheDirty) { |
|
123 | 123 | $this->setup->debugLog("Parsing File ($template to {$this->cacheFile})"); |
124 | - $this->parse($parseFunc?"":file_get_contents($template), $parseFunc); |
|
124 | + $this->parse($parseFunc ? "" : file_get_contents($template), $parseFunc); |
|
125 | 125 | } else |
126 | 126 | $this->setup->debugLog("Using Cached file ({$this->cacheFile})"); |
127 | 127 | return $this; |
@@ -135,22 +135,22 @@ discard block |
||
135 | 135 | * @throws Exception\ParseError if unable to write to the cache file |
136 | 136 | */ |
137 | 137 | function parse($hamleCode, \Closure $parseFunc = null) { |
138 | - if(!$this->cacheFile) |
|
138 | + if (!$this->cacheFile) |
|
139 | 139 | $this->cacheFile = $this->setup->cachePath("string.hamle.php"); |
140 | - if($parseFunc) |
|
140 | + if ($parseFunc) |
|
141 | 141 | $parseFunc($this->parse); |
142 | 142 | else |
143 | 143 | $this->parse->str($hamleCode); |
144 | 144 | $this->setup->debugLog("Loading Snippet Files"); |
145 | - foreach($this->snipFiles as $snip) |
|
145 | + foreach ($this->snipFiles as $snip) |
|
146 | 146 | $this->parse->parseSnip(file_get_contents($snip)); |
147 | 147 | $this->setup->debugLog("Applying Snippet Files"); |
148 | 148 | $this->parse->applySnip(); |
149 | 149 | $this->setup->debugLog("Executing Parse Filters"); |
150 | - foreach($this->setup->getFilters() as $filter) |
|
150 | + foreach ($this->setup->getFilters() as $filter) |
|
151 | 151 | $this->parse->parseFilter($filter); |
152 | 152 | $this->setup->debugLog("Updating Cache File ({$this->cacheFile})"); |
153 | - if(FALSE === file_put_contents($this->cacheFile, $this->parse->output())) |
|
153 | + if (FALSE === file_put_contents($this->cacheFile, $this->parse->output())) |
|
154 | 154 | throw new Exception\ParseError( |
155 | 155 | "Unable to write to cache file ({$this->cacheFile})"); |
156 | 156 | } |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | */ |
162 | 162 | function string($hamleString) { |
163 | 163 | $md5 = md5($hamleString); |
164 | - $stringId = substr($md5,0,12).substr($md5,24,8); |
|
164 | + $stringId = substr($md5, 0, 12).substr($md5, 24, 8); |
|
165 | 165 | $this->cacheFile = $this->setup->cachePath("string.$stringId.hamle.php"); |
166 | - if(!is_file($this->cacheFile)) |
|
166 | + if (!is_file($this->cacheFile)) |
|
167 | 167 | $this->parse($hamleString); |
168 | 168 | } |
169 | 169 | |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | $baseModel = $this->baseModel; |
180 | 180 | $this->baseModel = null; |
181 | 181 | $currentModel = $baseModel == Scope::getTopScope(); |
182 | - if(!$currentModel && $baseModel) Scope::add($baseModel); |
|
182 | + if (!$currentModel && $baseModel) Scope::add($baseModel); |
|
183 | 183 | require $this->cacheFile; |
184 | - if(!$currentModel && $baseModel) Scope::done(); |
|
184 | + if (!$currentModel && $baseModel) Scope::done(); |
|
185 | 185 | $this->baseModel = $baseModel; |
186 | 186 | $out = ob_get_contents(); |
187 | 187 | ob_end_clean(); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return int The line number being passed by the parser |
199 | 199 | */ |
200 | 200 | static function getLineNo() { |
201 | - if(!isset(self::$me)) |
|
201 | + if (!isset(self::$me)) |
|
202 | 202 | return 0; |
203 | 203 | return self::$me->parse->getLineNo(); |
204 | 204 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | function __construct($message = "", $code = 0, $previous = NULL) { |
34 | 34 | ///@todo Include Line number & file name within parse error exceptions |
35 | - $message .= ", on line " . Hamle\Hamle::getLineNo() . " in file ?.hamle"; |
|
35 | + $message .= ", on line ".Hamle\Hamle::getLineNo()." in file ?.hamle"; |
|
36 | 36 | parent::__construct($message, $code, $previous); |
37 | 37 | } |
38 | 38 |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | //if(strtoupper($this->type) == "A") var_dump($this); |
145 | 145 | $ind = $doIndent ? str_pad("", $indent, " ") : ""; |
146 | 146 | $oneliner = ((count($this->content) > 1 || $this->tags) ? false : true); |
147 | - $out = $ind . $this->renderStTag() . ($oneliner ? "" : "\n"); |
|
147 | + $out = $ind.$this->renderStTag().($oneliner ? "" : "\n"); |
|
148 | 148 | if ($this->content) $out .= $this->renderContent($ind, $oneliner); |
149 | 149 | foreach ($this->tags as $tag) |
150 | 150 | $out .= $tag->render($indent + self::INDENT_SIZE); |
151 | - $out .= ($oneliner ? "" : $ind) . $this->renderEnTag() . "\n"; |
|
151 | + $out .= ($oneliner ? "" : $ind).$this->renderEnTag()."\n"; |
|
152 | 152 | return $out; |
153 | 153 | } |
154 | 154 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | function renderContent($pad = "", $oneliner = false) { |
163 | 163 | $out = ""; |
164 | 164 | foreach ($this->content as $c) |
165 | - $out .= ($oneliner ? "" : $pad) . $c . ($oneliner ? "" : "\n"); |
|
165 | + $out .= ($oneliner ? "" : $pad).$c.($oneliner ? "" : "\n"); |
|
166 | 166 | return $out; |
167 | 167 | } |
168 | 168 |
@@ -112,19 +112,19 @@ discard block |
||
112 | 112 | |
113 | 113 | function getValue() { |
114 | 114 | if (!is_null($this->setValue)) return $this->setValue; |
115 | - if (isset($_REQUEST[$this->form . "_" . $this->name])) { |
|
115 | + if (isset($_REQUEST[$this->form."_".$this->name])) { |
|
116 | 116 | if (get_magic_quotes_runtime()) |
117 | - return stripslashes($_REQUEST[$this->form . "_" . $this->name]); |
|
117 | + return stripslashes($_REQUEST[$this->form."_".$this->name]); |
|
118 | 118 | else |
119 | - return $_REQUEST[$this->form . "_" . $this->name]; |
|
119 | + return $_REQUEST[$this->form."_".$this->name]; |
|
120 | 120 | } |
121 | 121 | return $this->opt['default']; |
122 | 122 | } |
123 | 123 | |
124 | 124 | function getInputAttStatic(&$atts, &$type, &$content) { |
125 | - $atts['id'] = $atts['name'] = $this->form . "_" . $this->name; |
|
125 | + $atts['id'] = $atts['name'] = $this->form."_".$this->name; |
|
126 | 126 | $atts['type'] = "text"; |
127 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
127 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | function getInputAttDynamic(&$atts, &$type, &$content) { |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | function getLabelAttStatic(&$atts, &$type, &$content) { |
145 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
146 | - $atts["for"] = $this->form . "_" . $this->name; |
|
145 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
146 | + $atts["for"] = $this->form."_".$this->name; |
|
147 | 147 | $content = array($this->opt['label']); |
148 | 148 | } |
149 | 149 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | function getHintAttStatic(&$atts, &$type, &$content) { |
154 | - $atts['class'][] = str_replace(['Seufert\\','\\'],['','_'],get_class($this)); |
|
154 | + $atts['class'][] = str_replace(['Seufert\\', '\\'], ['', '_'], get_class($this)); |
|
155 | 155 | $atts['class'][] = "hamleFormHint"; |
156 | 156 | } |
157 | 157 |
@@ -34,6 +34,6 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | function isClicked() { |
37 | - return isset($_REQUEST[$this->form . "_" . $this->name]); |
|
37 | + return isset($_REQUEST[$this->form."_".$this->name]); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | \ No newline at end of file |