@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) |
43 | 43 | { |
44 | - return '/* end template head */ ob_start(); /* template body */ ' . Compiler::PHP_CLOSE; |
|
44 | + return '/* end template head */ ob_start(); /* template body */ '.Compiler::PHP_CLOSE; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -55,6 +55,6 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) |
57 | 57 | { |
58 | - return $content . Compiler::PHP_OPEN . ' /* end template body */' . "\n" . 'return $this->buffer . ob_get_clean();'; |
|
58 | + return $content.Compiler::PHP_OPEN.' /* end template body */'."\n".'return $this->buffer . ob_get_clean();'; |
|
59 | 59 | } |
60 | 60 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | // textarea, pre, code tags and comments are to be left alone to avoid any non-wanted whitespace inside them so it just outputs them as they were |
80 | 80 | if (substr($input[1], 0, 9) == '<textarea' || substr($input[1], 0, 4) == '<pre' || substr($input[1], 0, 5) == '<code' || substr($input[1], 0, 4) == '<!--' || substr($input[1], 0, 9) == '<![CDATA[') { |
81 | - return $input[1] . $input[3]; |
|
81 | + return $input[1].$input[3]; |
|
82 | 82 | } |
83 | 83 | // closing textarea, code and pre tags and self-closed tags (i.e. <br />) are printed as singleTags because we didn't use openTag for the formers and the latter is a single tag |
84 | 84 | if (substr($input[1], 0, 10) == '</textarea' || substr($input[1], 0, 5) == '</pre' || substr($input[1], 0, 6) == '</code' || substr($input[1], - 2) == '/>') { |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected static function openTag($tag, $add, $whitespace) |
106 | 106 | { |
107 | - $tabs = str_pad('', self::$tabCount ++, "\t"); |
|
107 | + $tabs = str_pad('', self::$tabCount++, "\t"); |
|
108 | 108 | |
109 | 109 | if (preg_match('#^<(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)(?: [^>]*|)>#', $tag)) { |
110 | 110 | // if it's one of those tag it's inline so it does not require a leading line break |
111 | - $result = $tag . $whitespace . str_replace("\n", "\n" . $tabs, $add); |
|
111 | + $result = $tag.$whitespace.str_replace("\n", "\n".$tabs, $add); |
|
112 | 112 | } elseif (substr($tag, 0, 9) == '<!DOCTYPE') { |
113 | 113 | // it's the doctype declaration so no line break here either |
114 | - $result = $tabs . $tag; |
|
114 | + $result = $tabs.$tag; |
|
115 | 115 | } else { |
116 | 116 | // normal block tag |
117 | - $result = "\n" . $tabs . $tag; |
|
117 | + $result = "\n".$tabs.$tag; |
|
118 | 118 | |
119 | 119 | if (!empty($add)) { |
120 | - $result .= "\n" . $tabs . "\t" . str_replace("\n", "\n\t" . $tabs, $add); |
|
120 | + $result .= "\n".$tabs."\t".str_replace("\n", "\n\t".$tabs, $add); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | |
142 | 142 | // if it's one of those tag it's inline so it does not require a leading line break |
143 | 143 | if (preg_match('#^</(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)>#', $tag)) { |
144 | - $result = $tag . $whitespace . str_replace("\n", "\n" . $tabs, $add); |
|
144 | + $result = $tag.$whitespace.str_replace("\n", "\n".$tabs, $add); |
|
145 | 145 | } else { |
146 | - $result = "\n" . $tabs . $tag; |
|
146 | + $result = "\n".$tabs.$tag; |
|
147 | 147 | |
148 | 148 | if (!empty($add)) { |
149 | - $result .= "\n" . $tabs . "\t" . str_replace("\n", "\n\t" . $tabs, $add); |
|
149 | + $result .= "\n".$tabs."\t".str_replace("\n", "\n\t".$tabs, $add); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | // if it's img, br it's inline so it does not require a leading line break |
171 | 171 | // if it's a closing textarea, code or pre tag, it does not require a leading line break either or it creates whitespace at the end of those blocks |
172 | 172 | if (preg_match('#^<(img|br|/textarea|/pre|/code)(?: [^>]*|)>#', $tag)) { |
173 | - $result = $tag . $whitespace; |
|
173 | + $result = $tag.$whitespace; |
|
174 | 174 | |
175 | 175 | if (!empty($add)) { |
176 | - $result .= str_replace("\n", "\n" . $tabs, $add); |
|
176 | + $result .= str_replace("\n", "\n".$tabs, $add); |
|
177 | 177 | } |
178 | 178 | } else { |
179 | - $result = "\n" . $tabs . $tag; |
|
179 | + $result = "\n".$tabs.$tag; |
|
180 | 180 | |
181 | 181 | if (!empty($add)) { |
182 | - $result .= "\n" . $tabs . str_replace("\n", "\n" . $tabs, $add); |
|
182 | + $result .= "\n".$tabs.str_replace("\n", "\n".$tabs, $add); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 |
@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function __construct($cacheDir) |
63 | 63 | { |
64 | - $this->corePluginDir = __DIR__ . DIRECTORY_SEPARATOR . 'Plugins'; |
|
65 | - $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
64 | + $this->corePluginDir = __DIR__.DIRECTORY_SEPARATOR.'Plugins'; |
|
65 | + $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
66 | 66 | |
67 | 67 | // include class paths or rebuild paths if the cache file isn't there |
68 | - $cacheFile = $this->cacheDir . 'classpath.cache.d' . Core::RELEASE_TAG . '.php'; |
|
68 | + $cacheFile = $this->cacheDir.'classpath.cache.d'.Core::RELEASE_TAG.'.php'; |
|
69 | 69 | if (file_exists($cacheFile)) { |
70 | 70 | $classpath = file_get_contents($cacheFile); |
71 | - $this->classPath = unserialize($classpath) + $this->classPath; |
|
71 | + $this->classPath = unserialize($classpath)+$this->classPath; |
|
72 | 72 | } else { |
73 | 73 | $this->rebuildClassPathCache($this->corePluginDir, $cacheFile); |
74 | 74 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | // iterates over all files/folders |
93 | - $list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'); |
|
93 | + $list = glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*'); |
|
94 | 94 | if (is_array($list)) { |
95 | 95 | foreach ($list as $f) { |
96 | 96 | if (is_dir($f)) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | // save in file if it's the first call (not recursed) |
119 | 119 | if ($cacheFile !== false) { |
120 | 120 | if (!file_put_contents($cacheFile, serialize($this->classPath))) { |
121 | - throw new Exception('Could not write into ' . $cacheFile . |
|
121 | + throw new Exception('Could not write into '.$cacheFile. |
|
122 | 122 | ', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()'); |
123 | 123 | } |
124 | 124 | $this->classPath += $tmp; |
@@ -144,23 +144,23 @@ discard block |
||
144 | 144 | * so we check for that before trying to include() the plugin. |
145 | 145 | */ |
146 | 146 | if ((!isset($this->classPath[$class]) || !is_readable($this->classPath[$class])) || (!isset |
147 | - ($this->classPath[$class . 'Compile']) || !is_readable($this->classPath[$class . 'Compile']))) { |
|
147 | + ($this->classPath[$class.'Compile']) || !is_readable($this->classPath[$class.'Compile']))) { |
|
148 | 148 | if ($forceRehash) { |
149 | - $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d' . |
|
150 | - Core::RELEASE_TAG . '.php'); |
|
149 | + $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir.'classpath.cache.d'. |
|
150 | + Core::RELEASE_TAG.'.php'); |
|
151 | 151 | foreach ($this->paths as $path => $file) { |
152 | 152 | $this->rebuildClassPathCache($path, $file); |
153 | 153 | } |
154 | 154 | if (isset($this->classPath[$class])) { |
155 | 155 | include_once $this->classPath[$class]; |
156 | - } elseif (isset($this->classPath[$class . 'Compile'])) { |
|
157 | - include_once $this->classPath[$class . 'Compile']; |
|
156 | + } elseif (isset($this->classPath[$class.'Compile'])) { |
|
157 | + include_once $this->classPath[$class.'Compile']; |
|
158 | 158 | } else { |
159 | - throw new Exception('Plugin "' . $class . |
|
159 | + throw new Exception('Plugin "'.$class. |
|
160 | 160 | '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE); |
161 | 161 | } |
162 | 162 | } else { |
163 | - throw new Exception('Plugin "' . $class . |
|
163 | + throw new Exception('Plugin "'.$class. |
|
164 | 164 | '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE); |
165 | 165 | } |
166 | 166 | } |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | { |
184 | 184 | $pluginDir = realpath($pluginDirectory); |
185 | 185 | if (!$pluginDir) { |
186 | - throw new Exception('Plugin directory does not exist or can not be read : ' . $pluginDirectory); |
|
186 | + throw new Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory); |
|
187 | 187 | } |
188 | - $cacheFile = $this->cacheDir . 'classpath-' . substr(strtr($pluginDir, '/\\:' . PATH_SEPARATOR, '----'), |
|
189 | - strlen($pluginDir) > 80 ? - 80 : 0) . '.d' . Core::RELEASE_TAG . '.php'; |
|
188 | + $cacheFile = $this->cacheDir.'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), |
|
189 | + strlen($pluginDir) > 80 ? -80 : 0).'.d'.Core::RELEASE_TAG.'.php'; |
|
190 | 190 | $this->paths[$pluginDir] = $cacheFile; |
191 | 191 | if (file_exists($cacheFile)) { |
192 | 192 | $classpath = file_get_contents($cacheFile); |
193 | - $this->classPath = unserialize($classpath) + $this->classPath; |
|
193 | + $this->classPath = unserialize($classpath)+$this->classPath; |
|
194 | 194 | } else { |
195 | 195 | $this->rebuildClassPathCache($pluginDir, $cacheFile); |
196 | 196 | } |
@@ -290,7 +290,7 @@ |
||
290 | 290 | return call_user_func_array(array($obj, $method), $args); |
291 | 291 | } |
292 | 292 | } |
293 | - $dwoo->triggerError('The current security policy prevents you from calling ' . get_class($obj) . '::' . $method . '()'); |
|
293 | + $dwoo->triggerError('The current security policy prevents you from calling '.get_class($obj).'::'.$method.'()'); |
|
294 | 294 | |
295 | 295 | return null; |
296 | 296 | } |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | $this->cacheTime = $cacheTime; |
73 | 73 | |
74 | 74 | if ($compileId !== null) { |
75 | - $this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;' . PATH_SEPARATOR, '/-------')); |
|
75 | + $this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | if ($cacheId !== null) { |
79 | - $this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;' . PATH_SEPARATOR, '/-------')); |
|
79 | + $this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | if (is_string($includePath)) { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function isValidCompiledFile($file) |
123 | 123 | { |
124 | - return parent::isValidCompiledFile($file) && (int)$this->getUid() <= filemtime($file); |
|
124 | + return parent::isValidCompiledFile($file) && (int) $this->getUid() <= filemtime($file); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | } else { |
160 | 160 | foreach ($this->includePath as $path) { |
161 | 161 | $path = rtrim($path, DIRECTORY_SEPARATOR); |
162 | - if (file_exists($path . DIRECTORY_SEPARATOR . $this->file) === true) { |
|
163 | - $this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file; |
|
162 | + if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) { |
|
163 | + $this->resolvedPath = $path.DIRECTORY_SEPARATOR.$this->file; |
|
164 | 164 | |
165 | 165 | return $this->resolvedPath; |
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | - throw new DwooException('Template "' . $this->file . '" could not be found in any of your include path(s)'); |
|
169 | + throw new DwooException('Template "'.$this->file.'" could not be found in any of your include path(s)'); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getUid() |
180 | 180 | { |
181 | - return (string)filemtime($this->getResourceIdentifier()); |
|
181 | + return (string) filemtime($this->getResourceIdentifier()); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | throw new DwooException('When using an include path you can not reference a template into a parent directory (using ../)'); |
238 | 238 | } |
239 | 239 | } else { |
240 | - $resourceId = dirname($parentTemplate->getResourceIdentifier()) . DIRECTORY_SEPARATOR . $resourceId; |
|
240 | + $resourceId = dirname($parentTemplate->getResourceIdentifier()).DIRECTORY_SEPARATOR.$resourceId; |
|
241 | 241 | if (file_exists($resourceId) === false) { |
242 | 242 | return null; |
243 | 243 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | if ($policy = $core->getSecurityPolicy()) { |
251 | 251 | while (true) { |
252 | 252 | if (preg_match('{^([a-z]+?)://}i', $resourceId)) { |
253 | - throw new SecurityException('The security policy prevents you to read files from external sources : <em>' . $resourceId . '</em>.'); |
|
253 | + throw new SecurityException('The security policy prevents you to read files from external sources : <em>'.$resourceId.'</em>.'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if ($includePath) { |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | break 2; |
265 | 265 | } |
266 | 266 | } |
267 | - throw new SecurityException('The security policy prevents you to read <em>' . $resourceId . '</em>'); |
|
267 | + throw new SecurityException('The security policy prevents you to read <em>'.$resourceId.'</em>'); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $this->compileId = str_replace('../', '__', strtr($this->getResourceIdentifier(), '\\:', '/-')); |
292 | 292 | } |
293 | 293 | |
294 | - return $this->compileId . '.d' . Core::RELEASE_TAG . '.php'; |
|
294 | + return $this->compileId.'.d'.Core::RELEASE_TAG.'.php'; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -302,6 +302,6 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function getIsModifiedCode() |
304 | 304 | { |
305 | - return '"' . $this->getUid() . '" == filemtime(' . var_export($this->getResourceIdentifier(), true) . ')'; |
|
305 | + return '"'.$this->getUid().'" == filemtime('.var_export($this->getResourceIdentifier(), true).')'; |
|
306 | 306 | } |
307 | 307 | } |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | $this->cacheTime = $cacheTime; |
125 | 125 | |
126 | 126 | if ($compileId !== null) { |
127 | - $this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;' . PATH_SEPARATOR, '/-------')); |
|
127 | + $this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if ($cacheId !== null) { |
131 | - $this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;' . PATH_SEPARATOR, '/-------')); |
|
131 | + $this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) { |
277 | 277 | // already checked, return cache file |
278 | 278 | return $cachedFile; |
279 | - } elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === - 1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($core))) { |
|
279 | + } elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === - 1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME']-$cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($core))) { |
|
280 | 280 | // cache is still valid and can be loaded |
281 | 281 | self::$cache['cached'][$this->cacheId] = true; |
282 | 282 | |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | // thanks for his help on avoiding concurency issues |
305 | 305 | $temp = tempnam($cacheDir, 'temp'); |
306 | 306 | if (!($file = @fopen($temp, 'wb'))) { |
307 | - $temp = $cacheDir . uniqid('temp'); |
|
307 | + $temp = $cacheDir.uniqid('temp'); |
|
308 | 308 | if (!($file = @fopen($temp, 'wb'))) { |
309 | - trigger_error('Error writing temporary file \'' . $temp . '\'', E_USER_WARNING); |
|
309 | + trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING); |
|
310 | 310 | |
311 | 311 | return false; |
312 | 312 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | { |
343 | 343 | $cachedFile = $this->getCacheFilename($core); |
344 | 344 | |
345 | - return !file_exists($cachedFile) || (filectime($cachedFile) < (time() - $olderThan) && unlink($cachedFile)); |
|
345 | + return !file_exists($cachedFile) || (filectime($cachedFile) < (time()-$olderThan) && unlink($cachedFile)); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $this->compileId = $this->name; |
450 | 450 | } |
451 | 451 | |
452 | - return $core->getCompileDir() . $this->compileId . '.d' . Core::RELEASE_TAG . '.php'; |
|
452 | + return $core->getCompileDir().$this->compileId.'.d'.Core::RELEASE_TAG.'.php'; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -467,17 +467,17 @@ discard block |
||
467 | 467 | if (isset($_SERVER['REQUEST_URI']) === true) { |
468 | 468 | $cacheId = $_SERVER['REQUEST_URI']; |
469 | 469 | } elseif (isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['argv'])) { |
470 | - $cacheId = $_SERVER['SCRIPT_FILENAME'] . '-' . implode('-', $_SERVER['argv']); |
|
470 | + $cacheId = $_SERVER['SCRIPT_FILENAME'].'-'.implode('-', $_SERVER['argv']); |
|
471 | 471 | } else { |
472 | 472 | $cacheId = ''; |
473 | 473 | } |
474 | 474 | // force compiled id generation |
475 | 475 | $this->getCompiledFilename($core); |
476 | 476 | |
477 | - $this->cacheId = str_replace('../', '__', $this->compileId . strtr($cacheId, '\\%?=!:;' . PATH_SEPARATOR, '/-------')); |
|
477 | + $this->cacheId = str_replace('../', '__', $this->compileId.strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); |
|
478 | 478 | } |
479 | 479 | |
480 | - return $core->getCacheDir() . $this->cacheId . '.html'; |
|
480 | + return $core->getCacheDir().$this->cacheId.'.html'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | } |
515 | 515 | |
516 | 516 | $retries = 3; |
517 | - while ($retries --) { |
|
517 | + while ($retries--) { |
|
518 | 518 | @mkdir($path, $chmod, true); |
519 | 519 | if (is_dir($path)) { |
520 | 520 | break; |
@@ -527,9 +527,9 @@ discard block |
||
527 | 527 | $path = strtr(str_replace($baseDir, '', $path), '\\', '/'); |
528 | 528 | $folders = explode('/', trim($path, '/')); |
529 | 529 | foreach ($folders as $folder) { |
530 | - $baseDir .= $folder . DIRECTORY_SEPARATOR; |
|
530 | + $baseDir .= $folder.DIRECTORY_SEPARATOR; |
|
531 | 531 | if (!chmod($baseDir, $chmod)) { |
532 | - throw new Exception('Unable to chmod ' . "$baseDir to $chmod: " . print_r(error_get_last(), true)); |
|
532 | + throw new Exception('Unable to chmod '."$baseDir to $chmod: ".print_r(error_get_last(), true)); |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | } |