@@ -41,53 +41,53 @@ discard block |
||
| 41 | 41 | const VARIABLE_WARNINGS = 'warnings'; |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * @var string |
|
| 45 | - */ |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | 46 | protected $installPath; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var Localization_Source[] |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var Localization_Source[] |
|
| 50 | + */ |
|
| 51 | 51 | protected $sources; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @var Request |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * @var Request |
|
| 55 | + */ |
|
| 56 | 56 | protected $request; |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @var Localization_Source |
|
| 60 | - */ |
|
| 58 | + /** |
|
| 59 | + * @var Localization_Source |
|
| 60 | + */ |
|
| 61 | 61 | protected $activeSource; |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @var Localization_Scanner |
|
| 65 | - */ |
|
| 63 | + /** |
|
| 64 | + * @var Localization_Scanner |
|
| 65 | + */ |
|
| 66 | 66 | protected $scanner; |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var Localization_Locale[] |
|
| 70 | - */ |
|
| 68 | + /** |
|
| 69 | + * @var Localization_Locale[] |
|
| 70 | + */ |
|
| 71 | 71 | protected $appLocales = array(); |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @var Localization_Locale |
|
| 75 | - */ |
|
| 73 | + /** |
|
| 74 | + * @var Localization_Locale |
|
| 75 | + */ |
|
| 76 | 76 | protected $activeAppLocale; |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @var Localization_Editor_Filters |
|
| 80 | - */ |
|
| 78 | + /** |
|
| 79 | + * @var Localization_Editor_Filters |
|
| 80 | + */ |
|
| 81 | 81 | protected $filters; |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @var array<string,string> |
|
| 85 | - */ |
|
| 83 | + /** |
|
| 84 | + * @var array<string,string> |
|
| 85 | + */ |
|
| 86 | 86 | protected $requestParams = array(); |
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 88 | + /** |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | 91 | protected $varPrefix = 'applocalize_'; |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -128,15 +128,15 @@ discard block |
||
| 128 | 128 | return $this->request; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Adds a request parameter that will be persisted in all URLs |
|
| 133 | - * within the editor. This can be used when integrating the |
|
| 134 | - * editor in an existing page that needs specific request params. |
|
| 135 | - * |
|
| 136 | - * @param string $name |
|
| 137 | - * @param string $value |
|
| 138 | - * @return Localization_Editor |
|
| 139 | - */ |
|
| 131 | + /** |
|
| 132 | + * Adds a request parameter that will be persisted in all URLs |
|
| 133 | + * within the editor. This can be used when integrating the |
|
| 134 | + * editor in an existing page that needs specific request params. |
|
| 135 | + * |
|
| 136 | + * @param string $name |
|
| 137 | + * @param string $value |
|
| 138 | + * @return Localization_Editor |
|
| 139 | + */ |
|
| 140 | 140 | public function addRequestParam(string $name, string $value) : Localization_Editor |
| 141 | 141 | { |
| 142 | 142 | $this->requestParams[$name] = $value; |
@@ -500,13 +500,13 @@ discard block |
||
| 500 | 500 | ); |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * Sets the application name shown in the main navigation |
|
| 505 | - * in the user interface. |
|
| 506 | - * |
|
| 507 | - * @param string $name |
|
| 508 | - * @return Localization_Editor |
|
| 509 | - */ |
|
| 503 | + /** |
|
| 504 | + * Sets the application name shown in the main navigation |
|
| 505 | + * in the user interface. |
|
| 506 | + * |
|
| 507 | + * @param string $name |
|
| 508 | + * @return Localization_Editor |
|
| 509 | + */ |
|
| 510 | 510 | public function setAppName(string $name) : Localization_Editor |
| 511 | 511 | { |
| 512 | 512 | $this->setOption('appname', $name); |
@@ -536,15 +536,15 @@ discard block |
||
| 536 | 536 | return $this; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - /** |
|
| 540 | - * Sets an URL that the translators can use to go back to |
|
| 541 | - * the main application, for example if it is integrated into |
|
| 542 | - * an existing application. |
|
| 543 | - * |
|
| 544 | - * @param string $url The URL to use for the link |
|
| 545 | - * @param string $label Label of the link |
|
| 546 | - * @return Localization_Editor |
|
| 547 | - */ |
|
| 539 | + /** |
|
| 540 | + * Sets an URL that the translators can use to go back to |
|
| 541 | + * the main application, for example if it is integrated into |
|
| 542 | + * an existing application. |
|
| 543 | + * |
|
| 544 | + * @param string $url The URL to use for the link |
|
| 545 | + * @param string $label Label of the link |
|
| 546 | + * @return Localization_Editor |
|
| 547 | + */ |
|
| 548 | 548 | public function setBackURL(string $url, string $label) : Localization_Editor |
| 549 | 549 | { |
| 550 | 550 | $this->setOption('back-url', $url); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | public function __construct() |
| 103 | 103 | { |
| 104 | 104 | $path = realpath(__DIR__.'/../'); |
| 105 | - if($path === false) |
|
| 105 | + if ($path === false) |
|
| 106 | 106 | { |
| 107 | 107 | throw new Localization_Exception( |
| 108 | 108 | 'Local path not found', |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | protected function initSession() : void |
| 152 | 152 | { |
| 153 | - if(session_status() != PHP_SESSION_ACTIVE) { |
|
| 153 | + if (session_status() != PHP_SESSION_ACTIVE) { |
|
| 154 | 154 | session_start(); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if(!isset($_SESSION['localization_messages'])) { |
|
| 157 | + if (!isset($_SESSION['localization_messages'])) { |
|
| 158 | 158 | $_SESSION['localization_messages'] = array(); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $this->sources = Localization::getSources(); |
| 173 | 173 | |
| 174 | - if(empty($this->sources)) |
|
| 174 | + if (empty($this->sources)) |
|
| 175 | 175 | { |
| 176 | 176 | throw new Localization_Exception( |
| 177 | 177 | 'Cannot start editor: no sources defined.', |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $activeID = $this->request->registerParam($this->getVarName('source'))->setEnum(Localization::getSourceIDs())->get(); |
| 184 | - if(empty($activeID)) { |
|
| 184 | + if (empty($activeID)) { |
|
| 185 | 185 | $activeID = $this->getDefaultSourceID(); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | protected function getDefaultSourceID() : string |
| 192 | 192 | { |
| 193 | 193 | $default = $this->getOption('default-source'); |
| 194 | - if(!empty($default) && Localization::sourceAliasExists($default)) { |
|
| 194 | + if (!empty($default) && Localization::sourceAliasExists($default)) { |
|
| 195 | 195 | return Localization::getSourceByAlias($default)->getID(); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -203,21 +203,21 @@ discard block |
||
| 203 | 203 | $names = array(); |
| 204 | 204 | |
| 205 | 205 | $locales = Localization::getAppLocales(); |
| 206 | - foreach($locales as $locale) { |
|
| 207 | - if(!$locale->isNative()) { |
|
| 206 | + foreach ($locales as $locale) { |
|
| 207 | + if (!$locale->isNative()) { |
|
| 208 | 208 | $this->appLocales[] = $locale; |
| 209 | 209 | $names[] = $locale->getName(); |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // use the default locale if no other is available. |
| 214 | - if(empty($names)) { |
|
| 214 | + if (empty($names)) { |
|
| 215 | 215 | $this->activeAppLocale = Localization::getAppLocale(); |
| 216 | 216 | return; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $activeID = $this->request->registerParam($this->getVarName('locale'))->setEnum($names)->get(); |
| 220 | - if(empty($activeID)) { |
|
| 220 | + if (empty($activeID)) { |
|
| 221 | 221 | $activeID = $this->appLocales[0]->getName(); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | $this->filters = new Localization_Editor_Filters($this); |
| 270 | 270 | |
| 271 | - if($this->request->getBool($this->getVarName(self::VARIABLE_SCAN))) |
|
| 271 | + if ($this->request->getBool($this->getVarName(self::VARIABLE_SCAN))) |
|
| 272 | 272 | { |
| 273 | 273 | $this->executeScan(); |
| 274 | 274 | } |
| 275 | - else if($this->request->getBool($this->getSaveVariableName())) |
|
| 275 | + else if ($this->request->getBool($this->getSaveVariableName())) |
|
| 276 | 276 | { |
| 277 | 277 | $this->executeSave(); |
| 278 | 278 | } |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | $result = array(); |
| 328 | 328 | |
| 329 | - foreach($strings as $string) |
|
| 329 | + foreach ($strings as $string) |
|
| 330 | 330 | { |
| 331 | - if($this->filters->isStringMatch($string)) { |
|
| 331 | + if ($this->filters->isStringMatch($string)) { |
|
| 332 | 332 | $result[] = $string; |
| 333 | 333 | } |
| 334 | 334 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | return $this->activeAppLocale; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - public function getPaginationURL(int $page, array $params=array()) : string |
|
| 368 | + public function getPaginationURL(int $page, array $params = array()) : string |
|
| 369 | 369 | { |
| 370 | 370 | $params[$this->getVarName('page')] = $page; |
| 371 | 371 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | $result = array(); |
| 378 | 378 | preg_match_all('/%[0-9]+d|%s|%[0-9]+\$s/i', $string, $result, PREG_PATTERN_ORDER); |
| 379 | 379 | |
| 380 | - if(isset($result[0]) && !empty($result[0])) { |
|
| 380 | + if (isset($result[0]) && !empty($result[0])) { |
|
| 381 | 381 | return $result[0]; |
| 382 | 382 | } |
| 383 | 383 | |
@@ -389,14 +389,14 @@ discard block |
||
| 389 | 389 | echo $this->render(); |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - public function getSourceURL(Localization_Source $source, array $params=array()) : string |
|
| 392 | + public function getSourceURL(Localization_Source $source, array $params = array()) : string |
|
| 393 | 393 | { |
| 394 | 394 | $params[$this->getVarName('source')] = $source->getID(); |
| 395 | 395 | |
| 396 | 396 | return $this->getURL($params); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - public function getLocaleURL(Localization_Locale $locale, array $params=array()) : string |
|
| 399 | + public function getLocaleURL(Localization_Locale $locale, array $params = array()) : string |
|
| 400 | 400 | { |
| 401 | 401 | $params[$this->getVarName('locale')] = $locale->getName(); |
| 402 | 402 | |
@@ -413,12 +413,12 @@ discard block |
||
| 413 | 413 | return $this->getSourceURL($this->activeSource, array($this->getVarName(self::VARIABLE_WARNINGS) => 'yes')); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - public function getURL(array $params=array()) : string |
|
| 416 | + public function getURL(array $params = array()) : string |
|
| 417 | 417 | { |
| 418 | 418 | $persist = $this->getRequestParams(); |
| 419 | 419 | |
| 420 | - foreach($persist as $name => $value) { |
|
| 421 | - if(!isset($params[$name])) { |
|
| 420 | + foreach ($persist as $name => $value) { |
|
| 421 | + if (!isset($params[$name])) { |
|
| 422 | 422 | $params[$name] = $value; |
| 423 | 423 | } |
| 424 | 424 | } |
@@ -455,11 +455,11 @@ discard block |
||
| 455 | 455 | $translator = Localization::getTranslator($this->activeAppLocale); |
| 456 | 456 | |
| 457 | 457 | $strings = $data[$this->getVarName(self::VARIABLE_STRINGS)]; |
| 458 | - foreach($strings as $hash => $text) |
|
| 458 | + foreach ($strings as $hash => $text) |
|
| 459 | 459 | { |
| 460 | 460 | $text = trim($text); |
| 461 | 461 | |
| 462 | - if(empty($text)) { |
|
| 462 | + if (empty($text)) { |
|
| 463 | 463 | continue; |
| 464 | 464 | } |
| 465 | 465 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | $this->redirect($this->getURL()); |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - protected function addMessage(string $message, string $type=self::MESSAGE_INFO) : void |
|
| 482 | + protected function addMessage(string $message, string $type = self::MESSAGE_INFO) : void |
|
| 483 | 483 | { |
| 484 | 484 | $_SESSION['localization_messages'][] = array( |
| 485 | 485 | 'text' => $message, |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | public function getAppName() : string |
| 517 | 517 | { |
| 518 | 518 | $name = $this->getOption('appname'); |
| 519 | - if(!empty($name)) { |
|
| 519 | + if (!empty($name)) { |
|
| 520 | 520 | return $name; |
| 521 | 521 | } |
| 522 | 522 | |
@@ -271,8 +271,7 @@ |
||
| 271 | 271 | if($this->request->getBool($this->getVarName(self::VARIABLE_SCAN))) |
| 272 | 272 | { |
| 273 | 273 | $this->executeScan(); |
| 274 | - } |
|
| 275 | - else if($this->request->getBool($this->getSaveVariableName())) |
|
| 274 | + } else if($this->request->getBool($this->getSaveVariableName())) |
|
| 276 | 275 | { |
| 277 | 276 | $this->executeSave(); |
| 278 | 277 | } |