Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92842
Change subject: Fold history config into FlowActions
......................................................................
Fold history config into FlowActions
& add selected state to board history link
Change-Id: Ifa3646ffc6f45850ebe4c0292d3be34d01682d4d
---
M Flow.i18n.php
M Flow.php
M FlowActions.php
D HistoryActions.php
M Hooks.php
M container.php
A db_patches/patch-rev_change_type_update.sql
M includes/Block/Topic.php
M includes/Data/RecentChanges.php
M includes/Model/AbstractRevision.php
M includes/Model/PostRevision.php
M includes/Templating.php
M includes/View/History/History.php
M includes/View/History/HistoryBundle.php
M includes/View/History/HistoryRecord.php
M includes/View/History/HistoryRenderer.php
M modules/history/history.js
M modules/history/styles/history.less
M templates/post.html.php
M templates/topic.html.php
20 files changed, 322 insertions(+), 255 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/42/92842/1
diff --git a/Flow.i18n.php b/Flow.i18n.php
index 91cbe50..d7ca480 100644
--- a/Flow.i18n.php
+++ b/Flow.i18n.php
@@ -92,7 +92,7 @@
'flow-rev-message-edit-post' => '[[User:$1|$1]] {{GENDER:$1|edited}} a
<span class="plainlinks">[$2 comment]</span>',
'flow-rev-message-reply' => '[[User:$1|$1]] {{GENDER:$1|added}} a <span
class="plainlinks">[$2 comment]</span>.',
- 'flow-rev-message-reply-bundle' => '$1 {{PLURAL:$1|comment|comments}}
were added.',
+ 'flow-rev-message-reply-bundle' => "'''$1
{{PLURAL:$1|comment|comments}}''' were added.",
'flow-rev-message-new-post' => '[[User:$1|$1]] {{GENDER:$1|created}}
the topic <span class="plainlinks">[$2 $3]</span>.',
'flow-rev-message-hid-post' => '[[User:$1|$1]] {{GENDER:$1|hid}} a
<span class="plainlinks">[$3 comment]</span>.',
'flow-rev-message-edit-title' => '[[User:$1|$1]] {{GENDER:$1|edited}}
the topic title to <span class="plainlinks">[$2 $3]</span>.',
diff --git a/Flow.php b/Flow.php
index 5dc56ec..a298602 100755
--- a/Flow.php
+++ b/Flow.php
@@ -47,7 +47,6 @@
// Autoload
$dir = __DIR__ . '/';
require $dir . 'Resources.php';
-require $dir . 'HistoryActions.php';
$wgExtensionMessagesFiles['Flow'] = $dir . 'Flow.i18n.php';
$wgExtensionMessagesFiles['FlowAlias'] = $dir . 'Flow.alias.php';
@@ -232,7 +231,7 @@
$wgFlowOccupyPages = array();
// Namespaces to occupy is an array of NS_* constants, e.g. array(
NS_USER_TALK ).
-$wgFlowOccupyNamespaces = array();
+$wgFlowOccupyNamespaces = array( NS_TALK );
// Action details config file
require $dir . 'FlowActions.php';
diff --git a/FlowActions.php b/FlowActions.php
index ffbc72a..2cd070c 100644
--- a/FlowActions.php
+++ b/FlowActions.php
@@ -3,6 +3,8 @@
use Flow\Model\PostRevision;
use Flow\PostActionPermissions;
use Flow\Log\Logger;
+use Flow\UrlGenerator;
+use Flow\Block\Block;
/**
* Flow actions: key => value map with key being the action name.
@@ -12,8 +14,115 @@
* state and value is the action required to execute the action.
* * button-method: used in PostActionMenu, to generate GET (a) or POST (form)
* links for the action.
+ * * history: all history-related information:
+ * * i18n-message: the i18n message key for this change type
+ * * i18n-params: array of i18n parameters for the provided message (see
+ * HistoryRecord::buildMessage phpdoc for more details)
+ * * class: classname to be added to the list-item for this changetype
+ * * bundle: array with, again, all of the above information if multiple
types
+ * should be bundled (then the bundle i18n & class will be used to generate
+ * the list-item; clicking on it will reveal the individual history
entries)
*/
$wgFlowActions = array(
+ 'create-header' => array(
+ 'log_type' => false,
+ 'permissions' => null,
+ 'button-method' => 'POST',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-create-header',
+ 'i18n-params' => array(
+ function ( Header $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ ),
+ 'class' => 'flow-history-create-header',
+ ),
+ ),
+
+ 'edit-header' => array(
+ 'log_type' => false,
+ 'permissions' => null,
+ 'button-method' => 'POST',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-edit-header',
+ 'i18n-params' => array(
+ function ( Header $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ ),
+ 'class' => 'flow-history-edit-header',
+ ),
+ ),
+
+ 'edit-title' => array(
+ 'log_type' => false,
+ 'permissions' => array(
+ PostRevision::MODERATED_NONE => '',
+ ),
+ 'button-method' => 'GET',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-edit-title',
+ 'i18n-params' => array(
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $urlGenerator->generateUrl(
$revision->getPostId() );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getContent( $user,
'wikitext' );
+ },
+ // @todo: find previous revision & return title
of that revision
+ ),
+ 'class' => 'flow-history-edit-title',
+ ),
+ ),
+
+ 'new-post' => array(
+ 'log_type' => false,
+ 'permissions' => null,
+ 'button-method' => 'POST',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-new-post',
+ 'i18n-params' => array(
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $urlGenerator->generateUrl(
$revision->getPostId() );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getContent( $user,
'wikitext' );
+ },
+ ),
+ 'class' => 'flow-history-new-post',
+ ),
+ ),
+
+ 'edit-post' => array(
+ 'log_type' => false,
+ 'permissions' => array(
+ // no permissions needed for own posts
+ PostRevision::MODERATED_NONE => function( PostRevision
$post, PostActionPermissions $permissions ) {
+ return $post->isCreator(
$permissions->getUser() ) ? '' : 'flow-edit-post';
+ }
+ ),
+ 'button-method' => 'GET',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-edit-post',
+ 'i18n-params' => array(
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ $data = array( $block->getName() .
'[postId]' => $revision->getPostId()->getHex() );
+ return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
+ },
+ ),
+ 'class' => 'flow-history-edit-post',
+ ),
+ ),
+
'hide-post' => array(
'log_type' => false,
'permissions' => array(
@@ -23,7 +132,24 @@
PostRevision::MODERATED_NONE => 'flow-hide',
),
'button-method' => 'POST',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-hid-post',
+ 'i18n-params' => array(
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return
$revision->getModeratedByUserText();
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ $data = array( $block->getName() .
'[postId]' => $revision->getPostId()->getHex() );
+ return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
+ },
+ ),
+ 'class' => 'flow-history-hid-post',
+ ),
),
+
'delete-post' => array(
'log_type' => 'delete',
'permissions' => array(
@@ -31,7 +157,24 @@
PostRevision::MODERATED_HIDDEN => 'flow-delete',
),
'button-method' => 'POST',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-deleted-post',
+ 'i18n-params' => array(
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return
$revision->getModeratedByUserText();
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ $data = array( $block->getName() .
'[postId]' => $revision->getPostId()->getHex() );
+ return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
+ },
+ ),
+ 'class' => 'flow-history-deleted-post',
+ ),
),
+
'censor-post' => array(
'log_type' => 'suppress',
'permissions' => array(
@@ -40,7 +183,24 @@
PostRevision::MODERATED_DELETED => 'flow-censor',
),
'button-method' => 'POST',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-censored-post',
+ 'i18n-params' => array(
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return
$revision->getModeratedByUserText();
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ $data = array( $block->getName() .
'[postId]' => $revision->getPostId()->getHex() );
+ return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
+ },
+ ),
+ 'class' => 'flow-history-censored-post',
+ ),
),
+
'restore-post' => array(
'log_type' => function( PostRevision $post, Logger $logger ) {
// Kind of log depends on the previous change type:
@@ -55,7 +215,24 @@
PostRevision::MODERATED_CENSORED => 'flow-censor',
),
'button-method' => 'POST',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-restored-post',
+ 'i18n-params' => array(
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return
$revision->getModeratedByUserText();
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ $data = array( $block->getName() .
'[postId]' => $revision->getPostId()->getHex() );
+ return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
+ },
+ ),
+ 'class' => 'flow-history-restored-post',
+ ),
),
+
'post-history' => array(
'log_type' => false,
'permissions' => array(
@@ -66,16 +243,7 @@
),
'button-method' => 'GET',
),
- 'edit-post' => array(
- 'log_type' => false,
- 'permissions' => array(
- // no permissions needed for own posts
- PostRevision::MODERATED_NONE => function( PostRevision
$post, PostActionPermissions $permissions ) {
- return $post->isCreator(
$permissions->getUser() ) ? '' : 'flow-edit-post';
- }
- ),
- 'button-method' => 'GET',
- ),
+
'view' => array(
'log_type' => false, // don't log views
'permissions' => array(
@@ -85,19 +253,36 @@
PostRevision::MODERATED_CENSORED => 'flow-censor',
),
'button-method' => 'GET',
+ 'history' => array() // views don't generate history
),
+
'reply' => array(
'log_type' => false,
'permissions' => array(
PostRevision::MODERATED_NONE => '',
),
'button-method' => 'GET',
- ),
- 'edit-title' => array(
- 'log_type' => false,
- 'permissions' => array(
- PostRevision::MODERATED_NONE => '',
+ 'history' => array(
+ 'i18n-message' => 'flow-rev-message-reply',
+ 'i18n-params' => array(
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ return $revision->getUserText( $user );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ $data = array( $block->getName() .
'[postId]' => $revision->getPostId()->getHex() );
+ return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
+ },
+ ),
+ 'class' => 'flow-history-reply',
+ 'bundle' => array(
+ 'i18n-message' =>
'flow-rev-message-reply-bundle',
+ 'i18n-params' => array(
+ function ( array $revisions,
UrlGenerator $urlGenerator, User $user, Block $block ) {
+ return array( 'num' => count(
$revisions ) );
+ }
+ ),
+ 'class' => 'flow-history-bundle',
+ ),
),
- 'button-method' => 'GET',
),
);
diff --git a/HistoryActions.php b/HistoryActions.php
deleted file mode 100644
index 1bc34c6..0000000
--- a/HistoryActions.php
+++ /dev/null
@@ -1,170 +0,0 @@
-<?php
-
-use Flow\View\History;
-use Flow\Model\PostRevision;
-use Flow\Model\Header;
-use Flow\Block\Block;
-use Flow\UrlGenerator;
-
-/**
- * $wgFlowHistoryActions contains information on all logged change types. All
- * keys are the stored change types. The corresponding values are arrays, which
- * should have following info:
- * * i18n-message: the i18n message key for this change type
- * * i18n-params: array of i18n parameters for the provided message (see
- * HistoryRecord::buildMessage phpdoc for more details)
- * * class: classname to be added to the list-item for this changetype
- * * bundle: array with, again, all of the above information if multiple types
- * should be bundled (then the bundle i18n & class will be used to generate
- * the list-item & clicking on it will reveal the individual history entries)
- */
-$wgFlowHistoryActions = array(
- 'flow-edit-header' => array(
- 'i18n-message' => 'flow-rev-message-edit-header',
- 'i18n-params' => array(
- function ( Header $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- ),
- 'class' => 'flow-rev-message-edit-header',
- ),
- 'flow-create-header' => array(
- 'i18n-message' => 'flow-rev-message-create-header',
- 'i18n-params' => array(
- function ( Header $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- ),
- 'class' => 'flow-rev-message-create-header',
- ),
- 'flow-rev-message-edit-post' => array(
- 'i18n-message' => 'flow-rev-message-edit-post',
- 'i18n-params' => array(
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- $data = array( $block->getName() . '[postId]'
=> $revision->getPostId()->getHex() );
- return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
- },
- ),
- 'class' => 'flow-rev-message-edit-post',
- ),
- 'flow-rev-message-reply' => array(
- 'i18n-message' => 'flow-rev-message-reply',
- 'i18n-params' => array(
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- $data = array( $block->getName() . '[postId]'
=> $revision->getPostId()->getHex() );
- return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
- },
- ),
- 'class' => 'flow-rev-message-reply',
- 'bundle' => array(
- 'i18n-message' => 'flow-rev-message-reply-bundle',
- 'i18n-params' => array(
- function ( array $revisions, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return array( 'num' => count(
$revisions ) );
- }
- ),
- 'class' => 'flow-history-bundle',
- ),
- ),
- 'flow-rev-message-new-post' => array(
- 'i18n-message' => 'flow-rev-message-new-post',
- 'i18n-params' => array(
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $urlGenerator->generateUrl(
$revision->getPostId() );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getContent( $user, 'wikitext'
);
- },
- ),
- 'class' => 'flow-rev-message-new-post',
- ),
- 'flow-rev-message-edit-title' => array(
- 'i18n-message' => 'flow-rev-message-edit-title',
- 'i18n-params' => array(
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $urlGenerator->generateUrl(
$revision->getPostId() );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getContent( $user, 'wikitext'
);
- },
- // @todo: find previous revision & return title of that
revision
- ),
- 'class' => 'flow-rev-message-edit-title',
- ),
- 'flow-rev-message-restored-post' => array(
- 'i18n-message' => 'flow-rev-message-restored-post',
- 'i18n-params' => array(
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getModeratedByUserText();
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- $data = array( $block->getName() . '[postId]'
=> $revision->getPostId()->getHex() );
- return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
- },
- ),
- 'class' => 'flow-rev-message-restored-post',
- ),
- 'flow-rev-message-hid-post' => array(
- 'i18n-message' => 'flow-rev-message-hid-post',
- 'i18n-params' => array(
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getModeratedByUserText();
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- $data = array( $block->getName() . '[postId]'
=> $revision->getPostId()->getHex() );
- return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
- },
- ),
- 'class' => 'flow-rev-message-hid-post',
- ),
- 'flow-rev-message-deleted-post' => array(
- 'i18n-message' => 'flow-rev-message-deleted-post',
- 'i18n-params' => array(
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getModeratedByUserText();
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- $data = array( $block->getName() . '[postId]'
=> $revision->getPostId()->getHex() );
- return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
- },
- ),
- 'class' => 'flow-rev-message-deleted-post',
- ),
- 'flow-rev-message-censored-post' => array(
- 'i18n-message' => 'flow-rev-message-censored-post',
- 'i18n-params' => array(
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getModeratedByUserText();
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- return $revision->getUserText( $user );
- },
- function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
- $data = array( $block->getName() . '[postId]'
=> $revision->getPostId()->getHex() );
- return $urlGenerator->generateUrl(
$block->getWorkflowId(), 'view', $data );
- },
- ),
- 'class' => 'flow-rev-message-censored-post',
- ),
-);
diff --git a/Hooks.php b/Hooks.php
index 23cb43d..ff7a683 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -42,6 +42,7 @@
$updater->addExtensionIndex( 'flow_workflow',
'flow_workflow_lookup', "$dir/db_patches/patch-workflow_lookup_idx.sql" );
$updater->addExtensionIndex( 'flow_topic_list',
'flow_topic_list_topic_id', "$dir/db_patches/patch-topic_list_topic_id_idx.sql"
);
+ $updater->modifyExtensionField( 'flow_revision',
'rev_change_type', "$dir/db_patches/patch-rev_change_type_update.sql" );
require_once
__DIR__.'/maintenance/FlowInsertDefaultDefinitions.php';
$updater->addPostDatabaseUpdateMaintenance(
'FlowInsertDefaultDefinitions' );
@@ -195,8 +196,10 @@
if ( $occupationController->isTalkpageOccupied( $title ) ) {
$skname = $template->skinname;
+ global $wgRequest;
+ $selected = $wgRequest->getVal( 'action' ) ==
'board-history';
$links['views'] = array( array(
- 'class' => false,
+ 'class' => $selected ? 'selected' : '',
'text' => wfMessageFallback(
"$skname-view-history", "history_short" )->text(),
'href' => $title->getLocalURL(
'action=board-history' ),
) );
@@ -208,10 +211,6 @@
$links['actions']['move'],
$links['actions']['undelete']
);
-
- // @todo: at some point, we'll probably want to
re-use/override:
- // - ['views']['history']
- // - ['actions']['protect'] & ['actions']['unprotect']
}
return true;
diff --git a/container.php b/container.php
index d8d3286..5a6ccb0 100644
--- a/container.php
+++ b/container.php
@@ -238,7 +238,7 @@
$treeRepo = $c['repository.tree'];
$mapper = BasicObjectMapper::model( 'Flow\\Model\\PostRevision' );
$storage = new PostRevisionStorage( $c['db.factory'],
$wgFlowExternalStore, $treeRepo );
- $pk = new UniqueFeatureIndex( $cache, $storage, 'flow_revision:v2:pk',
array( 'rev_id' ) );
+ $pk = new UniqueFeatureIndex( $cache, $storage, 'flow_revision:v3:pk',
array( 'rev_id' ) );
$indexes = array(
$pk,
// revision history
diff --git a/db_patches/patch-rev_change_type_update.sql
b/db_patches/patch-rev_change_type_update.sql
new file mode 100644
index 0000000..29f0e89
--- /dev/null
+++ b/db_patches/patch-rev_change_type_update.sql
@@ -0,0 +1,14 @@
+-- Updates older change_type values to match with action names
+
+UPDATE /*_*/flow_revision SET rev_change_type = 'edit-title' WHERE
rev_change_type IN('flow-rev-message-edit-title', 'flow-edit-title') AND
rev_type = 'post';
+
+UPDATE /*_*/flow_revision SET rev_change_type = 'new-post' WHERE
rev_change_type IN('flow-rev-message-new-post', 'flow-new-post') AND rev_type =
'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'edit-post' WHERE
rev_change_type IN('flow-rev-message-edit-post', 'flow-edit-post') AND rev_type
= 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'reply' WHERE rev_change_type
IN('flow-rev-message-reply', 'flow-reply') AND rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'restore-post' WHERE
rev_change_type IN('flow-rev-message-restored-post', 'flow-post-restored') AND
rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'hide-post' WHERE
rev_change_type IN('flow-rev-message-hid-post', 'flow-post-hidden') AND
rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'delete-post' WHERE
rev_change_type IN('flow-rev-message-deleted-post', 'flow-post-deleted') AND
rev_type = 'post';
+UPDATE /*_*/flow_revision SET rev_change_type = 'censor-post' WHERE
rev_change_type IN('flow-rev-message-censored-post', 'flow-post-censored') AND
rev_type = 'post';
+
+UPDATE /*_*/flow_revision SET rev_change_type = 'edit-header' WHERE
rev_change_type IN ('flow-rev-message-edit-header', 'flow-edit-summary') AND
rev_type = 'header';
+UPDATE /*_*/flow_revision SET rev_change_type = 'create-header' WHERE
rev_change_type IS NULL OR rev_change_type IN
('flow-rev-message-create-header', 'flow-create-summary') AND rev_type =
'header';
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 6e890f6..f687d34 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -125,7 +125,7 @@
return;
}
- $this->newRevision = $topicTitle->newNextRevision(
$this->user, $this->submitted['content'], 'flow-rev-message-edit-title' );
+ $this->newRevision = $topicTitle->newNextRevision(
$this->user, $this->submitted['content'], 'edit-title' );
$this->setNotification(
'flow-topic-renamed',
@@ -324,7 +324,7 @@
switch( $this->action ) {
case 'post-history':
$templating->getOutput()->addModules(
'ext.flow.history' );
- return $this->renderPostHistory( $templating, $options,
$return );
+ return $prefix . $this->renderPostHistory( $templating,
$options, $return );
case 'topic-history':
$templating->getOutput()->addModules(
'ext.flow.history' );
@@ -335,7 +335,7 @@
$root = $this->loadRootPost();
- return $templating->render(
"flow:topic-history.html.php", array(
+ return $prefix . $templating->render(
"flow:topic-history.html.php", array(
'block' => $this,
'topic' => $this->workflow,
'root' => $root,
@@ -705,5 +705,4 @@
)
);
}
-
}
diff --git a/includes/Data/RecentChanges.php b/includes/Data/RecentChanges.php
index 2effd74..381851f 100644
--- a/includes/Data/RecentChanges.php
+++ b/includes/Data/RecentChanges.php
@@ -54,7 +54,7 @@
'rc_last_oldid' => 0,
'rc_params' => serialize( array(
'flow-workflow-change' => array(
- 'type' => $type,
+ 'type' => $type, // @todo: need a
maintenance script that retroactively fixes these
'workflow' =>
$workflow->getId()->getHex(),
'definition' =>
$workflow->getDefinitionId()->getHex(),
) + $changes,
diff --git a/includes/Model/AbstractRevision.php
b/includes/Model/AbstractRevision.php
index dc9b84d..69bd811 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -27,7 +27,7 @@
// Whether or not to create a new revision when setting
this state
'new-revision' => true,
// i18n key for history and recentchanges
- 'change-type' => 'flow-rev-message-restored-post',
+ 'change-type' => 'restore-post',
),
self::MODERATED_HIDDEN => array(
// The permission needed from User::isAllowed to see
and create new revisions
@@ -36,11 +36,11 @@
// NOTE: special case self::getHiddenContent still
retrieves content in this case only
'content' => 'flow-post-hidden-by',
// This is the bit of text rendered instead of the post
creator
- 'usertext' => 'flow-rev-message-hid-post',
+ 'usertext' => 'flow-rev-message-hid-post', // @todo:
message has changed
// Whether or not to create a new revision when setting
this state
'new-revision' => true,
// i18n key for history and recentchanges
- 'change-type' => 'flow-rev-message-hid-post',
+ 'change-type' => 'hide-post',
),
self::MODERATED_DELETED => array(
// The permission needed from User::isAllowed to see
and create new revisions
@@ -48,11 +48,11 @@
// i18n key to replace content with when state is active
'content' => 'flow-post-deleted-by',
// This is the bit of text rendered instead of the post
creator
- 'usertext' => 'flow-rev-message-deleted-post',
+ 'usertext' => 'flow-rev-message-deleted-post', //
@todo: message has changed
// Whether or not to create a new revision when setting
this state
'new-revision' => false,
// i18n key for history and recentchanges
- 'change-type' => 'flow-rev-message-deleted-post',
+ 'change-type' => 'delete-post',
),
self::MODERATED_CENSORED => array(
// The permission needed from User::isAllowed to see
and create new revisions
@@ -60,11 +60,11 @@
// i18n key to replace content with when state is active
'content' => 'flow-post-censored-by',
// This is the bit of text rendered instead of the post
creator
- 'usertext' => 'flow-rev-message-censored-post',
+ 'usertext' => 'flow-rev-message-censored-post', //
@todo: message has changed
// Whether or not to create a new revision when setting
this state
'new-revision' => false,
// i18n key for history and recentchanges
- 'change-type' => 'flow-rev-message-censored-post',
+ 'change-type' => 'censor-post',
),
);
diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php
index 553681e..8502586 100644
--- a/includes/Model/PostRevision.php
+++ b/includes/Model/PostRevision.php
@@ -38,7 +38,7 @@
$obj->origCreateTime = wfTimestampNow();
$obj->replyToId = null; // not a reply to anything
$obj->prevRevId = null; // no parent revision
- $obj->changeType = 'flow-rev-message-new-post';
+ $obj->changeType = 'new-post';
$obj->setContent( $content );
return $obj;
}
@@ -69,7 +69,7 @@
);
}
- public function reply( User $user, $content, $changeType =
'flow-rev-message-reply' ) {
+ public function reply( User $user, $content, $changeType = 'reply' ) {
$reply = new self;
// No great reason to create two uuid's, a post and its first
revision can share a uuid
$reply->revId = $reply->postId = UUID::create();
diff --git a/includes/Templating.php b/includes/Templating.php
index d22ee68..4d34a19 100644
--- a/includes/Templating.php
+++ b/includes/Templating.php
@@ -83,8 +83,12 @@
// abstracted templating implementation so these can be elsewhere.
Figure out if we can transition to an
// industry standard templating solution and stop the NIH.
+ public function getUrlGenerator() {
+ return $this->urlGenerator;
+ }
+
public function generateUrl( $workflow, $action = 'view', array $query
= array() ) {
- return $this->urlGenerator->generateUrl( $workflow, $action,
$query );
+ return $this->getUrlGenerator()->generateUrl( $workflow,
$action, $query );
}
public function renderPost( PostRevision $post, Block $block, $return =
true ) {
diff --git a/includes/View/History/History.php
b/includes/View/History/History.php
index 50647a1..cc2f171 100644
--- a/includes/View/History/History.php
+++ b/includes/View/History/History.php
@@ -6,8 +6,8 @@
use FakeResultWrapper;
/**
- * History is just an Iterator which takes an array of PostRevisions and sorts
- * them on timestamp, DESC.
+ * History is just an Iterator which takes an array of AbstractRevisions and
+ * sorts them on timestamp, DESC.
* It provides 1 addition method: getTimespan, which will return all records
* between 2 specified dates.
*/
diff --git a/includes/View/History/HistoryBundle.php
b/includes/View/History/HistoryBundle.php
index 1459436..88878a8 100644
--- a/includes/View/History/HistoryBundle.php
+++ b/includes/View/History/HistoryBundle.php
@@ -2,11 +2,11 @@
namespace Flow\View\History;
-use Flow\Model\PostRevision;
+use Flow\Model\AbstractRevision;
/**
* HistoryBundle is quite similar to HistoryRecord, but accepts an array of
- * PostRevision values. Instead of return the info for a specific revision's
+ * AbstractRevision values. Instead of return the info for a specific
revision's
* action, it will return the action's bundle info.
*/
class HistoryBundle extends HistoryRecord {
@@ -30,7 +30,7 @@
}
/**
- * @return PostRevision
+ * @return AbstractRevision
*/
public function getRevision() {
return $this->data[0];
@@ -38,10 +38,15 @@
/**
* @param string $action
- * @return array|bool Array of action details or false if invalid
+ * @return array Array of action details
*/
protected function getActionDetails( $action ) {
- $details = parent::getActionDetails( $action );
- return isset( $details['bundle'] ) ? $details['bundle'] : false;
+ $details = $this->getActions()->getValue( $action, 'history',
'bundle' );
+
+ if ( $details === null ) {
+ throw new MWException( "History bundle action '$action'
is not defined." );
+ }
+
+ return $details;
}
}
diff --git a/includes/View/History/HistoryRecord.php
b/includes/View/History/HistoryRecord.php
index b9d98ae..76cd4e6 100644
--- a/includes/View/History/HistoryRecord.php
+++ b/includes/View/History/HistoryRecord.php
@@ -2,15 +2,17 @@
namespace Flow\View\History;
+use Flow\Container;
+use Flow\FlowActions;
use Flow\Model\AbstractRevision;
use MWException;
use MWTimestamp;
use Message;
/**
- * HistoryRecord accepts a AbstractRevision and, based on
$wgFlowHistoryActions,
- * provides some methods to access history-related information for this
- * revision's specific action.
+ * HistoryRecord accepts an AbstractRevision and, based on FlowActions,
provides
+ * some methods to access history-related information for this revision's
+ * specific action.
*/
class HistoryRecord {
/**
@@ -26,19 +28,31 @@
}
/**
+ * @return FlowActions
+ */
+ protected function getActions() {
+ /*
+ * It's not pretty how this is just pulled form container, but
I don't
+ * want to pass along the actions config to all classes.
+ * I think pulling config is perhaps not that bad ;)
+ */
+ return Container::get( 'flow_actions' );
+ }
+
+ /**
* Returns action details.
*
* @param string $action
* @return array|bool Array of action details or false if invalid
*/
protected function getActionDetails( $action ) {
- global $wgFlowHistoryActions;
+ $details = $this->getActions()->getValue( $action, 'history' );
- if ( !isset( $wgFlowHistoryActions[$action] ) ) {
+ if ( $details === null ) {
throw new MWException( "History action '$action' is not
defined." );
}
- return $wgFlowHistoryActions[$action];
+ return $details;
}
/**
diff --git a/includes/View/History/HistoryRenderer.php
b/includes/View/History/HistoryRenderer.php
index 9a5470a..c1b11c4 100644
--- a/includes/View/History/HistoryRenderer.php
+++ b/includes/View/History/HistoryRenderer.php
@@ -110,7 +110,7 @@
continue;
// This record is part of a bundle, render it.
- } elseif ( $record->isBundled() &&count(
$bundles[$class] ) > 1 ) {
+ } elseif ( $record->isBundled() && count(
$bundles[$class] ) > 1 ) {
$bundle = new HistoryBundle( $bundles[$class] );
$output .= $this->renderLine( $bundle );
@@ -146,7 +146,7 @@
'message' => $record->getMessage(
// Arguments for the i18n messages' parameter
callbacks.
$record->getData(),
- $this->templating->urlGenerator,
+ $this->templating->getUrlGenerator(),
$wgUser,
$this->block
),
diff --git a/modules/history/history.js b/modules/history/history.js
index d6663d6..eca3c2a 100644
--- a/modules/history/history.js
+++ b/modules/history/history.js
@@ -1,18 +1,23 @@
( function ( $, mw ) {
// Bundled
$( '.flow-history-bundle' )
- .click( function () {
- var $bundled = $( this ).find( 'ul' );
+ .click( function ( e ) {
+ var $bundled = $( this ).find( 'ul' );
- if ( $bundled.is( ':visible' ) ) {
- $bundled.hide();
- $( this ).addClass( 'flow-history-bundle-inactive' );
- } else {
- $bundled.show();
- $( this ).removeClass( 'flow-history-bundle-inactive' );
- }
- } )
- // hide bundled records by default
- .addClass( 'flow-history-bundle-inactive' )
- .find( 'ul' ).hide();
+ // when clicking a child li, the bundle should not
collapse again
+ if ( !$( e.target ).closest( 'li' ).hasClass(
'flow-history-bundle' ) ) {
+ return;
+ }
+
+ if ( $bundled.is( ':visible' ) ) {
+ $bundled.hide();
+ $( this ).addClass(
'flow-history-bundle-inactive' );
+ } else {
+ $bundled.show();
+ $( this ).removeClass(
'flow-history-bundle-inactive' );
+ }
+ } )
+ // hide bundled records by default
+ .addClass( 'flow-history-bundle-inactive' )
+ .find( 'ul' ).hide();
} )( jQuery, mediaWiki );
diff --git a/modules/history/styles/history.less
b/modules/history/styles/history.less
index 18fe2f5..51cbc28 100644
--- a/modules/history/styles/history.less
+++ b/modules/history/styles/history.less
@@ -67,28 +67,32 @@
}
}
- &.flow-rev-message-edit-title,
&.flow-rev-message-edit-header, &.flow-rev-message-edit-post {
+ &.flow-history-edit-title,
+ &.flow-history-edit-header,
+ &.flow-history-edit-post {
.background-image-svg('../../base/images/edit_normal.svg',
'../../base/images/edit_normal.png');
}
- &.flow-rev-message-new-post,
&.flow-rev-message-create-header, &.flow-rev-message-reply {
+ &.flow-history-new-post,
+ &.flow-history-create-header,
+ &.flow-history-reply {
.background-image-svg('../../base/images/added_normal.svg',
'../../base/images/added_normal.png');
}
- &.flow-rev-message-restored-post {
+ &.flow-history-restored-post {
//
.background-image-svg('../../base/images/restored_active.svg',
'../../base/images/restored_active.png'); // @todo: need icon
}
- &.flow-rev-message-hid-post {
+ &.flow-history-hid-post {
background-position: left 9px; // this
icon has a smaller height ;)
.background-image-svg('../../base/images/hidden_active.svg',
'../../base/images/hidden_active.png');
}
- &.flow-rev-message-deleted-post {
+ &.flow-history-deleted-post {
.background-image-svg('../../base/images/deleted_active.svg',
'../../base/images/deleted_active.png');
}
- &.flow-rev-message-censored-post {
+ &.flow-history-censored-post {
.background-image-svg('../../base/images/suppressed_active.svg',
'../../base/images/suppressed_active.png');
}
diff --git a/templates/post.html.php b/templates/post.html.php
index 25d0caa..52a836b 100644
--- a/templates/post.html.php
+++ b/templates/post.html.php
@@ -97,8 +97,8 @@
<span class="flow-agotime"
style="display: inline">' . htmlspecialchars(
$post->getPostId()->getHumanTimestamp() ) . '</span>
<span class="flow-utctime"
style="display: none">' . htmlspecialchars(
$post->getPostId()->getTimestampObj()->getTimestamp( TS_RFC2822 ) ) . '</span>';
- // build history button with timestamp
html as content
- if ( $postActionMenu->isAllowed(
'post-history' ) ) {
+ // build history button with timestamp
html as content, if there is history & user has permissions
+ if ( $post->getPrevRevisionId() !==
null && $postActionMenu->isAllowed( 'post-history' ) ) {
echo
$postActionMenu->getButton( 'post-history', $content,
'flow-action-history-link' );
} else {
echo $content;
diff --git a/templates/topic.html.php b/templates/topic.html.php
index a0212d7..209e98a 100644
--- a/templates/topic.html.php
+++ b/templates/topic.html.php
@@ -54,14 +54,23 @@
<span class="flow-agotime"
style="display: inline">' . htmlspecialchars(
$topic->getLastModifiedObj()->getHumanTimestamp() ) . '</span>
<span class="flow-utctime"
style="display: none">' . htmlspecialchars(
$topic->getLastModifiedObj()->getTimestamp( TS_RFC2822 ) ) . '</span>';
- // build history button with timestamp html as
content
- echo Html::rawElement( 'a',
- array(
- 'class' =>
'flow-action-history-link',
- 'href' => $this->generateUrl(
$root->getPostId(), 'topic-history' ),
- ),
- $content
- );
+ // topic has history if:
+ // * $root (topic title) revision has been
changed
+ // * $root has > 1 children (= 1st post is the
topic content)
+ // * 1st post has > 1 children (= replies to
the first post)
+ $children = $root->getChildren();
+ if ( $root->getPrevRevisionId() !== null ||
count( $children ) > 1 || count( $children[0]->getChildren() ) > 0 ) {
+ // build history button with timestamp
html as content
+ echo Html::rawElement( 'a',
+ array(
+ 'class' =>
'flow-action-history-link',
+ 'href' =>
$this->generateUrl( $root->getPostId(), 'topic-history' ),
+ ),
+ $content
+ );
+ } else {
+ echo $content;
+ }
?>
</p>
--
To view, visit https://gerrit.wikimedia.org/r/92842
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa3646ffc6f45850ebe4c0292d3be34d01682d4d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits