@@ -109,8 +109,8 @@ |
||
| 109 | 109 | |
| 110 | 110 | // Preserve transparency |
| 111 | 111 | imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127)); |
| 112 | - imagealphablending($new, false); |
|
| 113 | - imagesavealpha($new, true); |
|
| 112 | + imagealphablending($new, false); |
|
| 113 | + imagesavealpha($new, true); |
|
| 114 | 114 | |
| 115 | 115 | imagecopyresampled($new, $imageResource, $this->_destX, $this->_destY, $this->_x, $this->_y, $this->_destWidth, $this->_destHeight, $this->_destWidth, $this->_destHeight); |
| 116 | 116 | |
@@ -62,8 +62,8 @@ |
||
| 62 | 62 | |
| 63 | 63 | // Preserve transparency |
| 64 | 64 | imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127)); |
| 65 | - imagealphablending($new, false); |
|
| 66 | - imagesavealpha($new, true); |
|
| 65 | + imagealphablending($new, false); |
|
| 66 | + imagesavealpha($new, true); |
|
| 67 | 67 | |
| 68 | 68 | imagecopyresampled($new, $imageResource, $this->_destX, $this->_destY, $this->_x, $this->_y, $this->_destWidth, $this->_destHeight, $originalWidth, $originalHeight); |
| 69 | 69 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @param resource $imageResource |
| 19 | 19 | * @return resource |
| 20 | - */ |
|
| 20 | + */ |
|
| 21 | 21 | public function Execute($imageResource) |
| 22 | 22 | { |
| 23 | 23 | // Define the origial width and height |
@@ -14,24 +14,24 @@ |
||
| 14 | 14 | class SitemapRouting implements CmsRouting |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * SitemapRouting constructor. |
|
| 19 | - * @param \library\cc\Request $request |
|
| 20 | - * @param mixed|string $relativeCmsUri |
|
| 21 | - * @param CmsComponent $cmsComponent |
|
| 22 | - */ |
|
| 23 | - public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 24 | - { |
|
| 25 | - if ($relativeCmsUri == '/sitemap') { |
|
| 17 | + /** |
|
| 18 | + * SitemapRouting constructor. |
|
| 19 | + * @param \library\cc\Request $request |
|
| 20 | + * @param mixed|string $relativeCmsUri |
|
| 21 | + * @param CmsComponent $cmsComponent |
|
| 22 | + */ |
|
| 23 | + public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 24 | + { |
|
| 25 | + if ($relativeCmsUri == '/sitemap') { |
|
| 26 | 26 | $this->overviewRoute($request, $cmsComponent); |
| 27 | - } elseif ($relativeCmsUri == '/sitemap/new') { |
|
| 27 | + } elseif ($relativeCmsUri == '/sitemap/new') { |
|
| 28 | 28 | $this->newRoute($request, $cmsComponent); |
| 29 | - } elseif ($relativeCmsUri == '/sitemap/edit' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 29 | + } elseif ($relativeCmsUri == '/sitemap/edit' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 30 | 30 | $this->editRoute($request, $cmsComponent); |
| 31 | - } elseif ($relativeCmsUri == '/sitemap/delete' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 31 | + } elseif ($relativeCmsUri == '/sitemap/delete' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 32 | 32 | $this->deleteRoute($request, $cmsComponent); |
| 33 | - } |
|
| 34 | - } |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @param $request |
@@ -6,124 +6,124 @@ |
||
| 6 | 6 | |
| 7 | 7 | class LanguageComponent implements Component |
| 8 | 8 | { |
| 9 | - protected $request; |
|
| 10 | - protected $parameters; |
|
| 11 | - |
|
| 12 | - protected $defaultLanguage = 'en'; |
|
| 13 | - protected $acceptedLanguages = null; |
|
| 14 | - protected $languageParameterName = 'language'; |
|
| 15 | - protected $forceRedirect = false; |
|
| 16 | - protected $sessionValues; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * Component constructor. |
|
| 20 | - * |
|
| 21 | - * @param $template |
|
| 22 | - * @param Request $request |
|
| 23 | - * @param $parameters |
|
| 24 | - * @param $matchedSitemapItem |
|
| 25 | - */ |
|
| 26 | - public function __construct($template, Request $request, $parameters, $matchedSitemapItem) |
|
| 27 | - { |
|
| 28 | - $this->parameters = (array) $parameters; |
|
| 29 | - $this->checkParameters(); |
|
| 30 | - |
|
| 31 | - $lang = substr(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : $this->defaultLanguage, 0, 2); |
|
| 32 | - $_SESSION['LanguageComponent']['detectedLanguage'] = $lang; |
|
| 33 | - |
|
| 34 | - $this->checkLanguageSwitch($request); |
|
| 35 | - |
|
| 36 | - if (!isset($_SESSION['LanguageComponent'][$this->languageParameterName])) { |
|
| 37 | - $this->detectLanguage($lang, $request); |
|
| 38 | - } else { |
|
| 39 | - if ($this->forceRedirect === true) { |
|
| 40 | - $this->detectLanguage($_SESSION['LanguageComponent'][$this->languageParameterName], $request); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $this->parameters[$this->languageParameterName] = $_SESSION['LanguageComponent'][$this->languageParameterName]; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Checks to see if any parameters are given from the configuration in the CMS |
|
| 49 | - */ |
|
| 50 | - private function checkParameters() |
|
| 51 | - { |
|
| 52 | - if (isset($this->parameters['defaultLanguage'])) { |
|
| 53 | - $this->defaultLanguage = $this->parameters['defaultLanguage']; |
|
| 54 | - unset($this->parameters['defaultLanguage']); |
|
| 55 | - } |
|
| 56 | - if (isset($this->parameters['acceptedLanguages'])) { |
|
| 57 | - $this->acceptedLanguages = explode(',', $this->parameters['acceptedLanguages']); |
|
| 58 | - unset($this->parameters['acceptedLanguages']); |
|
| 59 | - } |
|
| 60 | - if (isset($this->parameters['languageParameterName'])) { |
|
| 61 | - $this->languageParameterName = $this->parameters['languageParameterName']; |
|
| 62 | - unset($this->parameters['languageParameterName']); |
|
| 63 | - } |
|
| 64 | - if (isset($this->parameters['forceRedirect'])) { |
|
| 65 | - $this->forceRedirect = (bool) $this->parameters['forceRedirect']; |
|
| 66 | - unset($this->parameters['forceRedirect']); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 73 | - public function getParameters() |
|
| 74 | - { |
|
| 75 | - return $this->parameters; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Check if the found language is allowed and |
|
| 81 | - * if an action is to be taken. |
|
| 82 | - * |
|
| 83 | - * @param $lang |
|
| 84 | - * @param $request |
|
| 85 | - */ |
|
| 86 | - private function detectLanguage($lang, $request) |
|
| 87 | - { |
|
| 88 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $this->defaultLanguage; |
|
| 89 | - |
|
| 90 | - if ($this->acceptedLanguages === null) { |
|
| 91 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 92 | - } else if (in_array($lang, $this->acceptedLanguages)) { |
|
| 93 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 94 | - } else { |
|
| 95 | - $lang = $this->defaultLanguage; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $this->sessionValues = $_SESSION['LanguageComponent']; |
|
| 99 | - |
|
| 100 | - if ($this->forceRedirect === true) { |
|
| 101 | - if (substr($request::$relativeUri, 0, 2) !== $lang ) { |
|
| 102 | - if ($lang !== $this->defaultLanguage) { |
|
| 103 | - header('Location: ' . $request::$subfolders . $lang . '/' . $request::$relativeUri); |
|
| 104 | - exit; |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Detect if the language is switched manually |
|
| 112 | - * |
|
| 113 | - * @param $request |
|
| 114 | - */ |
|
| 115 | - private function checkLanguageSwitch($request) |
|
| 116 | - { |
|
| 117 | - if (isset($request::$get['langSwitch'])) { |
|
| 118 | - $this->forceRedirect = true; |
|
| 119 | - $this->detectLanguage($request::$get['langSwitch'], $request); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /* |
|
| 9 | + protected $request; |
|
| 10 | + protected $parameters; |
|
| 11 | + |
|
| 12 | + protected $defaultLanguage = 'en'; |
|
| 13 | + protected $acceptedLanguages = null; |
|
| 14 | + protected $languageParameterName = 'language'; |
|
| 15 | + protected $forceRedirect = false; |
|
| 16 | + protected $sessionValues; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * Component constructor. |
|
| 20 | + * |
|
| 21 | + * @param $template |
|
| 22 | + * @param Request $request |
|
| 23 | + * @param $parameters |
|
| 24 | + * @param $matchedSitemapItem |
|
| 25 | + */ |
|
| 26 | + public function __construct($template, Request $request, $parameters, $matchedSitemapItem) |
|
| 27 | + { |
|
| 28 | + $this->parameters = (array) $parameters; |
|
| 29 | + $this->checkParameters(); |
|
| 30 | + |
|
| 31 | + $lang = substr(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : $this->defaultLanguage, 0, 2); |
|
| 32 | + $_SESSION['LanguageComponent']['detectedLanguage'] = $lang; |
|
| 33 | + |
|
| 34 | + $this->checkLanguageSwitch($request); |
|
| 35 | + |
|
| 36 | + if (!isset($_SESSION['LanguageComponent'][$this->languageParameterName])) { |
|
| 37 | + $this->detectLanguage($lang, $request); |
|
| 38 | + } else { |
|
| 39 | + if ($this->forceRedirect === true) { |
|
| 40 | + $this->detectLanguage($_SESSION['LanguageComponent'][$this->languageParameterName], $request); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $this->parameters[$this->languageParameterName] = $_SESSION['LanguageComponent'][$this->languageParameterName]; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Checks to see if any parameters are given from the configuration in the CMS |
|
| 49 | + */ |
|
| 50 | + private function checkParameters() |
|
| 51 | + { |
|
| 52 | + if (isset($this->parameters['defaultLanguage'])) { |
|
| 53 | + $this->defaultLanguage = $this->parameters['defaultLanguage']; |
|
| 54 | + unset($this->parameters['defaultLanguage']); |
|
| 55 | + } |
|
| 56 | + if (isset($this->parameters['acceptedLanguages'])) { |
|
| 57 | + $this->acceptedLanguages = explode(',', $this->parameters['acceptedLanguages']); |
|
| 58 | + unset($this->parameters['acceptedLanguages']); |
|
| 59 | + } |
|
| 60 | + if (isset($this->parameters['languageParameterName'])) { |
|
| 61 | + $this->languageParameterName = $this->parameters['languageParameterName']; |
|
| 62 | + unset($this->parameters['languageParameterName']); |
|
| 63 | + } |
|
| 64 | + if (isset($this->parameters['forceRedirect'])) { |
|
| 65 | + $this->forceRedirect = (bool) $this->parameters['forceRedirect']; |
|
| 66 | + unset($this->parameters['forceRedirect']); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | + public function getParameters() |
|
| 74 | + { |
|
| 75 | + return $this->parameters; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Check if the found language is allowed and |
|
| 81 | + * if an action is to be taken. |
|
| 82 | + * |
|
| 83 | + * @param $lang |
|
| 84 | + * @param $request |
|
| 85 | + */ |
|
| 86 | + private function detectLanguage($lang, $request) |
|
| 87 | + { |
|
| 88 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $this->defaultLanguage; |
|
| 89 | + |
|
| 90 | + if ($this->acceptedLanguages === null) { |
|
| 91 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 92 | + } else if (in_array($lang, $this->acceptedLanguages)) { |
|
| 93 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 94 | + } else { |
|
| 95 | + $lang = $this->defaultLanguage; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $this->sessionValues = $_SESSION['LanguageComponent']; |
|
| 99 | + |
|
| 100 | + if ($this->forceRedirect === true) { |
|
| 101 | + if (substr($request::$relativeUri, 0, 2) !== $lang ) { |
|
| 102 | + if ($lang !== $this->defaultLanguage) { |
|
| 103 | + header('Location: ' . $request::$subfolders . $lang . '/' . $request::$relativeUri); |
|
| 104 | + exit; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Detect if the language is switched manually |
|
| 112 | + * |
|
| 113 | + * @param $request |
|
| 114 | + */ |
|
| 115 | + private function checkLanguageSwitch($request) |
|
| 116 | + { |
|
| 117 | + if (isset($request::$get['langSwitch'])) { |
|
| 118 | + $this->forceRedirect = true; |
|
| 119 | + $this->detectLanguage($request::$get['langSwitch'], $request); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /* |
|
| 124 | 124 | * These functions are required by the interface, but not for the functionality |
| 125 | 125 | */ |
| 126 | - public function run(JsonStorage $storage) {} |
|
| 127 | - public function render() {} |
|
| 128 | - public function get() {} |
|
| 126 | + public function run(JsonStorage $storage) {} |
|
| 127 | + public function render() {} |
|
| 128 | + public function get() {} |
|
| 129 | 129 | } |
| 130 | 130 | \ No newline at end of file |
@@ -11,37 +11,37 @@ |
||
| 11 | 11 | |
| 12 | 12 | abstract class StopWordsFilter implements Filter |
| 13 | 13 | { |
| 14 | - protected $tokens; |
|
| 15 | - protected $stopWords = array(); |
|
| 14 | + protected $tokens; |
|
| 15 | + protected $stopWords = array(); |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * StopWordsFilter constructor. |
|
| 19 | - * @param array $tokens |
|
| 20 | - */ |
|
| 21 | - public function __construct($tokens) |
|
| 22 | - { |
|
| 23 | - $this->tokens = $tokens; |
|
| 24 | - } |
|
| 17 | + /** |
|
| 18 | + * StopWordsFilter constructor. |
|
| 19 | + * @param array $tokens |
|
| 20 | + */ |
|
| 21 | + public function __construct($tokens) |
|
| 22 | + { |
|
| 23 | + $this->tokens = $tokens; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @return array |
|
| 28 | - */ |
|
| 29 | - public function getFilterResults() |
|
| 30 | - { |
|
| 31 | - foreach ($this->stopWords as $stopWord) { |
|
| 32 | - foreach ($this->tokens as $field => $tokens) { |
|
| 33 | - if (isset($tokens[$stopWord])) { |
|
| 34 | - $tokens[$stopWord] = null; |
|
| 35 | - unset($tokens[$stopWord]); |
|
| 36 | - $tokens = array_filter($tokens); |
|
| 37 | - asort($tokens); |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * @return array |
|
| 28 | + */ |
|
| 29 | + public function getFilterResults() |
|
| 30 | + { |
|
| 31 | + foreach ($this->stopWords as $stopWord) { |
|
| 32 | + foreach ($this->tokens as $field => $tokens) { |
|
| 33 | + if (isset($tokens[$stopWord])) { |
|
| 34 | + $tokens[$stopWord] = null; |
|
| 35 | + unset($tokens[$stopWord]); |
|
| 36 | + $tokens = array_filter($tokens); |
|
| 37 | + asort($tokens); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $this->tokens[$field] = $tokens; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - $this->tokens = array_filter($this->tokens); |
|
| 44 | - asort($this->tokens); |
|
| 45 | - return $this->tokens; |
|
| 46 | - } |
|
| 40 | + $this->tokens[$field] = $tokens; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + $this->tokens = array_filter($this->tokens); |
|
| 44 | + asort($this->tokens); |
|
| 45 | + return $this->tokens; |
|
| 46 | + } |
|
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | function shutdownHandler () { |
| 34 | 34 | $error = error_get_last(); |
| 35 | - if (isset($error['type'], $error['message'], $error['file'], $error['line'])) { |
|
| 35 | + if (isset($error['type'], $error['message'], $error['file'], $error['line'])) { |
|
| 36 | 36 | \library\cc\ErrorHandlingUtil::renderError($error['message'],$error['file'],$error['line'], $error['type']); |
| 37 | - }elseif ($error['type'] == 1) { |
|
| 38 | - dump($error); |
|
| 39 | - } |
|
| 37 | + }elseif ($error['type'] == 1) { |
|
| 38 | + dump($error); |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
@@ -13,26 +13,26 @@ |
||
| 13 | 13 | class ImagesRouting implements CmsRouting |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * ImagesRouting constructor. |
|
| 18 | - * @param \library\cc\Request $request |
|
| 19 | - * @param mixed|string $relativeCmsUri |
|
| 20 | - * @param CmsComponent $cmsComponent |
|
| 21 | - */ |
|
| 22 | - public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 23 | - { |
|
| 24 | - if ($relativeCmsUri == '/images') { |
|
| 16 | + /** |
|
| 17 | + * ImagesRouting constructor. |
|
| 18 | + * @param \library\cc\Request $request |
|
| 19 | + * @param mixed|string $relativeCmsUri |
|
| 20 | + * @param CmsComponent $cmsComponent |
|
| 21 | + */ |
|
| 22 | + public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 23 | + { |
|
| 24 | + if ($relativeCmsUri == '/images') { |
|
| 25 | 25 | $this->overviewRoute($cmsComponent); |
| 26 | - } elseif ($relativeCmsUri == '/images.json') { |
|
| 26 | + } elseif ($relativeCmsUri == '/images.json') { |
|
| 27 | 27 | $this->jsonRoute($cmsComponent); |
| 28 | - } elseif ($relativeCmsUri == '/images/new') { |
|
| 28 | + } elseif ($relativeCmsUri == '/images/new') { |
|
| 29 | 29 | $this->newRoute($request, $cmsComponent); |
| 30 | - } elseif ($relativeCmsUri == '/images/delete' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) { |
|
| 30 | + } elseif ($relativeCmsUri == '/images/delete' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) { |
|
| 31 | 31 | $this->deleteRoute($request, $cmsComponent); |
| 32 | - } elseif ($relativeCmsUri == '/images/show' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) { |
|
| 32 | + } elseif ($relativeCmsUri == '/images/show' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) { |
|
| 33 | 33 | $this->showRoute($request, $cmsComponent); |
| 34 | - } |
|
| 35 | - } |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param CmsComponent $cmsComponent |
@@ -20,60 +20,60 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class Document |
| 22 | 22 | { |
| 23 | - public $id; |
|
| 24 | - public $path; |
|
| 25 | - public $title; |
|
| 26 | - public $slug; |
|
| 27 | - public $type; |
|
| 28 | - public $documentType; |
|
| 29 | - public $documentTypeSlug; |
|
| 30 | - public $state; |
|
| 31 | - public $lastModificationDate; |
|
| 32 | - public $creationDate; |
|
| 33 | - public $lastModifiedBy; |
|
| 34 | - protected $fields; |
|
| 35 | - protected $bricks; |
|
| 36 | - protected $dynamicBricks; |
|
| 37 | - protected $content; |
|
| 23 | + public $id; |
|
| 24 | + public $path; |
|
| 25 | + public $title; |
|
| 26 | + public $slug; |
|
| 27 | + public $type; |
|
| 28 | + public $documentType; |
|
| 29 | + public $documentTypeSlug; |
|
| 30 | + public $state; |
|
| 31 | + public $lastModificationDate; |
|
| 32 | + public $creationDate; |
|
| 33 | + public $lastModifiedBy; |
|
| 34 | + protected $fields; |
|
| 35 | + protected $bricks; |
|
| 36 | + protected $dynamicBricks; |
|
| 37 | + protected $content; |
|
| 38 | 38 | |
| 39 | - protected $dbHandle; |
|
| 39 | + protected $dbHandle; |
|
| 40 | 40 | |
| 41 | - protected $jsonEncodedFields = array('fields', 'bricks', 'dynamicBricks'); |
|
| 42 | - protected $orderableFields = array('title', 'slug', 'type', 'documentType', 'documentTypeSlug', 'state', 'lastModificationDate', 'creationDate', 'lastModifiedBy'); |
|
| 41 | + protected $jsonEncodedFields = array('fields', 'bricks', 'dynamicBricks'); |
|
| 42 | + protected $orderableFields = array('title', 'slug', 'type', 'documentType', 'documentTypeSlug', 'state', 'lastModificationDate', 'creationDate', 'lastModifiedBy'); |
|
| 43 | 43 | |
| 44 | - public static $DOCUMENT_STATES = array('published', 'unpublished'); |
|
| 44 | + public static $DOCUMENT_STATES = array('published', 'unpublished'); |
|
| 45 | 45 | |
| 46 | - public function __get($name) { |
|
| 47 | - if (in_array($name, $this->jsonEncodedFields)) { |
|
| 48 | - if (is_string($this->$name)) { |
|
| 49 | - return json_decode($this->$name); |
|
| 50 | - } else { |
|
| 51 | - return $this->$name; |
|
| 52 | - } |
|
| 53 | - } elseif ($name === 'content') { |
|
| 54 | - if ($this->dbHandle === null) { |
|
| 55 | - throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')'); |
|
| 56 | - } else { |
|
| 57 | - if ($this->content === null) { |
|
| 58 | - return $this->getContent(); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } elseif ($name === 'dbHandle') { |
|
| 62 | - throw new \Exception('Trying to get protected property repository.'); |
|
| 63 | - } |
|
| 64 | - return $this->$name; |
|
| 65 | - } |
|
| 46 | + public function __get($name) { |
|
| 47 | + if (in_array($name, $this->jsonEncodedFields)) { |
|
| 48 | + if (is_string($this->$name)) { |
|
| 49 | + return json_decode($this->$name); |
|
| 50 | + } else { |
|
| 51 | + return $this->$name; |
|
| 52 | + } |
|
| 53 | + } elseif ($name === 'content') { |
|
| 54 | + if ($this->dbHandle === null) { |
|
| 55 | + throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')'); |
|
| 56 | + } else { |
|
| 57 | + if ($this->content === null) { |
|
| 58 | + return $this->getContent(); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } elseif ($name === 'dbHandle') { |
|
| 62 | + throw new \Exception('Trying to get protected property repository.'); |
|
| 63 | + } |
|
| 64 | + return $this->$name; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public function __set($name, $value) { |
|
| 68 | - if (in_array($name, $this->jsonEncodedFields)) { |
|
| 69 | - $this->$name = json_encode($value); |
|
| 70 | - } elseif ($name === 'content') { |
|
| 71 | - // Dont do anything for now.. |
|
| 72 | - return; |
|
| 73 | - } |
|
| 67 | + public function __set($name, $value) { |
|
| 68 | + if (in_array($name, $this->jsonEncodedFields)) { |
|
| 69 | + $this->$name = json_encode($value); |
|
| 70 | + } elseif ($name === 'content') { |
|
| 71 | + // Dont do anything for now.. |
|
| 72 | + return; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - $this->$name = $value; |
|
| 76 | - } |
|
| 75 | + $this->$name = $value; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @param string $orderBy |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | * @return array |
| 83 | 83 | * @throws \Exception |
| 84 | 84 | */ |
| 85 | - public function getContent($orderBy = 'title', $order = 'ASC') |
|
| 86 | - { |
|
| 87 | - $docs = $this->documentStorage->getDocumentsWithState($this->path); |
|
| 88 | - return $docs; |
|
| 89 | - //dump($this->path, $docs); |
|
| 90 | - $folderPathWithWildcard = $this->path . '%'; |
|
| 91 | - $sql = ' SELECT * |
|
| 85 | + public function getContent($orderBy = 'title', $order = 'ASC') |
|
| 86 | + { |
|
| 87 | + $docs = $this->documentStorage->getDocumentsWithState($this->path); |
|
| 88 | + return $docs; |
|
| 89 | + //dump($this->path, $docs); |
|
| 90 | + $folderPathWithWildcard = $this->path . '%'; |
|
| 91 | + $sql = ' SELECT * |
|
| 92 | 92 | FROM documents_published |
| 93 | 93 | WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard) . ' |
| 94 | 94 | AND substr(`path`, ' . (strlen($this->path) + 2) . ') NOT LIKE "%/%" |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | AND path != ' . $this->dbHandle->quote($this->path) . ' |
| 97 | 97 | ORDER BY ' . (in_array($orderBy, $this->orderableFields) ? $orderBy : 'title') . ' ' . ($order === 'ASC' ? 'ASC' : 'DESC') . ' |
| 98 | 98 | '; |
| 99 | - $stmt = $this->dbHandle->prepare($sql); |
|
| 99 | + $stmt = $this->dbHandle->prepare($sql); |
|
| 100 | 100 | if ($stmt === false) { |
| 101 | 101 | $errorInfo = $this->dbHandle->errorInfo(); |
| 102 | 102 | $errorMsg = $errorInfo[2]; |
| 103 | 103 | throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
| 104 | 104 | } |
| 105 | - $stmt->bindColumn(':orderBy', $orderBy, \PDO::PARAM_STMT); |
|
| 105 | + $stmt->bindColumn(':orderBy', $orderBy, \PDO::PARAM_STMT); |
|
| 106 | 106 | $stmt->execute(); |
| 107 | - $contents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
| 108 | - foreach ($contents as $key => $document) { |
|
| 109 | - if ($document->type === 'folder') { |
|
| 110 | - $document->dbHandle = $this->dbHandle; |
|
| 111 | - $contents[$key] = $document; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - $this->content = $contents; |
|
| 115 | - return $this->content; |
|
| 116 | - } |
|
| 107 | + $contents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
| 108 | + foreach ($contents as $key => $document) { |
|
| 109 | + if ($document->type === 'folder') { |
|
| 110 | + $document->dbHandle = $this->dbHandle; |
|
| 111 | + $contents[$key] = $document; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + $this->content = $contents; |
|
| 115 | + return $this->content; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * @return string |