Skip to content

Commit

Permalink
Make work in MW 1.27 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontalvo3 authored Apr 24, 2017
1 parent 3b1d5ee commit 774ddc1
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 209 deletions.
23 changes: 0 additions & 23 deletions Code Considerations.md

This file was deleted.

18 changes: 0 additions & 18 deletions CopyWatchers.i18n.php

This file was deleted.

78 changes: 13 additions & 65 deletions CopyWatchers.php
Original file line number Diff line number Diff line change
@@ -1,67 +1,15 @@
<?php
/**
* The CopyWatchers extension allows editors to copy watchers from other pages
* using the parser function #copywatchers.
*
* Documentation: http://???
* Support: http://???
* Source code: http://???
*
* @file CopyWatchers.php
* @addtogroup Extensions
* @author James Montalvo
* @copyright © 2013 by James Montalvo
* @licence GNU GPL v3+
*/

# Not a valid entry point, skip unless MEDIAWIKI is defined
if (!defined('MEDIAWIKI')) {
die( "CopyWatchers extension" );
if ( function_exists( 'wfLoadExtension' ) ) {
wfLoadExtension( 'CopyWatchers' );
// Keep i18n globals so mergeMessageFileList.php doesn't break
$wgMessagesDirs['CopyWatchers'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['CopyWatchersMagic'] = __DIR__ . '/Magic.php';
wfWarn(
'Deprecated PHP entry point used for FooBar extension. ' .
'Please use wfLoadExtension instead, ' .
'see https://www.mediawiki.org/wiki/Extension_registration for more details.'
);
return;
} else {
die( 'This version of the CopyWatchers extension requires MediaWiki 1.25+' );
}

$wgExtensionCredits['specialpage'][] = array(
'path' => __FILE__,
'name' => 'Copy Watchers',
'url' => 'http://www.mediawiki.org/wiki/Extension:CopyWatchers',
'author' => 'James Montalvo',
'descriptionmsg' => 'copywatchers-desc',
'version' => '0.1.0'
);

$dir = dirname( __FILE__ ) . '/';
$wgExtensionMessagesFiles['CopyWatchers'] = $dir . 'CopyWatchers.i18n.php';
$wgAutoloadClasses['CopyWatchers'] = $dir . 'CopyWatchers.body.php';

// Specify the function that will initialize the parser function.
$wgHooks['ParserFirstCallInit'][] = 'CopyWatchers::setup';


/*
$wgAvailableRights[] = 'semanticwatch';
$wgAvailableRights[] = 'semanticwatchgroups';
$wgHooks['LoadExtensionSchemaUpdates'][] = 'SWLHooks::onSchemaUpdate';
$wgHooks['SMWStore::updateDataBefore'][] = 'SWLHooks::onDataUpdate';
$wgHooks['GetPreferences'][] = 'SWLHooks::onGetPreferences';
$wgHooks['UserSaveOptions'][] = 'SWLHooks::onUserSaveOptions';
$wgHooks['AdminLinks'][] = 'SWLHooks::addToAdminLinks';
$wgHooks['PersonalUrls'][] = 'SWLHooks::onPersonalUrls';
$wgHooks['SWLGroupNotify'][] = 'SWLHooks::onGroupNotify';
$wgExtensionFunctions[] = 'wfSetupCatHook';
$wgHooks['LanguageGetMagic'][] = 'wfCatHookLanguageGetMagic';
$wgHooks['ParserAfterTidy'][] = 'wfUserPageViewTracker';
class CategoryWatch {
function __construct() {
global $wgHooks;
$wgHooks['ArticleSave'][] = $this;
$wgHooks['ArticleSaveComplete'][] = $this;
}
...
}
*/
7 changes: 7 additions & 0 deletions Magic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$magicWords = array();

/** English (English) **/
$magicWords['en'] = array(
'copywatchers' => array( 0, 'copywatchers' ),
);
9 changes: 0 additions & 9 deletions NOTES.md

This file was deleted.

33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,41 @@

A MediaWiki extension which allows a pages editor to add the watchers of one page to the page being edited using the parser function #copywatchers

## Notes

To-dos, random thoughts, things to consider...

### Possible considerations

* When saving a page with no (or few) watchers, promt with "would you
like to add watchers?" and give suggestions basd on content.

## Code Considerations

### Possible Hooks to use:
* Manual:Hooks/AlternateUserMailer (MW 1.19+)
* Manual:Hooks/AbortEmailNotification (MW 1.20+)

### Manual:Hooks/ArticleSave
Use this for MW 1.20 and earlier

####Define Function:
public static function onArticleSave( &$article, &$user, &$text, &$summary,
$minor, $watchthis, $sectionanchor, &$flags, &$status ) { ... }

####Attach hook:
$wgHooks['ArticleSave'][] = 'MyExtensionHooks::onArticleSave';


### Manual:Hooks/PageContentSave

Use this for MW 1.21 and later

####Define function:
public static function onPageContentSave( $wikiPage, $user, $content, $summary,
$isMinor, $isWatch, $section ) { ... }


####Attach Hook:
$wgHooks['PageContentSave'][] = 'MyExtensionHooks::onPageContentSave';

21 changes: 21 additions & 0 deletions extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Copy Watchers",
"version": "0.10.0",
"author": "James Montalvo",
"url": "http://www.mediawiki.org/wiki/Extension:CopyWatchers",
"descriptionmsg": "copywatchers-desc",
"type": "specialpage",
"ExtensionMessagesFiles": {
"CopyWatchersMagic": "Magic.php"
},
"AutoloadClasses": {
"CopyWatchers\\Setup": "includes/Setup.php",
"CopyWatchers\\CopyWatchers": "includes/CopyWatchers.php"
},
"Hooks": {
"ParserFirstCallInit": [
"CopyWatchers\\Setup::setupParserFunctions"
]
},
"manifest_version": 1
}
4 changes: 4 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"copywatchers": "Copy Watchers",
"copywatchers-desc": "Allows editors to copy watchers from other pages using the parser function #copywatchers"
}
Loading

0 comments on commit 774ddc1

Please sign in to comment.