Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/111717
Change subject: Turn \Flow\View into a ContextSource
......................................................................
Turn \Flow\View into a ContextSource
Also did some code cleanup
Change-Id: I1272a7b3bf2b017eb6aa05312dad6c0e92081f99
---
M includes/View.php
1 file changed, 16 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/17/111717/1
diff --git a/includes/View.php b/includes/View.php
index af32fe1..c3c3cd8 100644
--- a/includes/View.php
+++ b/includes/View.php
@@ -5,8 +5,9 @@
use Flow\Model\Workflow;
use Html;
use IContextSource;
+use ContextSource;
-class View {
+class View extends ContextSource {
function __construct(
Templating $templating,
UrlGenerator $urlGenerator,
@@ -14,41 +15,40 @@
) {
$this->templating = $templating;
$this->urlGenerator = $urlGenerator;
- $this->context = $requestContext;
- $this->output = $this->context->getOutput();
+ $this->setContext( $requestContext );
}
public function show( WorkflowLoader $loader, $action ) {
- $this->output->addModuleStyles( array( 'mediawiki.ui',
'mediawiki.ui.button', 'ext.flow.base' ) );
- $this->output->addModules( array( 'ext.flow.base',
'ext.flow.editor' ) );
+ $out = $this->getOutput();
+ $out->addModuleStyles( array( 'mediawiki.ui',
'mediawiki.ui.button', 'ext.flow.base' ) );
+ $out->addModules( array( 'ext.flow.base', 'ext.flow.editor' ) );
$workflow = $loader->getWorkflow();
$title = $workflow->getArticleTitle();
- $this->output->setPageTitle( $title->getPrefixedText() );
+ $out->setPageTitle( $title->getPrefixedText() );
// Temporary hack to make relative links work when the page is
requested as /w/index.php?title=
// @todo this wont work when we eventually display posts from
multiple source pages,
// @todo Patch core to either deprecate /w/index.php?title= and
issue redirects, or
// include the <base href="..."> directly from core
- $this->output->prependHTML( Html::element( 'base', array(
+ $out->prependHTML( Html::element( 'base', array(
'href' => $title->getLocalURL()
) ) );
- $request = $this->context->getRequest();
- $user = $this->context->getUser();
+ $request = $this->getRequest();
+ $user = $this->getUser();
$blocks = $loader->createBlocks();
foreach ( $blocks as $block ) {
$block->init( $action, $user );
}
- if ( $request->getMethod() === 'POST' ) {
+ if ( $request->wasPosted() ) {
global $wgFlowTokenSalt;
if ( $request->getVal( 'wpEditToken' ) !=
$user->getEditToken( $wgFlowTokenSalt ) ) {
- $error = '<div class="error">' . wfMessage(
'sessionfailure' ) . '</div>';
- $this->output->addHTML( $error );
+ $error = '<div class="error">' . $this->msg(
'sessionfailure' ) . '</div>';
+ $out->addHTML( $error );
} else {
- $request = $this->context->getRequest();
$blocksToCommit = $loader->handleSubmit(
$action, $blocks, $user, $request );
if ( $blocksToCommit ) {
$loader->commit( $workflow,
$blocksToCommit );
@@ -60,7 +60,7 @@
$workflowId = $workflow->isNew() ? '' :
$workflow->getId()->getHex();
$title = $workflow->getArticleTitle();
- $this->output->addHTML( Html::openElement( 'div',
+ $out->addHTML( Html::openElement( 'div',
array(
'class' => 'flow-container',
'data-workflow-id' => $workflowId,
@@ -71,11 +71,11 @@
foreach ( $blocks as $block ) {
$block->render( $this->templating, $request->getArray(
$block->getName(), array() ) );
}
- $this->output->addHTML( "</div>" );
+ $out->addHTML( "</div>" );
}
protected function redirect( Workflow $workflow, $action = 'view',
array $query = array() ) {
$url = $this->urlGenerator->generateUrl( $workflow, $action,
$query );
- $this->output->redirect( $url );
+ $this->getOutput()->redirect( $url );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/111717
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1272a7b3bf2b017eb6aa05312dad6c0e92081f99
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits