r64993 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64992‎ | r64993 | r64994 >
Date:16:44, 13 April 2010
Author:yaron
Status:deferred
Tags:
Comment:
Renaming and moving file, to fit standard MediaWiki convention
Modified paths:
  • /trunk/extensions/DataTransfer/DataTransfer.php (added) (history)
  • /trunk/extensions/DataTransfer/includes/DT_GlobalFunctions.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/DataTransfer/DataTransfer.php
@@ -0,0 +1,123 @@
 2+<?php
 3+/**
 4+ * Global functions and constants for the Data Transfer extension.
 5+ *
 6+ * @author Yaron Koren
 7+ */
 8+
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
 10+
 11+define( 'DT_VERSION', '0.3.4' );
 12+
 13+// constants for special properties
 14+define( 'DT_SP_HAS_XML_GROUPING', 1 );
 15+define( 'DT_SP_IS_EXCLUDED_FROM_XML', 2 );
 16+
 17+$wgExtensionCredits['specialpage'][] = array(
 18+ 'path' => __FILE__,
 19+ 'name' => 'Data Transfer',
 20+ 'version' => DT_VERSION,
 21+ 'author' => 'Yaron Koren',
 22+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Data_Transfer',
 23+ 'descriptionmsg' => 'dt-desc',
 24+);
 25+
 26+$dtgIP = $IP . '/extensions/DataTransfer';
 27+
 28+// register all special pages and other classes
 29+$wgSpecialPages['ViewXML'] = 'DTViewXML';
 30+$wgAutoloadClasses['DTViewXML'] = $dtgIP . '/specials/DT_ViewXML.php';
 31+$wgSpecialPages['ImportXML'] = 'DTImportXML';
 32+$wgAutoloadClasses['DTImportXML'] = $dtgIP . '/specials/DT_ImportXML.php';
 33+$wgSpecialPages['ImportCSV'] = 'DTImportCSV';
 34+$wgAutoloadClasses['DTImportCSV'] = $dtgIP . '/specials/DT_ImportCSV.php';
 35+$wgJobClasses['dtImport'] = 'DTImportJob';
 36+$wgAutoloadClasses['DTImportJob'] = $dtgIP . '/includes/DT_ImportJob.php';
 37+$wgAutoloadClasses['DTXMLParser'] = $dtgIP . '/includes/DT_XMLParser.php';
 38+$wgHooks['AdminLinks'][] = 'dtfAddToAdminLinks';
 39+$wgHooks['smwInitProperties'][] = 'dtfInitProperties';
 40+
 41+require_once( $dtgIP . '/languages/DT_Language.php' );
 42+$wgExtensionMessagesFiles['DataTransfer'] = $dtgIP . '/languages/DT_Messages.php';
 43+$wgExtensionAliasesFiles['DataTransfer'] = $dtgIP . '/languages/DT_Aliases.php';
 44+
 45+/**********************************************/
 46+/***** language settings *****/
 47+/**********************************************/
 48+
 49+/**
 50+ * Initialise a global language object for content language. This
 51+ * must happen early on, even before user language is known, to
 52+ * determine labels for additional namespaces. In contrast, messages
 53+ * can be initialised much later when they are actually needed.
 54+ */
 55+function dtfInitContentLanguage( $langcode ) {
 56+ global $dtgIP, $dtgContLang;
 57+
 58+ if ( !empty( $dtgContLang ) ) { return; }
 59+
 60+ $dtContLangClass = 'DT_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
 61+
 62+ if ( file_exists( $dtgIP . '/languages/' . $dtContLangClass . '.php' ) ) {
 63+ include_once( $dtgIP . '/languages/' . $dtContLangClass . '.php' );
 64+ }
 65+
 66+ // fallback if language not supported
 67+ if ( !class_exists( $dtContLangClass ) ) {
 68+ include_once( $dtgIP . '/languages/DT_LanguageEn.php' );
 69+ $dtContLangClass = 'DT_LanguageEn';
 70+ }
 71+
 72+ $dtgContLang = new $dtContLangClass();
 73+}
 74+
 75+/**
 76+ * Initialise the global language object for user language. This
 77+ * must happen after the content language was initialised, since
 78+ * this language is used as a fallback.
 79+ */
 80+function dtfInitUserLanguage( $langcode ) {
 81+ global $dtgIP, $dtgLang;
 82+
 83+ if ( !empty( $dtgLang ) ) { return; }
 84+
 85+ $dtLangClass = 'DT_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
 86+
 87+ if ( file_exists( $dtgIP . '/languages/' . $dtLangClass . '.php' ) ) {
 88+ include_once( $dtgIP . '/languages/' . $dtLangClass . '.php' );
 89+ }
 90+
 91+ // fallback if language not supported
 92+ if ( !class_exists( $dtLangClass ) ) {
 93+ global $dtgContLang;
 94+ $dtgLang = $dtgContLang;
 95+ } else {
 96+ $dtgLang = new $dtLangClass();
 97+ }
 98+}
 99+
 100+/**********************************************/
 101+/***** other global helpers *****/
 102+/**********************************************/
 103+
 104+function dtfInitProperties() {
 105+ global $dtgContLang;
 106+ $dt_props = $dtgContLang->getPropertyLabels();
 107+ SMWPropertyValue::registerProperty( '_DT_XG', '_str', $dt_props[DT_SP_HAS_XML_GROUPING], true );
 108+ // TODO - this should set a "backup" English value as well,
 109+ // so that the phrase "Has XML grouping" works in all languages
 110+ return true;
 111+}
 112+
 113+/**
 114+ * Add links to the 'AdminLinks' special page, defined by the Admin Links
 115+ * extension
 116+ */
 117+function dtfAddToAdminLinks( $admin_links_tree ) {
 118+ $import_export_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_importexport' ) );
 119+ $main_row = $import_export_section->getRow( 'main' );
 120+ $main_row->addItem( ALItem::newFromSpecialPage( 'ViewXML' ) );
 121+ $main_row->addItem( ALItem::newFromSpecialPage( 'ImportXML' ) );
 122+ $main_row->addItem( ALItem::newFromSpecialPage( 'ImportCSV' ) );
 123+ return true;
 124+}
