@@ -47,21 +47,21 @@ |
||
| 47 | 47 | { |
| 48 | 48 | global $rootPath; |
| 49 | 49 | |
| 50 | - self::$subfolders = '/' . str_replace('//', '/', str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), "", $rootPath)); |
|
| 50 | + self::$subfolders = '/'.str_replace('//', '/', str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), "", $rootPath)); |
|
| 51 | 51 | self::$subfolders = str_replace('//', '/', self::$subfolders); |
| 52 | 52 | if (PHP_SAPI === 'cli') { |
| 53 | 53 | global $argv; |
| 54 | 54 | array_shift($argv); |
| 55 | 55 | self::$queryString = ''; |
| 56 | - self::$requestUri = self::$subfolders . implode('/', $argv); |
|
| 56 | + self::$requestUri = self::$subfolders.implode('/', $argv); |
|
| 57 | 57 | } else { |
| 58 | 58 | self::$requestUri = $_SERVER['REQUEST_URI']; |
| 59 | 59 | self::$queryString = $_SERVER['QUERY_STRING']; |
| 60 | 60 | } |
| 61 | 61 | if (self::$subfolders === '/') { |
| 62 | - self::$relativeUri = str_replace('?' . self::$queryString, '', substr(self::$requestUri,1)); |
|
| 62 | + self::$relativeUri = str_replace('?'.self::$queryString, '', substr(self::$requestUri, 1)); |
|
| 63 | 63 | } else { |
| 64 | - self::$relativeUri = str_replace('?' . self::$queryString, '', str_replace(self::$subfolders, '', self::$requestUri)); |
|
| 64 | + self::$relativeUri = str_replace('?'.self::$queryString, '', str_replace(self::$subfolders, '', self::$requestUri)); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | self::$requestParameters = explode('/', self::$relativeUri); |
@@ -99,9 +99,9 @@ |
||
| 99 | 99 | $this->sessionValues = $_SESSION['LanguageComponent']; |
| 100 | 100 | |
| 101 | 101 | if ($this->forceRedirect === true) { |
| 102 | - if (substr($request::$relativeUri, 0, 2) !== $lang ) { |
|
| 102 | + if (substr($request::$relativeUri, 0, 2) !== $lang) { |
|
| 103 | 103 | if ($lang !== $this->defaultLanguage) { |
| 104 | - header('Location: ' . $request::$subfolders . $lang . '/' . $request::$relativeUri); |
|
| 104 | + header('Location: '.$request::$subfolders.$lang.'/'.$request::$relativeUri); |
|
| 105 | 105 | exit; |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -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 |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | if (isset($_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID])) { |
| 163 | 163 | $this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID]; |
| 164 | 164 | } else { |
| 165 | - $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string)microtime(true); |
|
| 165 | + $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string) microtime(true); |
|
| 166 | 166 | $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] = false; |
| 167 | 167 | $this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID]; |
| 168 | 168 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $postValues = $request::$post; |
| 191 | 191 | $postValues[self::PARAMETER_DOCUMENT_TYPE] = $this->documentType; |
| 192 | 192 | $postValues[self::GET_PARAMETER_PATH] = $this->responseFolder; |
| 193 | - $postValues['title'] = date('r') . ' - From: ' . $request::$requestUri; |
|
| 193 | + $postValues['title'] = date('r').' - From: '.$request::$requestUri; |
|
| 194 | 194 | |
| 195 | 195 | return $postValues; |
| 196 | 196 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | private function setFormParameter($form) |
| 326 | 326 | { |
| 327 | 327 | if ($this->isFormSubmitted($this->request) || $this->isSubmitAllowed() === false) { |
| 328 | - $this->parameters[$this->formParameterName] = '<a name="' . $this->formId . '"></a>' . $this->thankYouMessage; |
|
| 328 | + $this->parameters[$this->formParameterName] = '<a name="'.$this->formId.'"></a>'.$this->thankYouMessage; |
|
| 329 | 329 | } else { |
| 330 | 330 | $this->parameters[$this->formParameterName] = $form; |
| 331 | 331 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * submitting the form |
| 148 | 148 | * |
| 149 | 149 | * @param $postValues |
| 150 | - * @param $storage |
|
| 150 | + * @param Storage $storage |
|
| 151 | 151 | */ |
| 152 | 152 | protected function postSubmit($postValues, $storage) |
| 153 | 153 | {} |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | - * @param $form |
|
| 320 | + * @param string|null $form |
|
| 321 | 321 | */ |
| 322 | 322 | private function setFormParameter($form) |
| 323 | 323 | { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $whitelistIps = explode(',', $this->parameters[self::PARAMETER_WHITELIST_IPS]); |
| 160 | 160 | $whitelistIps = array_map("trim", $whitelistIps); |
| 161 | 161 | if (!in_array($remoteAddress, $whitelistIps)) { |
| 162 | - throw new \Exception('Ip address ' . $remoteAddress . ' is not on whitelist'); |
|
| 162 | + throw new \Exception('Ip address '.$remoteAddress.' is not on whitelist'); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $blacklistIps = explode(',', $this->parameters[self::PARAMETER_BLACKLIST_IPS]); |
| 176 | 176 | $blacklistIps = array_map("trim", $blacklistIps); |
| 177 | 177 | if (in_array($remoteAddress, $blacklistIps)) { |
| 178 | - throw new \Exception('Ip address ' . $remoteAddress . ' is on blacklist'); |
|
| 178 | + throw new \Exception('Ip address '.$remoteAddress.' is on blacklist'); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | if ($relativeCmsUri == '/log-off') { |
| 220 | 220 | $_SESSION[self::SESSION_PARAMETER_CLOUD_CONTROL] = null; |
| 221 | 221 | unset($_SESSION[self::SESSION_PARAMETER_CLOUD_CONTROL]); |
| 222 | - header('Location: ' . $request::$subfolders . $this->parameters[self::PARAMETER_CMS_PREFIX]); |
|
| 222 | + header('Location: '.$request::$subfolders.$this->parameters[self::PARAMETER_CMS_PREFIX]); |
|
| 223 | 223 | exit; |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class CmsComponent extends BaseComponent |
| 14 | 14 | { |
| 15 | - /** |
|
| 15 | + /** |
|
| 16 | 16 | * @var \library\storage\Storage |
| 17 | 17 | */ |
| 18 | 18 | public $storage; |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | const PARAMETER_IMAGE_SET = 'imageSet'; |
| 42 | 42 | const PARAMETER_MAIN_NAV_CLASS = 'mainNavClass'; |
| 43 | 43 | const PARAMETER_MY_BRICK_SLUG = 'myBrickSlug'; |
| 44 | - const PARAMETER_REDIRECT = 'redirect'; |
|
| 45 | - const PARAMETER_REDIRECTS = 'redirects'; |
|
| 44 | + const PARAMETER_REDIRECT = 'redirect'; |
|
| 45 | + const PARAMETER_REDIRECTS = 'redirects'; |
|
| 46 | 46 | const PARAMETER_SEARCH = 'search'; |
| 47 | 47 | const PARAMETER_SEARCH_LOG = "searchLog"; |
| 48 | 48 | const PARAMETER_SEARCH_NEEDS_UPDATE = "searchNeedsUpdate"; |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | const PARAMETER_VALUELISTS = "valuelists"; |
| 58 | 58 | const PARAMETER_WHITELIST_IPS = 'whitelistIps'; |
| 59 | 59 | |
| 60 | - const POST_PARAMETER_COMPONENT = 'component'; |
|
| 61 | - const POST_PARAMETER_FROM_URL = "fromUrl"; |
|
| 62 | - const POST_PARAMETER_PASSWORD = 'password'; |
|
| 63 | - const POST_PARAMETER_SAVE = 'save'; |
|
| 64 | - const POST_PARAMETER_TEMPLATE = 'template'; |
|
| 65 | - const POST_PARAMETER_TITLE = 'title'; |
|
| 66 | - const POST_PARAMETER_TO_URL = "toUrl"; |
|
| 67 | - const POST_PARAMETER_USERNAME = 'username'; |
|
| 60 | + const POST_PARAMETER_COMPONENT = 'component'; |
|
| 61 | + const POST_PARAMETER_FROM_URL = "fromUrl"; |
|
| 62 | + const POST_PARAMETER_PASSWORD = 'password'; |
|
| 63 | + const POST_PARAMETER_SAVE = 'save'; |
|
| 64 | + const POST_PARAMETER_TEMPLATE = 'template'; |
|
| 65 | + const POST_PARAMETER_TITLE = 'title'; |
|
| 66 | + const POST_PARAMETER_TO_URL = "toUrl"; |
|
| 67 | + const POST_PARAMETER_USERNAME = 'username'; |
|
| 68 | 68 | |
| 69 | 69 | const GET_PARAMETER_PATH = 'path'; |
| 70 | 70 | const GET_PARAMETER_SLUG = 'slug'; |
@@ -45,18 +45,18 @@ discard block |
||
| 45 | 45 | if ($stmt === false) { |
| 46 | 46 | $errorInfo = $db->errorInfo(); |
| 47 | 47 | $errorMsg = $errorInfo[2]; |
| 48 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 48 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 49 | 49 | } |
| 50 | 50 | if (($stmt->execute()) === false) { |
| 51 | 51 | $errorInfo = $db->errorInfo(); |
| 52 | 52 | $errorMsg = $errorInfo[2]; |
| 53 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 53 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 54 | 54 | } |
| 55 | 55 | $uniqueFieldsPerDocument = $stmt->fetchAll(\PDO::FETCH_OBJ); |
| 56 | 56 | $values = array(); |
| 57 | 57 | $i = 0; |
| 58 | 58 | foreach ($uniqueFieldsPerDocument as $fieldRow) { |
| 59 | - $values[] = 'UPDATE term_frequency SET termNorm = 1/sqrt(' . intval($fieldRow->termCount) . ') WHERE documentPath = ' . $db->quote($fieldRow->documentPath) . ' AND field = ' . $db->quote($fieldRow->field) . ';'; |
|
| 59 | + $values[] = 'UPDATE term_frequency SET termNorm = 1/sqrt('.intval($fieldRow->termCount).') WHERE documentPath = '.$db->quote($fieldRow->documentPath).' AND field = '.$db->quote($fieldRow->field).';'; |
|
| 60 | 60 | $i += 1; |
| 61 | 61 | if ($i >= Indexer::SQLITE_MAX_COMPOUND_SELECT) { |
| 62 | 62 | $this->executeUpdateTermNorm($values, $db); |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | private function executeUpdateTermNorm($values, $db) |
| 78 | 78 | { |
| 79 | - $sql = 'BEGIN TRANSACTION;' . PHP_EOL; |
|
| 80 | - $sql .= implode(PHP_EOL, $values) . PHP_EOL; |
|
| 79 | + $sql = 'BEGIN TRANSACTION;'.PHP_EOL; |
|
| 80 | + $sql .= implode(PHP_EOL, $values).PHP_EOL; |
|
| 81 | 81 | $sql .= 'COMMIT;'; |
| 82 | 82 | if (($db->exec($sql)) === false) { |
| 83 | 83 | $errorInfo = $db->errorInfo(); |
| 84 | 84 | $errorMsg = $errorInfo[2]; |
| 85 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 85 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | \ No newline at end of file |
@@ -47,14 +47,14 @@ |
||
| 47 | 47 | if (!$stmt = $db->prepare($sql)) { |
| 48 | 48 | $errorInfo = $db->errorInfo(); |
| 49 | 49 | $errorMsg = $errorInfo[2]; |
| 50 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 50 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 51 | 51 | } |
| 52 | 52 | $stmt->bindValue(':documentCount', $this->documentCount); |
| 53 | 53 | $result = $stmt->execute(); |
| 54 | 54 | if ($result === false) { |
| 55 | 55 | $errorInfo = $db->errorInfo(); |
| 56 | 56 | $errorMsg = $errorInfo[2]; |
| 57 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 57 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $i = 0; |
| 53 | 53 | foreach ($termsForDocumentField as $term) { |
| 54 | 54 | $frequency = intval($term->count) / $documentField->totalTermCount; |
| 55 | - $values[] = $quotedDocumentPath . ',' . $quotedField . ', ' . $db->quote($term->term) . ', ' . $db->quote($frequency); |
|
| 55 | + $values[] = $quotedDocumentPath.','.$quotedField.', '.$db->quote($term->term).', '.$db->quote($frequency); |
|
| 56 | 56 | $i += 1; |
| 57 | 57 | if ($i >= Indexer::SQLITE_MAX_COMPOUND_SELECT) { |
| 58 | 58 | $this->executeStore($sql, $values, $db); |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | private function executeStore($sql, $values, $db) |
| 103 | 103 | { |
| 104 | - $sql .= '(' . implode('),' . PHP_EOL . '(', $values) . ');'; |
|
| 104 | + $sql .= '('.implode('),'.PHP_EOL.'(', $values).');'; |
|
| 105 | 105 | if (!$db->query($sql)) { |
| 106 | 106 | $errorInfo = $db->errorInfo(); |
| 107 | 107 | $errorMsg = $errorInfo[2]; |
| 108 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 108 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | protected function configureDatabase() |
| 50 | 50 | { |
| 51 | 51 | $db = $this->getSearchDbHandle(); |
| 52 | - $sqlPath = __DIR__ . DIRECTORY_SEPARATOR . '../cc/install/search.sql'; |
|
| 52 | + $sqlPath = __DIR__.DIRECTORY_SEPARATOR.'../cc/install/search.sql'; |
|
| 53 | 53 | $searchSql = file_get_contents($sqlPath); |
| 54 | 54 | $db->exec($searchSql); |
| 55 | 55 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | protected function getSearchDbHandle() |
| 66 | 66 | { |
| 67 | 67 | if ($this->searchDbHandle === null) { |
| 68 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR; |
|
| 69 | - $this->searchDbHandle = new \PDO('sqlite:' . $path . 'search.db'); |
|
| 68 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$this->storageDir.DIRECTORY_SEPARATOR; |
|
| 69 | + $this->searchDbHandle = new \PDO('sqlite:'.$path.'search.db'); |
|
| 70 | 70 | } |
| 71 | 71 | return $this->searchDbHandle; |
| 72 | 72 | } |
@@ -10,5 +10,5 @@ |
||
| 10 | 10 | |
| 11 | 11 | class DutchStopWords extends StopWordsFilter |
| 12 | 12 | { |
| 13 | - protected $stopWords = array('aan','af','al','alles','als','altijd','andere','ben','bij','daar','dan','dat','de','der','deze','die','dit','doch','doen','door','doorgaans','dus','een','eens','en','er','ge','geen','geweest','haar','had','heb','hebben','heeft','hem','het','hier','hij','hoe','hun','iemand','iets','ik','in','is','ja','je','kan','kon','kunnen','maar','me','meer','men','met','mij','mijn','moet','na','naar','niet','niets','nog','nu','of','om','omdat','ons','ook','op','over','reeds','te','tegen','toch','toen','tot','u','uit','uw','van','veel','voor','want','waren','was','wat','we','wel','werd','wezen','wie','wij','wil','worden','zal','ze','zei','zelf','zich','zij','zijn','zo','zodat','zonder','zou'); |
|
| 13 | + protected $stopWords = array('aan', 'af', 'al', 'alles', 'als', 'altijd', 'andere', 'ben', 'bij', 'daar', 'dan', 'dat', 'de', 'der', 'deze', 'die', 'dit', 'doch', 'doen', 'door', 'doorgaans', 'dus', 'een', 'eens', 'en', 'er', 'ge', 'geen', 'geweest', 'haar', 'had', 'heb', 'hebben', 'heeft', 'hem', 'het', 'hier', 'hij', 'hoe', 'hun', 'iemand', 'iets', 'ik', 'in', 'is', 'ja', 'je', 'kan', 'kon', 'kunnen', 'maar', 'me', 'meer', 'men', 'met', 'mij', 'mijn', 'moet', 'na', 'naar', 'niet', 'niets', 'nog', 'nu', 'of', 'om', 'omdat', 'ons', 'ook', 'op', 'over', 'reeds', 'te', 'tegen', 'toch', 'toen', 'tot', 'u', 'uit', 'uw', 'van', 'veel', 'voor', 'want', 'waren', 'was', 'wat', 'we', 'wel', 'werd', 'wezen', 'wie', 'wij', 'wil', 'worden', 'zal', 'ze', 'zei', 'zelf', 'zich', 'zij', 'zijn', 'zo', 'zodat', 'zonder', 'zou'); |
|
| 14 | 14 | } |
| 15 | 15 | \ No newline at end of file |