@@ -108,6 +108,7 @@ |
||
108 | 108 | * CoreHelper#asyncで使用するコードを返却する |
109 | 109 | * @param string URL |
110 | 110 | * @param string CSSクラス名 |
111 | + * @param string $url |
|
111 | 112 | * @return string コード |
112 | 113 | */ |
113 | 114 | public function asyncHelperCode($url, $id) |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $isProjectRoot = false; |
24 | 24 | |
25 | 25 | while (!$isProjectRoot) { |
26 | - if (file_exists($targetPath . DIRECTORY_SEPARATOR . $this->getProjectFileName())) { |
|
26 | + if (file_exists($targetPath.DIRECTORY_SEPARATOR.$this->getProjectFileName())) { |
|
27 | 27 | $isProjectRoot = true; |
28 | 28 | } else { |
29 | 29 | if (preg_match("/(.*)\//", $targetPath, $matches)) { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if (preg_match("/^namespace\s(.*);$/", $line, $matches)) { |
57 | 57 | $namespace = $matches[1]; |
58 | 58 | if (substr($namespace, 0) !== '\\') { |
59 | - $namespace = '\\' . $namespace; |
|
59 | + $namespace = '\\'.$namespace; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | return $namespace; |
@@ -195,6 +195,7 @@ discard block |
||
195 | 195 | * テンプレートを描画する |
196 | 196 | * @param string テンプレートファイル |
197 | 197 | * @param mixed 展開するパラメータ |
198 | + * @param string $template |
|
198 | 199 | */ |
199 | 200 | private function outputHTML($template, $params) |
200 | 201 | { |
@@ -207,6 +208,7 @@ discard block |
||
207 | 208 | * テンプレート記法を変換する |
208 | 209 | * @param string 変換前出力内容 |
209 | 210 | * @param string mimeType |
211 | + * @param string $content |
|
210 | 212 | * @return bool 変換されたらtrue |
211 | 213 | */ |
212 | 214 | private function replaceTemplateMark(&$content, $mimeType) |
@@ -245,6 +247,7 @@ discard block |
||
245 | 247 | /** |
246 | 248 | * すべてのformタグにCSRF対策トークンを追加する |
247 | 249 | * @param string HTML文字列の参照 |
250 | + * @param string $csrfToken |
|
248 | 251 | */ |
249 | 252 | private function addToken(&$content, $csrfToken) |
250 | 253 | { |
@@ -284,10 +284,10 @@ |
||
284 | 284 | } |
285 | 285 | // 実体参照化をもとに戻す。 |
286 | 286 | $map = array('>' => '>', |
287 | - '<' => '<', |
|
288 | - '%20' => ' ', |
|
289 | - '%24' => '$', |
|
290 | - '%5C' => '\\'); |
|
287 | + '<' => '<', |
|
288 | + '%20' => ' ', |
|
289 | + '%24' => '$', |
|
290 | + '%5C' => '\\'); |
|
291 | 291 | |
292 | 292 | // HTMLタグを補完する |
293 | 293 | $content = <<< HTML |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function __construct(Container $container) |
56 | 56 | { |
57 | 57 | $this->container = $container; |
58 | - $this->session = $container->session; |
|
58 | + $this->session = $container->session; |
|
59 | 59 | $this->timestamp = 0; |
60 | 60 | $this->logger = $container->logger; |
61 | 61 | } |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | $params = ["model" => $params["model"], "helper" => $params["helper"]]; |
70 | 70 | $dirname = $this->camel2snake($this->container->router->pageName); |
71 | 71 | |
72 | - $filepath = $this->container->applicationInfo->applicationRoot . "/app/views/" . $dirname . "/" . $this->container->filename; |
|
73 | - $sharedpath = $this->container->applicationInfo->applicationRoot . "/app/views/" . $this->container->applicationInfo->sharedDir . "/" . $this->container->filename; |
|
72 | + $filepath = $this->container->applicationInfo->applicationRoot."/app/views/".$dirname."/".$this->container->filename; |
|
73 | + $sharedpath = $this->container->applicationInfo->applicationRoot."/app/views/".$this->container->applicationInfo->sharedDir."/".$this->container->filename; |
|
74 | 74 | |
75 | 75 | $realpath = realpath($filepath) ?: realpath($sharedpath); |
76 | 76 | |
77 | 77 | if ($realpath === false) { |
78 | - throw new ResourceNotFoundException("Invalid template file path: " . safetyOut($filepath)); |
|
78 | + throw new ResourceNotFoundException("Invalid template file path: ".safetyOut($filepath)); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // テンプレートファイルの最新の変更日時を取得 |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | $this->replaceTemplateMark($content, $mimeType); |
90 | 90 | |
91 | 91 | // テンプレートファイルをコンパイルし一時ファイルを作成 |
92 | - $temp = $this->getTemporaryDirectory() . "/" . $this->getRandomstring(30); |
|
92 | + $temp = $this->getTemporaryDirectory()."/".$this->getRandomstring(30); |
|
93 | 93 | $fileSize = file_put_contents($temp, $content, LOCK_EX); |
94 | 94 | if ($fileSize === false) { |
95 | - throw new IOException("File write failure: " . $temp); |
|
95 | + throw new IOException("File write failure: ".$temp); |
|
96 | 96 | } else { |
97 | - $this->logger->debug("Write temporary template file: " . $temp); |
|
98 | - $this->logger->debug("Compiled template file size: " . $fileSize); |
|
97 | + $this->logger->debug("Write temporary template file: ".$temp); |
|
98 | + $this->logger->debug("Compiled template file size: ".$fileSize); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | $params["__params__"] = $params; |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | // CSRFチェックが実行される前に非同期でリクエストがあった場合を考慮して |
127 | 127 | // CSRFトークンは削除しない |
128 | 128 | if (preg_match('/<form.*?>.*?<\/form>/is', $content)) { |
129 | - $csrfToken = sha1($this->session->id() . microtime()); |
|
129 | + $csrfToken = sha1($this->session->id().microtime()); |
|
130 | 130 | $this->session->set($this->getCsrfTokenKey(), $csrfToken); |
131 | 131 | $this->addToken($content, $csrfToken); |
132 | 132 | } |
133 | 133 | |
134 | 134 | // テンプレートファイルをコンパイルし一時ファイルを作成 |
135 | - $temp = $this->getTemporaryDirectory() . "/" . $this->getRandomstring(30); |
|
135 | + $temp = $this->getTemporaryDirectory()."/".$this->getRandomstring(30); |
|
136 | 136 | $fileSize = file_put_contents($temp, $content, LOCK_EX); |
137 | 137 | if ($fileSize === false) { |
138 | - throw new IOException("File write failure: " . $temp); |
|
138 | + throw new IOException("File write failure: ".$temp); |
|
139 | 139 | } else { |
140 | - $this->logger->debug("Write temporary template file: " . $temp); |
|
141 | - $this->logger->debug("Compiled template file size: " . $fileSize); |
|
140 | + $this->logger->debug("Write temporary template file: ".$temp); |
|
141 | + $this->logger->debug("Compiled template file size: ".$fileSize); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $params["__params__"] = $params; |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function cache($filename, $data, $expire) |
180 | 180 | { |
181 | - $cacheDir = $this->container->applicationInfo->applicationRoot . "/app/views/" . $this->container->applicationInfo->cacheDir; |
|
181 | + $cacheDir = $this->container->applicationInfo->applicationRoot."/app/views/".$this->container->applicationInfo->cacheDir; |
|
182 | 182 | $cache = new Cache($cacheDir); |
183 | 183 | $cache->inject('logger', $this->logger); |
184 | - $filepath = $cacheDir . "/" . $filename . ".cache"; |
|
184 | + $filepath = $cacheDir."/".$filename.".cache"; |
|
185 | 185 | if (!file_exists($filepath) || $this->timestamp > filemtime($filepath)) { |
186 | 186 | if ($cache->save($filename, $data, $expire)) { |
187 | - $this->logger->debug("Write template cache file: " . $filepath); |
|
187 | + $this->logger->debug("Write template cache file: ".$filepath); |
|
188 | 188 | } else { |
189 | - throw new IOException("File write failure: " . $filepath); |
|
189 | + throw new IOException("File write failure: ".$filepath); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
@@ -213,23 +213,23 @@ discard block |
||
213 | 213 | { |
214 | 214 | $originContentHash = md5($content); |
215 | 215 | |
216 | - $content = preg_replace_callback('/(%.{\$' . $this->getHelperVariableName() . '\->async\(.+?\)})/', function ($matches) { |
|
216 | + $content = preg_replace_callback('/(%.{\$'.$this->getHelperVariableName().'\->async\(.+?\)})/', function($matches) { |
|
217 | 217 | $asyncId = $this->getAsyncDomId(); |
218 | - $context = preg_replace_callback('/\$' . $this->getHelperVariableName() . '->async\((.+?)\)/', function ($matches2) use ($asyncId) { |
|
219 | - return '$' . $this->getHelperVariableName() . '->async(' . $matches2[1] . ',\'' . $asyncId . '\')'; |
|
218 | + $context = preg_replace_callback('/\$'.$this->getHelperVariableName().'->async\((.+?)\)/', function($matches2) use ($asyncId) { |
|
219 | + return '$'.$this->getHelperVariableName().'->async('.$matches2[1].',\''.$asyncId.'\')'; |
|
220 | 220 | }, $matches[1]); |
221 | 221 | |
222 | 222 | return "<div id='$asyncId'>$context</div>"; |
223 | 223 | }, $content); |
224 | 224 | |
225 | - $content = preg_replace('/' . self::TEMPLATE_MARK_PHP . '\{(.*?)\}/', '<?php echo $1; ?>', $content); |
|
226 | - $content = preg_replace('/' . self::TEMPLATE_MARK_TEMPLATE . '\{(.*?)\}/', '<?php $this->draw("$1", $__params__, $__mimeType__); ?>', $content); |
|
225 | + $content = preg_replace('/'.self::TEMPLATE_MARK_PHP.'\{(.*?)\}/', '<?php echo $1; ?>', $content); |
|
226 | + $content = preg_replace('/'.self::TEMPLATE_MARK_TEMPLATE.'\{(.*?)\}/', '<?php $this->draw("$1", $__params__, $__mimeType__); ?>', $content); |
|
227 | 227 | |
228 | 228 | if ($mimeType === "xml") { |
229 | - $content = preg_replace('/' . self::TEMPLATE_MARK_XML . '\{(.*?)\}/', '<?php echo safetyOutXML($1); ?>', $content); |
|
229 | + $content = preg_replace('/'.self::TEMPLATE_MARK_XML.'\{(.*?)\}/', '<?php echo safetyOutXML($1); ?>', $content); |
|
230 | 230 | } elseif ($mimeType === "html") { |
231 | - $content = preg_replace('/' . self::TEMPLATE_MARK_HTML . '\{(.*?)\}/', '<?php echo safetyOut($1); ?>', $content); |
|
232 | - $content = preg_replace('/' . self::TEMPLATE_MARK_JAVASCRIPT . '\{(.*?)\}/', '<?php echo safetyOutJavaScript($1); ?>', $content); |
|
231 | + $content = preg_replace('/'.self::TEMPLATE_MARK_HTML.'\{(.*?)\}/', '<?php echo safetyOut($1); ?>', $content); |
|
232 | + $content = preg_replace('/'.self::TEMPLATE_MARK_JAVASCRIPT.'\{(.*?)\}/', '<?php echo safetyOutJavaScript($1); ?>', $content); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | $replacedContentHash = md5($content); |
@@ -96,8 +96,8 @@ |
||
96 | 96 | public function async($path, $id) |
97 | 97 | { |
98 | 98 | $safetyPath = str_replace('\\', '', $this->encodeJavaScript($path)); |
99 | - $url = "//" . $this->container->request->server("HTTP_HOST") . $this->container->request->getBaseURL() . $safetyPath; |
|
99 | + $url = "//".$this->container->request->server("HTTP_HOST").$this->container->request->getBaseURL().$safetyPath; |
|
100 | 100 | |
101 | - return "<script type='text/javascript'>" . $this->asyncHelperCode($url, $id) . "</script>"; |
|
101 | + return "<script type='text/javascript'>".$this->asyncHelperCode($url, $id)."</script>"; |
|
102 | 102 | } |
103 | 103 | } |
@@ -120,11 +120,11 @@ |
||
120 | 120 | final public function __file($filepath) |
121 | 121 | { |
122 | 122 | $publicDir = $this->container->applicationInfo->publicDir; |
123 | - if (preg_match('/\/views\/' . $publicDir . '\/img\/.+\.(?:jp(?:e|)g|png|bmp|(?:tif|gi)f)$/i', $filepath) || |
|
124 | - preg_match('/\/views\/' . $publicDir . '\/css\/.+\.css$/i', $filepath) || |
|
125 | - preg_match('/\/views\/' . $publicDir . '\/js\/.+\.js$/i', $filepath)) { // 画像,css,jsの場合 |
|
123 | + if (preg_match('/\/views\/'.$publicDir.'\/img\/.+\.(?:jp(?:e|)g|png|bmp|(?:tif|gi)f)$/i', $filepath) || |
|
124 | + preg_match('/\/views\/'.$publicDir.'\/css\/.+\.css$/i', $filepath) || |
|
125 | + preg_match('/\/views\/'.$publicDir.'\/js\/.+\.js$/i', $filepath)) { // 画像,css,jsの場合 |
|
126 | 126 | $this->display($filepath); |
127 | - } elseif (preg_match('/\/views\/' . $publicDir . '\/file\/.+$/i', $filepath)) { // それ以外のファイル |
|
127 | + } elseif (preg_match('/\/views\/'.$publicDir.'\/file\/.+$/i', $filepath)) { // それ以外のファイル |
|
128 | 128 | $this->download($filepath); |
129 | 129 | } else { // 全てのファイル |
130 | 130 | $this->display($filepath); |
@@ -89,7 +89,7 @@ |
||
89 | 89 | if (array_key_exists($offset, $this->rowCache)) { |
90 | 90 | return $this->rowCache[$offset]; |
91 | 91 | } else { |
92 | - throw new \OutOfBoundsException("Current cursor is out of range: " . $offset); |
|
92 | + throw new \OutOfBoundsException("Current cursor is out of range: ".$offset); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -91,7 +91,7 @@ |
||
91 | 91 | if (array_key_exists($col, $propertyMap)) { |
92 | 92 | $propertyMap[$col]->setValue($instance, $value); |
93 | 93 | } else { |
94 | - $this->logger->error("Column '$col' is failed mapping in " . $this->classpath); |
|
94 | + $this->logger->error("Column '$col' is failed mapping in ".$this->classpath); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 |
@@ -29,6 +29,6 @@ |
||
29 | 29 | |
30 | 30 | $config = new Configuration([\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]); |
31 | 31 | $this->connection = DriverManager::getConnection($params, $config); |
32 | - $this->logger->debug(get_class($this) . " connect."); |
|
32 | + $this->logger->debug(get_class($this)." connect."); |
|
33 | 33 | } |
34 | 34 | } |
@@ -35,6 +35,6 @@ |
||
35 | 35 | ]); |
36 | 36 | |
37 | 37 | $this->connection = DriverManager::getConnection($params, $config); |
38 | - $this->logger->debug(get_class($this) . " connect."); |
|
38 | + $this->logger->debug(get_class($this)." connect."); |
|
39 | 39 | } |
40 | 40 | } |
@@ -31,6 +31,6 @@ |
||
31 | 31 | ]); |
32 | 32 | |
33 | 33 | $this->connection = DriverManager::getConnection($params, $config); |
34 | - $this->logger->debug(get_class($this) . " connect."); |
|
34 | + $this->logger->debug(get_class($this)." connect."); |
|
35 | 35 | } |
36 | 36 | } |