Property changes on: trunk/extensions/DataTransfer/DataTransfer.php
___________________________________________________________________
Name: svn:eol-style
1125 + native
Index: trunk/extensions/DataTransfer/includes/DT_GlobalFunctions.php
@@ -1,123 +0,0 @@
2 -<?php
3 -/**
4 - * Global functions and constants for the Data Transfer extension.
5 - *
6 - * @author Yaron Koren
7 - */
8 -
9 -if ( !defined( 'MEDIAWIKI' ) ) die();
10 -
11 -define( 'DT_VERSION', '0.3.4' );
12 -
13 -// constants for special properties
14 -define( 'DT_SP_HAS_XML_GROUPING', 1 );
15 -define( 'DT_SP_IS_EXCLUDED_FROM_XML', 2 );
16 -
17 -$wgExtensionCredits['specialpage'][] = array(
18 - 'path' => __FILE__,
19 - 'name' => 'Data Transfer',
20 - 'version' => DT_VERSION,
21 - 'author' => 'Yaron Koren',
22 - 'url' => 'http://www.mediawiki.org/wiki/Extension:Data_Transfer',
23 - 'descriptionmsg' => 'dt-desc',
24 -);
25 -
26 -$dtgIP = $IP . '/extensions/DataTransfer';
27 -
28 -// register all special pages and other classes
29 -$wgSpecialPages['ViewXML'] = 'DTViewXML';
30 -$wgAutoloadClasses['DTViewXML'] = $dtgIP . '/specials/DT_ViewXML.php';
31 -$wgSpecialPages['ImportXML'] = 'DTImportXML';
32 -$wgAutoloadClasses['DTImportXML'] = $dtgIP . '/specials/DT_ImportXML.php';
33 -$wgSpecialPages['ImportCSV'] = 'DTImportCSV';
34 -$wgAutoloadClasses['DTImportCSV'] = $dtgIP . '/specials/DT_ImportCSV.php';
35 -$wgJobClasses['dtImport'] = 'DTImportJob';
36 -$wgAutoloadClasses['DTImportJob'] = $dtgIP . '/includes/DT_ImportJob.php';
37 -$wgAutoloadClasses['DTXMLParser'] = $dtgIP . '/includes/DT_XMLParser.php';
38 -$wgHooks['AdminLinks'][] = 'dtfAddToAdminLinks';
39 -$wgHooks['smwInitProperties'][] = 'dtfInitProperties';
40 -
41 -require_once( $dtgIP . '/languages/DT_Language.php' );
42 -$wgExtensionMessagesFiles['DataTransfer'] = $dtgIP . '/languages/DT_Messages.php';
43 -$wgExtensionAliasesFiles['DataTransfer'] = $dtgIP . '/languages/DT_Aliases.php';
44 -
45 -/**********************************************/
46 -/***** language settings *****/
47 -/**********************************************/
48 -
49 -/**
50 - * Initialise a global language object for content language. This
51 - * must happen early on, even before user language is known, to
52 - * determine labels for additional namespaces. In contrast, messages
53 - * can be initialised much later when they are actually needed.
54 - */
55 -function dtfInitContentLanguage( $langcode ) {
56 - global $dtgIP, $dtgContLang;
57 -
58 - if ( !empty( $dtgContLang ) ) { return; }
59 -
60 - $dtContLangClass = 'DT_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
61 -
62 - if ( file_exists( $dtgIP . '/languages/' . $dtContLangClass . '.php' ) ) {
63 - include_once( $dtgIP . '/languages/' . $dtContLangClass . '.php' );
64 - }
65 -
66 - // fallback if language not supported
67 - if ( !class_exists( $dtContLangClass ) ) {
68 - include_once( $dtgIP . '/languages/DT_LanguageEn.php' );
69 - $dtContLangClass = 'DT_LanguageEn';
70 - }
71 -
72 - $dtgContLang = new $dtContLangClass();
73 -}
74 -
75 -/**
76 - * Initialise the global language object for user language. This
77 - * must happen after the content language was initialised, since
78 - * this language is used as a fallback.
79 - */
80 -function dtfInitUserLanguage( $langcode ) {
81 - global $dtgIP, $dtgLang;
82 -
83 - if ( !empty( $dtgLang ) ) { return; }
84 -
85 - $dtLangClass = 'DT_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
86 -
87 - if ( file_exists( $dtgIP . '/languages/' . $dtLangClass . '.php' ) ) {
88 - include_once( $dtgIP . '/languages/' . $dtLangClass . '.php' );
89 - }
90 -
91 - // fallback if language not supported
92 - if ( !class_exists( $dtLangClass ) ) {
93 - global $dtgContLang;
94 - $dtgLang = $dtgContLang;
95 - } else {
96 - $dtgLang = new $dtLangClass();
97 - }
98 -}
99 -
100 -/**********************************************/
101 -/***** other global helpers *****/
102 -/**********************************************/
103 -
104 -function dtfInitProperties() {
105 - global $dtgContLang;
106 - $dt_props = $dtgContLang->getPropertyLabels();
107 - SMWPropertyValue::registerProperty( '_DT_XG', '_str', $dt_props[DT_SP_HAS_XML_GROUPING], true );
108 - // TODO - this should set a "backup" English value as well,
109 - // so that the phrase "Has XML grouping" works in all languages
110 - return true;
111 -}
112 -
113 -/**
114 - * Add links to the 'AdminLinks' special page, defined by the Admin Links
115 - * extension
116 - */
117 -function dtfAddToAdminLinks( $admin_links_tree ) {
118 - $import_export_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_importexport' ) );
119 - $main_row = $import_export_section->getRow( 'main' );
120 - $main_row->addItem( ALItem::newFromSpecialPage( 'ViewXML' ) );
121 - $main_row->addItem( ALItem::newFromSpecialPage( 'ImportXML' ) );
122 - $main_row->addItem( ALItem::newFromSpecialPage( 'ImportCSV' ) );
123 - return true;
124 -}

Status & tagging log