Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/73577


Change subject: Added lingo support for ApprovedRevs. To enable feature use
......................................................................

Added lingo support for ApprovedRevs. To enable feature use

Change-Id: I45bf91f4f5e76c78bf72164b0148e79418d7157d
---
M Lingo.php
A LingoApprovedRevs.php
M LingoBasicBackend.php
3 files changed, 48 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/77/73577/1

diff --git a/Lingo.php b/Lingo.php
index 4e29ab4..e5f3641 100644
--- a/Lingo.php
+++ b/Lingo.php
@@ -43,6 +43,9 @@
 // set default cache type (null = use main cache)
 $wgexLingoCacheType = null;
 
+//use approved revs extension
+$wgLingoEnableApprovedRevs = false;
+
 // set extension credits
 // (no description here, will be set later)
 $wgExtensionCredits['parserhook']['lingo'] = array(
@@ -68,6 +71,7 @@
 $wgAutoloadClasses['LingoBackend'] = $dir . '/LingoBackend.php';
 $wgAutoloadClasses['LingoBasicBackend'] = $dir . '/LingoBasicBackend.php';
 $wgAutoloadClasses['LingoMessageLog'] = $dir . '/LingoMessageLog.php';
+$wgAutoloadClasses['LingoApprovedRevs'] = $dir . '/LingoApprovedRevs.php';
 
 // register hook handlers
 $wgHooks['SpecialVersionExtensionTypes'][] = 'LingoHooks::setCredits'; // set 
credits
diff --git a/LingoApprovedRevs.php b/LingoApprovedRevs.php
new file mode 100644
index 0000000..b85f89d
--- /dev/null
+++ b/LingoApprovedRevs.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Class for connection ApprovedRevs with Lingo
+ */
+if ( !defined( 'APPROVED_REVS_VERSION' ) ) {
+               die( 'Support for ApprovedRevs is enabled in Lingo. But 
ApprovedRevs was not found.' );
+}
+
+/*
+ * Returns revision of Terminology page approved by ApprovedRevs
+ */
+class LingoApprovedRevs
+{
+       public function __construct() { }
+
+       public static function getApprovedTerms( $title )
+       {
+               $article_id = $title->getArticleID();
+
+               $dbr = wfGetDB( DB_SLAVE );
+               $res = $dbr->select(
+                       'approved_revs',
+                       '*',
+                       array( 'page_id' => $article_id ),
+                       __METHOD__
+               );
+
+               foreach ( $res as $row ) {
+                       $id = $row->rev_id;
+                       $rev = Revision::newFromId( $id );
+                       return $rev;
+               }
+
+               return null;
+       }
+}
diff --git a/LingoBasicBackend.php b/LingoBasicBackend.php
index 6c1fba3..ac1cd21 100644
--- a/LingoBasicBackend.php
+++ b/LingoBasicBackend.php
@@ -22,7 +22,7 @@
 
        public function __construct( LingoMessageLog &$messages = null ) {
 
-               global $wgexLingoPage, $wgRequest;
+               global $wgexLingoPage, $wgRequest, $wgLingoEnableApprovedRevs;
 
                $page = $wgexLingoPage ? $wgexLingoPage : wfMsgForContent( 
'lingo-terminologypagename' );
 
@@ -35,6 +35,7 @@
                        return false;
                }
 
+               //$lingoApprovedRevs->getApprovedTerms($title);
                // FIXME: This is a hack special-casing the submitting of the 
terminology
                // page itself. In this case the Revision is not up to date 
when we get
                // here, i.e. $rev->getText() would return outdated Test.
@@ -46,7 +47,12 @@
 
                } else {
 
-                       $rev = Revision::newFromTitle( $title );
+                       if ( $wgLingoEnableApprovedRevs ) {
+                               $rev = LingoApprovedRevs::getApprovedTerms( 
$title );
+                       } else {
+                               $rev = Revision::newFromTitle( $title );
+                       }
+
                        if ( !$rev ) {
                                $this->getMessageLog()->addWarning( 
wfMsgForContent( 'lingo-noterminologypage', $page ) );
                                return false;

-- 
To view, visit https://gerrit.wikimedia.org/r/73577
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45bf91f4f5e76c78bf72164b0148e79418d7157d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Euvl <eu.vlase...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to