r83474 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83473‎ | r83474 | r83475 >
Date:19:01, 7 March 2011
Author:yaron
Status:deferred
Tags:
Comment:
Moved all the non-global-function code from SF_GlobalFunctions.php into SemanticForms.php; also updated version number to 2.1
Modified paths:
  • /trunk/extensions/SemanticForms/SemanticForms.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -8,6 +8,17 @@
99 */
1010 if ( !defined( 'MEDIAWIKI' ) ) die();
1111
 12+define( 'SF_VERSION', '2.1' );
 13+
 14+$wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'specialpage'][] = array(
 15+ 'path' => __FILE__,
 16+ 'name' => 'Semantic Forms',
 17+ 'version' => SF_VERSION,
 18+ 'author' => array( 'Yaron Koren', 'Stephan Gambke', '...' ),
 19+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Forms',
 20+ 'descriptionmsg' => 'semanticforms-desc',
 21+);
 22+
1223 # ##
1324 # This is the path to your installation of Semantic Forms as
1425 # seen from the web. Change it if required ($wgScriptPath is the
@@ -26,6 +37,143 @@
2738 # #
2839
2940
 41+// constants for special properties
 42+define( 'SF_SP_HAS_DEFAULT_FORM', 1 );
 43+define( 'SF_SP_HAS_ALTERNATE_FORM', 2 );
 44+define( 'SF_SP_CREATES_PAGES_WITH_FORM', 3 );
 45+define( 'SF_SP_PAGE_HAS_DEFAULT_FORM', 4 );
 46+define( 'SF_SP_HAS_FIELD_LABEL_FORMAT', 5 );
 47+
 48+$wgExtensionFunctions[] = 'sfgSetupExtension';
 49+
 50+// FIXME: Can be removed when new style magic words are used (introduced in r52503)
 51+$wgHooks['LanguageGetMagic'][] = 'SFParserFunctions::languageGetMagic';
 52+// the 'BrokenLink' hook exists only in MediaWiki v1.13 - it was replaced
 53+// by 'LinkBegin' and 'LinkEnd'
 54+$wgHooks['BrokenLink'][] = 'SFFormLinker::setBrokenLink_1_13';
 55+$wgHooks['LinkEnd'][] = 'SFFormLinker::setBrokenLink';
 56+$wgHooks['UnknownAction'][] = 'SFFormEditTab::displayForm';
 57+// 'SkinTemplateNavigation' replaced 'SkinTemplateTabs' in the Vector skin
 58+$wgHooks['SkinTemplateTabs'][] = 'SFFormEditTab::displayTab';
 59+$wgHooks['SkinTemplateNavigation'][] = 'SFFormEditTab::displayTab2';
 60+$wgHooks['smwInitProperties'][] = 'SFUtils::initProperties';
 61+$wgHooks['AdminLinks'][] = 'sffAddToAdminLinks';
 62+$wgHooks['ParserBeforeStrip'][] = 'SFUtils::cacheFormDefinition';
 63+$wgHooks['ParserFirstCallInit'][] = 'SFParserFunctions::registerFunctions';
 64+$wgHooks['MakeGlobalVariablesScript'][] = 'SFFormUtils::setGlobalJSVariables';
 65+
 66+$wgAPIModules['sfautocomplete'] = 'SFAutocompleteAPI';
 67+
 68+// register all special pages and other classes
 69+$wgSpecialPages['Forms'] = 'SFForms';
 70+$wgAutoloadClasses['SFForms'] = $sfgIP . '/specials/SF_Forms.php';
 71+$wgSpecialPageGroups['Forms'] = 'pages';
 72+$wgSpecialPages['CreateForm'] = 'SFCreateForm';
 73+$wgAutoloadClasses['SFCreateForm'] = $sfgIP . '/specials/SF_CreateForm.php';
 74+$wgSpecialPageGroups['CreateForm'] = 'sf_group';
 75+$wgSpecialPages['Templates'] = 'SFTemplates';
 76+$wgAutoloadClasses['SFTemplates'] = $sfgIP . '/specials/SF_Templates.php';
 77+$wgSpecialPageGroups['Templates'] = 'pages';
 78+$wgSpecialPages['CreateTemplate'] = 'SFCreateTemplate';
 79+$wgAutoloadClasses['SFCreateTemplate'] = $sfgIP . '/specials/SF_CreateTemplate.php';
 80+$wgSpecialPageGroups['CreateTemplate'] = 'sf_group';
 81+$wgSpecialPages['CreateProperty'] = 'SFCreateProperty';
 82+$wgAutoloadClasses['SFCreateProperty'] = $sfgIP . '/specials/SF_CreateProperty.php';
 83+$wgSpecialPageGroups['CreateProperty'] = 'sf_group';
 84+$wgSpecialPages['CreateCategory'] = 'SFCreateCategory';
 85+$wgAutoloadClasses['SFCreateCategory'] = $sfgIP . '/specials/SF_CreateCategory.php';
 86+$wgSpecialPageGroups['CreateCategory'] = 'sf_group';
 87+$wgSpecialPages['CreateClass'] = 'SFCreateClass';
 88+$wgAutoloadClasses['SFCreateClass'] = $sfgIP . '/specials/SF_CreateClass.php';
 89+$wgSpecialPageGroups['CreateClass'] = 'sf_group';
 90+$wgSpecialPages['FormStart'] = 'SFFormStart';
 91+$wgAutoloadClasses['SFFormStart'] = $sfgIP . '/specials/SF_FormStart.php';
 92+$wgSpecialPageGroups['FormStart'] = 'sf_group';
 93+$wgSpecialPages['FormEdit'] = 'SFFormEdit';
 94+$wgAutoloadClasses['SFFormEdit'] = $sfgIP . '/specials/SF_FormEdit.php';
 95+$wgSpecialPageGroups['FormEdit'] = 'sf_group';
 96+$wgSpecialPages['RunQuery'] = 'SFRunQuery';
 97+$wgAutoloadClasses['SFRunQuery'] = $sfgIP . '/specials/SF_RunQuery.php';
 98+$wgSpecialPageGroups['RunQuery'] = 'sf_group';
 99+// different upload-window class for MW 1.16+
 100+if ( class_exists( 'HTMLTextField' ) ) { // added in MW 1.16
 101+ $wgSpecialPages['UploadWindow'] = 'SFUploadWindow2';
 102+ $wgAutoloadClasses['SFUploadWindow2'] = $sfgIP . '/specials/SF_UploadWindow2.php';
 103+} else {
 104+ $wgSpecialPages['UploadWindow'] = 'SFUploadWindow';
 105+ $wgAutoloadClasses['SFUploadWindow'] = $sfgIP . '/specials/SF_UploadWindow.php';
 106+}
 107+$wgAutoloadClasses['SFTemplateField'] = $sfgIP . '/includes/SF_TemplateField.php';
 108+$wgAutoloadClasses['SFForm'] = $sfgIP . '/includes/SF_FormClasses.php';
 109+$wgAutoloadClasses['SFTemplateInForm'] = $sfgIP . '/includes/SF_FormClasses.php';
 110+$wgAutoloadClasses['SFFormField'] = $sfgIP . '/includes/SF_FormField.php';
 111+$wgAutoloadClasses['SFFormPrinter'] = $sfgIP . '/includes/SF_FormPrinter.php';
 112+$wgAutoloadClasses['SFTextInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 113+$wgAutoloadClasses['SFTextAreaInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 114+$wgAutoloadClasses['SFTextWithAutocompleteInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 115+$wgAutoloadClasses['SFDateInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 116+$wgAutoloadClasses['SFDateTimeInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 117+$wgAutoloadClasses['SFDropdownInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 118+$wgAutoloadClasses['SFRadioButtonInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 119+$wgAutoloadClasses['SFListBoxInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 120+$wgAutoloadClasses['SFCheckboxesInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 121+$wgAutoloadClasses['SFCheckboxInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 122+$wgAutoloadClasses['SFComboBoxInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 123+$wgAutoloadClasses['SFCategoryInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 124+$wgAutoloadClasses['SFCategoriesInput'] = $sfgIP . '/includes/SF_FormInputs.php';
 125+$wgAutoloadClasses['SFFormUtils'] = $sfgIP . '/includes/SF_FormUtils.php';
 126+$wgAutoloadClasses['SFFormEditTab'] = $sfgIP . '/includes/SF_FormEditTab.php';
 127+$wgAutoloadClasses['SFFormEditPage'] = $sfgIP . '/includes/SF_FormEditPage.php';
 128+$wgAutoloadClasses['SFUtils'] = $sfgIP . '/includes/SF_Utils.php';
 129+$wgAutoloadClasses['SFFormLinker'] = $sfgIP . '/includes/SF_FormLinker.php';
 130+$wgAutoloadClasses['SFParserFunctions'] = $sfgIP . '/includes/SF_ParserFunctions.php';
 131+$wgAutoloadClasses['SFAutocompleteAPI'] = $sfgIP . '/includes/SF_AutocompleteAPI.php';
 132+$wgJobClasses['createPage'] = 'SFCreatePageJob';
 133+$wgAutoloadClasses['SFCreatePageJob'] = $sfgIP . '/includes/SF_CreatePageJob.php';
 134+require_once( $sfgIP . '/languages/SF_Language.php' );
 135+
 136+$wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Messages.php';
 137+$wgExtensionAliasesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Aliases.php';
 138+// Allow for file-upload windows for MW >= 1.16.1
 139+$wgEditPageFrameOptions = 'SAMEORIGIN';
 140+
 141+// register client-side modules
 142+if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) {
 143+ $sfgResourceTemplate = array(
 144+ 'localBasePath' => $sfgIP,
 145+ 'remoteExtPath' => 'SemanticForms'
 146+ );
 147+ $wgResourceModules += array(
 148+ 'ext.semanticforms.main' => $sfgResourceTemplate + array(
 149+ 'scripts' => array(
 150+ 'libs/SemanticForms.js',
 151+ 'libs/SF_ajax_form_preview.js',
 152+ ),
 153+ 'styles' => array(
 154+ 'skins/SemanticForms.css',
 155+ 'skins/SF_jquery_ui_overrides.css',
 156+ ),
 157+ 'dependencies' => array(
 158+ 'jquery.ui.autocomplete',
 159+ 'jquery.ui.button',
 160+ 'jquery.ui.sortable',
 161+ ),
 162+ ),
 163+ 'ext.semanticforms.fancybox' => $sfgResourceTemplate + array(
 164+ 'scripts' => 'libs/jquery.fancybox-1.3.1.js',
 165+ 'styles' => 'skins/jquery.fancybox-1.3.1.css',
 166+ ),
 167+ 'ext.semanticforms.autogrow' => $sfgResourceTemplate + array(
 168+ 'scripts' => 'libs/SF_autogrow.js',
 169+ ),
 170+ 'ext.semanticforms.popupformedit' => $sfgResourceTemplate + array(
 171+ 'scripts' => 'libs/SF_popupform.js',
 172+ 'styles' => 'skins/SF_popupform.css',
 173+ 'dependencies' => array( 'jquery' ),
 174+ ),
 175+ );
 176+}
 177+
30178 // PHP fails to find relative includes at some level of inclusion:
31179 // $pathfix = $IP . $sfgScriptPath;
32180
Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php
@@ -1,160 +1,12 @@
22 <?php
33 /**
4 - * Constants and initializations for Semantic Forms.
 4+ * Global functions for Semantic Forms.
55 *
66 * @author Yaron Koren
77 */
88
99 if ( !defined( 'MEDIAWIKI' ) ) die();
1010
11 -define( 'SF_VERSION', '2.1alpha' );
12 -
13 -$wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'specialpage'][] = array(
14 - 'path' => __FILE__,
15 - 'name' => 'Semantic Forms',
16 - 'version' => SF_VERSION,
17 - 'author' => array( 'Yaron Koren', 'Stephan Gambke', '...' ),
18 - 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Forms',
19 - 'descriptionmsg' => 'semanticforms-desc',
20 -);
21 -
22 -// constants for special properties
23 -define( 'SF_SP_HAS_DEFAULT_FORM', 1 );
24 -define( 'SF_SP_HAS_ALTERNATE_FORM', 2 );
25 -define( 'SF_SP_CREATES_PAGES_WITH_FORM', 3 );
26 -define( 'SF_SP_PAGE_HAS_DEFAULT_FORM', 4 );
27 -define( 'SF_SP_HAS_FIELD_LABEL_FORMAT', 5 );
28 -
29 -$wgExtensionFunctions[] = 'sfgSetupExtension';
30 -
31 -// FIXME: Can be removed when new style magic words are used (introduced in r52503)
32 -$wgHooks['LanguageGetMagic'][] = 'SFParserFunctions::languageGetMagic';
33 -// the 'BrokenLink' hook exists only in MediaWiki v1.13 - it was replaced
34 -// by 'LinkBegin' and 'LinkEnd'
35 -$wgHooks['BrokenLink'][] = 'SFFormLinker::setBrokenLink_1_13';
36 -$wgHooks['LinkEnd'][] = 'SFFormLinker::setBrokenLink';
37 -$wgHooks['UnknownAction'][] = 'SFFormEditTab::displayForm';
38 -// 'SkinTemplateNavigation' replaced 'SkinTemplateTabs' in the Vector skin
39 -$wgHooks['SkinTemplateTabs'][] = 'SFFormEditTab::displayTab';
40 -$wgHooks['SkinTemplateNavigation'][] = 'SFFormEditTab::displayTab2';
41 -$wgHooks['smwInitProperties'][] = 'SFUtils::initProperties';
42 -$wgHooks['AdminLinks'][] = 'sffAddToAdminLinks';
43 -$wgHooks['ParserBeforeStrip'][] = 'SFUtils::cacheFormDefinition';
44 -$wgHooks['ParserFirstCallInit'][] = 'SFParserFunctions::registerFunctions';
45 -$wgHooks['MakeGlobalVariablesScript'][] = 'SFFormUtils::setGlobalJSVariables';
46 -
47 -$wgAPIModules['sfautocomplete'] = 'SFAutocompleteAPI';
48 -
49 -// register all special pages and other classes
50 -$wgSpecialPages['Forms'] = 'SFForms';
51 -$wgAutoloadClasses['SFForms'] = $sfgIP . '/specials/SF_Forms.php';
52 -$wgSpecialPageGroups['Forms'] = 'pages';
53 -$wgSpecialPages['CreateForm'] = 'SFCreateForm';
54 -$wgAutoloadClasses['SFCreateForm'] = $sfgIP . '/specials/SF_CreateForm.php';
55 -$wgSpecialPageGroups['CreateForm'] = 'sf_group';
56 -$wgSpecialPages['Templates'] = 'SFTemplates';
57 -$wgAutoloadClasses['SFTemplates'] = $sfgIP . '/specials/SF_Templates.php';
58 -$wgSpecialPageGroups['Templates'] = 'pages';
59 -$wgSpecialPages['CreateTemplate'] = 'SFCreateTemplate';
60 -$wgAutoloadClasses['SFCreateTemplate'] = $sfgIP . '/specials/SF_CreateTemplate.php';
61 -$wgSpecialPageGroups['CreateTemplate'] = 'sf_group';
62 -$wgSpecialPages['CreateProperty'] = 'SFCreateProperty';
63 -$wgAutoloadClasses['SFCreateProperty'] = $sfgIP . '/specials/SF_CreateProperty.php';
64 -$wgSpecialPageGroups['CreateProperty'] = 'sf_group';
65 -$wgSpecialPages['CreateCategory'] = 'SFCreateCategory';
66 -$wgAutoloadClasses['SFCreateCategory'] = $sfgIP . '/specials/SF_CreateCategory.php';
67 -$wgSpecialPageGroups['CreateCategory'] = 'sf_group';
68 -$wgSpecialPages['CreateClass'] = 'SFCreateClass';
69 -$wgAutoloadClasses['SFCreateClass'] = $sfgIP . '/specials/SF_CreateClass.php';
70 -$wgSpecialPageGroups['CreateClass'] = 'sf_group';
71 -$wgSpecialPages['FormStart'] = 'SFFormStart';
72 -$wgAutoloadClasses['SFFormStart'] = $sfgIP . '/specials/SF_FormStart.php';
73 -$wgSpecialPageGroups['FormStart'] = 'sf_group';
74 -$wgSpecialPages['FormEdit'] = 'SFFormEdit';
75 -$wgAutoloadClasses['SFFormEdit'] = $sfgIP . '/specials/SF_FormEdit.php';
76 -$wgSpecialPageGroups['FormEdit'] = 'sf_group';
77 -$wgSpecialPages['RunQuery'] = 'SFRunQuery';
78 -$wgAutoloadClasses['SFRunQuery'] = $sfgIP . '/specials/SF_RunQuery.php';
79 -$wgSpecialPageGroups['RunQuery'] = 'sf_group';
80 -// different upload-window class for MW 1.16+
81 -if ( class_exists( 'HTMLTextField' ) ) { // added in MW 1.16
82 - $wgSpecialPages['UploadWindow'] = 'SFUploadWindow2';
83 - $wgAutoloadClasses['SFUploadWindow2'] = $sfgIP . '/specials/SF_UploadWindow2.php';
84 -} else {
85 - $wgSpecialPages['UploadWindow'] = 'SFUploadWindow';
86 - $wgAutoloadClasses['SFUploadWindow'] = $sfgIP . '/specials/SF_UploadWindow.php';
87 -}
88 -$wgAutoloadClasses['SFTemplateField'] = $sfgIP . '/includes/SF_TemplateField.php';
89 -$wgAutoloadClasses['SFForm'] = $sfgIP . '/includes/SF_FormClasses.php';
90 -$wgAutoloadClasses['SFTemplateInForm'] = $sfgIP . '/includes/SF_FormClasses.php';
91 -$wgAutoloadClasses['SFFormField'] = $sfgIP . '/includes/SF_FormField.php';
92 -$wgAutoloadClasses['SFFormPrinter'] = $sfgIP . '/includes/SF_FormPrinter.php';
93 -$wgAutoloadClasses['SFTextInput'] = $sfgIP . '/includes/SF_FormInputs.php';
94 -$wgAutoloadClasses['SFTextAreaInput'] = $sfgIP . '/includes/SF_FormInputs.php';
95 -$wgAutoloadClasses['SFTextWithAutocompleteInput'] = $sfgIP . '/includes/SF_FormInputs.php';
96 -$wgAutoloadClasses['SFDateInput'] = $sfgIP . '/includes/SF_FormInputs.php';
97 -$wgAutoloadClasses['SFDateTimeInput'] = $sfgIP . '/includes/SF_FormInputs.php';
98 -$wgAutoloadClasses['SFDropdownInput'] = $sfgIP . '/includes/SF_FormInputs.php';
99 -$wgAutoloadClasses['SFRadioButtonInput'] = $sfgIP . '/includes/SF_FormInputs.php';
100 -$wgAutoloadClasses['SFListBoxInput'] = $sfgIP . '/includes/SF_FormInputs.php';
101 -$wgAutoloadClasses['SFCheckboxesInput'] = $sfgIP . '/includes/SF_FormInputs.php';
102 -$wgAutoloadClasses['SFCheckboxInput'] = $sfgIP . '/includes/SF_FormInputs.php';
103 -$wgAutoloadClasses['SFComboBoxInput'] = $sfgIP . '/includes/SF_FormInputs.php';
104 -$wgAutoloadClasses['SFCategoryInput'] = $sfgIP . '/includes/SF_FormInputs.php';
105 -$wgAutoloadClasses['SFCategoriesInput'] = $sfgIP . '/includes/SF_FormInputs.php';
106 -$wgAutoloadClasses['SFFormUtils'] = $sfgIP . '/includes/SF_FormUtils.php';
107 -$wgAutoloadClasses['SFFormEditTab'] = $sfgIP . '/includes/SF_FormEditTab.php';
108 -$wgAutoloadClasses['SFFormEditPage'] = $sfgIP . '/includes/SF_FormEditPage.php';
109 -$wgAutoloadClasses['SFUtils'] = $sfgIP . '/includes/SF_Utils.php';
110 -$wgAutoloadClasses['SFFormLinker'] = $sfgIP . '/includes/SF_FormLinker.php';
111 -$wgAutoloadClasses['SFParserFunctions'] = $sfgIP . '/includes/SF_ParserFunctions.php';
112 -$wgAutoloadClasses['SFAutocompleteAPI'] = $sfgIP . '/includes/SF_AutocompleteAPI.php';
113 -$wgJobClasses['createPage'] = 'SFCreatePageJob';
114 -$wgAutoloadClasses['SFCreatePageJob'] = $sfgIP . '/includes/SF_CreatePageJob.php';
115 -require_once( $sfgIP . '/languages/SF_Language.php' );
116 -
117 -$wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Messages.php';
118 -$wgExtensionAliasesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Aliases.php';
119 -// Allow for file-upload windows for MW >= 1.16.1
120 -$wgEditPageFrameOptions = 'SAMEORIGIN';
121 -
122 -// register client-side modules
123 -if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) {
124 - $sfgResourceTemplate = array(
125 - 'localBasePath' => $sfgIP,
126 - 'remoteExtPath' => 'SemanticForms'
127 - );
128 - $wgResourceModules += array(
129 - 'ext.semanticforms.main' => $sfgResourceTemplate + array(
130 - 'scripts' => array(
131 - 'libs/SemanticForms.js',
132 - 'libs/SF_ajax_form_preview.js',
133 - ),
134 - 'styles' => array(
135 - 'skins/SemanticForms.css',
136 - 'skins/SF_jquery_ui_overrides.css',
137 - ),
138 - 'dependencies' => array(
139 - 'jquery.ui.autocomplete',
140 - 'jquery.ui.button',
141 - 'jquery.ui.sortable',
142 - ),
143 - ),
144 - 'ext.semanticforms.fancybox' => $sfgResourceTemplate + array(
145 - 'scripts' => 'libs/jquery.fancybox-1.3.1.js',
146 - 'styles' => 'skins/jquery.fancybox-1.3.1.css',
147 - ),
148 - 'ext.semanticforms.autogrow' => $sfgResourceTemplate + array(
149 - 'scripts' => 'libs/SF_autogrow.js',
150 - ),
151 - 'ext.semanticforms.popupformedit' => $sfgResourceTemplate + array(
152 - 'scripts' => 'libs/SF_popupform.js',
153 - 'styles' => 'skins/SF_popupform.css',
154 - 'dependencies' => array( 'jquery' ),
155 - ),
156 - );
157 -}
158 -
15911 /**
16012 * Do the actual intialization of the extension. This is just a delayed init that makes sure
16113 * MediaWiki is set up properly before we add our stuff.