Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427085
WorkflowStatesMessageGroup.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
WorkflowStatesMessageGroup.php
View Options
<?php
/**
* This file contains an unmanaged message group implementation.
*
* @file
* @author Niklas Laxström
* @author Siebrand Mazeland
* @copyright Copyright © 2008-2013, Niklas Laxström, Siebrand Mazeland
* @license GPL-2.0-or-later
*/
use
MediaWiki\CommentStore\CommentStoreComment
;
use
MediaWiki\Context\IContextSource
;
use
MediaWiki\Extension\Translate\MessageGroupProcessing\MessageGroups
;
use
MediaWiki\Extension\Translate\SystemUsers\FuzzyBot
;
use
MediaWiki\Extension\Translate\Utilities\Utilities
;
use
MediaWiki\MediaWikiServices
;
use
MediaWiki\Revision\SlotRecord
;
use
MediaWiki\Title\Title
;
/** @ingroup MessageGroup */
class
WorkflowStatesMessageGroup
extends
WikiMessageGroup
{
// id and source are not needed
public
function
__construct
()
{
}
public
function
getId
()
{
return
'translate-workflow-states'
;
}
public
function
getLabel
(
?
IContextSource
$context
=
null
)
{
$msg
=
wfMessage
(
'translate-workflowgroup-label'
);
$msg
=
self
::
addContext
(
$msg
,
$context
);
return
$msg
->
plain
();
}
public
function
getDescription
(
?
IContextSource
$context
=
null
)
{
$msg
=
wfMessage
(
'translate-workflowgroup-desc'
);
$msg
=
self
::
addContext
(
$msg
,
$context
);
return
$msg
->
plain
();
}
public
function
getDefinitions
()
{
$groups
=
MessageGroups
::
getAllGroups
();
$keys
=
[];
/** @var $g MessageGroup */
foreach
(
$groups
as
$g
)
{
$states
=
$g
->
getMessageGroupStates
()->
getStates
();
foreach
(
array_keys
(
$states
)
as
$state
)
{
$keys
[
"Translate-workflow-state-$state"
]
=
$state
;
}
}
if
(
!
$keys
)
{
return
[];
}
$defs
=
Utilities
::
getContents
(
array_keys
(
$keys
),
$this
->
getNamespace
()
);
$wikiPageFactory
=
MediaWikiServices
::
getInstance
()->
getWikiPageFactory
();
foreach
(
$keys
as
$key
=>
$state
)
{
if
(
!
isset
(
$defs
[
$key
]
)
)
{
// @todo Use jobqueue
$title
=
Title
::
makeTitleSafe
(
$this
->
getNamespace
(),
$key
);
$page
=
$wikiPageFactory
->
newFromTitle
(
$title
);
$content
=
ContentHandler
::
makeContent
(
$state
,
$title
);
$fuzzyBotUser
=
FuzzyBot
::
getUser
();
$updater
=
$page
->
newPageUpdater
(
$fuzzyBotUser
)
->
setContent
(
SlotRecord
::
MAIN
,
$content
);
if
(
$fuzzyBotUser
->
authorizeWrite
(
'autopatrol'
,
$title
)
)
{
$updater
->
setRcPatrolStatus
(
RecentChange
::
PRC_AUTOPATROLLED
);
}
$summary
=
wfMessage
(
'translate-workflow-autocreated-summary'
,
$state
)->
inContentLanguage
()->
text
();
$updater
->
saveRevision
(
CommentStoreComment
::
newUnsavedComment
(
$summary
),
EDIT_FORCE_BOT
);
}
else
{
// Use the wiki translation as definition if available.
// getContents returns array( content, last author )
[
$content
,
]
=
$defs
[
$key
];
$keys
[
$key
]
=
$content
;
}
}
return
$keys
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 14:11 (1 d, 14 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b0/6a/41c59dd0ec0896dc3b9d6b9b39b3
Default Alt Text
WorkflowStatesMessageGroup.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment