Rtdwivedi has uploaded a new change for review. https://gerrit.wikimedia.org/r/76891
Change subject: Added preliminary model of ViewProofreadPage class. ...................................................................... Added preliminary model of ViewProofreadPage class. Change-Id: I8b6482723ecf21ce5bb045130c3ac17d6c0d9ef2 --- A includes/page/ViewProofreadPage.php 1 file changed, 114 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage refs/changes/91/76891/1 diff --git a/includes/page/ViewProofreadPage.php b/includes/page/ViewProofreadPage.php new file mode 100644 index 0000000..b02fda1 --- /dev/null +++ b/includes/page/ViewProofreadPage.php @@ -0,0 +1,114 @@ +<?php +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + */ + +class ViewProofreadPagePage { + + /** + * @var Title + */ + private $title; + + /** + * @var ProofreadPageContent + */ + private $content; + + /** + * @var ProofreadIndexPage + */ + private $index; + + /** + * @var image + */ + private $image; + + /** + * Constructor + * @param $title Title Reference to a Title object. + * @param $content ProofreadPageContent content of the page. Warning: only done for EditProofreadPagePage use. + * @param $index ProofreadIndexPage index related to the page. + * @param $image File + */ + public function __construct( Title $title, ProofreadPageContent $content = null, ProofreadIndexPage $index = null, $image = null) { + $this->title = $title; + $this->content = $content; + $this->index = $index; + $this->image = $image; + } + + /** + * Create a new ProofreadPagePage from a Title object + * @param $title Title + * @return ProofreadPagePage + */ + public function newFromTitle( Title $title ) { + return new self( $title, null, null ); + } + + public function getContent() { + if( !$this->content ) { + $page = ProofreadPagePage::newFromTitle( $this->title ); + $this->content = $page->getContent(); + } + return $this->content; + } + + public function getImage() { + if( !$this->image ) { + if( !$this->index ) { + $this->image = ProofreadIndexPage::newFromTitle( $this->title ); + } + $this->image = $this->index->getImage(); + } + return $this->image; + } + + public function displayPage() { + global $wgOut; + $body = $this->getContent()->getBody(); + $image = $this->getImage(); + $width = $image->getWidth(); + $height = $image->getHeight(); + if( $width > 800 ) { + $width = 800; + } + if( $height > 800 ) { + $height = 800; + } + $thumbnail = $image->transform( array( + 'page' => $page->getPageNumber(), + 'height' => $height, + 'width' => $width) ); + + $wgOut->addHTML( + Html::openElement('table', array( 'class' => 'wpBody') ) . + Html::openElement( 'tr', array( 'class' => 'bodyImage') ) . + Html::openElement( 'td', array( 'class' => 'bodyTextbox1', 'style' => 'height:'. $height . 'px;') ) . + Html::element( 'div', array( 'class' => 'wpPrBody' ), $body ) . + Html::closeElement('td' ) . + Html::openElement( 'td', array( 'id' => 'proofreadImage' ) ) . + $thumbnail->toHtml() . + Html::closeElement( 'td' ) . + Html::closeElement( 'tr' ) . + Html::closeElement( 'table') + ); + } +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/76891 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8b6482723ecf21ce5bb045130c3ac17d6c0d9ef2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ProofreadPage Gerrit-Branch: pagePagesRefactoring Gerrit-Owner: Rtdwivedi <ellydwivedi2...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits