@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | } else { |
| 46 | 46 | $configMap = $this->parseConfig($config); |
| 47 | 47 | if ($configMap === null) { |
| 48 | - throw new LoggerException("Log config file does not exist: " . $config); |
|
| 48 | + throw new LoggerException("Log config file does not exist: ".$config); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | $this->ioContainer = new Container(); |
| 54 | 54 | |
| 55 | 55 | $rootDir = $this->getApplicationRoot(); |
| 56 | - $this->ioContainer->file = function () use ($rootDir, $configMap) { |
|
| 56 | + $this->ioContainer->file = function() use ($rootDir, $configMap) { |
|
| 57 | 57 | if (!array_key_exists("path", $configMap)) { |
| 58 | 58 | throw new LoggerException("Log path must be defined."); |
| 59 | 59 | } |
| 60 | - return new File($rootDir . "/" . $configMap["path"]); |
|
| 60 | + return new File($rootDir."/".$configMap["path"]); |
|
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | 63 | $this->configMap = $configMap; |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $file = $this->ioContainer->file; |
| 112 | 112 | if (!($file->exists() && $file->isFile())) { |
| 113 | - throw new LoggerException("Log directory does not exist: " . $file->getFilePath()); |
|
| 113 | + throw new LoggerException("Log directory does not exist: ".$file->getFilePath()); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $this->logContainer->logPath = $file->getFilePath(); |
| 117 | - $this->logContainer->statusPath = preg_replace_callback('/(.*)\..+/', function ($matches) { |
|
| 117 | + $this->logContainer->statusPath = preg_replace_callback('/(.*)\..+/', function($matches) { |
|
| 118 | 118 | return "$matches[1].status"; |
| 119 | 119 | }, $this->logContainer->logPath); |
| 120 | 120 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $rotateSize = intval($this->configMap["rotate_size"]); |
| 145 | 145 | // ローテートサイズが不正の場合(正の整数以外の値が設定された場合) |
| 146 | 146 | if ($rotateSize <= 0) { |
| 147 | - throw new LoggerException("Invalid log rotate size: " . $this->configMap["rotate_size"]); |
|
| 147 | + throw new LoggerException("Invalid log rotate size: ".$this->configMap["rotate_size"]); |
|
| 148 | 148 | } |
| 149 | 149 | $this->logContainer->rotateSize = $rotateSize; |
| 150 | 150 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | case 'year': |
| 207 | 207 | return $year_to_h; |
| 208 | 208 | default: |
| 209 | - throw new LoggerException("Invalid log rotate cycle: " . $cycle); |
|
| 209 | + throw new LoggerException("Invalid log rotate cycle: ".$cycle); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | public function __construct(Container $container) |
| 59 | 59 | { |
| 60 | 60 | $this->container = $container; |
| 61 | - $this->session = $container->session; |
|
| 61 | + $this->session = $container->session; |
|
| 62 | 62 | $this->timestamp = 0; |
| 63 | 63 | $this->logger = $container->logger; |
| 64 | 64 | } |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | $params = ["model" => $params["model"], "helper" => $params["helper"]]; |
| 73 | 73 | $dirname = $this->camel2snake($this->container->router->pageName); |
| 74 | 74 | |
| 75 | - $templateFile = new File($this->container->applicationInfo->applicationRoot . "/app/views/" . $dirname . "/" . $this->container->filename); |
|
| 76 | - $sharedFile = new File($this->container->applicationInfo->applicationRoot . "/app/views/" . $this->container->applicationInfo->sharedDir . "/" . $this->container->filename); |
|
| 75 | + $templateFile = new File($this->container->applicationInfo->applicationRoot."/app/views/".$dirname."/".$this->container->filename); |
|
| 76 | + $sharedFile = new File($this->container->applicationInfo->applicationRoot."/app/views/".$this->container->applicationInfo->sharedDir."/".$this->container->filename); |
|
| 77 | 77 | |
| 78 | 78 | $file = $templateFile->exists() ? $templateFile : ($sharedFile->exists() ? $sharedFile : null); |
| 79 | 79 | if ($file === null) { |
| 80 | - $errorMessage = "Invalid template file path: " . $templateFile->getFilePath() . " or " . $sharedFile->getFilePath(); |
|
| 80 | + $errorMessage = "Invalid template file path: ".$templateFile->getFilePath()." or ".$sharedFile->getFilePath(); |
|
| 81 | 81 | throw new ResourceNotFoundException($errorMessage); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | $this->replaceTemplateMark($content, $mimeType); |
| 94 | 94 | |
| 95 | 95 | // テンプレートファイルをコンパイルし一時ファイルを作成 |
| 96 | - $tmpFile = new File($this->getTemporaryDirectory() . "/" . $this->getRandomstring(30)); |
|
| 96 | + $tmpFile = new File($this->getTemporaryDirectory()."/".$this->getRandomstring(30)); |
|
| 97 | 97 | $writer = new FileWriter($tmpFile); |
| 98 | 98 | $writer->write($content); |
| 99 | 99 | $writer->close(); |
| 100 | - $this->logger->debug("Write temporary template file: " . $tmpFile->getFilePath()); |
|
| 101 | - $this->logger->debug("Compiled template file size: " . $tmpFile->size()); |
|
| 100 | + $this->logger->debug("Write temporary template file: ".$tmpFile->getFilePath()); |
|
| 101 | + $this->logger->debug("Compiled template file size: ".$tmpFile->size()); |
|
| 102 | 102 | |
| 103 | 103 | $params["__params__"] = $params; |
| 104 | 104 | $params["__mimeType__"] = $mimeType; |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | // CSRFチェックが実行される前に非同期でリクエストがあった場合を考慮して |
| 129 | 129 | // CSRFトークンは削除しない |
| 130 | 130 | if (preg_match('/<form.*?>.*?<\/form>/is', $content)) { |
| 131 | - $csrfToken = sha1($this->session->id() . microtime()); |
|
| 131 | + $csrfToken = sha1($this->session->id().microtime()); |
|
| 132 | 132 | $this->session->set($this->getCsrfTokenKey(), $csrfToken); |
| 133 | 133 | $this->addToken($content, $csrfToken); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // テンプレートファイルをコンパイルし一時ファイルを作成 |
| 137 | - $tmpFile = new File($this->getTemporaryDirectory() . "/" . $this->getRandomstring(30)); |
|
| 137 | + $tmpFile = new File($this->getTemporaryDirectory()."/".$this->getRandomstring(30)); |
|
| 138 | 138 | $writer = new FileWriter($tmpFile); |
| 139 | 139 | $writer->write($content); |
| 140 | 140 | $writer->close(); |
| 141 | - $this->logger->debug("Write temporary template file: " . $tmpFile->getFilePath()); |
|
| 142 | - $this->logger->debug("Compiled template file size: " . $tmpFile->size()); |
|
| 141 | + $this->logger->debug("Write temporary template file: ".$tmpFile->getFilePath()); |
|
| 142 | + $this->logger->debug("Compiled template file size: ".$tmpFile->size()); |
|
| 143 | 143 | |
| 144 | 144 | $params["__params__"] = $params; |
| 145 | 145 | $params["__mimeType__"] = $mimeType; |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function cache($filename, $data, $expire) |
| 181 | 181 | { |
| 182 | - $cacheDir = $this->container->applicationInfo->applicationRoot . "/app/views/" . $this->container->applicationInfo->cacheDir; |
|
| 182 | + $cacheDir = $this->container->applicationInfo->applicationRoot."/app/views/".$this->container->applicationInfo->cacheDir; |
|
| 183 | 183 | $cache = new Cache($cacheDir); |
| 184 | 184 | $cache->inject('logger', $this->logger); |
| 185 | - $file = new File($cacheDir . "/" . $filename . ".cache"); |
|
| 185 | + $file = new File($cacheDir."/".$filename.".cache"); |
|
| 186 | 186 | if (!$file->exists() || $this->timestamp > $file->lastModified()) { |
| 187 | 187 | if ($cache->save($filename, $data, $expire)) { |
| 188 | - $this->logger->debug("Write template cache file: " . $file->getFilePath()); |
|
| 188 | + $this->logger->debug("Write template cache file: ".$file->getFilePath()); |
|
| 189 | 189 | } else { |
| 190 | - throw new IOException("File write failure: " . $file->getFilePath()); |
|
| 190 | + throw new IOException("File write failure: ".$file->getFilePath()); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -214,23 +214,23 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | $originContentHash = md5($content); |
| 216 | 216 | |
| 217 | - $content = preg_replace_callback('/(%.{\$' . $this->getHelperVariableName() . '\->async\(.+?\)})/', function ($matches) { |
|
| 217 | + $content = preg_replace_callback('/(%.{\$'.$this->getHelperVariableName().'\->async\(.+?\)})/', function($matches) { |
|
| 218 | 218 | $asyncId = $this->getAsyncDomId(); |
| 219 | - $context = preg_replace_callback('/\$' . $this->getHelperVariableName() . '->async\((.+?)\)/', function ($matches2) use ($asyncId) { |
|
| 220 | - return '$' . $this->getHelperVariableName() . '->async(' . $matches2[1] . ',\'' . $asyncId . '\')'; |
|
| 219 | + $context = preg_replace_callback('/\$'.$this->getHelperVariableName().'->async\((.+?)\)/', function($matches2) use ($asyncId) { |
|
| 220 | + return '$'.$this->getHelperVariableName().'->async('.$matches2[1].',\''.$asyncId.'\')'; |
|
| 221 | 221 | }, $matches[1]); |
| 222 | 222 | |
| 223 | 223 | return "<div id='$asyncId'>$context</div>"; |
| 224 | 224 | }, $content); |
| 225 | 225 | |
| 226 | - $content = preg_replace('/' . self::TEMPLATE_MARK_PHP . '\{(.*?)\}/', '<?php echo $1; ?>', $content); |
|
| 227 | - $content = preg_replace('/' . self::TEMPLATE_MARK_TEMPLATE . '\{(.*?)\}/', '<?php $this->draw("$1", $__params__, $__mimeType__); ?>', $content); |
|
| 226 | + $content = preg_replace('/'.self::TEMPLATE_MARK_PHP.'\{(.*?)\}/', '<?php echo $1; ?>', $content); |
|
| 227 | + $content = preg_replace('/'.self::TEMPLATE_MARK_TEMPLATE.'\{(.*?)\}/', '<?php $this->draw("$1", $__params__, $__mimeType__); ?>', $content); |
|
| 228 | 228 | |
| 229 | 229 | if ($mimeType === "xml") { |
| 230 | - $content = preg_replace('/' . self::TEMPLATE_MARK_XML . '\{(.*?)\}/', '<?php echo safetyOutXML($1); ?>', $content); |
|
| 230 | + $content = preg_replace('/'.self::TEMPLATE_MARK_XML.'\{(.*?)\}/', '<?php echo safetyOutXML($1); ?>', $content); |
|
| 231 | 231 | } elseif ($mimeType === "html") { |
| 232 | - $content = preg_replace('/' . self::TEMPLATE_MARK_HTML . '\{(.*?)\}/', '<?php echo safetyOut($1); ?>', $content); |
|
| 233 | - $content = preg_replace('/' . self::TEMPLATE_MARK_JAVASCRIPT . '\{(.*?)\}/', '<?php echo safetyOutJavaScript($1); ?>', $content); |
|
| 232 | + $content = preg_replace('/'.self::TEMPLATE_MARK_HTML.'\{(.*?)\}/', '<?php echo safetyOut($1); ?>', $content); |
|
| 233 | + $content = preg_replace('/'.self::TEMPLATE_MARK_JAVASCRIPT.'\{(.*?)\}/', '<?php echo safetyOutJavaScript($1); ?>', $content); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | $replacedContentHash = md5($content); |