Index: trunk/extensions/uniwiki/AutoCreateCategoryPages/AutoCreateCategoryPages.php |
— | — | @@ -3,32 +3,27 @@ |
4 | 4 | * http://www.mediawiki.org/wiki/Extension:Uniwiki_Auto_Create_Category_Pages |
5 | 5 | * http://www.gnu.org/licenses/gpl-3.0.txt */ |
6 | 6 | |
7 | | -if (!defined('MEDIAWIKI')) |
| 7 | +if ( !defined( 'MEDIAWIKI' ) ) |
8 | 8 | die(); |
9 | 9 | |
10 | 10 | /* ---- CREDITS ---- */ |
11 | 11 | $wgExtensionCredits['other'][] = array( |
12 | | - 'name' => "AutoCreateCategoryPages", |
13 | | - 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)", |
14 | | - 'description' => "Create stub Category pages automatically" |
| 12 | + 'name' => 'AutoCreateCategoryPages', |
| 13 | + 'author' => 'Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)', |
| 14 | + 'description' => 'Create stub Category pages automatically', |
| 15 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:Uniwiki/AutoCreateCategoryPages', |
| 16 | + 'svn-date' => '$LastChangedDate$', |
| 17 | + 'svn-revision' => '$LastChangedRevision$', |
| 18 | + 'descriptionmsg' => 'autocreatecategorypages-desc', |
15 | 19 | ); |
16 | 20 | |
17 | | -/* ---- INTERNATIONALIZATION ---- */ |
| 21 | +$wgExtensionMessagesFiles['AutoCreateCategoryPages'] = dirname( __FILE__ ) . '/AutoCreateCategoryPages.i18n.php'; |
18 | 22 | |
19 | | -require_once ("AutoCreateCategoryPages.i18n.php"); |
20 | | -$wgExtensionFunctions[] = "AutoCreateCategoryPages_i18n"; |
21 | | - |
22 | | -function AutoCreateCategoryPages_i18n() { |
23 | | - // add this extension's messages to the message cache |
24 | | - global $wgMessageCache, $wgAutoCreateCategoryPagesMessages; |
25 | | - foreach ($wgAutoCreateCategoryPagesMessages as $lang => $messages) |
26 | | - $wgMessageCache->addMessages ($messages, $lang); |
27 | | -} |
28 | | - |
29 | 23 | /* ---- HOOKS ---- */ |
30 | 24 | $wgHooks['ArticleSaveComplete'][] = "UW_AutoCreateCategoryPages_Save"; |
31 | | -function UW_AutoCreateCategoryPages_Save (&$article, &$user, &$text, &$summary, &$minoredit, |
32 | | - &$watchthis, &$sectionanchor, &$flags, $revision) { |
| 25 | + |
| 26 | +function UW_AutoCreateCategoryPages_Save ( &$article, &$user, &$text, &$summary, &$minoredit, |
| 27 | + &$watchthis, &$sectionanchor, &$flags, $revision ) { |
33 | 28 | global $wgDBprefix; |
34 | 29 | |
35 | 30 | /* after the page is saved, get all the categories |
— | — | @@ -37,38 +32,38 @@ |
38 | 33 | |
39 | 34 | // extract the categories on this page |
40 | 35 | $regex = "/\[\[category:(.+?)(?:\|.*)?\]\]/i"; |
41 | | - preg_match_all ($regex, $text, $matches); |
| 36 | + preg_match_all ( $regex, $text, $matches ); |
42 | 37 | |
43 | 38 | // array of the categories on the page (in db form) |
44 | 39 | $on_page = array(); |
45 | | - foreach ($matches[1] as $cat) |
46 | | - $on_page[] = Title::newFromText ($cat)->getDBkey(); |
| 40 | + foreach ( $matches[1] as $cat ) |
| 41 | + $on_page[] = Title::newFromText ( $cat )->getDBkey(); |
47 | 42 | |
48 | 43 | // array of the categories in the db |
49 | | - $db = wfGetDB (DB_MASTER); |
50 | | - $results = $db->resultObject ($db->query( |
| 44 | + $db = wfGetDB ( DB_MASTER ); |
| 45 | + $results = $db->resultObject ( $db->query( |
51 | 46 | "select distinct page_title from {$wgDBprefix}page " . |
52 | | - "where page_namespace = '".NS_CATEGORY."'")); |
| 47 | + "where page_namespace = '" . NS_CATEGORY . "'" ) ); |
53 | 48 | |
54 | 49 | $in_db = array(); |
55 | | - while ($r = $results->next()) |
| 50 | + while ( $r = $results->next() ) |
56 | 51 | $in_db[] = $r->page_title; |
57 | 52 | |
58 | 53 | /* loop through the categories in the page and |
59 | 54 | * see if they already exist as a category page */ |
60 | | - foreach ($on_page as $db_key) { |
61 | | - if (!in_array( $db_key, $in_db)) { |
| 55 | + foreach ( $on_page as $db_key ) { |
| 56 | + if ( !in_array( $db_key, $in_db ) ) { |
62 | 57 | |
63 | 58 | // if it doesn't exist, then create it here |
64 | | - $page_title = Title::newFromDBkey ($db_key)->getText(); |
65 | | - $stub = wfMsg ("accp_stub", $page_title); |
66 | | - $summary = wfMsg ("accp_createdby"); |
67 | | - $article = new Article (Title::newFromDBkey("Category:$db_key")); |
| 59 | + $page_title = Title::newFromDBkey ( $db_key )->getText(); |
| 60 | + $stub = wfMsgForContent ( 'autocreatecategorypages-stub', $page_title ); |
| 61 | + $summary = wfMsgForContent ( 'autocreatecategorypages-createdby' ); |
| 62 | + $article = new Article ( Title::newFromDBkey( "Category:$db_key" ) ); |
68 | 63 | |
69 | 64 | try { |
70 | | - $article->doEdit ($stub, $summary, EDIT_NEW & EDIT_SUPPRESS_RC); |
| 65 | + $article->doEdit ( $stub, $summary, EDIT_NEW & EDIT_SUPPRESS_RC ); |
71 | 66 | |
72 | | - } catch (MWException $e) { |
| 67 | + } catch ( MWException $e ) { |
73 | 68 | /* fail silently... |
74 | 69 | * todo: what can go wrong here? */ |
75 | 70 | } |
Property changes on: trunk/extensions/uniwiki/AutoCreateCategoryPages/AutoCreateCategoryPages.php |
___________________________________________________________________ |
Added: svn:keywords |
76 | 71 | + LastChangedDate LastChangedRevision |
Index: trunk/extensions/uniwiki/AutoCreateCategoryPages/AutoCreateCategoryPages.i18n.php |
— | — | @@ -1,28 +1,35 @@ |
2 | 2 | <?php |
3 | | -/* vim: noet ts=4 sw=4 |
4 | | - * http://www.mediawiki.org/wiki/Extension:Uniwiki_Auto_Create_Category_Pages |
5 | | - * http://www.gnu.org/licenses/gpl-3.0.txt */ |
| 3 | +/** |
| 4 | + * Internationalisation for Uniwiki/AutoCreateCategoryPages extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
6 | 9 | |
7 | | -if (!defined("MEDIAWIKI")) |
8 | | - die(); |
| 10 | +$messages = array(); |
9 | 11 | |
10 | | -$wgAutoCreateCategoryPagesMessages = array(); |
11 | | -$wgAutoCreateCategoryPagesMessages['en'] = array( |
12 | | - 'accp_stub' => "This is a category page. It lists all of the pages in category \"$1\" as well as all subcategories of category \"$1\" if any exist.", |
13 | | - 'accp_createdby' => "Created automatically by the AutoCreateCategoryPage extension." |
| 12 | +/** English */ |
| 13 | +$messages['en'] = array( |
| 14 | + 'autocreatecategorypages-desc' => 'Create missing category pages automatically on save', |
| 15 | + 'autocreatecategorypages-stub' => 'This is a category page. |
| 16 | +It lists all of the pages in category "$1" as well as all subcategories of category "$1" if any exist.', |
| 17 | + 'autocreatecategorypages-createdby' => 'Created automatically by the AutoCreateCategoryPages extension.' |
14 | 18 | ); |
15 | 19 | |
16 | | -$wgAutoCreateCategoryPagesMessages['es'] = array( |
17 | | - 'accp_stub' => "Esta es una página de categorÃas. Aquà se enumeran todas las páginas en la categorÃa \"$1\" asà como todas las subcategorÃas en la categorÃa \"$1\" si las hubiere.", |
18 | | - 'accp_createdby' => "Creado automáticamente por la extensión AutoCreateCategoryPe." |
| 20 | +$messages['es'] = array( |
| 21 | + 'autocreatecategorypages-stub' => 'Esta es una página de categorías. |
| 22 | +Aqx se enumeran todas las páginas en la categoría "$1" asx como todas las subcategorías en la categoría "$1" si las hubiere.', |
| 23 | + 'autocreatecategorypages-createdby' => 'Creado automáticamente por la extensión AutoCreateCategoryPages.' |
19 | 24 | ); |
20 | 25 | |
21 | | -$wgAutoCreateCategoryPagesMessages['de'] = array( |
22 | | - 'accp_stub' => "Dies ist eine Kategorie Übersicht. Es listet alle Seiten in der Kategorie \"$1\" sowie alle Unterkategorien der Kategorie \"$1\" wenn sie existiert.", |
23 | | - 'accp_createdby' => "Erstellt automatisch von der AutoCreateCategoryPage Erweiterung" |
| 26 | +$messages['de'] = array( |
| 27 | + 'autocreatecategorypages-stub' => 'Dies ist eine Kategorie Übersicht. |
| 28 | +Es listet alle Seiten in der Kategorie "$1" sowie alle Unterkategorien der Kategorie "$1" wenn sie existiert.', |
| 29 | + 'autocreatecategorypages-createdby' => 'Erstellt automatisch von der AutoCreateCategoryPages Erweiterung' |
24 | 30 | ); |
25 | 31 | |
26 | | -$wgAutoCreateCategoryPagesMessages['pt-br'] = array( |
27 | | - 'accp_stub' => "Esta é uma página de categoria. Ela lista todas as páginas da categoria \"$1\", bem como todas as subcategorias da categoria \"$1\", se existirem.", |
28 | | - 'accp_createdby' => "Gerada automaticamente pela extensão AutoCreateCategoryPag." |
| 32 | +$messages['pt-br'] = array( |
| 33 | + 'autocreatecategorypages-stub' => 'Esta é uma página de categoria. |
| 34 | +Ela lista todas as páginas da categoria "$1", bem como todas as subcategorias da categoria "$1", se existirem.', |
| 35 | + 'autocreatecategorypages-createdby' => 'Gerada automaticamente pela extensxo AutoCreateCategoryPages.' |
29 | 36 | ); |