PageRenderTime 369ms CodeModel.GetById 23ms RepoModel.GetById 5ms app.codeStats 0ms

/extensions/SemanticForms/SemanticForms.php

https://github.com/ChuguluGames/mediawiki-svn
PHP | 336 lines | 188 code | 38 blank | 110 comment | 6 complexity | 8e919eaa127c6fffbdf245d55a74f0d7 MD5 | raw file
  1. <?php
  2. /**
  3. * Default settings for Semantic Forms.
  4. *
  5. * @file
  6. * @ingroup SF
  7. */
  8. /**
  9. * Forms for adding and editing semantic data
  10. *
  11. * @defgroup SF Semantic Forms
  12. */
  13. /**
  14. * The module Form Inputs contains form input classes
  15. * @defgroup SFFormInput Form Inputs
  16. * @ingroup SF
  17. */
  18. /**
  19. * The module Special Pages contains all Special Pages defined by
  20. * Semantic Forms.
  21. *
  22. * @defgroup SFSpecialPages Special Pages
  23. * @ingroup SF
  24. */
  25. /**
  26. * The module Language contains all language-related classes.
  27. *
  28. * @defgroup SFLanguage Language
  29. * @ingroup SF
  30. */
  31. if ( !defined( 'MEDIAWIKI' ) ) die();
  32. if ( !defined( 'SMW_VERSION' ) ) {
  33. die( "ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!" );
  34. }
  35. define( 'SF_VERSION', '2.2.1' );
  36. $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'specialpage'][] = array(
  37. 'path' => __FILE__,
  38. 'name' => 'Semantic Forms',
  39. 'version' => SF_VERSION,
  40. 'author' => array( 'Yaron Koren', 'Stephan Gambke', '...' ),
  41. 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Forms',
  42. 'descriptionmsg' => 'semanticforms-desc',
  43. );
  44. # ##
  45. # This is the path to your installation of Semantic Forms as
  46. # seen from the web. Change it if required ($wgScriptPath is the
  47. # path to the base directory of your wiki). No final slash.
  48. # #
  49. $sfgPartialPath = '/extensions/SemanticForms';
  50. $sfgScriptPath = $wgScriptPath . $sfgPartialPath;
  51. # #
  52. # ##
  53. # This is the path to your installation of Semantic Forms as
  54. # seen on your local filesystem. Used against some PHP file path
  55. # issues.
  56. # #
  57. $sfgIP = dirname( __FILE__ );
  58. # #
  59. // constants for special properties
  60. define( 'SF_SP_HAS_DEFAULT_FORM', 1 );
  61. define( 'SF_SP_HAS_ALTERNATE_FORM', 2 );
  62. define( 'SF_SP_CREATES_PAGES_WITH_FORM', 3 );
  63. define( 'SF_SP_PAGE_HAS_DEFAULT_FORM', 4 );
  64. define( 'SF_SP_HAS_FIELD_LABEL_FORMAT', 5 );
  65. $wgExtensionFunctions[] = 'sffSetupExtension';
  66. // FIXME: Can be removed when new style magic words are used (introduced in r52503)
  67. $wgHooks['LanguageGetMagic'][] = 'SFParserFunctions::languageGetMagic';
  68. $wgHooks['LinkEnd'][] = 'SFFormLinker::setBrokenLink';
  69. $wgHooks['UnknownAction'][] = 'SFFormEditTab::displayForm';
  70. // 'SkinTemplateNavigation' replaced 'SkinTemplateTabs' in the Vector skin
  71. $wgHooks['SkinTemplateTabs'][] = 'SFFormEditTab::displayTab';
  72. $wgHooks['SkinTemplateNavigation'][] = 'SFFormEditTab::displayTab2';
  73. $wgHooks['smwInitProperties'][] = 'SFUtils::initProperties';
  74. $wgHooks['AdminLinks'][] = 'SFUtils::addToAdminLinks';
  75. $wgHooks['ParserBeforeStrip'][] = 'SFUtils::cacheFormDefinition';
  76. $wgHooks['ParserFirstCallInit'][] = 'SFParserFunctions::registerFunctions';
  77. $wgHooks['MakeGlobalVariablesScript'][] = 'SFFormUtils::setGlobalJSVariables';
  78. // Page Schemas extension hooks
  79. $wgHooks['PageSchemasGetObject'][] = 'SFUtils::createPageSchemasObject' ;
  80. $wgHooks['PageSchemasGeneratePages'][] = 'SFUtils::generatePages' ;
  81. $wgHooks['PSParseFieldElements'][] = 'SFUtils::parseFieldElements' ;
  82. $wgHooks['PageSchemasGetPageList'][] = 'SFUtils::getPageList' ;
  83. $wgHooks['PageSchemasGetSchemaHTML'][] = 'SFUtils::getSchemaHTMLForPS' ;
  84. $wgHooks['PageSchemasGetFieldHTML'][] = 'SFUtils::getFieldHTMLForPS' ;
  85. $wgHooks['PageSchemasGetSchemaXML'][] = 'SFUtils::getSchemaXMLForPS';
  86. $wgHooks['PageSchemasGetFieldXML'][] = 'SFUtils::getFieldXMLForPS';
  87. //$wgHooks['getFilledHtmlTextForFieldInputs'][] = 'SFUtils::getFilledHtmlTextForPS' ;
  88. $wgAPIModules['sfautocomplete'] = 'SFAutocompleteAPI';
  89. $wgAPIModules['sfautoedit'] = 'SFAutoeditAPI';
  90. // register all special pages and other classes
  91. $wgSpecialPages['Forms'] = 'SFForms';
  92. $wgAutoloadClasses['SFForms'] = $sfgIP . '/specials/SF_Forms.php';
  93. $wgSpecialPageGroups['Forms'] = 'pages';
  94. $wgSpecialPages['CreateForm'] = 'SFCreateForm';
  95. $wgAutoloadClasses['SFCreateForm'] = $sfgIP . '/specials/SF_CreateForm.php';
  96. $wgSpecialPageGroups['CreateForm'] = 'sf_group';
  97. $wgSpecialPages['Templates'] = 'SFTemplates';
  98. $wgAutoloadClasses['SFTemplates'] = $sfgIP . '/specials/SF_Templates.php';
  99. $wgSpecialPageGroups['Templates'] = 'pages';
  100. $wgSpecialPages['CreateTemplate'] = 'SFCreateTemplate';
  101. $wgAutoloadClasses['SFCreateTemplate'] = $sfgIP . '/specials/SF_CreateTemplate.php';
  102. $wgSpecialPageGroups['CreateTemplate'] = 'sf_group';
  103. $wgSpecialPages['CreateProperty'] = 'SFCreateProperty';
  104. $wgAutoloadClasses['SFCreateProperty'] = $sfgIP . '/specials/SF_CreateProperty.php';
  105. $wgSpecialPageGroups['CreateProperty'] = 'sf_group';
  106. $wgSpecialPages['CreateCategory'] = 'SFCreateCategory';
  107. $wgAutoloadClasses['SFCreateCategory'] = $sfgIP . '/specials/SF_CreateCategory.php';
  108. $wgSpecialPageGroups['CreateCategory'] = 'sf_group';
  109. $wgSpecialPages['CreateClass'] = 'SFCreateClass';
  110. $wgAutoloadClasses['SFCreateClass'] = $sfgIP . '/specials/SF_CreateClass.php';
  111. $wgSpecialPageGroups['CreateClass'] = 'sf_group';
  112. $wgSpecialPages['FormStart'] = 'SFFormStart';
  113. $wgAutoloadClasses['SFFormStart'] = $sfgIP . '/specials/SF_FormStart.php';
  114. $wgSpecialPageGroups['FormStart'] = 'sf_group';
  115. $wgSpecialPages['FormEdit'] = 'SFFormEdit';
  116. $wgAutoloadClasses['SFFormEdit'] = $sfgIP . '/specials/SF_FormEdit.php';
  117. $wgSpecialPageGroups['FormEdit'] = 'sf_group';
  118. $wgSpecialPages['RunQuery'] = 'SFRunQuery';
  119. $wgAutoloadClasses['SFRunQuery'] = $sfgIP . '/specials/SF_RunQuery.php';
  120. $wgSpecialPageGroups['RunQuery'] = 'sf_group';
  121. // different upload-window class for MW 1.16+
  122. if ( class_exists( 'HTMLTextField' ) ) { // added in MW 1.16
  123. $wgSpecialPages['UploadWindow'] = 'SFUploadWindow2';
  124. $wgAutoloadClasses['SFUploadWindow2'] = $sfgIP . '/specials/SF_UploadWindow2.php';
  125. } else {
  126. $wgSpecialPages['UploadWindow'] = 'SFUploadWindow';
  127. $wgAutoloadClasses['SFUploadWindow'] = $sfgIP . '/specials/SF_UploadWindow.php';
  128. }
  129. $wgAutoloadClasses['SFTemplateField'] = $sfgIP . '/includes/SF_TemplateField.php';
  130. $wgAutoloadClasses['SFForm'] = $sfgIP . '/includes/SF_Form.php';
  131. $wgAutoloadClasses['SFTemplateInForm'] = $sfgIP . '/includes/SF_TemplateInForm.php';
  132. $wgAutoloadClasses['SFFormField'] = $sfgIP . '/includes/SF_FormField.php';
  133. $wgAutoloadClasses['SFFormPrinter'] = $sfgIP . '/includes/SF_FormPrinter.php';
  134. $wgAutoloadClasses['SFFormUtils'] = $sfgIP . '/includes/SF_FormUtils.php';
  135. $wgAutoloadClasses['SFFormEditTab'] = $sfgIP . '/includes/SF_FormEditTab.php';
  136. $wgAutoloadClasses['SFFormEditPage'] = $sfgIP . '/includes/SF_FormEditPage.php';
  137. $wgAutoloadClasses['SFUtils'] = $sfgIP . '/includes/SF_Utils.php';
  138. $wgAutoloadClasses['SFFormLinker'] = $sfgIP . '/includes/SF_FormLinker.php';
  139. $wgAutoloadClasses['SFParserFunctions'] = $sfgIP . '/includes/SF_ParserFunctions.php';
  140. $wgAutoloadClasses['SFAutocompleteAPI'] = $sfgIP . '/includes/SF_AutocompleteAPI.php';
  141. $wgAutoloadClasses['SFAutoeditAPI'] = $sfgIP . '/includes/SF_AutoeditAPI.php';
  142. // FormInputs
  143. $wgAutoloadClasses['SFFormInput'] = $sfgIP . '/includes/forminputs/SF_FormInput.php';
  144. $wgAutoloadClasses['SFTextInput'] = $sfgIP . '/includes/forminputs/SF_TextInput.php';
  145. $wgAutoloadClasses['SFTextWithAutocompleteInput'] = $sfgIP . '/includes/forminputs/SF_TextWithAutocompleteInput.php';
  146. $wgAutoloadClasses['SFTextAreaInput'] = $sfgIP . '/includes/forminputs/SF_TextAreaInput.php';
  147. $wgAutoloadClasses['SFTextAreaWithAutocompleteInput'] = $sfgIP . '/includes/forminputs/SF_TextAreaWithAutocompleteInput.php';
  148. $wgAutoloadClasses['SFEnumInput'] = $sfgIP . '/includes/forminputs/SF_EnumInput.php';
  149. $wgAutoloadClasses['SFMultiEnumInput'] = $sfgIP . '/includes/forminputs/SF_MultiEnumInput.php';
  150. $wgAutoloadClasses['SFCheckboxInput'] = $sfgIP . '/includes/forminputs/SF_CheckboxInput.php';
  151. $wgAutoloadClasses['SFCheckboxesInput'] = $sfgIP . '/includes/forminputs/SF_CheckboxesInput.php';
  152. $wgAutoloadClasses['SFRadioButtonInput'] = $sfgIP . '/includes/forminputs/SF_RadioButtonInput.php';
  153. $wgAutoloadClasses['SFDropdownInput'] = $sfgIP . '/includes/forminputs/SF_DropdownInput.php';
  154. $wgAutoloadClasses['SFListBoxInput'] = $sfgIP . '/includes/forminputs/SF_ListBoxInput.php';
  155. $wgAutoloadClasses['SFComboBoxInput'] = $sfgIP . '/includes/forminputs/SF_ComboBoxInput.php';
  156. $wgAutoloadClasses['SFDateInput'] = $sfgIP . '/includes/forminputs/SF_DateInput.php';
  157. $wgAutoloadClasses['SFDateTimeInput'] = $sfgIP . '/includes/forminputs/SF_DateTimeInput.php';
  158. $wgAutoloadClasses['SFYearInput'] = $sfgIP . '/includes/forminputs/SF_YearInput.php';
  159. $wgAutoloadClasses['SFCategoryInput'] = $sfgIP . '/includes/forminputs/SF_CategoryInput.php';
  160. $wgAutoloadClasses['SFCategoriesInput'] = $sfgIP . '/includes/forminputs/SF_CategoriesInput.php';
  161. $wgJobClasses['createPage'] = 'SFCreatePageJob';
  162. $wgAutoloadClasses['SFCreatePageJob'] = $sfgIP . '/includes/SF_CreatePageJob.php';
  163. require_once( $sfgIP . '/languages/SF_Language.php' );
  164. $wgAjaxExportList[] = 'SFAutoeditAPI::handleAutoEdit';
  165. $wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Messages.php';
  166. $wgExtensionAliasesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Aliases.php';
  167. // Allow for file-upload windows for MW >= 1.16.1
  168. $wgEditPageFrameOptions = 'SAMEORIGIN';
  169. // register client-side modules
  170. if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) {
  171. $sfgResourceTemplate = array(
  172. 'localBasePath' => $sfgIP,
  173. 'remoteExtPath' => 'SemanticForms'
  174. );
  175. $wgResourceModules += array(
  176. 'ext.semanticforms.main' => $sfgResourceTemplate + array(
  177. 'scripts' => array(
  178. 'libs/SemanticForms.js',
  179. 'libs/SF_ajax_form_preview.js',
  180. ),
  181. 'styles' => array(
  182. 'skins/SemanticForms.css',
  183. 'skins/SF_jquery_ui_overrides.css',
  184. ),
  185. 'dependencies' => array(
  186. 'jquery.ui.autocomplete',
  187. 'jquery.ui.button',
  188. 'jquery.ui.sortable',
  189. ),
  190. ),
  191. 'ext.semanticforms.fancybox' => $sfgResourceTemplate + array(
  192. 'scripts' => 'libs/jquery.fancybox.js',
  193. 'styles' => 'skins/jquery.fancybox.css',
  194. ),
  195. 'ext.semanticforms.autogrow' => $sfgResourceTemplate + array(
  196. 'scripts' => 'libs/SF_autogrow.js',
  197. ),
  198. 'ext.semanticforms.popupformedit' => $sfgResourceTemplate + array(
  199. 'scripts' => 'libs/SF_popupform.js',
  200. 'styles' => 'skins/SF_popupform.css',
  201. 'dependencies' => array( 'jquery' ),
  202. ),
  203. 'ext.semanticforms.autoedit' => $sfgResourceTemplate + array(
  204. 'scripts' => 'libs/SF_autoedit.js',
  205. 'styles' => 'skins/SF_autoedit.css',
  206. 'dependencies' => array( 'jquery' ),
  207. ),
  208. 'ext.semanticforms.submit' => $sfgResourceTemplate + array(
  209. 'scripts' => 'libs/SF_submit.js',
  210. 'styles' => 'skins/SF_submit.css',
  211. 'dependencies' => array( 'jquery' ),
  212. ),
  213. 'ext.semanticforms.collapsible' => $sfgResourceTemplate + array(
  214. 'scripts' => 'libs/SF_collapsible.js',
  215. 'styles' => 'skins/SF_collapsible.css',
  216. 'dependencies' => array( 'jquery' ),
  217. ),
  218. );
  219. }
  220. // PHP fails to find relative includes at some level of inclusion:
  221. // $pathfix = $IP . $sfgScriptPath;
  222. // load global functions
  223. require_once( 'includes/SF_GlobalFunctions.php' );
  224. sffInitNamespaces();
  225. # ##
  226. # The number of allowed values per autocomplete - too many might
  227. # slow down the database, and Javascript's completion
  228. # ##
  229. $sfgMaxAutocompleteValues = 1000;
  230. # ##
  231. # Whether to autocomplete on all characters in a string, not just the
  232. # beginning of words - this is especially important for Unicode strings,
  233. # since the use of the '\b' regexp character to match on the beginnings
  234. # of words fails for them.
  235. # ##
  236. $sfgAutocompleteOnAllChars = false;
  237. # ##
  238. # Global variables for handling the two edit tabs (for traditional editing
  239. # and for editing with a form):
  240. # $sfgRenameEditTabs renames the edit-with-form tab to just "Edit", and
  241. # the traditional-editing tab, if it is visible, to "Edit source", in
  242. # whatever language is being used.
  243. # $sfgRenameMainEditTab renames only the traditional editing tab, to
  244. # "Edit source".
  245. # The wgGroupPermissions 'viewedittab' setting dictates which types of
  246. # visitors will see the "Edit" tab, for pages that are editable by form -
  247. # by default all will see it.
  248. # ##
  249. $sfgRenameEditTabs = false;
  250. $sfgRenameMainEditTab = false;
  251. $wgGroupPermissions['*']['viewedittab'] = true;
  252. $wgAvailableRights[] = 'viewedittab';
  253. # ##
  254. # Permission to edit form fields defined as 'restricted'
  255. # ##
  256. $wgGroupPermissions['sysop']['editrestrictedfields'] = true;
  257. $wgAvailableRights[] = 'editrestrictedfields';
  258. # ##
  259. # Permission to view, and create pages with, Special:CreateClass
  260. # ##
  261. $wgGroupPermissions['user']['createclass'] = true;
  262. $wgAvailableRights[] = 'createclass';
  263. # ##
  264. # List separator character
  265. # ##
  266. $sfgListSeparator = ",";
  267. # ##
  268. # Extend the edit form from the internal EditPage class rather than using a
  269. # special page and hacking things up.
  270. #
  271. # @note This is experimental and requires updates to EditPage which I have only
  272. # added into MediaWiki 1.14a
  273. # ##
  274. $sfgUseFormEditPage = false;// method_exists('EditPage', 'showFooter');
  275. # ##
  276. # Use 24-hour time format in forms, e.g. 15:30 instead of 3:30 PM
  277. # ##
  278. $sfg24HourTime = false;
  279. # ##
  280. # Cache parsed form definitions in the page_props table, to improve loading
  281. # speed
  282. # ##
  283. $sfgCacheFormDefinitions = false;
  284. # ##
  285. # When modifying red links to potentially point to a form to edit that page,
  286. # check only the properties pointing to that missing page from the page the
  287. # user is currently on, instead of from all pages in the wiki.
  288. # ##
  289. $sfgRedLinksCheckOnlyLocalProps = false;
  290. # ##
  291. # Page properties, used for the API
  292. # ##
  293. $wgPageProps['formdefinition'] = 'Definition of the semantic form used on the page';
  294. # ##
  295. # Global variables for Javascript
  296. # ##
  297. $sfgShowOnSelect = array();
  298. $sfgAutocompleteValues = array();