jenkins-bot has submitted this change and it was merged.
Change subject: Fold history config into FlowActions
......................................................................
Fold history config into FlowActions
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/Block.php
M includes/Block/Topic.php
M includes/Data/RecentChanges.php
M includes/FlowActions.php
M includes/Model/AbstractRevision.php
M includes/Model/Header.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
21 files changed, 378 insertions(+), 243 deletions(-)
Approvals:
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Flow.i18n.php b/Flow.i18n.php
index 1d6cebc..3a89abe 100644
--- a/Flow.i18n.php
+++ b/Flow.i18n.php
@@ -92,10 +92,11 @@
'flow-rev-message-edit-post' => '[[User:$1|$1]] {{GENDER:$1|edited}} a
[$2 comment]',
'flow-rev-message-reply' => '[[User:$1|$1]] {{GENDER:$1|added}} a [$2
comment].',
- '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 [$2 $3].',
'flow-rev-message-hid-post' => '[[User:$1|$1]] {{GENDER:$1|hid}} a [$3
comment].',
- 'flow-rev-message-edit-title' => '[[User:$1|$1]] {{GENDER:$1|edited}}
the topic title to [$2 $3].',
+ 'flow-rev-message-edit-title' => '[[User:$1|$1]] {{GENDER:$1|edited}}
the topic title to [$2 $3] from $4.',
+
'flow-rev-message-create-header' => "[[User:$1|$1]]
{{GENDER:$1|created}} the board header.",
'flow-rev-message-edit-header' => "[[User:$1|$1]] {{GENDER:$1|edited}}
the board header.",
'flow-rev-message-restored-post' => '[[User:$1|$1]]
{{GENDER:$1|restored}} a [$3 comment].',
@@ -395,7 +396,8 @@
Parameters:
* $1: Username of the user who edited the title. Can be used for GENDER
* $2: The url of the topic
-* $3: The topic title',
+* $3: The topic title
+* $4: The previous topic title',
'flow-rev-message-create-header' => 'Used as revision comment when the
header has been created.
Parameters:
diff --git a/Flow.php b/Flow.php
index 49cfef4..41cf04c 100755
--- a/Flow.php
+++ b/Flow.php
@@ -46,7 +46,6 @@
// Autoload
$dir = __DIR__ . '/';
require $dir . 'Resources.php';
-require $dir . 'HistoryActions.php';
$wgExtensionMessagesFiles['Flow'] = $dir . 'Flow.i18n.php';
@@ -226,7 +225,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..ad54194 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,135 @@
* 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,
+ /*
+ * null doesn't actually have any meaning here; we just have
not (yet?)
+ * implemented any permissions for headers (anyone can edit
them),
+ * only for posts (PostActionPermissions). This 1 key can, for
now,
+ * safely be ignored here.
+ */
+ '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,
+ /*
+ * null doesn't actually have any meaning here; we just have
not (yet?)
+ * implemented any permissions for headers (anyone can edit
them),
+ * only for posts (PostActionPermissions). This 1 key can, for
now,
+ * safely be ignored here.
+ */
+ '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' );
+ },
+ function ( PostRevision $revision, UrlGenerator
$urlGenerator, User $user, Block $block ) {
+ $previousId =
$revision->getPrevRevisionId();
+ if ( $previousId ) {
+ $previousRevision =
$block->getStorage()->get( get_class( $revision ), $previousId );
+ return
$previousRevision->getContent( $user, 'wikitext' );
+ }
+
+ return '';
+ },
+ ),
+ '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 +152,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 +177,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 +203,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 +235,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 +263,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 +273,64 @@
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',
),
+
+ /*
+ * Backwards compatibility; these are old values that may have made
their
+ * way into the database. patch-rev_change_type_update.sql should take
care
+ * of these, but just to be sure ;)
+ * Instead of having the correct config-array as value, you can just
+ * reference another action.
+ */
+ 'flow-rev-message-edit-title' => 'edit-title',
+ 'flow-edit-title' => 'edit-title',
+ 'flow-rev-message-new-post' => 'new-post',
+ 'flow-new-post' => 'new-post',
+ 'flow-rev-message-edit-post' => 'edit-post',
+ 'flow-edit-post' => 'edit-post',
+ 'flow-rev-message-reply' => 'reply',
+ 'flow-reply' => 'reply',
+ 'flow-rev-message-restored-post' => 'restore-post',
+ 'flow-post-restored' => 'restore-post',
+ 'flow-rev-message-hid-post' => 'hide-post',
+ 'flow-post-hidden' => 'hide-post',
+ 'flow-rev-message-deleted-post' => 'delete-post',
+ 'flow-post-deleted' => 'delete-post',
+ 'flow-rev-message-censored-post' => 'censor-post',
+ 'flow-post-censored' => 'censor-post',
+ 'flow-rev-message-edit-header' => 'edit-header',
+ 'flow-edit-summary' => 'edit-header',
+ 'flow-rev-message-create-header' => 'create-header',
+ 'flow-create-summary' => 'create-header',
);
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 4fbfe91..a4f79b7 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' );
diff --git a/container.php b/container.php
index d6c20d5..adb4c06 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/Block.php b/includes/Block/Block.php
index bfe6b16..174bfd8 100644
--- a/includes/Block/Block.php
+++ b/includes/Block/Block.php
@@ -106,4 +106,8 @@
public function getWorkflowId() {
return $this->workflow->getId();
}
+
+ public function getStorage() {
+ return $this->storage;
+ }
}
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index c7b7f44..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',
@@ -705,5 +705,4 @@
)
);
}
-
}
diff --git a/includes/Data/RecentChanges.php b/includes/Data/RecentChanges.php
index 8b62cef..26552f9 100644
--- a/includes/Data/RecentChanges.php
+++ b/includes/Data/RecentChanges.php
@@ -57,7 +57,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/FlowActions.php b/includes/FlowActions.php
index b9b5a22..246d4f2 100644
--- a/includes/FlowActions.php
+++ b/includes/FlowActions.php
@@ -33,10 +33,32 @@
* @return mixed|null Requested value or null if missing
*/
public function getValue( $action, $type /* [, $option = null [, ...]]
*/ ) {
+ $arguments = func_get_args();
+
try {
- return $this->actions[func_get_args()];
+ return $this->actions[$arguments];
} catch ( \OutOfBoundsException $e ) {
- return null;
+ // Do nothing; the whole remainder of this method is
fail-case.
}
+
+ /*
+ * If no value is found, check if the action is not actually
referencing
+ * another action (for BC reasons), then try fetching the
requested data
+ * from that action.
+ */
+ try {
+ $referencedAction = $this->actions[$action];
+ if ( is_string( $referencedAction ) &&
$referencedAction != $action ) {
+ // Replace action name in arguments.
+ array_shift( $arguments );
+ array_unshift( $arguments, $referencedAction );
+
+ return call_user_func_array( array( $this,
'getValue' ), $arguments );
+ }
+ } catch ( \OutOfBoundsException $e ) {
+ // Do nothing; the whole remainder of this method is
fail-case.
+ }
+
+ return null;
}
}
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/Header.php b/includes/Model/Header.php
index a321f90..f67dd18 100644
--- a/includes/Model/Header.php
+++ b/includes/Model/Header.php
@@ -41,4 +41,3 @@
return $this->workflowId;
}
}
-
diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php
index 7772838..08633f8 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 c657e78..5a935a3 100644
--- a/includes/Templating.php
+++ b/includes/Templating.php
@@ -82,8 +82,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');
}
--
To view, visit https://gerrit.wikimedia.org/r/92842
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifa3646ffc6f45850ebe4c0292d3be34d01682d4d
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits