Original: https://www.mediawiki.org/wiki/Extension:Comments Das hier ist eine an https://znil.net angepasste Version.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommentsHooks.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Hooked functions used by the Comments extension.
  4. * All class methods are public and static.
  5. *
  6. * @file
  7. * @ingroup Extensions
  8. * @author Jack Phoenix
  9. * @author Alexia E. Smith
  10. * @copyright (c) 2013 Curse Inc.
  11. * @license GPL-2.0-or-later
  12. * @link https://www.mediawiki.org/wiki/Extension:Comments Documentation
  13. */
  14. class CommentsHooks {
  15. /**
  16. * Registers the following tags and magic words:
  17. * - <comments />
  18. * - NUMBEROFCOMMENTSPAGE
  19. *
  20. * @param Parser $parser
  21. */
  22. public static function onParserFirstCallInit( Parser &$parser ) {
  23. $parser->setHook( 'comments', [ 'DisplayComments', 'getParserHandler' ] );
  24. $parser->setFunctionHook( 'NUMBEROFCOMMENTSPAGE', 'NumberOfComments::getParserHandler', Parser::SFH_NO_HASH );
  25. }
  26. /**
  27. * Adds the three new required database tables into the database when the
  28. * user runs /maintenance/update.php (the core database updater script).
  29. *
  30. * @param DatabaseUpdater $updater
  31. */
  32. public static function onLoadExtensionSchemaUpdates( $updater ) {
  33. $dir = __DIR__ . '/../sql';
  34. $dbType = $updater->getDB()->getType();
  35. // For non-MySQL/MariaDB/SQLite DBMSes, use the appropriately named file
  36. if ( !in_array( $dbType, [ 'mysql', 'sqlite' ] ) ) {
  37. $comments = "comments.{$dbType}.sql";
  38. $comments_vote = "comments_vote.{$dbType}.sql";
  39. $comments_block = "comments_block.{$dbType}.sql";
  40. } else {
  41. $comments = 'comments.sql';
  42. $comments_vote = 'comments_vote.sql';
  43. $comments_block = 'comments_block.sql';
  44. }
  45. $updater->addExtensionTable( 'Comments', "{$dir}/{$comments}" );
  46. $updater->addExtensionTable( 'Comments_Vote', "{$dir}/{$comments_vote}" );
  47. $updater->addExtensionTable( 'Comments_block', "{$dir}/{$comments_block}" );
  48. }
  49. /**
  50. * For integration with the Renameuser extension.
  51. *
  52. * @param RenameuserSQL $renameUserSQL
  53. */
  54. public static function onRenameUserSQL( $renameUserSQL ) {
  55. $renameUserSQL->tables['Comments'] = [ 'Comment_Username', 'Comment_user_id' ];
  56. $renameUserSQL->tables['Comments_Vote'] = [ 'Comment_Vote_Username', 'Comment_Vote_user_id' ];
  57. $renameUserSQL->tables['Comments_block'] = [ 'cb_user_name', 'cb_user_id' ];
  58. $renameUserSQL->tables['Comments_block'] = [ 'cb_user_name_blocked', 'cb_user_id_blocked' ];
  59. }
  60. }