ArticleSaveComplete executes after someone has saved an edit to a page
- either when the page is first created, or on subsequent edits. So
therefor, $_SERVER['HTTP_REFERER'] should always be the Edit version
of the page they just saved - or something to that effect.
It's not clear from your code fragment what it is you hope to achieve.
If you can provide more info on what it is you want the code to do, I
may be able to help more.
Hi Jim, hi @all,
here the total code.
I used the LabeledSectionTransclusion to create some kind of variable articles.
To enable the user to edit the origin article, the transcluded contents are
purchased from I use the function 'EditForwarding'.
When activating the edit-button, the content is checked for the LST-syntax. So
far this syntax exists in this content, the origin article-title is filtered out
of the syntax. Afterwards the user is forwarded to this article in the edit-mode.
What I know try to do is to 'reforward' the user to the site he came from, after
the article is saved. Therefore I want to check, if the content of the saved
article contains the string "<section begin=".
It's quite plain to me, that it will not work by using the 'HTTP_REFERER'. I
saw
this while using the same syntax in combination with the 'ArticleSave-Hook'.
But maybe it would be feasible by using cookies.
But I don't understand, why it doesn't work anyway if I change the hook to
'ArticleSaveComplete'. Seems I don't get the right vareables to get the
articles
content!?!
greets, demagggus
<?php
# get out if not part of mediawiki ..
if( !defined( 'MEDIAWIKI' ) ) {
echo( "This file is part of an extension to the MediaWiki software and
cannot be used standalone.\n" );
die( true );
}
$wgExtensionCredits['other'][] = array(
'name' => 'EditSubstitutionRestore',
'author' => 'Marcus Schäfer',
'url' => '',
'description' => '' );
$wgHooks['AlternateEdit'][] = 'EditForwarding';
$wgHooks['ArticleSaveComplete'][] = 'ArticleReturn';
function EditForwarding(&$editpage) {
global $wgOut, $wgUser, $wgRequest, $wgTitle, $wgParser;
// get the title for the current article
$articleTitle = $editpage->mTitle->getText();
// get the content for the current article
$articleText = $editpage->mArticle->getContent();
// check if the current article contains the LST-syntax
if (preg_match('/{{#lst:|#lsth:/i', $articleText)) {
// extract the origin article name out of the SelectedTransclusion-Syntax
$articleTitle_origin = preg_replace('/{{#lst:|\|lux}}|\ger}}/', '',
$articleText);
// forward to the origin article; enter in edit-mode (using php-header)
header("Location:
http://localhost/mediawiki/index.php?title=$articleTitle_origin&action=…)it");
} else {
return true;
}
}
function ArticleReturn(&$text) {
global $wgOut, $wgUser, $wgRequest, $wgTitle, $wgParser;
$articleText = $text->getContent();
$referer = $_SERVER['HTTP_REFERER'];
if (preg_match('/<section begin=/', $articleText)) {
header("Location: $referer");
} else {
return true;
}
}
?>