@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | const ERROR_UNSUPPORTED_FILE_EXTENSION = 40602; |
| 31 | 31 | const ERROR_INVALID_LANGUAGE_CLASS = 40603; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var Localization_Scanner |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var Localization_Scanner |
|
| 35 | + */ |
|
| 36 | 36 | protected $scanner; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var Localization_Scanner_StringsCollection |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var Localization_Scanner_StringsCollection |
|
| 40 | + */ |
|
| 41 | 41 | protected $collection; |
| 42 | 42 | |
| 43 | 43 | protected $languageMappings = array( |
@@ -51,15 +51,15 @@ discard block |
||
| 51 | 51 | $this->collection = $scanner->getCollection(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Parses a source file. Must have a valid supported file extension. |
|
| 56 | - * |
|
| 57 | - * @param string $path |
|
| 58 | - * @return Localization_Parser_Language |
|
| 59 | - * @throws Localization_Exception |
|
| 60 | - * |
|
| 61 | - * @see Localization_Parser::ERROR_UNSUPPORTED_FILE_EXTENSION |
|
| 62 | - */ |
|
| 54 | + /** |
|
| 55 | + * Parses a source file. Must have a valid supported file extension. |
|
| 56 | + * |
|
| 57 | + * @param string $path |
|
| 58 | + * @return Localization_Parser_Language |
|
| 59 | + * @throws Localization_Exception |
|
| 60 | + * |
|
| 61 | + * @see Localization_Parser::ERROR_UNSUPPORTED_FILE_EXTENSION |
|
| 62 | + */ |
|
| 63 | 63 | public function parseFile(string $path) : Localization_Parser_Language |
| 64 | 64 | { |
| 65 | 65 | $this->requireValidFile($path); |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | return $language; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Parses the string for the specified language. |
|
| 78 | - * |
|
| 79 | - * @param string $languageID |
|
| 80 | - * @param string $code |
|
| 81 | - * @return Localization_Parser_Language |
|
| 82 | - * @throws Localization_Exception |
|
| 83 | - * |
|
| 84 | - * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID |
|
| 85 | - */ |
|
| 76 | + /** |
|
| 77 | + * Parses the string for the specified language. |
|
| 78 | + * |
|
| 79 | + * @param string $languageID |
|
| 80 | + * @param string $code |
|
| 81 | + * @return Localization_Parser_Language |
|
| 82 | + * @throws Localization_Exception |
|
| 83 | + * |
|
| 84 | + * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID |
|
| 85 | + */ |
|
| 86 | 86 | public function parseString(string $languageID, string $code) : Localization_Parser_Language |
| 87 | 87 | { |
| 88 | 88 | $this->requireValidLanguageID($languageID); |
@@ -141,18 +141,18 @@ discard block |
||
| 141 | 141 | ); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * Retrieves a list of all language IDs that are supported. |
|
| 146 | - * @return string[] IDs list like "PHP", "Javascript" |
|
| 147 | - */ |
|
| 144 | + /** |
|
| 145 | + * Retrieves a list of all language IDs that are supported. |
|
| 146 | + * @return string[] IDs list like "PHP", "Javascript" |
|
| 147 | + */ |
|
| 148 | 148 | public function getLanguageIDs() : array |
| 149 | 149 | { |
| 150 | 150 | return array_values($this->languageMappings); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * @var array<string,Localization_Parser_Language> |
|
| 155 | - */ |
|
| 153 | + /** |
|
| 154 | + * @var array<string,Localization_Parser_Language> |
|
| 155 | + */ |
|
| 156 | 156 | protected $languageParsers = array(); |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -206,12 +206,12 @@ discard block |
||
| 206 | 206 | ); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * Whether the specified file extension is supported. |
|
| 211 | - * |
|
| 212 | - * @param string $ext |
|
| 213 | - * @return bool |
|
| 214 | - */ |
|
| 209 | + /** |
|
| 210 | + * Whether the specified file extension is supported. |
|
| 211 | + * |
|
| 212 | + * @param string $ext |
|
| 213 | + * @return bool |
|
| 214 | + */ |
|
| 215 | 215 | public function isExtensionSupported(string $ext) : bool |
| 216 | 216 | { |
| 217 | 217 | $ext = strtolower($ext); |
@@ -6,14 +6,14 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | abstract class Localization_Parser_Token |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * @var array|string |
|
| 11 | - */ |
|
| 9 | + /** |
|
| 10 | + * @var array|string |
|
| 11 | + */ |
|
| 12 | 12 | protected $definition; |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @var Localization_Parser_Token |
|
| 16 | - */ |
|
| 14 | + /** |
|
| 15 | + * @var Localization_Parser_Token |
|
| 16 | + */ |
|
| 17 | 17 | protected $parentToken; |
| 18 | 18 | |
| 19 | 19 | protected $token; |
@@ -86,6 +86,6 @@ discard block |
||
| 86 | 86 | 'value' => $this->getValue(), |
| 87 | 87 | 'line' => $this->getLine(), |
| 88 | 88 | 'isEncapsedString' => ConvertHelper::bool2string($this->isEncapsedString()) |
| 89 | - ); |
|
| 89 | + ); |
|
| 90 | 90 | } |
| 91 | 91 | } |
@@ -21,49 +21,49 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | protected $parser; |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * The function names that are included in the search. |
|
| 26 | - * @var array |
|
| 27 | - */ |
|
| 24 | + /** |
|
| 25 | + * The function names that are included in the search. |
|
| 26 | + * @var array |
|
| 27 | + */ |
|
| 28 | 28 | protected $functionNames = array(); |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * The tokens definitions. |
|
| 32 | - * @var array |
|
| 33 | - */ |
|
| 30 | + /** |
|
| 31 | + * The tokens definitions. |
|
| 32 | + * @var array |
|
| 33 | + */ |
|
| 34 | 34 | protected $tokens = array(); |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * The total amount of tokens found in the content. |
|
| 38 | - * @var integer |
|
| 39 | - */ |
|
| 36 | + /** |
|
| 37 | + * The total amount of tokens found in the content. |
|
| 38 | + * @var integer |
|
| 39 | + */ |
|
| 40 | 40 | protected $totalTokens = 0; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * All texts that have been collected. |
|
| 44 | - * @var Text[] |
|
| 45 | - */ |
|
| 42 | + /** |
|
| 43 | + * All texts that have been collected. |
|
| 44 | + * @var Text[] |
|
| 45 | + */ |
|
| 46 | 46 | protected $texts = array(); |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var string |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var string |
|
| 50 | + */ |
|
| 51 | 51 | protected $content = ''; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @var string|NULL |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * @var string|NULL |
|
| 55 | + */ |
|
| 56 | 56 | protected $id; |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @var Localization_Parser_Warning[] |
|
| 60 | - */ |
|
| 58 | + /** |
|
| 59 | + * @var Localization_Parser_Warning[] |
|
| 60 | + */ |
|
| 61 | 61 | protected $warnings = array(); |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * The source file that was parsed (if any) |
|
| 65 | - * @var string |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * The source file that was parsed (if any) |
|
| 65 | + * @var string |
|
| 66 | + */ |
|
| 67 | 67 | protected $sourceFile = ''; |
| 68 | 68 | |
| 69 | 69 | public function __construct(Localization_Parser $parser) |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | abstract protected function getTokens() : array; |
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Retrieves the ID of the language. |
|
| 79 | - * @return string E.g. "PHP", "Javascript" |
|
| 80 | - */ |
|
| 77 | + /** |
|
| 78 | + * Retrieves the ID of the language. |
|
| 79 | + * @return string E.g. "PHP", "Javascript" |
|
| 80 | + */ |
|
| 81 | 81 | public function getID() : string |
| 82 | 82 | { |
| 83 | 83 | if(!isset($this->id)) { |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | return $this->sourceFile; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Parses the code from a file. |
|
| 102 | - * |
|
| 103 | - * @param string $path |
|
| 104 | - * @throws Localization_Exception |
|
| 105 | - */ |
|
| 100 | + /** |
|
| 101 | + * Parses the code from a file. |
|
| 102 | + * |
|
| 103 | + * @param string $path |
|
| 104 | + * @throws Localization_Exception |
|
| 105 | + */ |
|
| 106 | 106 | public function parseFile(string $path) : void |
| 107 | 107 | { |
| 108 | 108 | if(!file_exists($path)) |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | ); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * Parses a source code string. |
|
| 140 | - * @param string $content |
|
| 141 | - */ |
|
| 138 | + /** |
|
| 139 | + * Parses a source code string. |
|
| 140 | + * @param string $content |
|
| 141 | + */ |
|
| 142 | 142 | public function parseString($content) : void |
| 143 | 143 | { |
| 144 | 144 | $this->content = $content; |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | $this->texts[] = new Text($text, $line, $explanation); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Retrieves a list of all the function names that are |
|
| 184 | - * used as translation functions in the language. |
|
| 185 | - * @return array |
|
| 186 | - */ |
|
| 182 | + /** |
|
| 183 | + * Retrieves a list of all the function names that are |
|
| 184 | + * used as translation functions in the language. |
|
| 185 | + * @return array |
|
| 186 | + */ |
|
| 187 | 187 | public function getFunctionNames() : array |
| 188 | 188 | { |
| 189 | 189 | return $this->createToken('dummy')->getFunctionNames(); |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | Localization::log(sprintf('%1$s parser | %2$s', $this->getID(), $message)); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * Adds a warning message when a text cannot be parsed correctly for some reason. |
|
| 199 | - * |
|
| 200 | - * @param Localization_Parser_Token $token |
|
| 201 | - * @param string $message |
|
| 202 | - * @return Localization_Parser_Warning |
|
| 203 | - */ |
|
| 197 | + /** |
|
| 198 | + * Adds a warning message when a text cannot be parsed correctly for some reason. |
|
| 199 | + * |
|
| 200 | + * @param Localization_Parser_Token $token |
|
| 201 | + * @param string $message |
|
| 202 | + * @return Localization_Parser_Warning |
|
| 203 | + */ |
|
| 204 | 204 | protected function addWarning(Localization_Parser_Token $token, string $message) : Localization_Parser_Warning |
| 205 | 205 | { |
| 206 | 206 | $warning = new Localization_Parser_Warning($this, $token, $message); |
@@ -210,34 +210,34 @@ discard block |
||
| 210 | 210 | return $warning; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Whether any warnings were generated during parsing. |
|
| 215 | - * @return bool |
|
| 216 | - */ |
|
| 213 | + /** |
|
| 214 | + * Whether any warnings were generated during parsing. |
|
| 215 | + * @return bool |
|
| 216 | + */ |
|
| 217 | 217 | public function hasWarnings() : bool |
| 218 | 218 | { |
| 219 | 219 | return !empty($this->warnings); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Retrieves all warnings that were generated during parsing, |
|
| 224 | - * if any. |
|
| 225 | - * |
|
| 226 | - * @return Localization_Parser_Warning[] |
|
| 227 | - */ |
|
| 222 | + /** |
|
| 223 | + * Retrieves all warnings that were generated during parsing, |
|
| 224 | + * if any. |
|
| 225 | + * |
|
| 226 | + * @return Localization_Parser_Warning[] |
|
| 227 | + */ |
|
| 228 | 228 | public function getWarnings() : array |
| 229 | 229 | { |
| 230 | 230 | return $this->warnings; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * Creates a token instance: this retrieves information on |
|
| 235 | - * the language token being parsed. |
|
| 236 | - * |
|
| 237 | - * @param array|string $definition The token definition. |
|
| 238 | - * @param Localization_Parser_Token|NULL $parentToken |
|
| 239 | - * @return Localization_Parser_Token |
|
| 240 | - */ |
|
| 233 | + /** |
|
| 234 | + * Creates a token instance: this retrieves information on |
|
| 235 | + * the language token being parsed. |
|
| 236 | + * |
|
| 237 | + * @param array|string $definition The token definition. |
|
| 238 | + * @param Localization_Parser_Token|NULL $parentToken |
|
| 239 | + * @return Localization_Parser_Token |
|
| 240 | + */ |
|
| 241 | 241 | protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token |
| 242 | 242 | { |
| 243 | 243 | $class = Localization_Parser_Token::class.'_'.$this->getID(); |
@@ -245,12 +245,12 @@ discard block |
||
| 245 | 245 | return new $class($definition, $parentToken); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - /** |
|
| 249 | - * Parses a translation function token. |
|
| 250 | - * |
|
| 251 | - * @param int $number |
|
| 252 | - * @param Localization_Parser_Token $token |
|
| 253 | - */ |
|
| 248 | + /** |
|
| 249 | + * Parses a translation function token. |
|
| 250 | + * |
|
| 251 | + * @param int $number |
|
| 252 | + * @param Localization_Parser_Token $token |
|
| 253 | + */ |
|
| 254 | 254 | protected function parseToken(int $number, Localization_Parser_Token $token) : void |
| 255 | 255 | { |
| 256 | 256 | $textParts = array(); |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | const SERIALIZED_PROPERTIES = 'properties'; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * @var Localization_Scanner_StringsCollection |
|
| 16 | - */ |
|
| 15 | + * @var Localization_Scanner_StringsCollection |
|
| 16 | + */ |
|
| 17 | 17 | protected $collection; |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -12,19 +12,19 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | const STORAGE_FORMAT_VERSION = 2; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var Localization_Scanner |
|
| 17 | - */ |
|
| 15 | + /** |
|
| 16 | + * @var Localization_Scanner |
|
| 17 | + */ |
|
| 18 | 18 | protected $scanner; |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var Localization_Scanner_StringHash[] |
|
| 22 | - */ |
|
| 20 | + /** |
|
| 21 | + * @var Localization_Scanner_StringHash[] |
|
| 22 | + */ |
|
| 23 | 23 | protected $hashes = array(); |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var array |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var array |
|
| 27 | + */ |
|
| 28 | 28 | protected $warnings = array(); |
| 29 | 29 | |
| 30 | 30 | public function __construct(Localization_Scanner $scanner) |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | return new Localization_Scanner_StringInfo($this, $sourceID, $sourceType, $text); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Adds a single translateable string. |
|
| 57 | - * |
|
| 58 | - * @param Localization_Scanner_StringInfo $string |
|
| 59 | - * @return Localization_Scanner_StringsCollection |
|
| 60 | - */ |
|
| 55 | + /** |
|
| 56 | + * Adds a single translateable string. |
|
| 57 | + * |
|
| 58 | + * @param Localization_Scanner_StringInfo $string |
|
| 59 | + * @return Localization_Scanner_StringsCollection |
|
| 60 | + */ |
|
| 61 | 61 | protected function add(Localization_Scanner_StringInfo $string) : Localization_Scanner_StringsCollection |
| 62 | 62 | { |
| 63 | 63 | $hash = $string->getHash(); |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Retrieves all available translateable strings, |
|
| 75 | - * grouped by their hash to identify unique strings. |
|
| 76 | - * |
|
| 77 | - * @return Localization_Scanner_StringHash[] |
|
| 78 | - */ |
|
| 73 | + /** |
|
| 74 | + * Retrieves all available translateable strings, |
|
| 75 | + * grouped by their hash to identify unique strings. |
|
| 76 | + * |
|
| 77 | + * @return Localization_Scanner_StringHash[] |
|
| 78 | + */ |
|
| 79 | 79 | public function getHashes() : array |
| 80 | 80 | { |
| 81 | 81 | return array_values($this->hashes); |
@@ -139,32 +139,32 @@ discard block |
||
| 139 | 139 | return true; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Whether the parser reported warnings during the |
|
| 144 | - * search for translateable texts. |
|
| 145 | - * |
|
| 146 | - * @return bool |
|
| 147 | - */ |
|
| 142 | + /** |
|
| 143 | + * Whether the parser reported warnings during the |
|
| 144 | + * search for translateable texts. |
|
| 145 | + * |
|
| 146 | + * @return bool |
|
| 147 | + */ |
|
| 148 | 148 | public function hasWarnings() : bool |
| 149 | 149 | { |
| 150 | 150 | return !empty($this->warnings); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Retrieves the amount of warnings. |
|
| 155 | - * @return int |
|
| 156 | - */ |
|
| 153 | + /** |
|
| 154 | + * Retrieves the amount of warnings. |
|
| 155 | + * @return int |
|
| 156 | + */ |
|
| 157 | 157 | public function countWarnings() : int |
| 158 | 158 | { |
| 159 | 159 | return count($this->warnings); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Retrieves all warning messages that were added |
|
| 164 | - * during the search for translateable texts, if any. |
|
| 165 | - * |
|
| 166 | - * @return Localization_Scanner_StringsCollection_Warning[] |
|
| 167 | - */ |
|
| 162 | + /** |
|
| 163 | + * Retrieves all warning messages that were added |
|
| 164 | + * during the search for translateable texts, if any. |
|
| 165 | + * |
|
| 166 | + * @return Localization_Scanner_StringsCollection_Warning[] |
|
| 167 | + */ |
|
| 168 | 168 | public function getWarnings() : array |
| 169 | 169 | { |
| 170 | 170 | $result = array(); |
@@ -191,12 +191,12 @@ discard block |
||
| 191 | 191 | return $amount; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Retrieves all string hashed for the specified source. |
|
| 196 | - * |
|
| 197 | - * @param string $id |
|
| 198 | - * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
| 199 | - */ |
|
| 194 | + /** |
|
| 195 | + * Retrieves all string hashed for the specified source. |
|
| 196 | + * |
|
| 197 | + * @param string $id |
|
| 198 | + * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
| 199 | + */ |
|
| 200 | 200 | public function getHashesBySourceID(string $id) |
| 201 | 201 | { |
| 202 | 202 | $hashes = array(); |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | return $hashes; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Retrieves all hashes for the specified language ID. |
|
| 215 | - * |
|
| 216 | - * @param string $languageID The language ID, e.g. "PHP" |
|
| 217 | - * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
| 218 | - */ |
|
| 213 | + /** |
|
| 214 | + * Retrieves all hashes for the specified language ID. |
|
| 215 | + * |
|
| 216 | + * @param string $languageID The language ID, e.g. "PHP" |
|
| 217 | + * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
| 218 | + */ |
|
| 219 | 219 | public function getHashesByLanguageID(string $languageID) |
| 220 | 220 | { |
| 221 | 221 | $hashes = array(); |
@@ -36,54 +36,54 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | const ERROR_NO_SOURCES_AVAILABLE = 40001; |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var string |
|
| 41 | - */ |
|
| 39 | + /** |
|
| 40 | + * @var string |
|
| 41 | + */ |
|
| 42 | 42 | protected $installPath; |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var Localization_Source[] |
|
| 46 | - */ |
|
| 44 | + /** |
|
| 45 | + * @var Localization_Source[] |
|
| 46 | + */ |
|
| 47 | 47 | protected $sources; |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var \AppUtils\Request |
|
| 51 | - */ |
|
| 49 | + /** |
|
| 50 | + * @var \AppUtils\Request |
|
| 51 | + */ |
|
| 52 | 52 | protected $request; |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var Localization_Source |
|
| 56 | - */ |
|
| 54 | + /** |
|
| 55 | + * @var Localization_Source |
|
| 56 | + */ |
|
| 57 | 57 | protected $activeSource; |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @var Localization_Scanner |
|
| 61 | - */ |
|
| 59 | + /** |
|
| 60 | + * @var Localization_Scanner |
|
| 61 | + */ |
|
| 62 | 62 | protected $scanner; |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @var Localization_Locale[] |
|
| 66 | - */ |
|
| 64 | + /** |
|
| 65 | + * @var Localization_Locale[] |
|
| 66 | + */ |
|
| 67 | 67 | protected $appLocales = array(); |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @var Localization_Locale |
|
| 71 | - */ |
|
| 69 | + /** |
|
| 70 | + * @var Localization_Locale |
|
| 71 | + */ |
|
| 72 | 72 | protected $activeAppLocale; |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @var Localization_Editor_Filters |
|
| 76 | - */ |
|
| 74 | + /** |
|
| 75 | + * @var Localization_Editor_Filters |
|
| 76 | + */ |
|
| 77 | 77 | protected $filters; |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @var string[]string |
|
| 81 | - */ |
|
| 79 | + /** |
|
| 80 | + * @var string[]string |
|
| 81 | + */ |
|
| 82 | 82 | protected $requestParams = array(); |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @var string |
|
| 86 | - */ |
|
| 84 | + /** |
|
| 85 | + * @var string |
|
| 86 | + */ |
|
| 87 | 87 | protected $varPrefix = 'applocalize_'; |
| 88 | 88 | |
| 89 | 89 | public function __construct() |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | return $this->request; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Adds a request parameter that will be persisted in all URLs |
|
| 107 | - * within the editor. This can be used when integrating the |
|
| 108 | - * editor in an existing page that needs specific request params. |
|
| 109 | - * |
|
| 110 | - * @param string $name |
|
| 111 | - * @param string $value |
|
| 112 | - * @return Localization_Editor |
|
| 113 | - */ |
|
| 105 | + /** |
|
| 106 | + * Adds a request parameter that will be persisted in all URLs |
|
| 107 | + * within the editor. This can be used when integrating the |
|
| 108 | + * editor in an existing page that needs specific request params. |
|
| 109 | + * |
|
| 110 | + * @param string $name |
|
| 111 | + * @param string $value |
|
| 112 | + * @return Localization_Editor |
|
| 113 | + */ |
|
| 114 | 114 | public function addRequestParam(string $name, string $value) : Localization_Editor |
| 115 | 115 | { |
| 116 | 116 | $this->requestParams[$name] = $value; |
@@ -264,34 +264,34 @@ discard block |
||
| 264 | 264 | </a> |
| 265 | 265 | <div class="dropdown-menu" aria-labelledby="dropdown01"> |
| 266 | 266 | <?php |
| 267 | - foreach($this->sources as $source) |
|
| 268 | - { |
|
| 269 | - ?> |
|
| 267 | + foreach($this->sources as $source) |
|
| 268 | + { |
|
| 269 | + ?> |
|
| 270 | 270 | <a class="dropdown-item" href="<?php echo $this->getSourceURL($source) ?>"> |
| 271 | 271 | <?php |
| 272 | - if($source->getID() === $this->activeSource->getID()) |
|
| 273 | - { |
|
| 274 | - ?> |
|
| 272 | + if($source->getID() === $this->activeSource->getID()) |
|
| 273 | + { |
|
| 274 | + ?> |
|
| 275 | 275 | <b><?php echo $source->getLabel() ?></b> |
| 276 | 276 | <?php |
| 277 | - } |
|
| 278 | - else |
|
| 279 | - { |
|
| 280 | - echo $source->getLabel(); |
|
| 281 | - } |
|
| 282 | - ?> |
|
| 277 | + } |
|
| 278 | + else |
|
| 279 | + { |
|
| 280 | + echo $source->getLabel(); |
|
| 281 | + } |
|
| 282 | + ?> |
|
| 283 | 283 | <?php |
| 284 | - $untranslated = $source->countUntranslated($this->scanner); |
|
| 285 | - if($untranslated > 0) { |
|
| 286 | - ?> |
|
| 284 | + $untranslated = $source->countUntranslated($this->scanner); |
|
| 285 | + if($untranslated > 0) { |
|
| 286 | + ?> |
|
| 287 | 287 | (<span class="text-danger" title="<?php ptex('%1$s texts have not been translated in this text source.', 'Amount of texts', $untranslated) ?>"><?php echo $untranslated ?></span>) |
| 288 | 288 | <?php |
| 289 | - } |
|
| 290 | - ?> |
|
| 289 | + } |
|
| 290 | + ?> |
|
| 291 | 291 | </a> |
| 292 | 292 | <?php |
| 293 | - } |
|
| 294 | - ?> |
|
| 293 | + } |
|
| 294 | + ?> |
|
| 295 | 295 | </div> |
| 296 | 296 | </li> |
| 297 | 297 | <li class="nav-item dropdown"> |
@@ -300,15 +300,15 @@ discard block |
||
| 300 | 300 | </a> |
| 301 | 301 | <div class="dropdown-menu" aria-labelledby="dropdown01"> |
| 302 | 302 | <?php |
| 303 | - foreach($this->appLocales as $locale) |
|
| 304 | - { |
|
| 305 | - ?> |
|
| 303 | + foreach($this->appLocales as $locale) |
|
| 304 | + { |
|
| 305 | + ?> |
|
| 306 | 306 | <a class="dropdown-item" href="<?php echo $this->getLocaleURL($locale) ?>"> |
| 307 | 307 | <?php echo $locale->getLabel() ?> |
| 308 | 308 | </a> |
| 309 | 309 | <?php |
| 310 | - } |
|
| 311 | - ?> |
|
| 310 | + } |
|
| 311 | + ?> |
|
| 312 | 312 | </div> |
| 313 | 313 | </li> |
| 314 | 314 | <li class="nav-item"> |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | </a> |
| 319 | 319 | </li> |
| 320 | 320 | <?php |
| 321 | - if($this->scanner->hasWarnings()) { |
|
| 322 | - ?> |
|
| 321 | + if($this->scanner->hasWarnings()) { |
|
| 322 | + ?> |
|
| 323 | 323 | <li class="nav-item"> |
| 324 | 324 | <a href="<?php echo $this->getWarningsURL() ?>"> |
| 325 | 325 | <span class="badge badge-warning" title="<?php pts('The last scan for translateable texts reported warnings.'); pts('Click for details.'); ?>" data-toggle="tooltip"> |
@@ -329,8 +329,8 @@ discard block |
||
| 329 | 329 | </a> |
| 330 | 330 | </li> |
| 331 | 331 | <?php |
| 332 | - } |
|
| 333 | - ?> |
|
| 332 | + } |
|
| 333 | + ?> |
|
| 334 | 334 | </ul> |
| 335 | 335 | <?php |
| 336 | 336 | } |
@@ -346,36 +346,36 @@ discard block |
||
| 346 | 346 | </a> |
| 347 | 347 | <?php |
| 348 | 348 | } |
| 349 | - ?> |
|
| 349 | + ?> |
|
| 350 | 350 | </div> |
| 351 | 351 | </nav> |
| 352 | 352 | <main role="main" class="container"> |
| 353 | 353 | <div> |
| 354 | 354 | <?php |
| 355 | - if(empty($this->appLocales)) |
|
| 356 | - { |
|
| 357 | - ?> |
|
| 355 | + if(empty($this->appLocales)) |
|
| 356 | + { |
|
| 357 | + ?> |
|
| 358 | 358 | <div class="alert alert-danger"> |
| 359 | 359 | <i class="fa fa-exclamation-triangle"></i> |
| 360 | 360 | <b><?php pt('Nothing to translate:') ?></b> |
| 361 | 361 | <?php pt('No application locales were added to translate to.') ?> |
| 362 | 362 | </div> |
| 363 | 363 | <?php |
| 364 | - } |
|
| 365 | - else if($this->request->getBool($this->getVarName('warnings'))) |
|
| 366 | - { |
|
| 367 | - echo $this->renderWarnings(); |
|
| 368 | - } |
|
| 369 | - else |
|
| 370 | - { |
|
| 371 | - ?> |
|
| 364 | + } |
|
| 365 | + else if($this->request->getBool($this->getVarName('warnings'))) |
|
| 366 | + { |
|
| 367 | + echo $this->renderWarnings(); |
|
| 368 | + } |
|
| 369 | + else |
|
| 370 | + { |
|
| 371 | + ?> |
|
| 372 | 372 | <h1><?php echo $this->activeSource->getLabel() ?></h1> |
| 373 | 373 | <?php |
| 374 | - if(!empty($_SESSION['localization_messages'])) |
|
| 375 | - { |
|
| 376 | - foreach($_SESSION['localization_messages'] as $def) |
|
| 377 | - { |
|
| 378 | - ?> |
|
| 374 | + if(!empty($_SESSION['localization_messages'])) |
|
| 375 | + { |
|
| 376 | + foreach($_SESSION['localization_messages'] as $def) |
|
| 377 | + { |
|
| 378 | + ?> |
|
| 379 | 379 | <div class="alert alert-<?php echo $def['type'] ?>" role="alert"> |
| 380 | 380 | <?php echo $def['text'] ?> |
| 381 | 381 | <button type="button" class="close" data-dismiss="alert" aria-label="<?php pt('Close') ?>" title="<?php pt('Dismiss this message.') ?>" data-toggle="tooltip"> |
@@ -383,28 +383,28 @@ discard block |
||
| 383 | 383 | </button> |
| 384 | 384 | </div> |
| 385 | 385 | <?php |
| 386 | - } |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - // reset the messages after having displayed them |
|
| 389 | - $_SESSION['localization_messages'] = array(); |
|
| 390 | - } |
|
| 391 | - ?> |
|
| 388 | + // reset the messages after having displayed them |
|
| 389 | + $_SESSION['localization_messages'] = array(); |
|
| 390 | + } |
|
| 391 | + ?> |
|
| 392 | 392 | <p> |
| 393 | 393 | <?php |
| 394 | - pt( |
|
| 395 | - 'You are translating to %1$s', |
|
| 396 | - '<span class="badge badge-info">'. |
|
| 397 | - $this->activeAppLocale->getLabel(). |
|
| 398 | - '</span>' |
|
| 394 | + pt( |
|
| 395 | + 'You are translating to %1$s', |
|
| 396 | + '<span class="badge badge-info">'. |
|
| 397 | + $this->activeAppLocale->getLabel(). |
|
| 398 | + '</span>' |
|
| 399 | 399 | ); |
| 400 | - ?><br> |
|
| 400 | + ?><br> |
|
| 401 | 401 | <?php pt('Found %1$s texts to translate.', $this->activeSource->countUntranslated($this->scanner)) ?> |
| 402 | 402 | </p> |
| 403 | 403 | <br> |
| 404 | 404 | <?php |
| 405 | - if(!$this->scanner->isScanAvailable()) |
|
| 406 | - { |
|
| 407 | - ?> |
|
| 405 | + if(!$this->scanner->isScanAvailable()) |
|
| 406 | + { |
|
| 407 | + ?> |
|
| 408 | 408 | <div class="alert alert-primary" role="alert"> |
| 409 | 409 | <b><?php pt('No texts found:') ?></b> |
| 410 | 410 | <?php pt('The source folders have not been scanned yet.') ?> |
@@ -416,15 +416,15 @@ discard block |
||
| 416 | 416 | </a> |
| 417 | 417 | </p> |
| 418 | 418 | <?php |
| 419 | - } |
|
| 420 | - else |
|
| 421 | - { |
|
| 422 | - echo $this->filters->renderForm(); |
|
| 423 | - echo $this->renderList(); |
|
| 424 | - } |
|
| 419 | + } |
|
| 420 | + else |
|
| 421 | + { |
|
| 422 | + echo $this->filters->renderForm(); |
|
| 423 | + echo $this->renderList(); |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - } |
|
| 427 | - ?> |
|
| 426 | + } |
|
| 427 | + ?> |
|
| 428 | 428 | </div> |
| 429 | 429 | </main> |
| 430 | 430 | </body> |
@@ -442,22 +442,22 @@ discard block |
||
| 442 | 442 | <h1><?php pt('Warnings') ?></h1> |
| 443 | 443 | <p class="abstract"> |
| 444 | 444 | <?php |
| 445 | - pts('The following shows all texts where the system decided that they cannot be translated.'); |
|
| 446 | - ?> |
|
| 445 | + pts('The following shows all texts where the system decided that they cannot be translated.'); |
|
| 446 | + ?> |
|
| 447 | 447 | </p> |
| 448 | 448 | <dl> |
| 449 | 449 | <?php |
| 450 | - $warnings = $this->scanner->getWarnings(); |
|
| 450 | + $warnings = $this->scanner->getWarnings(); |
|
| 451 | 451 | |
| 452 | - foreach($warnings as $warning) |
|
| 453 | - { |
|
| 454 | - ?> |
|
| 452 | + foreach($warnings as $warning) |
|
| 453 | + { |
|
| 454 | + ?> |
|
| 455 | 455 | <dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt> |
| 456 | 456 | <dd><?php echo $warning->getMessage() ?></dd> |
| 457 | 457 | <?php |
| 458 | - } |
|
| 458 | + } |
|
| 459 | 459 | |
| 460 | - ?> |
|
| 460 | + ?> |
|
| 461 | 461 | </dl> |
| 462 | 462 | <?php |
| 463 | 463 | |
@@ -526,13 +526,13 @@ discard block |
||
| 526 | 526 | <form method="post"> |
| 527 | 527 | <div class="form-hiddens"> |
| 528 | 528 | <?php |
| 529 | - $params = $this->getRequestParams(); |
|
| 530 | - foreach($params as $name => $value) { |
|
| 531 | - ?> |
|
| 529 | + $params = $this->getRequestParams(); |
|
| 530 | + foreach($params as $name => $value) { |
|
| 531 | + ?> |
|
| 532 | 532 | <input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>"> |
| 533 | 533 | <?php |
| 534 | - } |
|
| 535 | - ?> |
|
| 534 | + } |
|
| 535 | + ?> |
|
| 536 | 536 | </div> |
| 537 | 537 | <table class="table table-hover"> |
| 538 | 538 | <thead> |
@@ -545,20 +545,20 @@ discard block |
||
| 545 | 545 | </thead> |
| 546 | 546 | <tbody> |
| 547 | 547 | <?php |
| 548 | - foreach($keep as $string) |
|
| 549 | - { |
|
| 550 | - $this->renderListEntry($string); |
|
| 551 | - } |
|
| 552 | - ?> |
|
| 548 | + foreach($keep as $string) |
|
| 549 | + { |
|
| 550 | + $this->renderListEntry($string); |
|
| 551 | + } |
|
| 552 | + ?> |
|
| 553 | 553 | </tbody> |
| 554 | 554 | </table> |
| 555 | 555 | <?php |
| 556 | - if($pager->hasPages()) |
|
| 557 | - { |
|
| 558 | - $prevUrl = $this->getPaginationURL($pager->getPreviousPage()); |
|
| 559 | - $nextUrl = $this->getPaginationURL($pager->getNextPage()); |
|
| 556 | + if($pager->hasPages()) |
|
| 557 | + { |
|
| 558 | + $prevUrl = $this->getPaginationURL($pager->getPreviousPage()); |
|
| 559 | + $nextUrl = $this->getPaginationURL($pager->getNextPage()); |
|
| 560 | 560 | |
| 561 | - ?> |
|
| 561 | + ?> |
|
| 562 | 562 | <nav aria-label="<?php pt('Navigate available pages of texts.') ?>"> |
| 563 | 563 | <ul class="pagination"> |
| 564 | 564 | <li class="page-item"> |
@@ -567,20 +567,20 @@ discard block |
||
| 567 | 567 | </a> |
| 568 | 568 | </li> |
| 569 | 569 | <?php |
| 570 | - $numbers = $pager->getPageNumbers(); |
|
| 571 | - foreach($numbers as $number) |
|
| 572 | - { |
|
| 573 | - $url = $this->getPaginationURL($number); |
|
| 570 | + $numbers = $pager->getPageNumbers(); |
|
| 571 | + foreach($numbers as $number) |
|
| 572 | + { |
|
| 573 | + $url = $this->getPaginationURL($number); |
|
| 574 | 574 | |
| 575 | - ?> |
|
| 575 | + ?> |
|
| 576 | 576 | <li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>"> |
| 577 | 577 | <a class="page-link" href="<?php echo $url ?>"> |
| 578 | 578 | <?php echo $number ?> |
| 579 | 579 | </a> |
| 580 | 580 | </li> |
| 581 | 581 | <?php |
| 582 | - } |
|
| 583 | - ?> |
|
| 582 | + } |
|
| 583 | + ?> |
|
| 584 | 584 | <li class="page-item"> |
| 585 | 585 | <a class="page-link" href="<?php echo $nextUrl ?>"> |
| 586 | 586 | <i class="fa fa-arrow-right"></i> |
@@ -589,8 +589,8 @@ discard block |
||
| 589 | 589 | </ul> |
| 590 | 590 | </nav> |
| 591 | 591 | <?php |
| 592 | - } |
|
| 593 | - ?> |
|
| 592 | + } |
|
| 593 | + ?> |
|
| 594 | 594 | <br> |
| 595 | 595 | <p> |
| 596 | 596 | <button type="submit" name="<?php echo $this->getVarName('save') ?>" value="yes" class="btn btn-primary"> |
@@ -661,48 +661,48 @@ discard block |
||
| 661 | 661 | <div class="files-list"> |
| 662 | 662 | <p> |
| 663 | 663 | <?php |
| 664 | - $totalFiles = count($files); |
|
| 664 | + $totalFiles = count($files); |
|
| 665 | 665 | |
| 666 | - if($totalFiles == 1) |
|
| 667 | - { |
|
| 668 | - pt('Found in a single file:'); |
|
| 669 | - } |
|
| 670 | - else |
|
| 671 | - { |
|
| 672 | - pt('Found in %1$s files:', $totalFiles); |
|
| 673 | - } |
|
| 674 | - ?> |
|
| 666 | + if($totalFiles == 1) |
|
| 667 | + { |
|
| 668 | + pt('Found in a single file:'); |
|
| 669 | + } |
|
| 670 | + else |
|
| 671 | + { |
|
| 672 | + pt('Found in %1$s files:', $totalFiles); |
|
| 673 | + } |
|
| 674 | + ?> |
|
| 675 | 675 | </p> |
| 676 | 676 | <div class="files-scroller"> |
| 677 | 677 | <ul> |
| 678 | 678 | <?php |
| 679 | - $locations = $string->getStrings(); |
|
| 679 | + $locations = $string->getStrings(); |
|
| 680 | 680 | |
| 681 | - foreach($locations as $location) |
|
| 682 | - { |
|
| 683 | - $file = $location->getSourceFile(); |
|
| 684 | - $line = $location->getLine(); |
|
| 681 | + foreach($locations as $location) |
|
| 682 | + { |
|
| 683 | + $file = $location->getSourceFile(); |
|
| 684 | + $line = $location->getLine(); |
|
| 685 | 685 | |
| 686 | - $icon = ''; |
|
| 686 | + $icon = ''; |
|
| 687 | 687 | |
| 688 | - $ext = \AppUtils\FileHelper::getExtension($file); |
|
| 688 | + $ext = \AppUtils\FileHelper::getExtension($file); |
|
| 689 | 689 | |
| 690 | - if($ext == 'php') { |
|
| 691 | - $icon = 'fab fa-php'; |
|
| 692 | - } else if($ext == 'js') { |
|
| 693 | - $icon = 'fab fa-js-square'; |
|
| 694 | - } else { |
|
| 695 | - $icon = 'fas fa-file-code'; |
|
| 696 | - } |
|
| 690 | + if($ext == 'php') { |
|
| 691 | + $icon = 'fab fa-php'; |
|
| 692 | + } else if($ext == 'js') { |
|
| 693 | + $icon = 'fab fa-js-square'; |
|
| 694 | + } else { |
|
| 695 | + $icon = 'fas fa-file-code'; |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | - ?> |
|
| 698 | + ?> |
|
| 699 | 699 | <li> |
| 700 | 700 | <i class="<?php echo $icon ?>"></i> |
| 701 | 701 | <?php echo $file ?><span class="line-number">:<?php echo $line ?></span> |
| 702 | 702 | </li> |
| 703 | 703 | <?php |
| 704 | - } |
|
| 705 | - ?> |
|
| 704 | + } |
|
| 705 | + ?> |
|
| 706 | 706 | </ul> |
| 707 | 707 | </div> |
| 708 | 708 | </div> |
@@ -912,13 +912,13 @@ discard block |
||
| 912 | 912 | ); |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - /** |
|
| 916 | - * Sets the application name shown in the main navigation |
|
| 917 | - * in the user interface. |
|
| 918 | - * |
|
| 919 | - * @param string $name |
|
| 920 | - * @return Localization_Editor |
|
| 921 | - */ |
|
| 915 | + /** |
|
| 916 | + * Sets the application name shown in the main navigation |
|
| 917 | + * in the user interface. |
|
| 918 | + * |
|
| 919 | + * @param string $name |
|
| 920 | + * @return Localization_Editor |
|
| 921 | + */ |
|
| 922 | 922 | public function setAppName(string $name) : Localization_Editor |
| 923 | 923 | { |
| 924 | 924 | $this->setOption('appname', $name); |
@@ -935,27 +935,27 @@ discard block |
||
| 935 | 935 | return t('Localization editor'); |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | - /** |
|
| 939 | - * Selects the default source to use if none has been |
|
| 940 | - * explicitly selected. |
|
| 941 | - * |
|
| 942 | - * @param string $sourceID |
|
| 943 | - */ |
|
| 938 | + /** |
|
| 939 | + * Selects the default source to use if none has been |
|
| 940 | + * explicitly selected. |
|
| 941 | + * |
|
| 942 | + * @param string $sourceID |
|
| 943 | + */ |
|
| 944 | 944 | public function selectDefaultSource(string $sourceID) : Localization_Editor |
| 945 | 945 | { |
| 946 | 946 | $this->setOption('default-source', $sourceID); |
| 947 | 947 | return $this; |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | - /** |
|
| 951 | - * Sets an URL that the translators can use to go back to |
|
| 952 | - * the main application, for example if it is integrated into |
|
| 953 | - * an existing application. |
|
| 954 | - * |
|
| 955 | - * @param string $url The URL to use for the link |
|
| 956 | - * @param string $label Label of the link |
|
| 957 | - * @return Localization_Editor |
|
| 958 | - */ |
|
| 950 | + /** |
|
| 951 | + * Sets an URL that the translators can use to go back to |
|
| 952 | + * the main application, for example if it is integrated into |
|
| 953 | + * an existing application. |
|
| 954 | + * |
|
| 955 | + * @param string $url The URL to use for the link |
|
| 956 | + * @param string $label Label of the link |
|
| 957 | + * @return Localization_Editor |
|
| 958 | + */ |
|
| 959 | 959 | public function setBackURL(string $url, string $label) : Localization_Editor |
| 960 | 960 | { |
| 961 | 961 | $this->setOption('back-url', $url); |