Foxtrott has submitted this change and it was merged.
Change subject: Minor rework of LingoParser
......................................................................
Minor rework of LingoParser
Change-Id: I5a92c1465d9c381910245cf44807f7df874ba1a2
---
M src/LingoParser.php
1 file changed, 19 insertions(+), 12 deletions(-)
Approvals:
Foxtrott: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/src/LingoParser.php b/src/LingoParser.php
index 6d4b5ce..da4d039 100644
--- a/src/LingoParser.php
+++ b/src/LingoParser.php
@@ -71,18 +71,8 @@
*/
public function parse( Parser &$parser, &$text ) {
- global $wgexLingoUseNamespaces;
-
- $title = $parser->getTitle();
-
// parse if
- if ( !isset( $parser->mDoubleUnderscores[ 'noglossary' ] ) &&
// __NOGLOSSARY__ not present and
- (
- !$title || // title not set or
- !isset( $wgexLingoUseNamespaces[
$title->getNamespace() ] ) || // namespace not explicitly forbidden (i.e. not
in list of namespaces and set to false) or
- $wgexLingoUseNamespaces[ $title->getNamespace()
] // namespace explicitly allowed
- )
- ) {
+ if ( $this->shouldParse( $parser ) ) {
// unstrip strip items of the 'general' group
// this will be done again by parse when this hook
returns, but it should not hurt to do this twice
@@ -90,7 +80,6 @@
$text = $parser->mStripState->unstripGeneral( $text );
$this->realParse( $parser, $text );
}
-
return true;
}
@@ -391,5 +380,23 @@
$this->mLingoBackend = $backend;
$backend->setLingoParser( $this );
}
+
+ /**
+ * @param Parser $parser
+ * @return bool
+ */
+ protected function shouldParse( Parser &$parser ) {
+ global $wgexLingoUseNamespaces;
+
+ $title = $parser->getTitle();
+ $namespace = $title->getNamespace();
+
+ return !isset( $parser->mDoubleUnderscores[ 'noglossary' ] ) &&
// __NOGLOSSARY__ not present and
+ (
+ !$title || // title not set (i.e. when text is outside
the page content) or
+ !isset( $wgexLingoUseNamespaces[ $namespace ] ) || //
namespace not explicitly forbidden (i.e. not in list of namespaces and set to
false) or
+ $wgexLingoUseNamespaces[ $namespace ] // namespace
explicitly allowed
+ );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/278697
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5a92c1465d9c381910245cf44807f7df874ba1a2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits