diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/CategoryByList |
first commit
Diffstat (limited to 'www/wiki/extensions/CategoryByList')
3 files changed, 62 insertions, 0 deletions
diff --git a/www/wiki/extensions/CategoryByList/CategoryByList.i18n.php b/www/wiki/extensions/CategoryByList/CategoryByList.i18n.php new file mode 100644 index 00000000..29125d50 --- /dev/null +++ b/www/wiki/extensions/CategoryByList/CategoryByList.i18n.php @@ -0,0 +1,14 @@ +<?php +/** + * @license GPL-2.0-or-later + * @author Your Name (YourUserName) + */ + +$magicWords = []; + +/** English + * @author Your Name (YourUserName) + */ +$magicWords['en'] = [ + 'CategoryByList' => [ 0, 'CategoryByList' ], +]; diff --git a/www/wiki/extensions/CategoryByList/CategoryByListHooks.php b/www/wiki/extensions/CategoryByList/CategoryByListHooks.php new file mode 100644 index 00000000..d99795af --- /dev/null +++ b/www/wiki/extensions/CategoryByList/CategoryByListHooks.php @@ -0,0 +1,24 @@ +<?php +class CategoryByListHooks { + // Register any render callbacks with the parser + public static function onParserFirstCallInit( Parser $parser ) { + + // Create a function hook associating the "example" magic word with CategoryByList() + $parser->setFunctionHook( 'CategoryByList', [ self::class, 'CategoryByList' ] ); + } + + // Render the output of {{#example:}}. + public static function CategoryByList( Parser $parser, $param1 = '', $param2 = '', $param3 = '' ) { + + // The input parameters are wikitext with templates expanded. + // The output should be wikitext too. + $output = ""; + + $categories = explode(', ', $param1); + foreach ($categories as $item) { + $output .= '[[CategorÃa:'.$item.']]'; + } + + return $output; + } +} diff --git a/www/wiki/extensions/CategoryByList/extension.json b/www/wiki/extensions/CategoryByList/extension.json new file mode 100644 index 00000000..4308f83a --- /dev/null +++ b/www/wiki/extensions/CategoryByList/extension.json @@ -0,0 +1,24 @@ +{ + "name": "CategoryByList", + "author": "Yaco", + "version": "1.0.0", + "url": "", + "descriptionmsg": "Used to convert a list of separated categories into categories", + "license-name": "GPL-2.0-or-later", + "type": "parserhook", + "MessagesDirs": { + "CategoryByList": [ + "i18n" + ] + }, + "AutoloadClasses": { + "CategoryByListHooks": "CategoryByListHooks.php" + }, + "ExtensionMessagesFiles": { + "CategoryByListMagic": "CategoryByList.i18n.php" + }, + "Hooks": { + "ParserFirstCallInit": "CategoryByListHooks::onParserFirstCallInit" + }, + "manifest_version": 1 +} |