@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | spl_autoload_extensions('.php'); |
| 3 | 3 | spl_autoload_register("autoloader"); |
| 4 | 4 | |
| 5 | -$rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)) . '/../../') . '/'); |
|
| 5 | +$rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)).'/../../').'/'); |
|
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * The function to be registered as the default autoload functino |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | global $rootPath; |
| 35 | - $file = $rootPath . str_replace('\\', '/', $class) . ".php"; |
|
| 35 | + $file = $rootPath.str_replace('\\', '/', $class).".php"; |
|
| 36 | 36 | $debug_backtrace = debug_backtrace(); |
| 37 | 37 | |
| 38 | 38 | if (file_exists($file)) { |
| 39 | 39 | require_once($file); |
| 40 | 40 | if ($throwException) { |
| 41 | 41 | if (class_exists($class, false) === false && interface_exists($class, false) === false) { |
| 42 | - throw new \Exception('Could not load class "' . $class . '" in file ' . $file); |
|
| 42 | + throw new \Exception('Could not load class "'.$class.'" in file '.$file); |
|
| 43 | 43 | } else { |
| 44 | 44 | return true; |
| 45 | 45 | } |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | } else { |
| 49 | 49 | if (isset($debug_backtrace[2]) && isset($debug_backtrace[2]['file']) && isset($debug_backtrace[2]['line'])) { |
| 50 | 50 | if ($throwException) { |
| 51 | - errorHandler(0, 'Could not load class \'' . $class . '\' in file ' . $rootPath . $file, $debug_backtrace[2]['file'], $debug_backtrace[2]['line']); |
|
| 51 | + errorHandler(0, 'Could not load class \''.$class.'\' in file '.$rootPath.$file, $debug_backtrace[2]['file'], $debug_backtrace[2]['line']); |
|
| 52 | 52 | } else { |
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | } else { |
| 56 | 56 | if ($throwException) { |
| 57 | - throw new \Exception('Could not load class "' . $class . '" in file ' . $file . "\n" . 'Called from unknown origin.'); |
|
| 57 | + throw new \Exception('Could not load class "'.$class.'" in file '.$file."\n".'Called from unknown origin.'); |
|
| 58 | 58 | } else { |
| 59 | 59 | return false; |
| 60 | 60 | } |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | return '0 seconds'; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $a = array( 365 * 24 * 60 * 60 => 'year', |
|
| 41 | + $a = array(365 * 24 * 60 * 60 => 'year', |
|
| 42 | 42 | 30 * 24 * 60 * 60 => 'month', |
| 43 | 43 | 24 * 60 * 60 => 'day', |
| 44 | 44 | 60 * 60 => 'hour', |
| 45 | 45 | 60 => 'minute', |
| 46 | 46 | 1 => 'second' |
| 47 | 47 | ); |
| 48 | - $a_plural = array( 'year' => 'years', |
|
| 48 | + $a_plural = array('year' => 'years', |
|
| 49 | 49 | 'month' => 'months', |
| 50 | 50 | 'day' => 'days', |
| 51 | 51 | 'hour' => 'hours', |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if ($d >= 1) |
| 60 | 60 | { |
| 61 | 61 | $r = round($d); |
| 62 | - return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago'; |
|
| 62 | + return $r.' '.($r > 1 ? $a_plural[$str] : $str).' ago'; |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | return 0; |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | * @param string $unit |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | -function humanFileSize($size,$unit="") { |
|
| 77 | - if( (!$unit && $size >= 1<<30) || $unit == "GB") |
|
| 78 | - return number_format($size/(1<<30),2)."GB"; |
|
| 79 | - if( (!$unit && $size >= 1<<20) || $unit == "MB") |
|
| 80 | - return number_format($size/(1<<20),2)."MB"; |
|
| 81 | - if( (!$unit && $size >= 1<<10) || $unit == "KB") |
|
| 82 | - return number_format($size/(1<<10),2)."KB"; |
|
| 76 | +function humanFileSize($size, $unit = "") { |
|
| 77 | + if ((!$unit && $size >= 1 << 30) || $unit == "GB") |
|
| 78 | + return number_format($size / (1 << 30), 2)."GB"; |
|
| 79 | + if ((!$unit && $size >= 1 << 20) || $unit == "MB") |
|
| 80 | + return number_format($size / (1 << 20), 2)."MB"; |
|
| 81 | + if ((!$unit && $size >= 1 << 10) || $unit == "KB") |
|
| 82 | + return number_format($size / (1 << 10), 2)."KB"; |
|
| 83 | 83 | return number_format($size)." bytes"; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @return mixed|string |
| 135 | 135 | */ |
| 136 | -function slugify($str, $replace=array(), $delimiter='-') { |
|
| 137 | - if( !empty($replace) ) { |
|
| 138 | - $str = str_replace((array)$replace, ' ', $str); |
|
| 136 | +function slugify($str, $replace = array(), $delimiter = '-') { |
|
| 137 | + if (!empty($replace)) { |
|
| 138 | + $str = str_replace((array) $replace, ' ', $str); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $clean = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str); |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $debug_backtrace = current(debug_backtrace()); |
| 160 | 160 | if (PHP_SAPI == 'cli') { |
| 161 | - echo 'Dump: ' . $debug_backtrace['file'] . ':' . $debug_backtrace['line'] . "\n"; |
|
| 161 | + echo 'Dump: '.$debug_backtrace['file'].':'.$debug_backtrace['line']."\n"; |
|
| 162 | 162 | foreach (func_get_args() as $data) { |
| 163 | 163 | var_dump($data); |
| 164 | 164 | } |
| 165 | 165 | } else { |
| 166 | 166 | ob_clean(); |
| 167 | - echo '<div>Dump: ' . $debug_backtrace['file'] . ':<b>' . $debug_backtrace['line'] . "</b></div>"; |
|
| 167 | + echo '<div>Dump: '.$debug_backtrace['file'].':<b>'.$debug_backtrace['line']."</b></div>"; |
|
| 168 | 168 | echo '<pre>'; |
| 169 | 169 | foreach (func_get_args() as $data) { |
| 170 | 170 | echo "<code>"; |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | function utf8Convert($array) |
| 216 | 216 | { |
| 217 | - array_walk_recursive($array, function(&$item, $key){ |
|
| 218 | - if(!mb_detect_encoding($item, 'utf-8', true)){ |
|
| 217 | + array_walk_recursive($array, function(&$item, $key) { |
|
| 218 | + if (!mb_detect_encoding($item, 'utf-8', true)) { |
|
| 219 | 219 | $item = utf8_encode($item); |
| 220 | 220 | } |
| 221 | 221 | }); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | } elseif ($name === 'content') { |
| 41 | 41 | if ($this->dbHandle === null) { |
| 42 | - throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')'); |
|
| 42 | + throw new \Exception('Document doesnt have a dbHandle handle. (path: '.$this->path.')'); |
|
| 43 | 43 | } else { |
| 44 | 44 | if ($this->content === null) { |
| 45 | 45 | $this->getContent(); |
@@ -68,19 +68,19 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | protected function getContent() |
| 70 | 70 | { |
| 71 | - $folderPathWithWildcard = $this->path . '%'; |
|
| 71 | + $folderPathWithWildcard = $this->path.'%'; |
|
| 72 | 72 | $sql = ' SELECT * |
| 73 | 73 | FROM documents |
| 74 | - WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard) . ' |
|
| 75 | - AND substr(`path`, ' . (strlen($this->path) + 2) . ') NOT LIKE "%/%" |
|
| 76 | - AND substr(`path`, ' . (strlen($this->path) + 1) . ', 1) = "/" |
|
| 77 | - AND path != ' . $this->dbHandle->quote($this->path) . ' |
|
| 74 | + WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard).' |
|
| 75 | + AND substr(`path`, ' . (strlen($this->path) + 2).') NOT LIKE "%/%" |
|
| 76 | + AND substr(`path`, ' . (strlen($this->path) + 1).', 1) = "/" |
|
| 77 | + AND path != ' . $this->dbHandle->quote($this->path).' |
|
| 78 | 78 | '; |
| 79 | 79 | $stmt = $this->dbHandle->query($sql); |
| 80 | 80 | if ($stmt === false) { |
| 81 | 81 | $errorInfo = $this->dbHandle->errorInfo(); |
| 82 | 82 | $errorMsg = $errorInfo[2]; |
| 83 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 83 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 84 | 84 | } |
| 85 | 85 | $contents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
| 86 | 86 | foreach ($contents as $key => $document) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | private function config() |
| 38 | 38 | { |
| 39 | - $storagePath = __DIR__ . '/../../' . $this->storageDir; |
|
| 39 | + $storagePath = __DIR__.'/../../'.$this->storageDir; |
|
| 40 | 40 | if (realpath($storagePath) === false) { |
| 41 | 41 | initFramework($storagePath); |
| 42 | 42 | if (Repository::create($storagePath)) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $repository->init(); |
| 45 | 45 | $this->repository = $repository; |
| 46 | 46 | } else { |
| 47 | - throw new \Exception('Could not create repository directory: ' . $storagePath); |
|
| 47 | + throw new \Exception('Could not create repository directory: '.$storagePath); |
|
| 48 | 48 | } |
| 49 | 49 | } else { |
| 50 | 50 | $this->repository = new Repository($storagePath); |
@@ -194,20 +194,20 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function getDocumentBySlug($slug) |
| 196 | 196 | { |
| 197 | - $path = '/' . $slug; |
|
| 197 | + $path = '/'.$slug; |
|
| 198 | 198 | return $this->repository->getDocumentByPath($path); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | public function saveDocument($postValues) |
| 202 | 202 | { |
| 203 | - $oldPath = '/' . $postValues['path']; |
|
| 203 | + $oldPath = '/'.$postValues['path']; |
|
| 204 | 204 | |
| 205 | 205 | $container = $this->getDocumentContainerByPath($oldPath); |
| 206 | 206 | $documentObject = $this->createDocumentFromPostValues($postValues); |
| 207 | 207 | if ($container->path === '/') { |
| 208 | - $newPath = $container->path . $documentObject->slug; |
|
| 208 | + $newPath = $container->path.$documentObject->slug; |
|
| 209 | 209 | } else { |
| 210 | - $newPath = $container->path . '/' . $documentObject->slug; |
|
| 210 | + $newPath = $container->path.'/'.$documentObject->slug; |
|
| 211 | 211 | } |
| 212 | 212 | $documentObject->path = $newPath; |
| 213 | 213 | $this->repository->saveDocument($documentObject); |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | $documentObject = $this->createDocumentFromPostValues($postValues); |
| 219 | 219 | if ($postValues['path'] === '/') { |
| 220 | - $documentObject->path = $postValues['path'] . $documentObject->slug; |
|
| 220 | + $documentObject->path = $postValues['path'].$documentObject->slug; |
|
| 221 | 221 | } else { |
| 222 | - $documentObject->path = $postValues['path'] . '/' . $documentObject->slug; |
|
| 222 | + $documentObject->path = $postValues['path'].'/'.$documentObject->slug; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | $this->repository->saveDocument($documentObject); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | public function deleteDocumentBySlug($slug) |
| 229 | 229 | { |
| 230 | - $path = '/' . $slug; |
|
| 230 | + $path = '/'.$slug; |
|
| 231 | 231 | $this->repository->deleteDocumentByPath($path); |
| 232 | 232 | } |
| 233 | 233 | |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | { |
| 310 | 310 | $documentFolderObject = $this->createDocumentFolderFromPostValues($postValues); |
| 311 | 311 | if ($postValues['path'] === '/') { |
| 312 | - $documentFolderObject->path = $postValues['path'] . $documentFolderObject->slug; |
|
| 312 | + $documentFolderObject->path = $postValues['path'].$documentFolderObject->slug; |
|
| 313 | 313 | } else { |
| 314 | - $documentFolderObject->path = $postValues['path'] . '/' . $documentFolderObject->slug; |
|
| 314 | + $documentFolderObject->path = $postValues['path'].'/'.$documentFolderObject->slug; |
|
| 315 | 315 | } |
| 316 | 316 | $this->repository->saveDocument($documentFolderObject); |
| 317 | 317 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function deleteDocumentFolderBySlug($slug) |
| 327 | 327 | { |
| 328 | - $path = '/' . $slug; |
|
| 328 | + $path = '/'.$slug; |
|
| 329 | 329 | $this->repository->deleteDocumentByPath($path); |
| 330 | 330 | } |
| 331 | 331 | |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | public function getDocumentFolderBySlug($slug) |
| 341 | 341 | { |
| 342 | - $path = '/' . $slug; |
|
| 342 | + $path = '/'.$slug; |
|
| 343 | 343 | return $this->repository->getDocumentByPath($path); |
| 344 | 344 | } |
| 345 | 345 | |
@@ -550,13 +550,13 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | public function addImage($postValues) |
| 552 | 552 | { |
| 553 | - $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
| 553 | + $destinationPath = realpath(__DIR__.'/../../www/images/'); |
|
| 554 | 554 | |
| 555 | 555 | $filename = $this->validateFilename($postValues['name'], $destinationPath); |
| 556 | - $destination = $destinationPath . '/' . $filename; |
|
| 556 | + $destination = $destinationPath.'/'.$filename; |
|
| 557 | 557 | |
| 558 | 558 | if ($postValues['error'] != '0') { |
| 559 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
| 559 | + throw new \Exception('Error uploading file. Error code: '.$postValues['error']); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
@@ -581,14 +581,14 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | public function deleteImageByName($filename) |
| 583 | 583 | { |
| 584 | - $destinationPath = realpath(__DIR__ . '/../../www/images/'); |
|
| 584 | + $destinationPath = realpath(__DIR__.'/../../www/images/'); |
|
| 585 | 585 | |
| 586 | 586 | $images = $this->getImages(); |
| 587 | 587 | |
| 588 | 588 | foreach ($images as $key => $image) { |
| 589 | 589 | if ($image->file == $filename) { |
| 590 | 590 | foreach ($image->set as $imageSetFilename) { |
| 591 | - $destination = $destinationPath . '/' . $imageSetFilename; |
|
| 591 | + $destination = $destinationPath.'/'.$imageSetFilename; |
|
| 592 | 592 | if (file_exists($destination)) { |
| 593 | 593 | unlink($destination); |
| 594 | 594 | } else { |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | */ |
| 631 | 631 | public function getFiles() |
| 632 | 632 | { |
| 633 | - $files = $this->repository->files; |
|
| 633 | + $files = $this->repository->files; |
|
| 634 | 634 | usort($files, array($this, 'compareFiles')); |
| 635 | 635 | return $files; |
| 636 | 636 | } |
@@ -642,13 +642,13 @@ discard block |
||
| 642 | 642 | |
| 643 | 643 | public function addFile($postValues) |
| 644 | 644 | { |
| 645 | - $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
|
| 645 | + $destinationPath = realpath(__DIR__.'/../../www/files/'); |
|
| 646 | 646 | |
| 647 | 647 | $filename = $this->validateFilename($postValues['name'], $destinationPath); |
| 648 | - $destination = $destinationPath . '/' . $filename; |
|
| 648 | + $destination = $destinationPath.'/'.$filename; |
|
| 649 | 649 | |
| 650 | 650 | if ($postValues['error'] != '0') { |
| 651 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
| 651 | + throw new \Exception('Error uploading file. Error code: '.$postValues['error']); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
@@ -674,23 +674,23 @@ discard block |
||
| 674 | 674 | array_pop($fileParts); |
| 675 | 675 | $fileNameWithoutExtension = implode('-', $fileParts); |
| 676 | 676 | $fileNameWithoutExtension = slugify($fileNameWithoutExtension); |
| 677 | - $filename = $fileNameWithoutExtension . '.' . $extension; |
|
| 677 | + $filename = $fileNameWithoutExtension.'.'.$extension; |
|
| 678 | 678 | } else { |
| 679 | 679 | $filename = slugify($filename); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - if (file_exists($path . '/' . $filename)) { |
|
| 682 | + if (file_exists($path.'/'.$filename)) { |
|
| 683 | 683 | $fileParts = explode('.', $filename); |
| 684 | 684 | if (count($fileParts) > 1) { |
| 685 | 685 | $extension = end($fileParts); |
| 686 | 686 | array_pop($fileParts); |
| 687 | 687 | $fileNameWithoutExtension = implode('-', $fileParts); |
| 688 | 688 | $fileNameWithoutExtension .= '-copy'; |
| 689 | - $filename = $fileNameWithoutExtension . '.' . $extension; |
|
| 689 | + $filename = $fileNameWithoutExtension.'.'.$extension; |
|
| 690 | 690 | } else { |
| 691 | 691 | $filename .= '-copy'; |
| 692 | 692 | } |
| 693 | - return $this->validateFilename($filename,$path); |
|
| 693 | + return $this->validateFilename($filename, $path); |
|
| 694 | 694 | } |
| 695 | 695 | return $filename; |
| 696 | 696 | } |
@@ -716,8 +716,8 @@ discard block |
||
| 716 | 716 | */ |
| 717 | 717 | public function deleteFileByName($filename) |
| 718 | 718 | { |
| 719 | - $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
|
| 720 | - $destination = $destinationPath . '/' . $filename; |
|
| 719 | + $destinationPath = realpath(__DIR__.'/../../www/files/'); |
|
| 720 | + $destination = $destinationPath.'/'.$filename; |
|
| 721 | 721 | |
| 722 | 722 | if (file_exists($destination)) { |
| 723 | 723 | $files = $this->getFiles(); |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | if (in_array($name, $this->fileBasedSubsets)) { |
| 104 | 104 | return $this->$name; |
| 105 | 105 | } else { |
| 106 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
| 106 | + throw new \Exception('Trying to get undefined property from Repository: '.$name); |
|
| 107 | 107 | } |
| 108 | 108 | } else { |
| 109 | 109 | if (in_array($name, $this->fileBasedSubsets)) { |
| 110 | 110 | return $this->loadSubset($name); |
| 111 | 111 | } else { |
| 112 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
| 112 | + throw new \Exception('Trying to get undefined property from Repository: '.$name); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | { |
| 125 | 125 | if (in_array($name, $this->fileBasedSubsets)) { |
| 126 | 126 | $this->$name = $value; |
| 127 | - $changes = $name . 'Changes'; |
|
| 127 | + $changes = $name.'Changes'; |
|
| 128 | 128 | $this->$changes = true; |
| 129 | 129 | } else { |
| 130 | - throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>'); |
|
| 130 | + throw new \Exception('Trying to persist unknown subset in repository: '.$name.' <br /><pre>'.print_r($value, true).'</pre>'); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | protected function saveSubset($subset) |
| 154 | 154 | { |
| 155 | 155 | $json = json_encode($this->$subset); |
| 156 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
| 156 | + $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json'; |
|
| 157 | 157 | file_put_contents($subsetStoragePath, $json); |
| 158 | - $changes = $subset . 'Changes'; |
|
| 158 | + $changes = $subset.'Changes'; |
|
| 159 | 159 | $this->$changes = false; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | protected function loadSubset($subset) |
| 168 | 168 | { |
| 169 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
| 169 | + $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json'; |
|
| 170 | 170 | $json = file_get_contents($subsetStoragePath); |
| 171 | 171 | $json = json_decode($json); |
| 172 | 172 | $this->$subset = $json; |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | protected function getContentDbHandle() |
| 215 | 215 | { |
| 216 | 216 | if ($this->contentDbHandle === null) { |
| 217 | - $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db'); |
|
| 217 | + $this->contentDbHandle = new \PDO('sqlite:'.$this->storagePath.DIRECTORY_SEPARATOR.'content.db'); |
|
| 218 | 218 | } |
| 219 | 219 | return $this->contentDbHandle; |
| 220 | 220 | } |
@@ -237,14 +237,14 @@ discard block |
||
| 237 | 237 | public function getDocumentsByPath($folderPath) |
| 238 | 238 | { |
| 239 | 239 | $db = $this->getContentDbHandle(); |
| 240 | - $folderPathWithWildcard = $folderPath . '%'; |
|
| 240 | + $folderPathWithWildcard = $folderPath.'%'; |
|
| 241 | 241 | |
| 242 | 242 | $stmt = $this->getDbStatement(' |
| 243 | 243 | SELECT * |
| 244 | 244 | FROM documents |
| 245 | - WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
| 246 | - AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%" |
|
| 247 | - AND path != ' . $db->quote($folderPath) . ' |
|
| 245 | + WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard).' |
|
| 246 | + AND substr(`path`, ' . (strlen($folderPath) + 1).') NOT LIKE "%/%" |
|
| 247 | + AND path != ' . $db->quote($folderPath).' |
|
| 248 | 248 | ORDER BY `type` DESC, `path` ASC |
| 249 | 249 | '); |
| 250 | 250 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $document = $this->fetchDocument(' |
| 289 | 289 | SELECT * |
| 290 | 290 | FROM documents |
| 291 | - WHERE path = ' . $db->quote($path) . ' |
|
| 291 | + WHERE path = ' . $db->quote($path).' |
|
| 292 | 292 | '); |
| 293 | 293 | if ($document instanceof Document && $document->type === 'folder') { |
| 294 | 294 | $document->dbHandle = $db; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | if ($stmt === false) { |
| 334 | 334 | $errorInfo = $db->errorInfo(); |
| 335 | 335 | $errorMsg = $errorInfo[2]; |
| 336 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 336 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 337 | 337 | } |
| 338 | 338 | return $stmt; |
| 339 | 339 | } |
@@ -363,19 +363,19 @@ discard block |
||
| 363 | 363 | $stmt = $this->getDbStatement(' |
| 364 | 364 | INSERT OR REPLACE INTO documents (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
| 365 | 365 | VALUES( |
| 366 | - ' . $db->quote($documentObject->path) . ', |
|
| 367 | - ' . $db->quote($documentObject->title) . ', |
|
| 368 | - ' . $db->quote($documentObject->slug) . ', |
|
| 369 | - ' . $db->quote($documentObject->type) . ', |
|
| 370 | - ' . $db->quote($documentObject->documentType) . ', |
|
| 371 | - ' . $db->quote($documentObject->documentTypeSlug) . ', |
|
| 372 | - ' . $db->quote($documentObject->state) . ', |
|
| 373 | - ' . $db->quote($documentObject->lastModificationDate) . ', |
|
| 374 | - ' . $db->quote($documentObject->creationDate) . ', |
|
| 375 | - ' . $db->quote($documentObject->lastModifiedBy) . ', |
|
| 376 | - ' . $db->quote(json_encode($documentObject->fields)) . ', |
|
| 377 | - ' . $db->quote(json_encode($documentObject->bricks)) . ', |
|
| 378 | - ' . $db->quote(json_encode($documentObject->dynamicBricks)) . ' |
|
| 366 | + ' . $db->quote($documentObject->path).', |
|
| 367 | + ' . $db->quote($documentObject->title).', |
|
| 368 | + ' . $db->quote($documentObject->slug).', |
|
| 369 | + ' . $db->quote($documentObject->type).', |
|
| 370 | + ' . $db->quote($documentObject->documentType).', |
|
| 371 | + ' . $db->quote($documentObject->documentTypeSlug).', |
|
| 372 | + ' . $db->quote($documentObject->state).', |
|
| 373 | + ' . $db->quote($documentObject->lastModificationDate).', |
|
| 374 | + ' . $db->quote($documentObject->creationDate).', |
|
| 375 | + ' . $db->quote($documentObject->lastModifiedBy).', |
|
| 376 | + ' . $db->quote(json_encode($documentObject->fields)).', |
|
| 377 | + ' . $db->quote(json_encode($documentObject->bricks)).', |
|
| 378 | + ' . $db->quote(json_encode($documentObject->dynamicBricks)).' |
|
| 379 | 379 | ) |
| 380 | 380 | '); |
| 381 | 381 | $result = $stmt->execute(); |
@@ -396,16 +396,16 @@ discard block |
||
| 396 | 396 | if ($documentToDelete->type == 'document') { |
| 397 | 397 | $stmt = $this->getDbStatement(' |
| 398 | 398 | DELETE FROM documents |
| 399 | - WHERE path = ' . $db->quote($path) . ' |
|
| 399 | + WHERE path = ' . $db->quote($path).' |
|
| 400 | 400 | '); |
| 401 | 401 | $stmt->execute(); |
| 402 | 402 | } elseif ($documentToDelete->type == 'folder') { |
| 403 | - $folderPathWithWildcard = $path . '%'; |
|
| 403 | + $folderPathWithWildcard = $path.'%'; |
|
| 404 | 404 | $stmt = $this->getDbStatement(' |
| 405 | 405 | DELETE FROM documents |
| 406 | - WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
| 407 | - AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/") |
|
| 408 | - OR path = ' . $db->quote($path) . ' |
|
| 406 | + WHERE (path LIKE ' . $db->quote($folderPathWithWildcard).' |
|
| 407 | + AND substr(`path`, ' . (strlen($path) + 1).', 1) = "/") |
|
| 408 | + OR path = ' . $db->quote($path).' |
|
| 409 | 409 | '); |
| 410 | 410 | $stmt->execute(); |
| 411 | 411 | } |