@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | { |
38 | 38 | $debug_backtrace = current(debug_backtrace()); |
39 | 39 | if (PHP_SAPI == 'cli') { |
40 | - echo 'Dump: ' . $debug_backtrace['file'] . ':' . $debug_backtrace['line'] . "\n"; |
|
40 | + echo 'Dump: '.$debug_backtrace['file'].':'.$debug_backtrace['line']."\n"; |
|
41 | 41 | foreach (func_get_args() as $data) { |
42 | 42 | var_dump($data); |
43 | 43 | } |
44 | 44 | } else { |
45 | 45 | ob_clean(); |
46 | - echo '<div>Dump: ' . $debug_backtrace['file'] . ':<b>' . $debug_backtrace['line'] . "</b></div>"; |
|
46 | + echo '<div>Dump: '.$debug_backtrace['file'].':<b>'.$debug_backtrace['line']."</b></div>"; |
|
47 | 47 | echo '<pre>'; |
48 | 48 | foreach (func_get_args() as $data) { |
49 | 49 | echo "<code>"; |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function utf8Convert($array) |
93 | 93 | { |
94 | - array_walk_recursive($array, function(&$item){ |
|
95 | - if(!mb_detect_encoding($item, 'utf-8', true)){ |
|
94 | + array_walk_recursive($array, function(&$item) { |
|
95 | + if (!mb_detect_encoding($item, 'utf-8', true)) { |
|
96 | 96 | $item = utf8_encode($item); |
97 | 97 | } |
98 | 98 | }); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public static function slugify($str, $replace = array(), $delimiter = '-') |
21 | 21 | { |
22 | 22 | if (!empty($replace)) { |
23 | - $str = str_replace((array)$replace, ' ', $str); |
|
23 | + $str = str_replace((array) $replace, ' ', $str); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | $clean = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str); |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | public static function humanFileSize($size, $unit = "") |
80 | 80 | { |
81 | 81 | if ((!$unit && $size >= 1 << 30) || $unit == "GB") |
82 | - return number_format($size / (1 << 30), 2) . "GB"; |
|
82 | + return number_format($size / (1 << 30), 2)."GB"; |
|
83 | 83 | if ((!$unit && $size >= 1 << 20) || $unit == "MB") |
84 | - return number_format($size / (1 << 20), 2) . "MB"; |
|
84 | + return number_format($size / (1 << 20), 2)."MB"; |
|
85 | 85 | if ((!$unit && $size >= 1 << 10) || $unit == "KB") |
86 | - return number_format($size / (1 << 10), 2) . "KB"; |
|
86 | + return number_format($size / (1 << 10), 2)."KB"; |
|
87 | 87 | |
88 | - return number_format($size) . " bytes"; |
|
88 | + return number_format($size)." bytes"; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | if ($d >= 1) { |
122 | 122 | $r = round($d); |
123 | 123 | |
124 | - return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago'; |
|
124 | + return $r.' '.($r > 1 ? $a_plural[$str] : $str).' ago'; |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 |
@@ -10,22 +10,22 @@ |
||
10 | 10 | <div class="show-image"> |
11 | 11 | <label>File</label> |
12 | 12 | <div class="value"> |
13 | - <?=isset($image)? $image->file : '' ?> |
|
13 | + <?=isset($image) ? $image->file : '' ?> |
|
14 | 14 | </div> |
15 | 15 | <label>Type</label> |
16 | 16 | <div class="value"> |
17 | - <?=isset($image)? $image->type : '' ?> |
|
17 | + <?=isset($image) ? $image->type : '' ?> |
|
18 | 18 | </div> |
19 | 19 | <label>Size</label> |
20 | 20 | <div class="value"> |
21 | - <?=isset($image)? \library\cc\StringUtil::humanFileSize($image->size) : '' ?> |
|
21 | + <?=isset($image) ? \library\cc\StringUtil::humanFileSize($image->size) : '' ?> |
|
22 | 22 | </div> |
23 | 23 | <label>Set</label> |
24 | 24 | <? if (isset($image)) : ?> |
25 | 25 | <? foreach ($image->set as $key => $set) : ?> |
26 | 26 | <div class="sets"> |
27 | 27 | <label><?=$key?></label> |
28 | - <img src="<?=\library\cc\Request::$subfolders . 'images/' . $set?>" /> |
|
28 | + <img src="<?=\library\cc\Request::$subfolders.'images/'.$set?>" /> |
|
29 | 29 | </div> |
30 | 30 | <? endforeach ?> |
31 | 31 | <? endif ?> |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | protected function applyFilters($tokens) |
47 | 47 | { |
48 | 48 | foreach ($this->filters as $filterName) { |
49 | - $filterClassName = '\library\search\filters\\' . $filterName; |
|
49 | + $filterClassName = '\library\search\filters\\'.$filterName; |
|
50 | 50 | $filter = new $filterClassName($tokens); |
51 | 51 | $tokens = $filter->getFilterResults(); |
52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | foreach ($documentTermCount as $field => $countArray) { |
67 | 67 | $quotedField = $db->quote($field); |
68 | 68 | foreach ($countArray as $term => $count) { |
69 | - $values[] = $quotedDocumentPath . ', ' . $db->quote($term) . ', ' . $db->quote($count) . ', ' . $quotedField; |
|
69 | + $values[] = $quotedDocumentPath.', '.$db->quote($term).', '.$db->quote($count).', '.$quotedField; |
|
70 | 70 | $i += 1; |
71 | 71 | if ($i >= Indexer::SQLITE_MAX_COMPOUND_SELECT) { |
72 | 72 | $this->executeStoreDocumentTermCount($values, $sql, $db); |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function executeStoreDocumentTermCount($values, $sql, $db) |
92 | 92 | { |
93 | - $sql .= '(' . implode('),' . PHP_EOL . '(', $values) . ');'; |
|
93 | + $sql .= '('.implode('),'.PHP_EOL.'(', $values).');'; |
|
94 | 94 | |
95 | 95 | $stmt = $db->prepare($sql); |
96 | 96 | if ($stmt === false || !$stmt->execute()) { |
97 | 97 | $errorInfo = $db->errorInfo(); |
98 | 98 | $errorMsg = $errorInfo[2]; |
99 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
99 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function getDocuments($state = 'published') |
22 | 22 | { |
23 | 23 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
24 | - throw new \Exception('Unsupported document state: ' . $state); |
|
24 | + throw new \Exception('Unsupported document state: '.$state); |
|
25 | 25 | } |
26 | 26 | return $this->repository->getDocuments($state); |
27 | 27 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | public function getDocumentBySlug($slug, $state = 'published') |
51 | 51 | { |
52 | 52 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
53 | - throw new \Exception('Unsupported document state: ' . $state); |
|
53 | + throw new \Exception('Unsupported document state: '.$state); |
|
54 | 54 | } |
55 | - $path = '/' . $slug; |
|
55 | + $path = '/'.$slug; |
|
56 | 56 | |
57 | 57 | return $this->repository->getDocumentByPath($path, $state); |
58 | 58 | } |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | public function saveDocument($postValues, $state = 'unpublished') |
67 | 67 | { |
68 | 68 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
69 | - throw new \Exception('Unsupported document state: ' . $state); |
|
69 | + throw new \Exception('Unsupported document state: '.$state); |
|
70 | 70 | } |
71 | - $oldPath = '/' . $postValues['path']; |
|
71 | + $oldPath = '/'.$postValues['path']; |
|
72 | 72 | |
73 | 73 | $container = $this->getDocumentContainerByPath($oldPath); |
74 | 74 | $documentObject = DocumentFactory::createDocumentFromPostValues($postValues, new DocumentTypesStorage($this->repository)); |
75 | 75 | if ($container->path === '/') { |
76 | - $newPath = $container->path . $documentObject->slug; |
|
76 | + $newPath = $container->path.$documentObject->slug; |
|
77 | 77 | } else { |
78 | - $newPath = $container->path . '/' . $documentObject->slug; |
|
78 | + $newPath = $container->path.'/'.$documentObject->slug; |
|
79 | 79 | } |
80 | 80 | $documentObject->path = $newPath; |
81 | 81 | $this->repository->saveDocument($documentObject, $state); |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | { |
90 | 90 | $documentObject = DocumentFactory::createDocumentFromPostValues($postValues, new DocumentTypesStorage($this->repository)); |
91 | 91 | if ($postValues['path'] === '/') { |
92 | - $documentObject->path = $postValues['path'] . $documentObject->slug; |
|
92 | + $documentObject->path = $postValues['path'].$documentObject->slug; |
|
93 | 93 | } else { |
94 | - $documentObject->path = $postValues['path'] . '/' . $documentObject->slug; |
|
94 | + $documentObject->path = $postValues['path'].'/'.$documentObject->slug; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $this->repository->saveDocument($documentObject, $state); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function deleteDocumentBySlug($slug) |
104 | 104 | { |
105 | - $path = '/' . $slug; |
|
105 | + $path = '/'.$slug; |
|
106 | 106 | $this->repository->deleteDocumentByPath($path); |
107 | 107 | } |
108 | 108 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | } elseif ($name === 'content') { |
54 | 54 | if ($this->dbHandle === null) { |
55 | - throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')'); |
|
55 | + throw new \Exception('Document doesnt have a dbHandle handle. (path: '.$this->path.')'); |
|
56 | 56 | } else { |
57 | 57 | if ($this->content === null) { |
58 | 58 | return $this->getContent(); |
@@ -87,20 +87,20 @@ discard block |
||
87 | 87 | $docs = $this->documentStorage->getDocumentsWithState($this->path); |
88 | 88 | return $docs; |
89 | 89 | //dump($this->path, $docs); |
90 | - $folderPathWithWildcard = $this->path . '%'; |
|
90 | + $folderPathWithWildcard = $this->path.'%'; |
|
91 | 91 | $sql = ' SELECT * |
92 | 92 | FROM documents_published |
93 | - WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard) . ' |
|
94 | - AND substr(`path`, ' . (strlen($this->path) + 2) . ') NOT LIKE "%/%" |
|
95 | - AND substr(`path`, ' . (strlen($this->path) + 1) . ', 1) = "/" |
|
96 | - AND path != ' . $this->dbHandle->quote($this->path) . ' |
|
97 | - ORDER BY ' . (in_array($orderBy, $this->orderableFields) ? $orderBy : 'title') . ' ' . ($order === 'ASC' ? 'ASC' : 'DESC') . ' |
|
93 | + WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard).' |
|
94 | + AND substr(`path`, ' . (strlen($this->path) + 2).') NOT LIKE "%/%" |
|
95 | + AND substr(`path`, ' . (strlen($this->path) + 1).', 1) = "/" |
|
96 | + AND path != ' . $this->dbHandle->quote($this->path).' |
|
97 | + ORDER BY ' . (in_array($orderBy, $this->orderableFields) ? $orderBy : 'title').' '.($order === 'ASC' ? 'ASC' : 'DESC').' |
|
98 | 98 | '; |
99 | 99 | $stmt = $this->dbHandle->prepare($sql); |
100 | 100 | if ($stmt === false) { |
101 | 101 | $errorInfo = $this->dbHandle->errorInfo(); |
102 | 102 | $errorMsg = $errorInfo[2]; |
103 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
103 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
104 | 104 | } |
105 | 105 | $stmt->bindColumn(':orderBy', $orderBy, \PDO::PARAM_STMT); |
106 | 106 | $stmt->execute(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function __toString() |
122 | 122 | { |
123 | - return 'Document:' . $this->title; |
|
123 | + return 'Document:'.$this->title; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | private function config() |
84 | 84 | { |
85 | - $storagePath = __DIR__ . '/../../' . $this->storageDir; |
|
85 | + $storagePath = __DIR__.'/../../'.$this->storageDir; |
|
86 | 86 | if (realpath($storagePath) === false) { |
87 | 87 | initFramework(); |
88 | 88 | if (Repository::create($storagePath)) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $repository->init(); |
91 | 91 | $this->repository = $repository; |
92 | 92 | } else { |
93 | - throw new \Exception('Could not create repository directory: ' . $storagePath); |
|
93 | + throw new \Exception('Could not create repository directory: '.$storagePath); |
|
94 | 94 | } |
95 | 95 | } else { |
96 | 96 | $this->repository = new Repository($storagePath); |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | { |
134 | 134 | $documentFolderObject = DocumentFolderFactory::createDocumentFolderFromPostValues($postValues); |
135 | 135 | if ($postValues['path'] === '/') { |
136 | - $documentFolderObject->path = $postValues['path'] . $documentFolderObject->slug; |
|
136 | + $documentFolderObject->path = $postValues['path'].$documentFolderObject->slug; |
|
137 | 137 | } else { |
138 | - $documentFolderObject->path = $postValues['path'] . '/' . $documentFolderObject->slug; |
|
138 | + $documentFolderObject->path = $postValues['path'].'/'.$documentFolderObject->slug; |
|
139 | 139 | } |
140 | 140 | $this->repository->saveDocument($documentFolderObject, 'published'); |
141 | 141 | $this->repository->saveDocument($documentFolderObject, 'unpublished'); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function deleteDocumentFolderBySlug($slug) |
152 | 152 | { |
153 | - $path = '/' . $slug; |
|
153 | + $path = '/'.$slug; |
|
154 | 154 | $this->repository->deleteDocumentByPath($path, 'published'); |
155 | 155 | $this->repository->deleteDocumentByPath($path, 'unpublished'); |
156 | 156 | $this->repository->cleanPublishedDeletedDocuments(); |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | |
159 | 159 | public function publishDocumentBySlug($slug) |
160 | 160 | { |
161 | - $path = '/' . $slug; |
|
161 | + $path = '/'.$slug; |
|
162 | 162 | $this->repository->publishDocumentByPath($path); |
163 | 163 | } |
164 | 164 | |
165 | 165 | public function unpublishDocumentBySlug($slug) |
166 | 166 | { |
167 | - $path = '/' . $slug; |
|
167 | + $path = '/'.$slug; |
|
168 | 168 | $this->repository->unpublishDocumentByPath($path); |
169 | 169 | } |
170 | 170 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getDocumentFolderBySlug($slug) |
180 | 180 | { |
181 | - $path = '/' . $slug; |
|
181 | + $path = '/'.$slug; |
|
182 | 182 | |
183 | 183 | return $this->repository->getDocumentByPath($path); |
184 | 184 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $this->storage->getDocuments()->cleanPublishedDeletedDocuments(); |
61 | 61 | $this->addLog('Retrieving documents to be indexed.'); |
62 | 62 | $documents = $this->storage->getDocuments()->getPublishedDocumentsNoFolders(); |
63 | - $this->addLog('Start Document Term Count for ' . count($documents) . ' documents'); |
|
63 | + $this->addLog('Start Document Term Count for '.count($documents).' documents'); |
|
64 | 64 | $this->createDocumentTermCount($documents); |
65 | 65 | $this->addLog('Start Document Term Frequency.'); |
66 | 66 | $this->createDocumentTermFrequency(); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | private function addLog($string) |
162 | 162 | { |
163 | 163 | $currentTime = round(microtime(true) * 1000); |
164 | - $this->log .= date('d-m-Y H:i:s - ') . str_pad($string, 50, " ", STR_PAD_RIGHT) . "\t" . ($currentTime - $this->lastLog) . 'ms since last log. ' . "\t" . ($currentTime - $this->loggingStart) . 'ms since start.' . PHP_EOL; |
|
164 | + $this->log .= date('d-m-Y H:i:s - ').str_pad($string, 50, " ", STR_PAD_RIGHT)."\t".($currentTime - $this->lastLog).'ms since last log. '."\t".($currentTime - $this->loggingStart).'ms since start.'.PHP_EOL; |
|
165 | 165 | $this->lastLog = round(microtime(true) * 1000); |
166 | 166 | } |
167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | protected function getSearchDbHandle() |
174 | 174 | { |
175 | 175 | if ($this->searchDbHandle === null) { |
176 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR; |
|
177 | - $this->searchDbHandle = new \PDO('sqlite:' . $path . self::SEARCH_TEMP_DB); |
|
176 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$this->storageDir.DIRECTORY_SEPARATOR; |
|
177 | + $this->searchDbHandle = new \PDO('sqlite:'.$path.self::SEARCH_TEMP_DB); |
|
178 | 178 | } |
179 | 179 | return $this->searchDbHandle; |
180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | public function replaceOldIndex() |
186 | 186 | { |
187 | 187 | $this->searchDbHandle = null; |
188 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR; |
|
189 | - rename($path . self::SEARCH_TEMP_DB, $path . 'search.db'); |
|
188 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$this->storageDir.DIRECTORY_SEPARATOR; |
|
189 | + rename($path.self::SEARCH_TEMP_DB, $path.'search.db'); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | \ No newline at end of file |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | private function showJson($obj, $httpHeader = 'HTTP/1.0 200 OK') { |
75 | - header($_SERVER['SERVER_PROTOCOL'] . $httpHeader, true); |
|
75 | + header($_SERVER['SERVER_PROTOCOL'].$httpHeader, true); |
|
76 | 76 | header('Content-type: application/json'); |
77 | 77 | die(json_encode($obj)); |
78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | private function stepRouting($step, $cmsComponent, $indexer) |
86 | 86 | { |
87 | - switch($step) { |
|
87 | + switch ($step) { |
|
88 | 88 | case 'resetIndex': $indexer->resetIndex(); break; |
89 | 89 | case 'cleanPublishedDeletedDocuments': $cmsComponent->storage->getDocuments()->cleanPublishedDeletedDocuments(); break; |
90 | 90 | case 'createDocumentTermCount': |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | case 'createTermFieldLengthNorm': $indexer->createTermFieldLengthNorm(); break; |
96 | 96 | case 'createInverseDocumentFrequency': $indexer->createInverseDocumentFrequency(); break; |
97 | 97 | case 'replaceOldIndex': $indexer->replaceOldIndex(); break; |
98 | - default : $this->showJson('Invalid step: ' . $step . '.', 'HTTP/1.0 500 Internal Server Error'); break; |
|
98 | + default : $this->showJson('Invalid step: '.$step.'.', 'HTTP/1.0 500 Internal Server Error'); break; |
|
99 | 99 | } |
100 | 100 | $this->showJson('done'); |
101 | 101 | } |