Rtdwivedi has uploaded a new change for review.

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


Change subject: Addition of code that will be used for setting up of editing 
system in PHP instead of JS.
......................................................................

Addition of code that will be used for setting up of editing system in PHP 
instead of JS.

Change-Id: I62b10d3d23d3282c36babdab364f4b97a6f2c85e
---
M ProofreadPage.body.php
M includes/page/EditProofreadPagePage.php
M includes/page/ProofreadPagePage.php
3 files changed, 72 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/33/72933/1

diff --git a/ProofreadPage.body.php b/ProofreadPage.body.php
index ddf91eb..1ec6a20 100644
--- a/ProofreadPage.body.php
+++ b/ProofreadPage.body.php
@@ -118,6 +118,17 @@
                }
        }
 
+       public static function setPageEditor( $article, $user ) {
+               global $request;
+               if ( $article->getTitle()->inNamespace( 
self::getPageNamespaceId() ) ) {
+                       $editor = new EditProofreadPagePage( $article );
+                       $editor->edit();
+                       return false;
+               } else {
+                       return true;
+               }
+       }
+
        /**
         * Set up our custom parser hooks when initializing parser.
         *
diff --git a/includes/page/EditProofreadPagePage.php 
b/includes/page/EditProofreadPagePage.php
index 82b1e65..319eb7e 100644
--- a/includes/page/EditProofreadPagePage.php
+++ b/includes/page/EditProofreadPagePage.php
@@ -19,7 +19,29 @@
  * @ingroup ProofreadPage
  */
 
-class EditProofreadPagePage {
+class EditProofreadPagePage extends EditPage{
+
+       protected function isSectionEditSupported() {
+               return false; // sections and forms don't mix
+       }
+
+       /**
+        * Init $this->textbox1 from form content
+        *
+        * @param $request WebRequest
+        */
+       protected function importContentFormData( &$request ) {
+
+               $value = ProofreadPageContent::newEmpty();
+               $value->setHeader( $this->safeUnicodeInput( $request, 
'wpHeaderTextbox' ) );
+               $value->setBody( $this->textbox1 );
+               $value->setFooter( $this->safeUnicodeInput( $request, 
'wpFooterTextbox' ) );
+               $value->setLevel( $request->getInt( 'wpQuality' ) );
+               $value->setProofreaderFromName( $this->safeUnicodeInput( 
$request, 'wpProofreader' ) );
+
+               $this->textbox1 = $value->serialize();
+               return true;
+       }
 
        /**
         * Preload text layer from multipage formats
@@ -197,4 +219,39 @@
 
                return true;
        }
+
+       protected function showContentForm() {
+               global $wgOut;
+
+               $pageLang = $this->mTitle->getPageLanguage();
+               $inputAttributes = array( 'lang' => $pageLang->getCode(), 'dir' 
=> $pageLang->getDir() );
+               if( wfReadOnly() === true ) {
+                       $inputAttributes['readonly'] = '';
+               }
+
+               $index = new ProofreadIndexPage( $this->mTitle, 
ProofreadIndexPage::getDataConfig(), $this->textbox1 );
+               $content = ProofreadPageContent::newFromWikiText( 
$this->textbox1 );
+               $page = new ProofreadPagePage( $this->mTitle, $content, $index 
);
+               $wgOut->addHTML( Html::textarea( 'wpTextBox1', $this->textbox1, 
array( 'tabindex' => '1', 'accesskey' =>',', 'id' => 'wpTextbox1', 'cols' => 
'80', 'rows' => '25', 'style' =>'', 'lang' => 'en', 'dir' => 'ltr' ) ) );
+       }
+
+       /**
+        * Check the validity of the page
+        */
+       function internalAttemptSave( &$result, $bot = false ) {
+               $index = new ProofreadIndexPage( $this->mTitle, 
ProofreadIndexPage::getDataConfig(), $this->textbox1 );
+               $content = ProofreadPageContent::newFromWikiText( 
$this->textbox1 );
+               $page = new ProofreadPagePage( $this->mTitle, $content, $index 
);
+
+               if ( $content->serialize != $this->textbox1 ) {
+                       $wgOut->showErrorPage( 'proofreadpage_pagexdupe', 
'proofreadpage_indexdupetext' );
+                       $status = Status::newGood();
+                       $status->fatal( 'hookaborted' );
+                       $status->value = self::AS_HOOK_ERROR;
+                       return $status;
+               }
+               return parent::internalAttemptSave( $result, $bot );
+       }
+
+       
 }
diff --git a/includes/page/ProofreadPagePage.php 
b/includes/page/ProofreadPagePage.php
index 004dc3c..6e62554 100644
--- a/includes/page/ProofreadPagePage.php
+++ b/includes/page/ProofreadPagePage.php
@@ -30,7 +30,7 @@
        protected $title;
 
        /**
-        * @var ProofreadPageContent content of the page
+        * @var string content of the page
         */
        protected $content;
 
@@ -127,9 +127,9 @@
                if ( $this->content === null ) {
                        $rev = Revision::newFromTitle( $this->title );
                        if ( $rev === null ) {
-                               $this->content = ProofreadPageValue::newEmpty();
+                               $this->content = 
ProofreadPageContent::newEmpty();
                        } else {
-                               $this->content = 
ProofreadPageValue::newFromWikitext( $rev->getText() );
+                               $this->content = 
ProofreadPageContent::newFromWikitext( $rev->getText() );
                        }
                }
                return $this->content;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I62b10d3d23d3282c36babdab364f4b97a6f2c85e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: pagePagesRefactoring
Gerrit-Owner: Rtdwivedi <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to