mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-27 17:20:01 +00:00
8c27921232
This adds a TemplateData manager to the edit page in the Template namespace. If a <templatedata> tag already exists, the tool will parse it and display it in a visual interface that the user can then manipulate in their own language. If there is no <templatedata> tag, the dialog will appear empty and allow users to add and tweak their desired template parameter data. The tool also allows rudimentary parameter import, which picks up the parameters from a current template into the GUI to make the user's life easier when producing TemplateData. The template documentation editor feature is off by default. To enable it use $wgTemplateDataUseGUI = true in LocalSettings. Bug: 50436 Change-Id: I863a8199c0b08cc52b320ed00dcba912dd2aeefc
113 lines
3.5 KiB
PHP
113 lines
3.5 KiB
PHP
<?php
|
|
/**
|
|
* TemplateData extension.
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
*/
|
|
|
|
if ( version_compare( $wgVersion, '1.22wmf18', '<' ) ) {
|
|
echo "Extension:TemplateData requires MediaWiki 1.22 or higher.\n";
|
|
exit( 1 );
|
|
}
|
|
|
|
$wgExtensionCredits['parserhook'][] = array(
|
|
'path' => __FILE__,
|
|
'name' => 'TemplateData',
|
|
'author' => array( 'Timo Tijhof' ),
|
|
'version' => '0.1.0',
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:TemplateData',
|
|
'descriptionmsg' => 'templatedata-desc',
|
|
);
|
|
|
|
/* Setup */
|
|
|
|
$dir = __DIR__;
|
|
|
|
// Register files
|
|
$wgExtensionMessagesFiles['TemplateData'] = $dir . '/TemplateData.i18n.php';
|
|
$wgAutoloadClasses['TemplateDataHooks'] = $dir . '/TemplateData.hooks.php';
|
|
$wgAutoloadClasses['TemplateDataBlob'] = $dir . '/TemplateDataBlob.php';
|
|
$wgAutoloadClasses['ApiTemplateData'] = $dir . '/api/ApiTemplateData.php';
|
|
|
|
// Register hooks
|
|
$wgHooks['ParserFirstCallInit'][] = 'TemplateDataHooks::onParserFirstCallInit';
|
|
$wgHooks['PageContentSave'][] = 'TemplateDataHooks::onPageContentSave';
|
|
$wgHooks['UnitTestsList'][] = 'TemplateDataHooks::onUnitTestsList';
|
|
$wgHooks['ResourceLoaderTestModules'][] = 'TemplateDataHooks::onResourceLoaderTestModules';
|
|
$wgHooks['EditPage::showEditForm:initial'][] = 'TemplateDataHooks::onEditPage';
|
|
|
|
// Register APIs
|
|
$wgAPIModules['templatedata'] = 'ApiTemplateData';
|
|
|
|
// Register page properties
|
|
$wgPageProps['templatedata'] = 'Content of <templatedata> tag';
|
|
|
|
// Register modules
|
|
$wgResourceModules['ext.templateData'] = array(
|
|
'styles' => 'resources/ext.templateData.css',
|
|
'position' => 'top',
|
|
'localBasePath' => $dir,
|
|
'remoteExtPath' => 'TemplateData',
|
|
);
|
|
|
|
$wgResourceModules['ext.templateDataGenerator.editPage'] = array(
|
|
'localBasePath' => $dir,
|
|
'remoteExtPath' => 'TemplateData',
|
|
'scripts' => array(
|
|
'modules/ext.templateDataGenerator.editPage.js',
|
|
),
|
|
'dependencies' => array(
|
|
'ext.templateDataGenerator.core',
|
|
),
|
|
'messages' => array(
|
|
'templatedata-editbutton',
|
|
'templatedata-errormsg-jsonbadformat',
|
|
)
|
|
);
|
|
|
|
$wgResourceModules['ext.templateDataGenerator.core'] = array(
|
|
'localBasePath' => $dir,
|
|
'remoteExtPath' => 'TemplateData',
|
|
'styles' => 'modules/ext.templateDataGenerator.css',
|
|
'scripts' => array(
|
|
'modules/ext.templateDataGenerator.core.js',
|
|
),
|
|
'dependencies' => array(
|
|
'jquery.ui.dialog',
|
|
'jquery.ui.button',
|
|
),
|
|
'messages' => array(
|
|
'templatedata-modal-button-addparam',
|
|
'templatedata-modal-button-apply',
|
|
'templatedata-modal-button-cancel',
|
|
'templatedata-modal-button-delparam',
|
|
'templatedata-modal-button-importParams',
|
|
'templatedata-modal-errormsg',
|
|
'templatedata-modal-errormsg-import-noparams',
|
|
'templatedata-modal-notice-import-numparams',
|
|
'templatedata-modal-table-param-actions',
|
|
'templatedata-modal-table-param-aliases',
|
|
'templatedata-modal-table-param-default',
|
|
'templatedata-modal-table-param-desc',
|
|
'templatedata-modal-table-param-label',
|
|
'templatedata-modal-table-param-name',
|
|
'templatedata-modal-table-param-required',
|
|
'templatedata-modal-table-param-type',
|
|
'templatedata-modal-table-param-type-number',
|
|
'templatedata-modal-table-param-type-page',
|
|
'templatedata-modal-table-param-type-string',
|
|
'templatedata-modal-table-param-type-undefined',
|
|
'templatedata-modal-table-param-type-user',
|
|
'templatedata-modal-title',
|
|
'templatedata-modal-title-templatedesc',
|
|
'templatedata-modal-title-templateparams',
|
|
)
|
|
);
|
|
|
|
/* Configuration */
|
|
|
|
// Set this to true to use the template documentation
|
|
// editor feature
|
|
$wgTemplateDataUseGUI = false;
|