I'm writing a ArticleAfterFetchContent hook:
$wgHooks['ArticleAfterFetchContent'][] = 'myArticleAfterFetchContent';
function myArticleAfterFetchContent (&$article) { ... }
Inside myArticleAfterFetchContent, how do I tell if the user is in edit/view source mode?
A hacky way that almost works: if (isset($article->mMinorEdit)) {...}
This works fine if the user has permission to edit, but not when I'm using the "view source" hack (user who can't edit can still view the source):
$wgHooks['userCan'][] = 'fnMyUserCan'; function fnMyUserCan ($title, $user, $action, $result) { if (($action == 'edit') && $user->isAnon()) {$result = false;} }
What's the correct way of telling if a user is edit mode, even if he's viewing the source? I don't want my hook to run in this case, because I want people to see/edit what's stored in the MySQL backend *before* my hook processes it.
AFAIK, in the codebase, this is the typical way to test for "is edit":
global $wgRequest; $isEdit = $wgRequest->getVal('action') == 'edit';
There are a bunch of Special pages which do this, as well as Article.php
-- Jim R. Wilson (jimbojw)
On 5/28/07, Kelly Jones kelly.terry.jones@gmail.com wrote:
I'm writing a ArticleAfterFetchContent hook:
$wgHooks['ArticleAfterFetchContent'][] = 'myArticleAfterFetchContent';
function myArticleAfterFetchContent (&$article) { ... }
Inside myArticleAfterFetchContent, how do I tell if the user is in edit/view source mode?
A hacky way that almost works: if (isset($article->mMinorEdit)) {...}
This works fine if the user has permission to edit, but not when I'm using the "view source" hack (user who can't edit can still view the source):
$wgHooks['userCan'][] = 'fnMyUserCan'; function fnMyUserCan ($title, $user, $action, $result) { if (($action == 'edit') && $user->isAnon()) {$result = false;} }
What's the correct way of telling if a user is edit mode, even if he's viewing the source? I don't want my hook to run in this case, because I want people to see/edit what's stored in the MySQL backend *before* my hook processes it.
-- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistance to new ideas and technology is unwise and ultimately futile.
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org