DanTMan <dan_the_man@...> writes:
It could be implemented inside of an extension using the ArticleSave hook. You can use $user->ifAllowed( '' ); to check if the saving user has the permissions to save without a category. And you can either do a regex on $text to see if there is a category tag in the page. Or you can parse $text using the parser, and use the ParserOutput to see if a category is inside the page or not. The method is your pick, the former is faster, but the latter will allow for use of templates with categories instead of only [[Category:]] tags.
~Daniel Friesen(Dantman) of: -The Gaiapedia (http://gaia.wikia.com) -Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG) -and Wiki-Tools.com (http://wiki-tools.com)
Christensen, Courtney wrote:
Swapnil schreef:
But it seems users are still creating pages without any category. How
can I
forcefully apply this policy so that users cannot create a page
without a
category? Is there any way to impose this rule in mediawiki.
Try http://www.mediawiki.org/wiki/Extension:Postloader
If you have a default category that articles can be saved to then you could add the [[Category:Default]] to every article. Or you could use something like this: http://www.mediawiki.org/wiki/Extension:CategorySuggest
I'm pretty sure you can also check to make sure a category has been selected and not allow a save to complete without it. Especially if your category entry spot is its own form element.
Good luck! -Courtney
Wikitech-l mailing list Wikitech-l@... http://lists.wikimedia.org/mailman/listinfo/wikitech-l
Hey Thanks Dantman !!!! Your ArticleSave trick worked !!! I'm listening for this event and then checking for the existance of category in the $text of the page. If not found then add a message at the begining of the page for not having a category and then allow it to be saved. Upon saving the user cannot just miss the ugly message and will add a category to get rid of this message.
The ugly message is actually a template called {{MissingCategory}}.
<?php # - Author: Swapnil Sapar $wgHooks['ArticleSave'][] = 'wfCheckCategory';
function wfCheckCategory(&$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor) { // remove the ugly message if its already presnt in $text $text = str_replace("{{MissingCategory}}", "",$text); // check if the category is present in the $text if(preg_match("/[[category:[\w~!@$%^&*()\s]+]]/i",$text)) { // let him go if he already has the category. return true; } else { //gotcha !!! you will get my ugly message with your page. $text = "{{MissingCategory}}".$text; return true; } } ?>
Now I dont have to go after 100+ users to add a category to their pages. Thanks a ton.
Swapnil