[MediaWiki-commits] [Gerrit] mediawiki...RSS[master]: Add prefix support to URL whitelist

2018-01-23 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406017 )

Change subject: Add prefix support to URL whitelist
..

Add prefix support to URL whitelist

Permit URLs in the whitelist to end in '*' in order to permit any
that start with the given prefix.

Bug: T185087
Change-Id: I458aa74f1862d4da6bf162f996ff4a8b3dcba580
---
M RSSHooks.php
M extension.json
2 files changed, 60 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RSS 
refs/changes/17/406017/1

diff --git a/RSSHooks.php b/RSSHooks.php
index 3968257..4c598e3 100644
--- a/RSSHooks.php
+++ b/RSSHooks.php
@@ -1,5 +1,7 @@
 getTitle()->getNamespace();
@@ -39,30 +40,10 @@
return RSSUtils::RSSError( 
'rss-deprecated-wgrssallowedfeeds-found' );
}
 
-   # disallow because there is no whitelist at all or an empty 
whitelist
-
-   if ( !isset( $wgRSSUrlWhitelist )
-   || !is_array( $wgRSSUrlWhitelist )
-   || ( count( $wgRSSUrlWhitelist ) === 0 ) ) {
-   return RSSUtils::RSSError( 'rss-empty-whitelist',
-   $input
-   );
-
-   }
-
-   # disallow the feed url because the url is not whitelisted;  or
-   # disallow because the wildcard joker is not present to allow 
any feed url
-   # which can be dangerous
-
-   if ( !( in_array( $input, $wgRSSUrlWhitelist ) )
-   && !( in_array( "*", $wgRSSUrlWhitelist ) ) ) {
-   $listOfAllowed = 
$parser->getFunctionLang()->listToText( $wgRSSUrlWhitelist );
-   $numberAllowed = $parser->getFunctionLang()->formatNum( 
count( $wgRSSUrlWhitelist ) );
-
-   return RSSUtils::RSSError( 'rss-url-is-not-whitelisted',
-   [ $input, $listOfAllowed, $numberAllowed ]
-   );
-
+   // Check the input against the configured whitelist of URLs.
+   $whitelistError = static::checkAgainstWhitelist( $input, 
$parser->getFunctionLang() );
+   if ( $whitelistError ) {
+   return $whitelistError;
}
 
if ( !Http::isValidURI( $input ) ) {
@@ -93,4 +74,54 @@
return $rss->renderFeed( $parser, $frame );
}
 
+   /**
+* Check whether a given URL is in the configured whitelist of RSS URLs.
+* @param string $inputUrl The URL to check. Can be '*' to allow any,
+* or end in '*' to allow any prefix.
+* @param Language $language The language to use for the error message 
list and numbers.
+* @return string The error message if the URL is not allowed, or an 
empty string if it is.
+*/
+   protected static function checkAgainstWhitelist( $inputUrl, Language 
$language ) {
+   // Get the whitelist.
+   $whitelist = MediaWikiServices::getInstance()
+   ->getConfigFactory()
+   ->makeConfig('RSS' )
+   ->get( 'RSSUrlWhitelist' );
+
+   // Disallow because there is an empty whitelist.
+   if ( !isset( $whitelist ) || !is_array( $whitelist ) || ( 
count( $whitelist ) === 0 ) ) {
+   return RSSUtils::RSSError( 'rss-empty-whitelist', 
$inputUrl );
+   }
+
+   // Check for exact match or asterisk.
+   $whitelisted = in_array( $inputUrl, $whitelist ) || in_array( 
'*', $whitelist );
+   // Otherwise, check for a match for URLs that end in an 
asterisk (T185087).
+   if ( !$whitelisted ) {
+   $whitelistedUrls = array_filter(
+   $whitelist,
+   function ( $whitelistedUrl ) use ( $inputUrl ) {
+   if ( substr( $whitelistedUrl, -1 ) !== 
'*' ) {
+   // If it's not a wildcard 
whitelisted URL.
+   return false;
+   }
+   // See if the supplied URL starts with 
the whitelisted prefix.
+   $whitelistedPrefix = substr( 
$whitelistedUrl, 0, -1 );
+   $inputUrlPrefix = substr( $inputUrl, 0, 
strlen( $whitelistedPrefix ) );
+   return $inputUrlPrefix === 
$whitelistedPrefix;
+   }
+   );
+   // It's whitelisted if it matches any of the whitelist 
prefixes.
+   $whitelisted = ( count( $whitelistedUrls ) > 0 );
+   }
+   if ( !$whitelisted ) {
+

[MediaWiki-commits] [Gerrit] mediawiki...Thanks[master]: Fix member variable visbility and doc

2018-01-19 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405254 )

Change subject: Fix member variable visbility and doc
..

Fix member variable visbility and doc

Change-Id: I22d16b05d24c615f0c792063e33433d50a34ad8a
---
M .phpcs.xml
M tests/phpunit/ApiFlowThankIntegrationTest.php
2 files changed, 15 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Thanks 
refs/changes/54/405254/1

diff --git a/.phpcs.xml b/.phpcs.xml
index f55eb30..3f9d0cb 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -6,7 +6,6 @@



-   

.

diff --git a/tests/phpunit/ApiFlowThankIntegrationTest.php 
b/tests/phpunit/ApiFlowThankIntegrationTest.php
index 8bfcfee..60a79af 100644
--- a/tests/phpunit/ApiFlowThankIntegrationTest.php
+++ b/tests/phpunit/ApiFlowThankIntegrationTest.php
@@ -18,14 +18,21 @@
  * @author Benjamin Chen
  */
 class ApiFlowThankTest extends ApiTestCase {
-   /**
-* @var PostRevision
-*/
-   public $topic,
-   $meUser,
-   $otherUser,
-   $postByOtherUser,
-   $postByMe;
+
+   /** @var PostRevision */
+   public $topic;
+
+   /** @var User */
+   public $meUser;
+
+   /** @var User */
+   public $otherUser;
+
+   /** @var PostRevision */
+   public $postByOtherUser;
+
+   /** @var PostRevision */
+   public $postByMe;
 
public function setUp() {
parent::setUp();

-- 
To view, visit https://gerrit.wikimedia.org/r/405254
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I22d16b05d24c615f0c792063e33433d50a34ad8a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Thanks
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...MsUpload[master]: Remove deprecated call, and simplify loading

2018-01-19 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405252 )

Change subject: Remove deprecated call, and simplify loading
..

Remove deprecated call, and simplify loading

Remove the use of mw.toolbar, which is deprecated, and replace it
with a new method in MsUpload (that does only what it needs to in
this situation).

Also remove second redundant mw.loader.using( 'ext.wikiEditor' )
and fix up that module's name to the new form.

Bug: T185290
Change-Id: I3d99b7ca11173a9aa289359928ae4a44411a8b05
---
M MsUpload.js
M extension.json
2 files changed, 22 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MsUpload 
refs/changes/52/405252/1

diff --git a/MsUpload.js b/MsUpload.js
index 8da7a87..2c7d837 100644
--- a/MsUpload.js
+++ b/MsUpload.js
@@ -17,20 +17,28 @@
galleryArray: [],
insertGallery: function () {
var galleryText = 'File:' + MsUpload.galleryArray.join( 
'\nFile:' );
-   mw.toolbar.insertTags( '\n' + galleryText + 
'\n\n', '', '', '' );
+   MsUpload.insertText( '\n' + galleryText + 
'\n\n' );
},
 
filesArray: [],
insertFiles: function () {
-   mw.toolbar.insertTags( '[[File:' + 
MsUpload.filesArray.join( ']]\n[[File:' ) + ']]\n', '', '', '' );
+   MsUpload.insertText( '[[File:' + 
MsUpload.filesArray.join( ']]\n[[File:' ) + ']]\n' );
},
 
insertLinks: function () {
if ( msuVars.useMsLinks === true ) {
-   mw.toolbar.insertTags( '*{{#l:' + 
MsUpload.filesArray.join( '}}\n*{{#l:' ) + '}}\n', '', '', '' );
+   MsUpload.insertText( '*{{#l:' + 
MsUpload.filesArray.join( '}}\n*{{#l:' ) + '}}\n' );
} else {
-   mw.toolbar.insertTags( '*[[:File:' + 
MsUpload.filesArray.join( ']]\n*[[:File:' ) + ']]\n', '', '', '' );
+   MsUpload.insertText( '*[[:File:' + 
MsUpload.filesArray.join( ']]\n*[[:File:' ) + ']]\n' );
}
+   },
+
+   /**
+* Add text to selection in the main textarea.
+* @param {string} text
+*/
+   insertText: function ( text ) {
+   $( '#wpTextbox1' ).textSelection( 
'encapsulateSelection', { pre: text } );
},
 
unconfirmedReplacements: 0,
@@ -408,9 +416,9 @@
}
$( '' ).text( mw.msg( 
'msu-insert-link' ) ).click( function () {
if ( msuVars.useMsLinks === 
true ) {
-   mw.toolbar.insertTags( 
'{{#l:' + file.name + '}}', '', '', '' ); // Insert link
+   MsUpload.insertText( 
'{{#l:' + file.name + '}}' ); // Insert link
} else {
-   mw.toolbar.insertTags( 
'[[:File:' + file.name + ']]', '', '', '' ); // Insert link
+   MsUpload.insertText( 
'[[:File:' + file.name + ']]' ); // Insert link
}
} ).appendTo( file.li );
if ( file.group === 'image' ) {
@@ -420,12 +428,12 @@
}
$( '' ).text( ' | ' 
).appendTo( file.li );
$( '' ).text( mw.msg( 
'msu-insert-image' ) ).click( function () {
-   mw.toolbar.insertTags( 
'[[File:' + file.name + msuVars.imgParams + ']]', '', '', '' );
+   MsUpload.insertText( 
'[[File:' + file.name + msuVars.imgParams + ']]' );
} ).appendTo( file.li );
} else if ( file.group === 'video' ) {
$( '' ).text( ' | ' 
).appendTo( file.li );
$( '' ).text( mw.msg( 
'msu-insert-video' ) ).click( function () {
-   mw.toolbar.insertTags( 
'[[File:' + file.name + ']]', '', '', '' );
+   MsUpload.insertText( 
'[[File:' + file.name + ']]' );
} ).appendTo( file.li );
}

[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Override now-protected showResetForm() rather than re-implem...

2018-01-16 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404625 )

Change subject: Override now-protected showResetForm() rather than 
re-implementing
..

Override now-protected showResetForm() rather than re-implementing

The parent method used to be private, but is now protected, and
so we can clean some things up here. It's still duplicating code,
but it's less than before.

Change-Id: If9dbdd78c2818483c76e92fe70fe9b4a2b7c9fa5
---
M includes/SpecialGlobalPreferences.php
1 file changed, 2 insertions(+), 18 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/25/404625/1

diff --git a/includes/SpecialGlobalPreferences.php 
b/includes/SpecialGlobalPreferences.php
index 204623c..4bb4920 100644
--- a/includes/SpecialGlobalPreferences.php
+++ b/includes/SpecialGlobalPreferences.php
@@ -27,12 +27,6 @@
 * @throws UserNotLoggedIn
 */
public function execute( $par ) {
-   // Because parent::showResetForm() is private, we have to 
override it separately here.
-   if ( $par == 'reset' ) {
-   $this->showGlobalPrefsResetForm();
-   return;
-   }
-
// Dirty override to check user can set global prefs.
if ( $this->getUser()->isAnon() ) {
// @todo use our own error messages here
@@ -76,23 +70,13 @@
 
/**
 * Display the preferences-reset confirmation page.
-* This mostly repeats code in parent::execute() and 
parent::showResetForm().
+* This is identical to parent::showResetForm except with the message 
names changed.
 * @throws PermissionsError
 */
-   protected function showGlobalPrefsResetForm() {
+   protected function showResetForm() {
if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
throw new PermissionsError( 'editmyoptions' );
}
-
-   // This section is duplicated from parent::execute().
-   $this->setHeaders();
-   $this->outputHeader();
-   $out = $this->getOutput();
-   // Prevent hijacked user scripts from sniffing passwords etc.
-   $out->disallowUserJs();
-   // Use the same message as normal Preferences for the 
login-redirection message.
-   $this->requireLogin( 'prefsnologintext2' );
-   $this->checkReadOnly();
 
$this->getOutput()->addWikiMsg( 'globalprefs-reset-intro' );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/404625
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If9dbdd78c2818483c76e92fe70fe9b4a2b7c9fa5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Centre globalizing checkboxes, and prevent overwrapping of h...

2018-01-16 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404623 )

Change subject: Centre globalizing checkboxes, and prevent overwrapping of 
header
..

Centre globalizing checkboxes, and prevent overwrapping of header

Bug: T179542
Change-Id: Ibdde03d95c3c314b8162f8bf474c54bf862d026e
---
M resources/ext.GlobalPreferences.global-nojs.css
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/23/404623/1

diff --git a/resources/ext.GlobalPreferences.global-nojs.css 
b/resources/ext.GlobalPreferences.global-nojs.css
index 8b091b9..b8852b9 100644
--- a/resources/ext.GlobalPreferences.global-nojs.css
+++ b/resources/ext.GlobalPreferences.global-nojs.css
@@ -51,21 +51,31 @@
padding-right: 0.5em;
 }
 
-.mw-globalprefs-global-check {
+div.mw-globalprefs-global-check {
font-size: smaller;
padding-left: 0;
float: left;
width: 5%;
+   text-align: center;
 }
-.mw-globalprefs-global-check input.mw-globalprefs-global-check {
+div.mw-globalprefs-global-check div.mw-input {
+   display: inline;
+}
+div.mw-globalprefs-global-check input.mw-globalprefs-global-check {
float: none;
width: auto;
+}
+
+/** Remove fieldset border to distinguish it from other 'proper' fieldsets. */
+fieldset.ext-globalpreferences-select-all {
+   border: 0;
 }
 
 /** Make the column header a bit narrower so it looks more associated with the 
column. */
 .globalprefs-section-header .col-header {
display: block;
width: 7%;
+   min-width: 7em;
text-align: center;
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/404623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdde03d95c3c314b8162f8bf474c54bf862d026e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Don't disable local preferences if a local exception is bein...

2018-01-15 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404411 )

Change subject: Don't disable local preferences if a local exception is being 
saved
..

Don't disable local preferences if a local exception is being saved

Local preferences are disabled unless their already flagged as
having a local exception, or such a flag is being set in the
current request.

Bug: T184973
Change-Id: I5c063c9b4c63069b4912a6e0a980fbd94f4750de
---
M includes/GlobalPreferencesFactory.php
1 file changed, 16 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/11/404411/1

diff --git a/includes/GlobalPreferencesFactory.php 
b/includes/GlobalPreferencesFactory.php
index 3d29e59..111af80 100644
--- a/includes/GlobalPreferencesFactory.php
+++ b/includes/GlobalPreferencesFactory.php
@@ -20,6 +20,7 @@
 use RequestContext;
 use SpecialPage;
 use User;
+use WebRequest;
 
 /**
  * Global preferences.
@@ -106,7 +107,7 @@
if ( $this->onGlobalPrefsPage() ) {
return $this->getPreferencesGlobal( $preferences, 
$globalPrefNames );
}
-   return $this->getPreferencesLocal( $preferences, 
$globalPrefNames );
+   return $this->getPreferencesLocal( $preferences, 
$globalPrefNames, $context->getRequest() );
}
 
/**
@@ -114,18 +115,26 @@
 * and add the link to Special:GlobalPreferences to the personal 
preferences tab.
 * @param mixed[][] $preferences The preferences array.
 * @param string[] $globalPrefNames The names of those preferences that 
are already global.
+* @param WebRequest $request The current request, to check for local 
exceptions being set.
 * @return mixed[][]
 */
-   protected function getPreferencesLocal( $preferences, $globalPrefNames 
) {
+   protected function getPreferencesLocal( $preferences, $globalPrefNames, 
WebRequest $request ) {
$modifiedPrefs = [];
foreach ( $preferences as $name => $def ) {
$modifiedPrefs[$name] = $def;
 
// If this has been set globally.
if ( in_array( $name, $globalPrefNames ) ) {
-   // Disable this preference unless it has a 
local exception.
-   $localException = $this->user->getOption( $name 
. static::LOCAL_EXCEPTION_SUFFIX );
-   $modifiedPrefs[$name]['disabled'] = is_null( 
$localException );
+   // Disable this local preference unless it 
either
+   // A) already has a local exception, or
+   // B) a local exception is being enabled in the 
current request.
+   // This is because HTMLForm changes submitted 
values to their defaults
+   // after preferences have been defined here, if 
a field is disabled.
+   $localExName = $name . 
static::LOCAL_EXCEPTION_SUFFIX;
+   $localExValue = $this->user->getOption( 
$localExName );
+   $requestHasLocalEx = $request->getVal( 'wp' . 
$localExName );
+   $modifiedPrefs[$name]['disabled'] = is_null( 
$localExValue )
+   && is_null( $requestHasLocalEx );
 
// Add a new local exception preference after 
this one.
$cssClasses = [
@@ -134,10 +143,10 @@
];
$secFragment = static::getSectionFragmentId( 
$def['section'] );
$labelMsg = wfMessage( 
'globalprefs-set-local-exception', [ $secFragment ] );
-   $modifiedPrefs[ $name . 
static::LOCAL_EXCEPTION_SUFFIX ] = [
+   $modifiedPrefs[ $localExName ] = [
'type' => 'toggle',
'label-raw' => $labelMsg->parse(),
-   'default' => $this->user->getOption( 
$name . static::LOCAL_EXCEPTION_SUFFIX ),
+   'default' => $localExValue,
'section' => $def['section'],
'cssclass' => join( ' ', $cssClasses ),
];

-- 
To view, visit https://gerrit.wikimedia.org/r/404411
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c063c9b4c63069b4912a6e0a980fbd94f4750de
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 


[MediaWiki-commits] [Gerrit] mediawiki...BetaFeatures[master]: Make preference fields infusable

2018-01-10 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403583 )

Change subject: Make preference fields infusable
..

Make preference fields infusable

Bug: T178267
Change-Id: Ib04701464e4869c0b89387b7291d2eb6326e3fc0
---
M includes/NewHTMLCheckField.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures 
refs/changes/83/403583/1

diff --git a/includes/NewHTMLCheckField.php b/includes/NewHTMLCheckField.php
index 17a59fb..d607371 100644
--- a/includes/NewHTMLCheckField.php
+++ b/includes/NewHTMLCheckField.php
@@ -52,6 +52,7 @@
return Html::openElement( 'div', [ 'class' => 
'mw-ui-feature-checkbox' ] ) .
new OOUI\FieldLayout(
new OOUI\CheckboxInputWidget( [
+   'infusable' => true,
'name' => $this->mName,
'selected' => $value,
'value' => 1,

-- 
To view, visit https://gerrit.wikimedia.org/r/403583
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib04701464e4869c0b89387b7291d2eb6326e3fc0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Enable/disable related preference field with local exception...

2018-01-10 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403582 )

Change subject: Enable/disable related preference field with local exception 
checkbox.
..

Enable/disable related preference field with local exception checkbox.

When the local-exception checkbox is changed, enable or disable
the related preference field. Also takes into account OOUI fields
such as is used by BetaFeatures.

Bug: T178267
Change-Id: I3dcd540a29635614aaa9404b8482d1493fda0c3c
---
M resources/ext.GlobalPreferences.local.js
1 file changed, 26 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/82/403582/1

diff --git a/resources/ext.GlobalPreferences.local.js 
b/resources/ext.GlobalPreferences.local.js
index 5f68fbe..e36b1b3 100644
--- a/resources/ext.GlobalPreferences.local.js
+++ b/resources/ext.GlobalPreferences.local.js
@@ -1 +1,26 @@
-// @TODO re-enable global preferences. T178267
+( function ( mw, $ ) {
+   'use strict';
+
+   /**
+* Enable and disable the related preference field when selecting the 
local exception checkbox.
+*/
+   $( ':input.mw-globalprefs-local-exception' ).on( 'change', function () {
+   var localExName, prefName, enabled, $prefInput, oouiWidget;
+   // Figure out what the preference name is by stripping the 
local exception suffix.
+   localExName = $( this ).attr( 'name' );
+   prefName = localExName.substr( 0, localExName.length - 
'-local-exception'.length );
+   enabled = $( this ).prop( 'checked' );
+   $prefInput = $( ':input[name="' + prefName + '"]' );
+
+   if ( $prefInput.parent( '.oo-ui-widget' ).length > 0 ) {
+   // First see if this is a OOUI field.
+   oouiWidget = OO.ui.infuse( $prefInput.parent( 
'.oo-ui-widget' ) );
+   oouiWidget.setDisabled( !enabled );
+
+   } else {
+   // Otherwise treat it as a normal form input.
+   $prefInput.prop( 'disabled', !enabled );
+   }
+   } );
+
+}( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/403582
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3dcd540a29635614aaa9404b8482d1493fda0c3c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Improve div-style form layout

2018-01-08 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403111 )

Change subject: Improve div-style form layout
..

Improve div-style form layout

Bug: T179738
Change-Id: Ic3eddc49735b93c23605de1c2c73be477a683023
---
M includes/GlobalPreferencesForm.php
M resources/ext.GlobalPreferences.special.css
2 files changed, 30 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/11/403111/1

diff --git a/includes/GlobalPreferencesForm.php 
b/includes/GlobalPreferencesForm.php
index 5c36867..1aee82f 100644
--- a/includes/GlobalPreferencesForm.php
+++ b/includes/GlobalPreferencesForm.php
@@ -3,6 +3,7 @@
 namespace GlobalPreferences;
 
 use Html;
+use HTMLFormField;
 use IContextSource;
 use PreferencesForm;
 
@@ -28,6 +29,27 @@
}
 
/**
+* Override this in order to hide empty labels.
+* @param array[]|HTMLFormField[] $fields
+* @param string $sectionName
+* @param string $fieldsetIDPrefix
+* @param bool $hasUserVisibleFields
+* @return string
+*/
+   public function displaySection(
+   $fields, $sectionName = '', $fieldsetIDPrefix = '', 
&$hasUserVisibleFields = false
+   ) {
+   foreach ( $fields as $key => $value ) {
+   if ( $value instanceof HTMLFormField ) {
+   $value->setShowEmptyLabel( false );
+   }
+   }
+   return parent::displaySection(
+   $fields, $sectionName, $fieldsetIDPrefix, 
$hasUserVisibleFields
+   );
+   }
+
+   /**
 * Get the whole body of the form, adding the global preferences header 
text to the top of each
 * section. Javascript will later add the 'select all' checkbox to this 
header.
 * @return string
diff --git a/resources/ext.GlobalPreferences.special.css 
b/resources/ext.GlobalPreferences.special.css
index 4d42ba8..fa204d7 100644
--- a/resources/ext.GlobalPreferences.special.css
+++ b/resources/ext.GlobalPreferences.special.css
@@ -2,6 +2,14 @@
background-color: #eaecf0;
 }
 
+div.mw-input,
+div.mw-label {
+   display: inline-block;
+}
+div.mw-label {
+   padding-right: 0.5em;
+}
+
 /* Style fixes for Skin:Vector. The ID selector is whitelisted in .stylelintrc 
because Vector uses it. */
 body.skin-vector #preferences fieldset.ext-globalpreferences-select-all {
padding-bottom: 0;

-- 
To view, visit https://gerrit.wikimedia.org/r/403111
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3eddc49735b93c23605de1c2c73be477a683023
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Handle CheckMatrix fields

2018-01-03 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401893 )

Change subject: Handle CheckMatrix fields
..

Handle CheckMatrix fields

Bug: T172585
Change-Id: Ic862cc69f8d6a3703fecd86510c79766c4d1c4d5
---
M includes/GlobalPreferencesFactory.php
M includes/Hooks.php
M resources/ext.GlobalPreferences.special.js
3 files changed, 22 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/93/401893/1

diff --git a/includes/GlobalPreferencesFactory.php 
b/includes/GlobalPreferencesFactory.php
index edc1b90..06db523 100644
--- a/includes/GlobalPreferencesFactory.php
+++ b/includes/GlobalPreferencesFactory.php
@@ -69,6 +69,7 @@
'CirrusSearch\HTMLCompletionProfileSettings',
'NewHTMLCheckField',
'HTMLFeatureField',
+   'HTMLCheckMatrix',
];
 
/**
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 7f04f90..bd2dd72 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -82,16 +82,26 @@
 
$prefs = [];
foreach ( $formData as $name => $value ) {
+   // If this is the '-global' counterpart of a preference.
if ( substr( $name, -strlen( 'global' ) ) === 'global' 
&& $value === true ) {
+   // Determine the real name of the preference.
$realName = substr( $name, 0, -strlen( 
'-global' ) );
if ( isset( $formData[$realName] ) ) {
+   // Store normal preference values.
$prefs[$realName] = 
$formData[$realName];
+
} else {
-   // FIXME: Handle checkbox matrixes 
properly
-   /*
-   var_dump($realName);
-   var_dump($name);
-   */
+   // If the real-named preference isn't 
set, this must be a CheckMatrix value
+   // where the preference names are of 
the form "$realName-$column-$row"
+   // (we also have to remove the 
"$realName-global" entry).
+   $checkMatrix = preg_grep( 
"/^$realName/", array_keys( $formData ) );
+   unset( $checkMatrix[ array_search( 
$name, $checkMatrix ) ] );
+   $checkMatrixVals = array_intersect_key( 
$formData, array_flip( $checkMatrix ) );
+   $prefs = array_merge( $prefs, 
$checkMatrixVals );
+   // Also store a global $realName 
preference for benefit of the the
+   // 'globalize-this' checkbox.
+   $prefs[ $realName ] = true;
+
}
}
}
diff --git a/resources/ext.GlobalPreferences.special.js 
b/resources/ext.GlobalPreferences.special.js
index ed1d045..d736fa5 100644
--- a/resources/ext.GlobalPreferences.special.js
+++ b/resources/ext.GlobalPreferences.special.js
@@ -25,12 +25,15 @@
$rows,
 
// The current preference's inputs (can be multiple, 
and not all will have the same name).
-   $inputs = $( ':input[name="' + name + '"]' ).parents( 
'.mw-input' ).find( ':input' );
+   $inputs = $( ':input[name="' + name + '"], 
:input[name="' + name + '[]"]' )
+   .parents( '.mw-input' )
+   .find( ':input' )
+   .not( '.checkmatrix-forced' );
 
-   // All the labels for this preference (not all have for='').
+   // All the labels for this preference (not all have for='' nor 
are even labels).
$labels = $inputs
.closest( fieldSelector )
-   .find( 'label' )
+   .find( 'label, td' )
.not( '[for$="-global"]' );
 
// Collect the related rows. The main field row is sometimes 
followed by a help-tip row.

-- 
To view, visit https://gerrit.wikimedia.org/r/401893
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic862cc69f8d6a3703fecd86510c79766c4d1c4d5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org

[MediaWiki-commits] [Gerrit] mediawiki...PageAssessments[master]: Ensure project name is set on 2nd loop when saving

2017-12-21 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399774 )

Change subject: Ensure project name is set on 2nd loop when saving
..

Ensure project name is set on 2nd loop when saving

Also move top-level and other classes into a common namespace.

Change-Id: I1a5ef32df6c3164ff0f9bf8d2a0260d6d1a9c935
---
M extension.json
R src/Hooks.php
M src/NamespaceSelect.php
R src/PageAssessmentsDAO.php
M src/SpecialPage.php
M tests/phpunit/PageAssessmentsTest.php
6 files changed, 85 insertions(+), 22 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageAssessments 
refs/changes/74/399774/1

diff --git a/extension.json b/extension.json
index 7387269..cfa78a8 100644
--- a/extension.json
+++ b/extension.json
@@ -19,13 +19,13 @@
"pageassessments": "ApiQueryPageAssessments"
},
"AutoloadClasses": {
-   "PageAssessmentsHooks": "PageAssessmentsHooks.php",
-   "PageAssessmentsBody": "PageAssessmentsBody.php",
"ApiQueryPageAssessments": "api/ApiQueryPageAssessments.php",
"ApiQueryProjectPages": "api/ApiQueryProjectPages.php",
"ApiQueryProjects": "api/ApiQueryProjects.php",
-   "PageAssessments\\SpecialPage": "src/SpecialPage.php",
-   "PageAssessments\\NamespaceSelect": "src/NamespaceSelect.php"
+   "MediaWiki\\Extension\\PageAssessments\\Hooks": "src/Hooks.php",
+   "MediaWiki\\Extension\\PageAssessments\\NamespaceSelect": 
"src/NamespaceSelect.php",
+   "MediaWiki\\Extension\\PageAssessments\\PageAssessmentsDAO": 
"src/PageAssessmentsDAO.php",
+   "MediaWiki\\Extension\\PageAssessments\\SpecialPage": 
"src/SpecialPage.php"
},
"ExtensionMessagesFiles": {
"PageAssessmentsMagic": "PageAssessments.i18n.magic.php",
@@ -33,16 +33,16 @@
},
"Hooks": {
"ParserFirstCallInit": [
-   "PageAssessmentsHooks::onParserFirstCallInit"
+   
"MediaWiki\\Extension\\PageAssessments\\Hooks::onParserFirstCallInit"
],
"LoadExtensionSchemaUpdates": [
-   "PageAssessmentsHooks::onLoadExtensionSchemaUpdates"
+   
"MediaWiki\\Extension\\PageAssessments\\Hooks::onLoadExtensionSchemaUpdates"
],
"LinksUpdateComplete": [
-   "PageAssessmentsHooks::onLinksUpdateComplete"
+   
"MediaWiki\\Extension\\PageAssessments\\Hooks::onLinksUpdateComplete"
],
"ArticleDeleteComplete": [
-   "PageAssessmentsHooks::onArticleDeleteComplete"
+   
"MediaWiki\\Extension\\PageAssessments\\Hooks::onArticleDeleteComplete"
]
},
"MessagesDirs": {
@@ -64,7 +64,7 @@
}
},
"SpecialPages": {
-   "PageAssessments": "PageAssessments\\SpecialPage"
+   "PageAssessments": 
"MediaWiki\\Extension\\PageAssessments\\SpecialPage"
},
"config": {
"PageAssessmentsOnTalkPages": true,
diff --git a/PageAssessmentsHooks.php b/src/Hooks.php
similarity index 86%
rename from PageAssessmentsHooks.php
rename to src/Hooks.php
index fae597b..e31fb6d 100644
--- a/PageAssessmentsHooks.php
+++ b/src/Hooks.php
@@ -17,17 +17,30 @@
  *
  * Hooks for PageAssessments extension
  *
+ * @file
  * @ingroup Extensions
  */
 
-class PageAssessmentsHooks {
+namespace MediaWiki\Extension\PageAssessments;
+
+use Article;
+use Content;
+use DatabaseUpdater;
+use LinksUpdate;
+use LogEntry;
+use Parser;
+use RequestContext;
+use User;
+
+class Hooks {
 
/**
 * Register the parser function hook
 * @param Parser &$parser
 */
public static function onParserFirstCallInit( &$parser ) {
-   $parser->setFunctionHook( 'assessment', 
'PageAssessmentsBody::cacheAssessment' );
+   $parser->setFunctionHook( 'assessment', 
+   
\MediaWiki\Extension\PageAssessments\PageAssessmentsDAO::class.'::cacheAssessment'
 );
}
 
/**
@@ -57,7 +70,7 @@
if ( $title->isTalkPage() ) {
$title = $title->getSubjectPage();
}
-   PageAssessmentsBody::doUpdates( $title, 
$assessmentData, $ticket );
+   PageAssessmentsDAO::doUpdates( $title, $assessmentData, 
$ticket );
}
}
 
@@ -87,7 +100,7 @@
public static function onArticleDeleteComplete(
&$article, &$user, $reason, $id, $content = null, $logEntry
) {
-   PageAssessmentsBody::deleteRecordsForPage( $id );
+   PageAssessmentsDAO::deleteRecordsForPage( $id );
}
 
 }
diff --git 

[MediaWiki-commits] [Gerrit] mediawiki...GraphViz[master]: Regenerate graphs even when user is not permitted to upload

2017-12-17 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398784 )

Change subject: Regenerate graphs even when user is not permitted to upload
..

Regenerate graphs even when user is not permitted to upload

This adds a new feature whereby graph images can be regenerated
and uploaded to the wiki even when the user viewing them does
not have upload permission. This means that one need not grant
upload permission to users who just need to edit graphs (i.e. they
already are allowed to edit wikitext) and is also of use to other
extensions such as SemanticResultFormats and Genealogy which
create dynamic graphs that need to be re-rendered by anonymous
users.

The upload is done by a new 'GraphViz' user, whose name is defined
by the 'graphviz-upload-user' system message.

This change also fixes a few minor deprecations and bugs such as
the error message shown when there is no filename known.

Bug: T176594
Change-Id: Idc72ff953a82229665e4aa1798eaf785750cab45
---
M i18n/en.json
M i18n/qqq.json
M includes/GraphViz.php
M includes/UploadFromLocalFile.php
M includes/UploadLocalFile.php
M tests/phpunit/GraphVizTest.php
6 files changed, 75 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GraphViz 
refs/changes/84/398784/1

diff --git a/i18n/en.json b/i18n/en.json
index 10d772f..5c38016 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -25,5 +25,6 @@
"graphviz-unrecognized-preparse-value": "The preparse value \"$1\" is 
unrecognized.",
"graphviz-category-desc": "$1 contains pages created by the GraphViz 
extension.",
"graphviz-subcategory-desc": "$1 contains pages created using the $2 
command.",
-   "graphviz-map-desc": "= ImageMap =\nWhen including this image in a wiki 
page, use the following mark-up to enable links:\n 
\n\nFile:$1\n$2\n\nSee 
[https://www.mediawiki.org/wiki/Extension:ImageMap ImageMap] for more 
information."
+   "graphviz-map-desc": "= ImageMap =\nWhen including this image in a wiki 
page, use the following mark-up to enable links:\n 
\n\nFile:$1\n$2\n\nSee 
[https://www.mediawiki.org/wiki/Extension:ImageMap ImageMap] for more 
information.",
+   "graphviz-upload-user": "GraphViz"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index a8267e8..e201986 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -26,5 +26,6 @@
"graphviz-unrecognized-preparse-value": "Used as error message.  
Parameters:\n* $1 - attribute name",
"graphviz-category-desc": "GraphViz category page text.  Parameters:\n* 
$1 - GraphViz category tag",
"graphviz-subcategory-desc": "GraphViz subcategory page text.  
Parameters:\n* $1 - GraphViz subcategory tag\n* $2 - graph render command 
associated with subcategory",
-   "graphviz-map-desc": "Do not translate the tags , 
,  or .  
Parameters:\n* $1 - image file name\n* $2 - image map shape, coordinates and 
URL (0 or more lines)"
+   "graphviz-map-desc": "Do not translate the tags , 
,  or .  
Parameters:\n* $1 - image file name\n* $2 - image map shape, coordinates and 
URL (0 or more lines)",
+   "graphviz-upload-user": "The username of the user that graph images 
should be uploaded as (if the current user doesn't have permission)"
 }
diff --git a/includes/GraphViz.php b/includes/GraphViz.php
index c1f5d91..7524a50 100644
--- a/includes/GraphViz.php
+++ b/includes/GraphViz.php
@@ -29,6 +29,7 @@
 use ImageMap;
 use MWException;
 use Parser;
+use PPFrame;
 use Sanitizer;
 use User;
 
@@ -475,13 +476,15 @@
 * - The optional "format" attribute allows the user to specify the 
image type from
 * among those supported for the graph language.  @ref Files.
 *
-* @param[in] Parser $parser
+* @param Parser $parser The parser.
+*
+* @param PPFrame $frame The preprocessor frame.
 *
 * @return string HTML of a graph image and optional map or an HTML 
error message.
 *
 * @author Keith Welter et al.
 */
-   protected static function render( $input, $args, $parser, $frame ) {
+   protected static function render( $input, $args, Parser $parser, 
PPFrame $frame ) {
global $wgUser;
 
// sanity check the input
@@ -536,11 +539,18 @@
$imageType = $settings->defaultImageType;
}
 
-   // determine user...
+   // Determine user. If the current user can't upload (e.g. this 
graph generation is being
+   // done by an extension and no user is logged in) then fall 
back to the GraphViz user as
+   // defined by the system message.
// In testing I found that $parser->getUser() did not give the 
logged-in user when doing an edit preview.
// So, I've gone against the recommended practice and used the 
global which gave the desired results.

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Move graph-creating and checking to the Tree class

2017-12-16 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398622 )

Change subject: Move graph-creating and checking to the Tree class
..

Move graph-creating and checking to the Tree class

Also give a better error when GraphViz isn't installed.

Change-Id: I8289afe5d73a77e2ec92ff64ec8d5b1604b1861e
---
M i18n/en.json
M i18n/qqq.json
M src/Hooks.php
M src/Tree.php
4 files changed, 46 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/22/398622/1

diff --git a/i18n/en.json b/i18n/en.json
index d1a9141..9e9e3d1 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -18,5 +18,6 @@
"genealogy-parser-function-not-found": "Genealogy parser function type 
not recognised: $1",
"genealogy-existing-partners": "This person already has the following 
{{PLURAL:$1|partner|partners}}: ",
"genealogy-invalid-parent-title": "Error: invalid parent page title: 
'$1'",
-   "genealogy-invalid-partner-title": "Error: invalid partner page title: 
'$1'"
+   "genealogy-invalid-partner-title": "Error: invalid partner page title: 
'$1'",
+   "genealogy-no-graphviz": "Graphic tree generation requires the GraphViz 
extension to be installed"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index a8783e8..9ae4f09 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -20,5 +20,6 @@
"genealogy-parser-function-not-found": "The error message shown when 
the parser function is passed something it doesn't recognise.",
"genealogy-existing-partners": "The message that is shown above the 
page-editing form, alerting the user to the fact that the person they're 
editing has already got a defined partner from another page.",
"genealogy-invalid-parent-title": "The error message that is shown when 
a user-supplied parent name is not a valid page title.",
-   "genealogy-invalid-partner-title": "The error message that is shown 
when a user-supplied partner name is not a valid page title."
+   "genealogy-invalid-partner-title": "The error message that is shown 
when a user-supplied partner name is not a valid page title.",
+   "genealogy-no-graphviz": "An error message displayed when the GraphViz 
extension isn't installed."
 }
diff --git a/src/Hooks.php b/src/Hooks.php
index 1e2c3f3..83e8d68 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -131,11 +131,7 @@
if ( isset( $params['descendant depth'] ) ) {
$tree->setDescendantDepth( 
$params['descendant depth'] );
}
-   if ( $tree->hasAncestorsOrDescendants() ) {
-   $graphviz = $tree->getGraphviz();
-   $out .= $parser->recursiveTagParse( 
"\n$graphviz\n" );
-   // $out .= $parser->recursiveTagParse( 
"$graphviz" );
-   }
+   $out = $tree->getWikitext( $parser );
break;
default:
$msg = wfMessage( 
'genealogy-parser-function-not-found', [ $type ] );
diff --git a/src/Tree.php b/src/Tree.php
index e8316f4..0a0cc73 100644
--- a/src/Tree.php
+++ b/src/Tree.php
@@ -2,6 +2,8 @@
 
 namespace MediaWiki\Extensions\Genealogy;
 
+use Html;
+use Parser;
 use Title;
 
 class Tree {
@@ -77,15 +79,41 @@
}
 
/**
+* Get the wikitext for the tree, containing the  element and 
dot-formatted contents.
+* @param Parser $parser The parser.
+* @return string Unsafe half-parsed HTML, as returned by 
Parser::recursiveTagParse().
+*/
+   public function getWikitext( Parser $parser ) {
+   // If there's nothing to render, give up.
+   if ( !$this->hasAncestorsOrDescendants() ) {
+   return '';
+   }
+
+   // See if GraphViz is installed.
+   if ( !class_exists( '\MediaWiki\Extension\GraphViz\GraphViz' ) 
) {
+   $err = wfMessage( 'genealogy-no-graphviz' );
+   return Html::element( 'p', [ 'class' => 'error' ], $err 
);
+   }
+
+   // Make sure the current user (even anonymous IP users) can 
upload the image file.
+   // @todo Move to GraphViz
+   // $parser->getUser()->mRights[] = 'upload';
+
+   // Get the GraphViz source and run it through the GraphViz 
extension.
+   $graphSource = $this->getGraphvizSource();
+   $out = $parser->recursiveTagParse( 
"\n$graphSource\n" );
+
+   // Debugging.
+   // $out .= $parser->recursiveTagParse( 
"$graphSource" );
+
+   return $out;
+   }
+
+   /**
 * Get the Dot source code for the graph of 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Always return a string from Language::formatNum()

2017-12-06 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395878 )

Change subject: Always return a string from Language::formatNum()
..

Always return a string from Language::formatNum()

It says it returns a string, and so it should.

Change-Id: Ic68c65c634c2557a1d07281623cd6c971b000323
---
M languages/Language.php
M tests/phpunit/languages/LanguageTest.php
2 files changed, 27 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/78/395878/1

diff --git a/languages/Language.php b/languages/Language.php
index 81564ab..8d3984d 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -3268,7 +3268,7 @@
}
}
 
-   return $number;
+   return (string)$number;
}
 
/**
diff --git a/tests/phpunit/languages/LanguageTest.php 
b/tests/phpunit/languages/LanguageTest.php
index cd52366..9abe45b 100644
--- a/tests/phpunit/languages/LanguageTest.php
+++ b/tests/phpunit/languages/LanguageTest.php
@@ -1630,6 +1630,32 @@
}
 
/**
+* @dataProvider testFormatNumProvider
+*/
+   public function testFormatNum(
+   $translateNumerals, $langCode, $number, $nocommafy, $expected
+   ) {
+   $this->setMwGlobals( [ 'wgTranslateNumerals' => 
$translateNumerals ] );
+   $lang = Language::factory( $langCode );
+   $formattedNum = $lang->formatNum( $number, $nocommafy );
+   $this->assertType( 'string', $formattedNum );
+   $this->assertEquals( $expected, $formattedNum );
+   }
+
+   public function testFormatNumProvider() {
+   return [
+   [ true, 'en', 100, false, '100' ],
+   [ true, 'en', 101, true, '101' ],
+   [ false, 'en', 103, false, '103' ],
+   [ false, 'en', 104, true, '104' ],
+   [ true, 'en', '105', false, '105' ],
+   [ true, 'en', '106', true, '106' ],
+   [ false, 'en', '107', false, '107' ],
+   [ false, 'en', '108', true, '108' ],
+   ];
+   }
+
+   /**
 * @dataProvider parseFormattedNumberProvider
 */
public function testParseFormattedNumber( $langCode, $number ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/395878
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic68c65c634c2557a1d07281623cd6c971b000323
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Don't construct HTML manually

2017-12-04 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395184 )

Change subject: Don't construct HTML manually
..

Don't construct HTML manually

Also some other minor tweaks.

Change-Id: Ie99feecfd17134d04e25c796d524028a0cc35c83
---
M README.md
M src/Hooks.php
M src/Person.php
3 files changed, 9 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/84/395184/1

diff --git a/README.md b/README.md
index 75ac6c3..6e2de20 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
 MediaWiki Genealogy extension
 =
 
-All details: https://mediawiki.org/wiki/Extension:Genealogy
+All details: https://www.mediawiki.org/wiki/Extension:Genealogy
diff --git a/src/Hooks.php b/src/Hooks.php
index 267dff2..1e2c3f3 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -3,6 +3,7 @@
 namespace MediaWiki\Extensions\Genealogy;
 
 use EditPage;
+use Html;
 use MediaWiki\MediaWikiServices;
 use OutputPage;
 use Parser;
@@ -36,9 +37,9 @@
$peopleList[] = $renderer->makeKnownLink( 
$partner->getTitle() );
}
if ( count( $peopleList ) > 0 ) {
-   $msg = wfMessage( 'genealogy-existing-partners', count( 
$peopleList ) );
-   $successBox = '' . $msg. join( ', 
', $peopleList ) . '';
-   $output->addHTML( $successBox );
+   $msg = $output->msg( 'genealogy-existing-partners', 
count( $peopleList ) );
+   $partnersMsg = $msg . join( ', ', $peopleList );
+   $output->addHTML( Html::rawElement( 'p', [], 
$partnersMsg ) );
}
}
 
@@ -47,7 +48,7 @@
 * The input parameters are wikitext with templates expanded.
 * The output should be wikitext too.
 * @param Parser $parser The parser.
-* @return string The wikitext with which to replace the parser 
function call.
+* @return string|mixed[] The wikitext with which to replace the parser 
function call.
 */
public static function renderParserFunction( Parser $parser ) {
$params = [];
@@ -56,7 +57,7 @@
array_shift( $args );
// Get param 1, the function type.
$type = array_shift( $args );
-   // Everything that's left must be named.
+   // Everything that remains is required to be named (i.e. we 
discard other unnamed args).
foreach ( $args as $arg ) {
$pair = explode( '=', $arg, 2 );
if ( count( $pair ) == 2 ) {
diff --git a/src/Person.php b/src/Person.php
index a62ff13..825f7e2 100644
--- a/src/Person.php
+++ b/src/Person.php
@@ -120,7 +120,7 @@
 * @return string
 */
public function getBirthDate() {
-   return $this->getPropSingle( "birth date" );
+   return $this->getPropSingle( 'birth date' );
}
 
/**
@@ -128,7 +128,7 @@
 * @return string
 */
public function getDeathDate() {
-   return $this->getPropSingle( "death date" );
+   return $this->getPropSingle( 'death date' );
}
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/395184
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie99feecfd17134d04e25c796d524028a0cc35c83
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...minus-x[master]: Use env instead of /usr/bin/php directly

2017-12-03 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394908 )

Change subject: Use env instead of /usr/bin/php directly
..

Use env instead of /usr/bin/php directly

Bug: T181957
Change-Id: Ieb51d38fe1ec182bdbe54a33a7a51abfa96a3246
---
M bin/minus-x
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/minus-x 
refs/changes/08/394908/1

diff --git a/bin/minus-x b/bin/minus-x
index b5a6fe3..494355e 100755
--- a/bin/minus-x
+++ b/bin/minus-x
@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 https://gerrit.wikimedia.org/r/394908
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb51d38fe1ec182bdbe54a33a7a51abfa96a3246
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/minus-x
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...FlickrAPI[master]: Add license-name to extension.json

2017-12-03 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394844 )

Change subject: Add license-name to extension.json
..

Add license-name to extension.json

Bug: T123943
Change-Id: Ie9d78eec13a5e67a1530c785a24e6e0368fa81ab
---
M extension.json
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlickrAPI 
refs/changes/44/394844/1

diff --git a/extension.json b/extension.json
index 5ca6384..e4b069a 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,7 @@
 {
"name": "FlickrAPI",
-   "version": "2.0.0",
+   "version": "2.0.1",
+   "license-name": "GPL-2.0+",
"author": [
"Ike Hecht",
"Sam Wilson"

-- 
To view, visit https://gerrit.wikimedia.org/r/394844
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9d78eec13a5e67a1530c785a24e6e0368fa81ab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlickrAPI
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...DisplayTitle[master]: Add test for italics in title

2017-11-23 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393057 )

Change subject: Add test for italics in title
..

Add test for italics in title

Change-Id: I2e5dfb586e5169dd7c3b0c4ffdca84974c2163c8
---
M composer.json
A tests/phpunit/DisplayTitleTest.php
2 files changed, 65 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DisplayTitle 
refs/changes/57/393057/1

diff --git a/composer.json b/composer.json
index 392434c..37ca006 100644
--- a/composer.json
+++ b/composer.json
@@ -7,10 +7,14 @@
"scripts": {
"test": [
"parallel-lint . --exclude vendor --exclude 
node_modules",
-   "minus-x check ."
+   "minus-x check .",
+   "phpcs -p -s"
],
"fix": [
"minus-x fix ."
]
+   },
+   "require": {
+   "mediawiki/mediawiki-codesniffer": "^14.1"
}
 }
diff --git a/tests/phpunit/DisplayTitleTest.php 
b/tests/phpunit/DisplayTitleTest.php
new file mode 100644
index 000..0a1ad27
--- /dev/null
+++ b/tests/phpunit/DisplayTitleTest.php
@@ -0,0 +1,60 @@
+doEditContent( new WikitextContent( $wikitext ), '' );
+   return $page;
+   }
+
+   /**
+* @dataProvider testCorrectRetrievalProvider
+*/
+   public function testCorrectRetrieval( $p1Title, $p1Display, $p2Title, 
$p2Text, $p2HtmlPattern ) {
+   // First page has a custom display title.
+   $wikiText1 = "{{DISPLAYTITLE:$p1Display}}";
+   $this->setPageContent( $p1Title, $wikiText1 );
+
+   // Second page has a link to the first page.
+   $this->setPageContent( $p2Title, $p2Text );
+   $secondPageTitle = Title::newFromText( $p2Title );
+
+   // Make sure the HTML of the second page is what we expect.
+   $secondPage = WikiPage::factory( $secondPageTitle );
+   $parserOptions = new ParserOptions( 
$this->getTestUser()->getUser() );
+   $parserOptions->setRemoveComments( true );
+   $this->assertRegExp(
+   '|.*'.$p2HtmlPattern.'.*|',
+   $secondPage->getContent()->getParserOutput( 
$secondPageTitle, null, $parserOptions )->getText()
+   );
+   }
+
+   public function testCorrectRetrievalProvider() {
+   return [
+   [
+   'p1Title' => 'FirstPage',
+   'p1Display' => 'The first page',
+   'p2Title' => 'SecondPage',
+   'p2Text' => 'Link to [[FirstPage]]',
+   'p2HtmlPattern' => 'Link to The first page'
+   ],
+   [
+   'p1Title' => 'Page3',
+   'p1Display' => "The ''third'' page",
+   'p2Title' => 'ForthPage',
+   'p2Text' => 'Link to [[Page3]]',
+   'p2HtmlPattern' => 'Link to The third page'
+   ]
+   ];
+   }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/393057
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e5dfb586e5169dd7c3b0c4ffdca84974c2163c8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DisplayTitle
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Make it possible to subclass SpecialPreferences

2017-11-06 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389660 )

Change subject: Make it possible to subclass SpecialPreferences
..

Make it possible to subclass SpecialPreferences

This updates the constructor with all of its arguments,
and makes a method protected rather than private.

Change-Id: I390e9d46fd2b8d4d8a1f9fd250c964a696b48244
---
M includes/specials/SpecialPreferences.php
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/60/389660/1

diff --git a/includes/specials/SpecialPreferences.php 
b/includes/specials/SpecialPreferences.php
index 7c55e5c..f31bacc 100644
--- a/includes/specials/SpecialPreferences.php
+++ b/includes/specials/SpecialPreferences.php
@@ -27,8 +27,15 @@
  * @ingroup SpecialPage
  */
 class SpecialPreferences extends SpecialPage {
-   function __construct() {
-   parent::__construct( 'Preferences' );
+
+   /**
+* @inheritDoc
+*/
+   public function __construct(
+   $name = 'Preferences', $restriction = '', $listed = true,
+   $function = false, $file = '', $includable = false
+   ) {
+   parent::__construct( $name, $restriction, $listed, $function, 
$file, $includable );
}
 
public function doesWrites() {
@@ -127,7 +134,7 @@
return Preferences::getFormObject( $user, $context );
}
 
-   private function showResetForm() {
+   protected function showResetForm() {
if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
throw new PermissionsError( 'editmyoptions' );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/389660
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I390e9d46fd2b8d4d8a1f9fd250c964a696b48244
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Description2[master]: Add composer for CI, and fix CS errors

2017-11-02 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/388003 )

Change subject: Add composer for CI, and fix CS errors
..

Add composer for CI, and fix CS errors

Change-Id: I5a89efd3f162d73e247543c86967562a949a3bf4
---
M Description2.class.php
M Description2.i18n.magic.php
M Description2.php
A composer.json
M extension.json
5 files changed, 59 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Description2 
refs/changes/03/388003/1

diff --git a/Description2.class.php b/Description2.class.php
index c3a6683..7fef3b2 100644
--- a/Description2.class.php
+++ b/Description2.class.php
@@ -1,4 +1,7 @@
  tag to MW pages and into 
the parser output
  *
@@ -13,8 +16,8 @@
 class Description2 {
 
/**
-* @param Parser $parser
-* @param string $desc
+* @param Parser $parser The parser.
+* @param string $desc The description text.
 */
public static function setDescription( Parser $parser, $desc ) {
$parserOutput = $parser->getOutput();
@@ -25,16 +28,18 @@
}
 
/**
-* @param Parser $parser
-* @param string $text
+* @link https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterTidy
+* @param Parser &$parser The parser.
+* @param string $text The page text.
 * @return bool
 */
public static function onParserAfterTidy( Parser &$parser, &$text ) {
$desc = '';
 
-   $myText = preg_replace( 
'%]*+>(?:(?R)|[^<]*+(?:(?!%i', '', 
$text );
+   $pattern = 
'%]*+>(?:(?R)|[^<]*+(?:(?!%i';
+   $myText = preg_replace( $pattern, '', $text );
 
-   $paragraphs = array();
+   $paragraphs = [];
if ( preg_match_all( '#.*?#is', $myText, $paragraphs ) ) 
{
foreach ( $paragraphs[0] as $paragraph ) {
$paragraph = trim( strip_tags( $paragraph ) );
@@ -58,37 +63,48 @@
 * @return bool
 */
public static function onParserFirstCallInit( Parser &$parser ) {
-   global $wgEnableMetaDescriptionFunctions;
-   if ( !$wgEnableMetaDescriptionFunctions ) {
+   $config = MediaWikiServices::getInstance()
+   ->getConfigFactory()
+   ->makeConfig( 'Description2' );
+   if ( !$config->get( 'EnableMetaDescriptionFunctions' ) ) {
// Functions and tags are disabled
return true;
}
-   $parser->setFunctionHook( 'description2', array( 
'Description2', 'parserFunctionCallback' ), Parser::SFH_OBJECT_ARGS );
-   $parser->setFunctionTagHook( 'metadesc', array( 'Description2', 
'tagCallback' ), Parser::SFH_OBJECT_ARGS );
+   $parser->setFunctionHook(
+   'description2',
+   [ static::class, 'parserFunctionCallback' ],
+   Parser::SFH_OBJECT_ARGS
+   );
+   $parser->setFunctionTagHook(
+   'metadesc',
+   [ static::class, 'tagCallback' ],
+   Parser::SFH_OBJECT_ARGS
+   );
return true;
}
 
/**
-* @param Parser $parser
-* @param $frame
-* @param $args
+* @param Parser $parser The parser.
+* @param PPFrame $frame The frame.
+* @param string[] $args The arguments of the parser function call.
 * @return string
 */
-   public static function parserFunctionCallback( Parser $parser, $frame, 
$args ) {
+   public static function parserFunctionCallback( Parser $parser, PPFrame 
$frame, $args ) {
$desc = isset( $args[0] ) ? $frame->expand( $args[0] ) : '';
self::setDescription( $parser, $desc );
return '';
}
 
/**
-* @param Parser $parser
-* @param $frame
-* @param $content
-* @param $attributes
+* @param Parser $parser The parser.
+* @param PPFrame $frame Not used.
+* @param string $content The contents of the tag (if any).
+* @param string[] $attributes The tag attributes (if any).
 * @return string
 */
-   public static function tagCallback( Parser $parser, $frame, $content, 
$attributes ) {
-   $desc = ( isset( $content ) ? $content : ( isset( 
$attributes['content'] ) ? $attributes['content'] : null ) );
+   public static function tagCallback( Parser $parser, PPFrame $frame, 
$content, $attributes ) {
+   $contentAttr = isset( $attributes['content'] ) ? 
$attributes['content'] : null;
+   $desc = isset( $content ) ? $content : $contentAttr;
if ( isset( $desc ) 

[MediaWiki-commits] [Gerrit] mediawiki...RandomFeaturedUser[master]: Add phpcs and fix up some coding standards and HTML generation

2017-10-29 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387075 )

Change subject: Add phpcs and fix up some coding standards and HTML generation
..

Add phpcs and fix up some coding standards and HTML generation

Bug: T179245
Change-Id: Ie3a62fe21420bb1a3aab5552aee1792bd4e4737e
---
M .gitignore
A .phpcs.xml
A composer.json
M extension.json
R includes/RandomFeaturedUser.php
5 files changed, 55 insertions(+), 19 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RandomFeaturedUser 
refs/changes/75/387075/1

diff --git a/.gitignore b/.gitignore
index a30a7d4..dd69b6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
 /node_modules/
+/vendor/
 .svn
 *~
 *.kate-swp
 .*.swp
+/composer.lock
diff --git a/.phpcs.xml b/.phpcs.xml
new file mode 100644
index 000..95b1ff2
--- /dev/null
+++ b/.phpcs.xml
@@ -0,0 +1,8 @@
+
+
+   
+   .
+   
+   
+   vendor
+
diff --git a/composer.json b/composer.json
new file mode 100644
index 000..40246f4
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,14 @@
+{
+   "require-dev": {
+   "jakub-onderka/php-parallel-lint": "0.9.2",
+   "mediawiki/mediawiki-codesniffer": "14.1.0",
+   "jakub-onderka/php-console-highlighter": "0.3.2"
+   },
+   "scripts": {
+   "fix": "phpcbf",
+   "test": [
+   "parallel-lint . --exclude vendor",
+   "phpcs -p -s"
+   ]
+   }
+}
diff --git a/extension.json b/extension.json
index 9b859a8..a9249b4 100644
--- a/extension.json
+++ b/extension.json
@@ -22,7 +22,7 @@
]
},
"AutoloadClasses": {
-   "RandomFeaturedUser": "includes/RandomFeaturedUser.class.php"
+   "RandomFeaturedUser": "includes/RandomFeaturedUser.php"
},
"Hooks": {
"ParserFirstCallInit": 
"RandomFeaturedUser::onParserFirstCallInit"
diff --git a/includes/RandomFeaturedUser.class.php 
b/includes/RandomFeaturedUser.php
similarity index 79%
rename from includes/RandomFeaturedUser.class.php
rename to includes/RandomFeaturedUser.php
index 317d71c..ae03bad 100644
--- a/includes/RandomFeaturedUser.class.php
+++ b/includes/RandomFeaturedUser.php
@@ -25,15 +25,21 @@
/**
 * Set up the  tag
 *
-* @param Parser $parser
+* @param Parser &$parser The parser.
 * @return bool
 */
public static function onParserFirstCallInit( &$parser ) {
-   $parser->setHook( 'randomfeatureduser', array( __CLASS__, 
'getRandomUser' ) );
+   $parser->setHook( 'randomfeatureduser', [ __CLASS__, 
'getRandomUser' ] );
return true;
}
 
-   public static function getRandomUser( $input, $args, $parser ) {
+   /**
+* @param string $input The contents of the randomfeatureduser tag.
+* @param string[] $args The arguments to the randomfeatureduser tag.
+* @param Parser $parser The parser.
+* @return string
+*/
+   public static function getRandomUser( $input, $args, Parser $parser ) {
global $wgMemc, $wgRandomFeaturedUser;
 
$parser->disableCache();
@@ -46,7 +52,7 @@
// Add CSS
$parser->getOutput()->addModuleStyles( 
'ext.RandomFeaturedUser.css' );
 
-   $user_list = array();
+   $user_list = [];
$count = 20;
$realCount = 10;
 
@@ -63,24 +69,24 @@
$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select(
'user_points_' . $period,
-   array( 'up_user_id', 'up_user_name', 
'up_points' ),
-   array( 'up_user_id <> 0' ),
+   [ 'up_user_id', 'up_user_name', 'up_points' ],
+   [ 'up_user_id <> 0' ],
__METHOD__,
-   array(
+   [
'ORDER BY' => 'up_points DESC',
'LIMIT' => $count
-   )
+   ]
);
$loop = 0;
foreach ( $res as $row ) {
// Prevent blocked users from appearing
$user = User::newFromId( $row->up_user_id );
if ( !$user->isBlocked() ) {
-   $user_list[] = array(
+   $user_list[] = [
'user_id' => $row->up_user_id,
'user_name' => 
$row->up_user_name,
   

[MediaWiki-commits] [Gerrit] mediawiki...FlickrAPI[master]: Switch to fork of the phpflickr library

2017-10-16 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/384642 )

Change subject: Switch to fork of the phpflickr library
..

Switch to fork of the phpflickr library

The upstream project is dead, so I've forked it to
samwilson/phpflickr and updated it.

This change just switches to the new fork.

Change-Id: I094fb25aa6b589ee1d99907c18ff011be2217923
---
M FlickrAPI.hooks.php
M composer.json
2 files changed, 5 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlickrAPI 
refs/changes/42/384642/1

diff --git a/FlickrAPI.hooks.php b/FlickrAPI.hooks.php
index c2f7332..e4fbeda 100644
--- a/FlickrAPI.hooks.php
+++ b/FlickrAPI.hooks.php
@@ -1,5 +1,7 @@
 https://github.com/dan-coulter/phpflickr.git;,
-   "type": "git",
-   "reference": 
"bc4f2092b15d347e3d40c19fe0dbff8759fc8e51"
-   },
-   "autoload": {
-   "classmap": [
-   "phpFlickr.php"
-   ]
-   }
-   }
-   }
-   ]
+   }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/384642
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I094fb25aa6b589ee1d99907c18ff011be2217923
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlickrAPI
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...AddHTMLMetaAndTitle[master]: Convert to extension registration

2017-10-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/384200 )

Change subject: Convert to extension registration
..

Convert to extension registration

This is a bit of a rewrite, to move to extension registration but
also remove some of the duplication of the code.

Change-Id: I9e980bf9a31286860972991f0b16d60485b85670
---
A .eslintrc.json
D AddHTMLMetaAndTitle.php
D Add_HTML_Meta_and_Title.php
M composer.json
A extension.json
A includes/Adder.php
A includes/Hooks.php
M phpcs.xml
8 files changed, 229 insertions(+), 219 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AddHTMLMetaAndTitle 
refs/changes/00/384200/1

diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 000..4843240
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,10 @@
+{
+   "extends": "wikimedia",
+   "env": {
+   "browser": true,
+   "jquery": true
+   },
+   "globals": {
+   "mediaWiki": false
+   }
+}
diff --git a/AddHTMLMetaAndTitle.php b/AddHTMLMetaAndTitle.php
deleted file mode 100644
index d24e03c..000
--- a/AddHTMLMetaAndTitle.php
+++ /dev/null
@@ -1,205 +0,0 @@
-https://www.mediawiki.org/wiki/Extension:Add_HTML_Meta_and_Title
-*
- */
-
-/**
- * Protect against register_globals vulnerabilities.
- * This line must be present before any global variable is referenced.
- */
-if ( !defined( 'MEDIAWIKI' ) ) {
-   echo << __FILE__,
-   'name' => 'AddHTMLMetaAndTitle',
-   'author' => [
-   'Vladimir Radulovski - vladradulovatgmail.com',
-   'Jim Wilson - wilson.jim.ratgmail.com',
-   'Dennis Roczek - dennisroczekatgmail.com'
-   ],
-   'url' => 
'https://www.mediawiki.org/wiki/Extension:Add_HTML_Meta_and_Title',
-   'descriptionmsg' => 'addhtmlmetaandtitle-desc',
-   'version' => '0.7',
-   'license-name' => 'MIT'
-];
-
-# Add Extension Function
-$wgExtensionFunctions[] = 'wfSetupSEOParserHooks';
-$wgMessagesDirs['AddHTMLMetaAndTitle'] = __DIR__ . '/i18n';
-
-/**
- * Sets up the MetaKeywordsTag Parser hook and system messages
- */
-function wfSetupSEOParserHooks() {
-   global $wgParser;
-   # meta if empty
-   $wgParser->setHook( 'seo', 'wfRenderSEO' );
-}
-
-function wfParamEncode( $param_text, &$parser, $frame ) {
-   $expanded_param = $parser->recursiveTagParse( $param_text, $frame );
-
-   return base64_encode( $expanded_param );
-}
-
-/**
- * Renders the  tag.
- * @param String $text Incomming text - should always be null or empty (passed 
by value).
- * @param Array $params Attributes specified for tag - must contain 'content' 
(passed by value).
- * @param Parser $parser Reference to currently running parser (passed by 
reference).
- * @return String Always empty.
- */
-function wfRenderSEO( $text, $params = [], $parser, $frame ) {
-   # Short-circuit with error message if content is not specified.
-   $emt = '';
-   if ( ( isset( $params['title'] ) ) ||
-   ( isset( $params['metak'] ) ) ||
-   ( isset( $params['metad'] ) ) ||
-   ( isset( $params['metakeywords'] ) ) ||
-   ( isset( $params['metadescription'] ) ) ||
-   ( isset( $params['google-site-verification'] ) )
-   ) {
-   if ( isset( $params['title'] ) ) {
-   $emt .= "";
-   }
-   if ( isset( $params['metak'] ) ) {
-   $emt .= "";
-   }
-   if ( isset( $params['metakeywords'] ) ) {
-   $emt .= "";
-   }
-   if ( isset( $params['metad'] ) ) {
-   $emt .= "";
-   }
-   if ( isset( $params['metadescription'] ) ) {
-   $emt .= "";
-   }
-   if ( isset( $params['google-site-verification'] ) ) {
-   $emt .= "";
-   }
-
-   return $emt; // $encoded_metas_and_title;
-
-   } else {
-   return
-   '' .
-   wfMessage( 'addhtmlmetaandtitle-empty-attr' 
)->inContentLanguage()->text() .
-   '';
-   }
-}
-
-# Attach post-parser hook to extract metadata and alter headers
-$wgHooks['OutputPageBeforeHTML'][] = 'wfInsertMeta';
-$wgHooks['BeforePageDisplay'][] = 'wfInsertTitle';
-
-/**
- * Adds the  keywords to document head.
- * Usage: $wgHooks['OutputPageBeforeHTML'][] = 'insertMetaKeywords';
- * @param OutputPage $out Handle to an OutputPage object - presumably $wgOut 
(passed by reference).
- * @param String $text Output text.
- * @return Boolean Always true to allow other extensions to continue 
processing.
- */
-function wfInsertTitle( $out ) {
-   # Extract meta keywords
-   if ( preg_match_all(
-   '//m',
-   $out->mBodytext,
-

[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Set up local_preferences table

2017-10-09 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383304 )

Change subject: Set up local_preferences table
..

Set up local_preferences table

This adds a new local_preferences table, of exactly the same
design as the global_preferences and user_properties tables.

No integration into the rest of GlobalPreferences is done yet.

Change-Id: I8e15f1570f314cae63a38325589f3d4811919bc6
---
M includes/Hooks.php
R sql/create_global_preferences.sql
A sql/create_local_preferences.sql
3 files changed, 15 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/04/383304/1

diff --git a/includes/Hooks.php b/includes/Hooks.php
index 5a461fb..7a35919 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -189,12 +189,18 @@
 */
public static function onLoadExtensionSchemaUpdates( DatabaseUpdater 
$updater ) {
global $wgGlobalPreferencesDB;
+
+   // Global preferences table.
if ( is_null( $wgGlobalPreferencesDB ) || 
$wgGlobalPreferencesDB === wfWikiID() ) {
// Only add the table if it's supposed to be on this 
wiki.
-   $sqlPath = __DIR__ . '/../schema.sql';
+   $sqlPath = __DIR__ . 
'/../sql/create_global_preferences.sql';
$updater->addExtensionTable( 'global_preferences', 
$sqlPath );
}
 
+   // Local preferences table.
+   $sqlPath = __DIR__ . '/../sql/create_local_preferences.sql';
+   $updater->addExtensionTable( 'local_preferences', $sqlPath );
+
return true;
}
 
diff --git a/schema.sql b/sql/create_global_preferences.sql
similarity index 100%
rename from schema.sql
rename to sql/create_global_preferences.sql
diff --git a/sql/create_local_preferences.sql b/sql/create_local_preferences.sql
new file mode 100644
index 000..c9af6fa
--- /dev/null
+++ b/sql/create_local_preferences.sql
@@ -0,0 +1,8 @@
+CREATE TABLE local_preferences (
+  gp_user INT(11) NOT NULL,
+  gp_property VARBINARY(255) NOT NULL,
+  gp_value BLOB
+) /*$wgDBTableOptions*/;
+
+CREATE UNIQUE INDEX /*i*/local_preferences_user_property ON 
/*_*/local_preferences (gp_user,gp_property);
+CREATE INDEX /*i*/local_preferences_property ON /*_*/local_preferences 
(gp_property);

-- 
To view, visit https://gerrit.wikimedia.org/r/383304
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e15f1570f314cae63a38325589f3d4811919bc6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...BoilerPlate[master]: Move classes into src directory, and remove exclusions for p...

2017-10-09 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383302 )

Change subject: Move classes into src directory, and remove exclusions for phpcs
..

Move classes into src directory, and remove exclusions for phpcs

Bug: T97105
Change-Id: Ia85f6fd7367f63e0922ec64f2c9bb46a48e416e0
---
M README.md
M extension.json
M phpcs.xml
R src/Hooks.php
R src/SpecialHelloWorld.php
5 files changed, 17 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BoilerPlate 
refs/changes/02/383302/1

diff --git a/README.md b/README.md
index c973562..4bec7a3 100644
--- a/README.md
+++ b/README.md
@@ -12,9 +12,10 @@
 This automates the recommended code checkers for PHP and JavaScript code in 
Wikimedia projects
 (see https://www.mediawiki.org/wiki/Continuous_integration/Entry_points).
 To take advantage of this automation.
-  # install nodejs, npm, and PHP composer
-  # change to the extension's directory
-  # npm install
-  # composer install
+
+1. install nodejs, npm, and PHP composer
+2. change to the extension's directory
+3. `npm install`
+4. `composer install`
 
 Once set up, running `npm test` and `composer test` will run automated code 
checks.
diff --git a/extension.json b/extension.json
index 51c48ce..0f3b1ae 100644
--- a/extension.json
+++ b/extension.json
@@ -9,8 +9,8 @@
"license-name": "MIT",
"type": "other",
"AutoloadClasses": {
-   "MediaWiki\\Extension\\BoilerPlate\\Hooks": 
"BoilerPlate.hooks.php",
-   "MediaWiki\\Extension\\BoilerPlate\\SpecialHelloWorld": 
"specials/SpecialHelloWorld.php"
+   "MediaWiki\\Extension\\BoilerPlate\\Hooks": "src/Hooks.php",
+   "MediaWiki\\Extension\\BoilerPlate\\SpecialHelloWorld": 
"src/SpecialHelloWorld.php"
},
"ConfigRegistry": {
"boilerplate": "GlobalVarConfig::newInstance"
diff --git a/phpcs.xml b/phpcs.xml
index e688c40..95b1ff2 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,11 +1,6 @@
 
 
-   
-   
-   
-   
-   
-   
+   
.


diff --git a/BoilerPlate.hooks.php b/src/Hooks.php
similarity index 100%
rename from BoilerPlate.hooks.php
rename to src/Hooks.php
diff --git a/specials/SpecialHelloWorld.php b/src/SpecialHelloWorld.php
similarity index 92%
rename from specials/SpecialHelloWorld.php
rename to src/SpecialHelloWorld.php
index 5e1162b..292135b 100644
--- a/specials/SpecialHelloWorld.php
+++ b/src/SpecialHelloWorld.php
@@ -42,7 +42,8 @@
'myfield2' => [
'section' => 'section1',
'label-message' => 'testform-myfield2',
-   'class' => 'HTMLTextField', // same as type 
'text'
+   // HTMLTextField class is the same as type 
'text'
+   'class' => 'HTMLTextField',
],
'myfield3' => [
'class' => 'HTMLTextField',
@@ -94,6 +95,10 @@
$htmlForm->show();
}
 
+   /**
+* @param string[] $formData The submitted form data.
+* @return bool|string
+*/
static function trySubmit( $formData ) {
if ( $formData['myfield1'] == 'Fleep' ) {
return true;
@@ -102,6 +107,9 @@
return 'HAHA FAIL';
}
 
+   /**
+* @return string
+*/
protected function getGroupName() {
return 'other';
}

-- 
To view, visit https://gerrit.wikimedia.org/r/383302
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia85f6fd7367f63e0922ec64f2c9bb46a48e416e0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BoilerPlate
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...RandomImage[master]: Fix up DOMDOcument::loadHTML() usage

2017-09-20 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379197 )

Change subject: Fix up DOMDOcument::loadHTML() usage
..

Fix up DOMDOcument::loadHTML() usage

This was failing to create the DOMXPath object, because $doc was
just the boolean returned from loadHTML.

Change-Id: I21556658c31a5d2667c30dda677d66f36128d8cb
---
M RandomImage.class.php
1 file changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RandomImage 
refs/changes/97/379197/1

diff --git a/RandomImage.class.php b/RandomImage.class.php
index ec81113..d99c8b4 100644
--- a/RandomImage.class.php
+++ b/RandomImage.class.php
@@ -118,12 +118,12 @@
 */
protected function removeMagnifier( $html ) {
$dom = new DOMDocument();
-   $doc = $dom->loadHTML( $html );
-   $xpath = new DOMXPath( $doc );
+   $dom->loadHTML( $html );
+   $xpath = new DOMXPath( $dom );
foreach ( $xpath->query( '//div[@class="magnify"]' ) as $mag ) {
$mag->parentNode->removeChild( $mag );
}
-   return preg_replace( '!<\?xml[^?]*\?>!', '', $doc->saveXml() );
+   return preg_replace( '!<\?xml[^?]*\?>!', '', $dom->saveXml() );
}
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/379197
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21556658c31a5d2667c30dda677d66f36128d8cb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/RandomImage
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add classes to HTMLCheckMatrix items to identify forced ones

2017-09-19 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378843 )

Change subject: Add classes to HTMLCheckMatrix items to identify forced ones
..

Add classes to HTMLCheckMatrix items to identify forced ones

Some items in an HTMLCheckMatrix form field can be forced to be
on or off, in which case they're disabled. This adds three new
class names, so that (for example) Javascript can identify these
checkboxes. There are not currently any classes assigned to them.

Bug: T172585
Change-Id: I984020ce2437effb3ff5f186470105fd80d4a00f
---
M includes/htmlform/fields/HTMLCheckMatrix.php
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/43/378843/1

diff --git a/includes/htmlform/fields/HTMLCheckMatrix.php 
b/includes/htmlform/fields/HTMLCheckMatrix.php
index fa18a3c..dd4e707 100644
--- a/includes/htmlform/fields/HTMLCheckMatrix.php
+++ b/includes/htmlform/fields/HTMLCheckMatrix.php
@@ -121,9 +121,11 @@
if ( $this->isTagForcedOff( $thisTag ) ) {
$checked = false;
$thisAttribs['disabled'] = 1;
+   $thisAttribs['class'] = 
'checkmatrix-forced checkmatrix-forced-off';
} elseif ( $this->isTagForcedOn( $thisTag ) ) {
$checked = true;
$thisAttribs['disabled'] = 1;
+   $thisAttribs['class'] = 
'checkmatrix-forced checkmatrix-forced-on';
}
 
$checkbox = $this->getOneCheckbox( $checked, 
$attribs + $thisAttribs );

-- 
To view, visit https://gerrit.wikimedia.org/r/378843
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I984020ce2437effb3ff5f186470105fd80d4a00f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...FlickrAPI[master]: [WiP] Remove dependency on phpflickr

2017-09-17 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378506 )

Change subject: [WiP] Remove dependency on phpflickr
..

[WiP] Remove dependency on phpflickr

This moves the small parts of phpflickr that this extension was
using, into a new Flickr class. This is because that library is
now rather out of date, and was throwing lots of errors from parts
of it that have nothing to do with the simple usage here.

Change-Id: I63352c905c2491200e62c1f6810f0604bb7e8baf
---
M FlickrAPI.hooks.php
D FlickrAPICache.php
M composer.json
M extension.json
A includes/Flickr.php
5 files changed, 143 insertions(+), 83 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlickrAPI 
refs/changes/06/378506/1

diff --git a/FlickrAPI.hooks.php b/FlickrAPI.hooks.php
index c2f7332..694dccd 100644
--- a/FlickrAPI.hooks.php
+++ b/FlickrAPI.hooks.php
@@ -1,5 +1,7 @@
 getConfig();
+   $apiKey = $config->get( 'FlickrAPIKey' );
+   $apiSecret = $config->get( 'FlickrAPISecret' );
 
$options = self::extractOptions( $optionsString );
 
/** @todo i18n these errors? */
-   if ( $wgFlickrAPIKey == '' ) {
+   if ( $apiKey == '' ) {
throw new MWException(
'Flickr Error ( No API key ): You must set 
$wgFlickrAPIKey!' );
}
@@ -155,18 +157,10 @@
throw new MWException( 'Flickr Error ( Not a valid ID 
): PhotoID not numeric' );
}
 
-   $phpFlickr = new phpFlickr( $wgFlickrAPIKey, $wgFlickrAPISecret 
);
+   $flickr = new Flickr( $apiKey, $apiSecret );
 
-   // Decide which cache to use
-   if ( $wgUseFileCache ) {
-   $phpFlickr->enableCache( 'fs', $wgFileCacheDirectory );
-   } else {
-   $phpFlickr->enableCache( 'custom',
-   [ 'FlickrAPICache::getCache', 
'FlickrAPICache::setCache' ] );
-   }
-
-   $info = $phpFlickr->photos_getInfo( $options['id'] );
-   $flickrSizes = $phpFlickr->photos_getSizes( $options['id'] );
+   $info = $flickr->photosGetInfo( $options['id'] );
+   $flickrSizes = $flickr->photosGetSizes( $options['id'] );
if ( !$info || !$flickrSizes ) {
throw new MWException( 'Flickr Error ( Photo not found 
): PhotoID ' . $options['id'] );
}
@@ -191,7 +185,7 @@
 
$validSizes = self::getValidSizes();
$handlerParams = [];
-   foreach ( $flickrSizes as $flickrSize ) {
+   foreach ( $flickrSizes['size'] as $flickrSize ) {
if ( $flickrSize['label'] === 
$validSizes[$options['size']] ) {
$handlerParams['width'] = $flickrSize['width'];
$url = $flickrSize['source'];
@@ -206,7 +200,6 @@
 
$imageLink = FlickrAPIUtils::makeImageLink( $parser, $url, 
$frameParams, $handlerParams );
 
-   wfProfileOut( __METHOD__ );
return Html::rawElement( 'div', [ 'class' => 'flickrapi' ], 
$imageLink );
}
 }
diff --git a/FlickrAPICache.php b/FlickrAPICache.php
deleted file mode 100644
index d376edd..000
--- a/FlickrAPICache.php
+++ /dev/null
@@ -1,41 +0,0 @@
-get( $key );
-   wfDebugLog( "FlickrAPI", __METHOD__ . ": got " . var_export( 
$cached, true ) .
-   " from cache." );
-   return $cached;
-   }
-
-   /**
-* Store this call in cache.
-*
-* @param string $reqhash The cache key.
-* @param string $response The response to cache.
-* @param int $cache_expire Either an interval in seconds or a unix 
timestamp for expiry.
-* @return bool
-*/
-   public static function setCache( $reqhash, $response, $cache_expire ) {
-   $cache = wfGetCache( CACHE_ANYTHING );
-   $key = wfMemcKey( 'flickrapi', $reqhash );
-   wfDebugLog( "FlickrAPI",
-   __METHOD__ . ": caching " . var_export( $response, true 
) .
-   " from Flickr." );
-   return $cache->set( $key, $response, $cache_expire );
-   }
-}
diff --git a/composer.json b/composer.json
index 32c9312..9dc2960 100755
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,4 @@
 {
-   "require": {
-   "dan-coulter/phpflickr": "dev-master"
-   },
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.9.2",
"mediawiki/mediawiki-codesniffer": "0.12.0",
@@ -15,24 +12,5 @@
"fix": [
"phpcbf"
]
-   },
-   "repositories": [
-   {
-   "type": 

[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Add GlobalPreferences-specific text to the reset form

2017-09-12 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/377409 )

Change subject: Add GlobalPreferences-specific text to the reset form
..

Add GlobalPreferences-specific text to the reset form

Add two new messages for the global preferences reset form, based
on those for Special:Preferences.

Bug: T174755
Depends-On: I3f7e9067c2faa915c2b05a2ae01312c3f2fee2ea
Change-Id: Ie174c7d398861f2275126627eefb7d6b1c44f953
---
M i18n/en.json
M i18n/qqq.json
M includes/SpecialGlobalPreferences.php
3 files changed, 34 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/09/377409/1

diff --git a/i18n/en.json b/i18n/en.json
index 0043b24..0e37692 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -11,5 +11,7 @@
"globalprefs-notglobal": "Your account is not a global account and 
cannot set global preferences.",
"globalpreferences": "Global preferences",
"globalprefs-info-label": "Global preferences:",
-   "globalprefs-info-link": "Set your global preferences"
-}
\ No newline at end of file
+   "globalprefs-info-link": "Set your global preferences",
+   "globalprefs-reset-intro": "You can use this page to disable all global 
preferences and return to your local preferences.\nThis cannot be undone.",
+   "globalprefs-restoreprefs": "Remove all global preferences (in all 
sections)"
+}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index d727a39..f158572 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -12,5 +12,7 @@
"globalprefs-notglobal": "Error message a user sees if they don not 
have a global account.",
"globalpreferences": "{{doc-special|GlobalPreferences}}",
"globalprefs-info-label": "Label for link in [[Special:Preferences]] to 
go set your global preferences.",
-   "globalprefs-info-link": "Link text to [[Special:GlobalPreferences]]."
+   "globalprefs-info-link": "Link text to [[Special:GlobalPreferences]].",
+   "globalprefs-reset-intro": "Used in 
[[Special:GlobalPreferences/reset]].",
+   "globalprefs-restoreprefs": "Used as link text in 
[[Special:GlobalPreferences]]. The link points to 
[[Special:GlobalPreferences/reset]] which shows the \"Remove all global 
preferences\" form.\n\nAlso used as label for the Submit button in 
[[Special:GlobalPreferences/reset]]."
 }
diff --git a/includes/SpecialGlobalPreferences.php 
b/includes/SpecialGlobalPreferences.php
index 2daafa4..9f41662 100644
--- a/includes/SpecialGlobalPreferences.php
+++ b/includes/SpecialGlobalPreferences.php
@@ -2,7 +2,9 @@
 
 namespace GlobalPreferences;
 
+use DerivativeContext;
 use ErrorPageError;
+use HTMLForm;
 use PermissionsError;
 use SpecialPage;
 use SpecialPreferences;
@@ -47,6 +49,31 @@
}
 
/**
+* Display the preferences-reset confirmation page.
+* This is a duplicate of parent::showResetForm, with the message names 
changed.
+* @throws PermissionsError
+*/
+   protected function showResetForm() {
+   // TODO: Should we have our own userright here?
+   if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
+   throw new PermissionsError( 'editmyoptions' );
+   }
+
+   $this->getOutput()->addWikiMsg( 'globalprefs-reset-intro' );
+
+   $context = new DerivativeContext( $this->getContext() );
+   $context->setTitle( $this->getPageTitle( 'reset' ) ); // Reset 
subpage
+   $htmlForm = new HTMLForm( [], $context, 'globalprefs-restore' );
+
+   $htmlForm->setSubmitTextMsg( 'globalprefs-restoreprefs' );
+   $htmlForm->setSubmitDestructive();
+   $htmlForm->setSubmitCallback( [ $this, 'submitReset' ] );
+   $htmlForm->suppressReset();
+
+   $htmlForm->show();
+   }
+
+   /**
 * Handle reset submission (subpage '/reset').
 * @param string[] $formData The submitted data (not used).
 * @return bool

-- 
To view, visit https://gerrit.wikimedia.org/r/377409
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie174c7d398861f2275126627eefb7d6b1c44f953
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...CodeMirror[master]: Change popup label colour to green

2017-09-11 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/377376 )

Change subject: Change popup label colour to green
..

Change popup label colour to green

This is to stop it looking so much like a link that can be clicked on.

Bug: T174219
Change-Id: Icdae8ddf32aa0c08fe0d708eb289bafe53f9b589
---
M resources/modules/popup.less
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeMirror 
refs/changes/76/377376/1

diff --git a/resources/modules/popup.less b/resources/modules/popup.less
index 53f4fba..12cf3dd 100644
--- a/resources/modules/popup.less
+++ b/resources/modules/popup.less
@@ -14,7 +14,7 @@
}
 
.codemirror-popup-label span {
-   color: #1e90ff;
+   color: #457d39;
}
 
.codemirror-popup-text {

-- 
To view, visit https://gerrit.wikimedia.org/r/377376
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icdae8ddf32aa0c08fe0d708eb289bafe53f9b589
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...CodeMirror[master]: Join the popup label into one message

2017-09-10 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/377183 )

Change subject: Join the popup label into one message
..

Join the popup label into one message

The popup label was being styled as two words from two different
i18n messages, each a different colour. This combines them into
one, moves the identifing class name up to the outer span, and
colours both words blue (the outer braces are left black).

Bug: T174219
Change-Id: Id1166f48ae4b3b8daff29be56dd92ef330dd9cef
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M resources/ext.CodeMirror.js
M resources/modules/popup.less
5 files changed, 10 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeMirror 
refs/changes/83/377183/1

diff --git a/extension.json b/extension.json
index 00f95b3..51b67fe 100644
--- a/extension.json
+++ b/extension.json
@@ -44,8 +44,7 @@
],
"messages": [
"codemirror-toggle-label",
-   "codemirror-popup-syntax",
-   "codemirror-popup-highlighting",
+   "codemirror-popup-label",
"codemirror-popup-desc",
"codemirror-popup-btn-yes",
"codemirror-popup-btn-no"
diff --git a/i18n/en.json b/i18n/en.json
index 020bf82..09bba13 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -8,8 +8,7 @@
"codemirror-toggle-label": "Syntax highlighting",
"codemirror-beta-title": "Wikitext syntax highlighting",
"codemirror-beta-desc": "Syntax highlighting makes editing easier by 
using color and shade to visually separate page text from the code for links, 
references and templates.",
-   "codemirror-popup-syntax": "Syntax",
-   "codemirror-popup-highlighting": "Highlighting",
+   "codemirror-popup-label": "Syntax Highlighting",
"codemirror-popup-desc": "Syntax highlighting will help you easily 
distinguish different parts of your edit by color coding them.",
"codemirror-popup-btn-yes": "Try it",
"codemirror-popup-btn-no": "No, thank you"
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 614b16b..508f693 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -12,8 +12,7 @@
"codemirror-toggle-label": "Title tooltip for button to toggle 
CodeMirror in the editing toolbar.",
"codemirror-beta-title": "Title for syntax highlighting beta feature",
"codemirror-beta-desc": "Description for syntax highlight beta feature",
-   "codemirror-popup-syntax": "This message appears before the message 
{{msg-mw|codemirror-popup-highlighting}} to form the title \"Syntax 
Highlighting\" (with the two words having different styling). If you would 
translate \"Syntax Highlighting\" as \"Highlighting of Syntax\", translate this 
message as \"Highlighting\" and {{msg-mw|codemirror-popup-highlighting}} as 
\"Syntax\".",
-   "codemirror-popup-highlighting": "This message appears after the 
message {{msg-mw|codemirror-popup-syntax}} to form the title \"Syntax 
Highlighting\" (with the two words having different styling). If you would 
translate \"Syntax Highlighting\" as \"Highlighting of Syntax\", translate 
{{msg-mw|codemirror-popup-highlighting}} as \"Highlighting\" and this message 
as \"Syntax\".",
+   "codemirror-popup-label": "The title of the popup",
"codemirror-popup-desc": "Description of the syntax highlighting 
feature in the popup",
"codemirror-popup-btn-yes": "Text on the button for trying out 
codemirror",
"codemirror-popup-btn-no": "Text on the button for dismissing popup"
diff --git a/resources/ext.CodeMirror.js b/resources/ext.CodeMirror.js
index 072df3c..a54ae13 100644
--- a/resources/ext.CodeMirror.js
+++ b/resources/ext.CodeMirror.js
@@ -398,10 +398,8 @@
 * If popup hasn't been shown before, show popup and add a localStorage 
entry.
 * check it before showing popup in future.
 */
-   /**
-*/
function handlePopup() {
-   var yesButton, noButton, $title, $content, popup;
+   var yesButton, noButton, $labelText, $label, $content, popup;
 
// If CodeMirror button doesn't exist, don't show popup
if ( !$( '#mw-editbutton-codemirror' ).length ) {
@@ -422,14 +420,10 @@
label: mw.msg( 'codemirror-popup-btn-no' ),
flags: [ 'destructive' ]
} );
-   $title =
-   $( '' ).append(
-   '{ ',
-   $( '' ).addClass( 
'codemirror-popup-color-blue' ).text( mw.msg( 'codemirror-popup-syntax' ) ),
-   ' ',
-   document.createTextNode( mw.msg( 

[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Add breadcrumb as subpage subtitle, to go back to Preferences

2017-09-07 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376479 )

Change subject: Add breadcrumb as subpage subtitle, to go back to Preferences
..

Add breadcrumb as subpage subtitle, to go back to Preferences

Add a breadcrumb link for navigating back to local Preferences
page to the subpage subtitle area of Special:GlobalPreferences.

Bug: T173873
Change-Id: I1f43643d42e739c190951ef55dc6d596d1a3b31c
---
M extension.json
M includes/Hooks.php
2 files changed, 22 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/79/376479/1

diff --git a/extension.json b/extension.json
index 8245339..3d7526c 100644
--- a/extension.json
+++ b/extension.json
@@ -37,6 +37,9 @@
"PreferencesFormPreSave": [
"GlobalPreferences\\Hooks::onPreferencesFormPreSave"
],
+   "SkinSubPageSubtitle": [
+   "GlobalPreferences\\Hooks::onSkinSubPageSubtitle"
+   ],
"LoadExtensionSchemaUpdates": [
"GlobalPreferences\\Hooks::onLoadExtensionSchemaUpdates"
]
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 9ab9ffd..bc61019 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -4,7 +4,9 @@
 
 use DatabaseUpdater;
 use Linker;
+use MediaWiki\MediaWikiServices;
 use PreferencesForm;
+use Skin;
 use SpecialPage;
 use User;
 
@@ -199,6 +201,23 @@
}
 
/**
+* @link https://www.mediawiki.org/wiki/Manual:Hooks/SkinSubPageSubtitle
+* @param string &$subpages The HTML of the subpage subtitle.
+* @param Skin $skin The skin.
+*/
+   public static function onSkinSubPageSubtitle( &$subpages, Skin $skin ) {
+   if ( $skin->getContext()->getTitle()->isSpecial( 
'GlobalPreferences' ) ) {
+   $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
+   $link = $linkRenderer->makeKnownLink(
+   SpecialPage::getSafeTitleFor( 'Preferences' ),
+   wfMessage( 'mypreferences' )->escaped()
+   );
+   // Same left-arrow as used in Skin::subPageSubtitle() 
where this hook is called.
+   $subpages = " $link";
+   }
+   }
+
+   /**
 * @link https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
 * @param User $user User whose preferences are being modified.
 * @param array &$prefs Preferences description array, to be fed to an 
HTMLForm object.

-- 
To view, visit https://gerrit.wikimedia.org/r/376479
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1f43643d42e739c190951ef55dc6d596d1a3b31c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Gadgets[master]: Opt out of being available as a global preference

2017-09-06 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376190 )

Change subject: Opt out of being available as a global preference
..

Opt out of being available as a global preference

Bug: T175118
Depends-On: I9cad21057472bee83d8146cc6992be07bc65a717
Change-Id: Id6df3fd233471048a84edfdd2b7876b3b84b8c66
---
M GadgetHooks.php
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gadgets 
refs/changes/90/376190/1

diff --git a/GadgetHooks.php b/GadgetHooks.php
index 5dd756a..449e707 100644
--- a/GadgetHooks.php
+++ b/GadgetHooks.php
@@ -121,6 +121,7 @@
'section' => 'gadgets',
'raw' => 1,
'rawrow' => 1,
+   'noglobal' => true,
];
 
$preferences['gadgets'] =
@@ -131,6 +132,7 @@
'label' => '',
'prefix' => 'gadget-',
'default' => $default,
+   'noglobal' => true,
];
 
return true;

-- 
To view, visit https://gerrit.wikimedia.org/r/376190
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6df3fd233471048a84edfdd2b7876b3b84b8c66
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gadgets
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Add 'noglobal' preference parameter, for extensions to opt out

2017-09-06 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376188 )

Change subject: Add 'noglobal' preference parameter, for extensions to opt out
..

Add 'noglobal' preference parameter, for extensions to opt out

Not all extensions want their preferences to be able to be set
globally (e.g. Gadgets, where the preference contains the gadget
name that may be repeated on multiple wikis). This adds a new
boolean preference parameter 'noglobal' to make this possible.

Bug: T174099
Change-Id: I9cad21057472bee83d8146cc6992be07bc65a717
---
M includes/Hooks.php
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/88/376188/1

diff --git a/includes/Hooks.php b/includes/Hooks.php
index f18f1f1..9ab9ffd 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -215,6 +215,13 @@
$user->getOption( '' );
}
foreach ( $prefs as $name => $info ) {
+   // Preferences can opt out of being globalized 
by setting the 'noglobal' flag.
+   $hasOptedOut = ( isset( $info['noglobal'] ) && 
$info['noglobal'] === true );
+   if ( $hasOptedOut ) {
+   unset( $prefs[ $name ] );
+   continue;
+   }
+
// FIXME: This whole code section sucks
if ( !isset( $prefs["$name-global"] )
&& self::isGlobalizablePreference( 
$name, $info )

-- 
To view, visit https://gerrit.wikimedia.org/r/376188
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9cad21057472bee83d8146cc6992be07bc65a717
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...ArticleCreationWorkflow[master]: Redirect directly to landing page, without special page

2017-09-04 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/375942 )

Change subject: Redirect directly to landing page, without special page
..

Redirect directly to landing page, without special page

This removes the special page and instead redirects intercepted
users directly to the nominated wiki page, with a `page` query
parameter added that specifies the original target page name.

Bug: T174969
Change-Id: I0e4322ac818281e32ce7a5ab322d0e54328f8516
---
D ArticleCreationWorkflow.alias.php
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/Hooks.php
D includes/SpecialCreatePage.php
M includes/Workflow.php
D modules/acw.eventlogging.js
M tests/phpunit/WorkflowTest.php
9 files changed, 24 insertions(+), 140 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleCreationWorkflow 
refs/changes/42/375942/1

diff --git a/ArticleCreationWorkflow.alias.php 
b/ArticleCreationWorkflow.alias.php
deleted file mode 100644
index 1abf9b5..000
--- a/ArticleCreationWorkflow.alias.php
+++ /dev/null
@@ -1,15 +0,0 @@
- array( 'CreatePage' ),
-);
diff --git a/extension.json b/extension.json
index fab2759..5ac4979 100644
--- a/extension.json
+++ b/extension.json
@@ -9,15 +9,11 @@
"requires": {
"MediaWiki": ">= 1.30.0-alpha"
},
-   "SpecialPages": {
-   "CreatePage": "ArticleCreationWorkflow\\SpecialCreatePage"
-   },
"Hooks": {
"AlternateEdit": 
"ArticleCreationWorkflow\\Hooks::onAlternateEdit"
},
"AutoloadClasses": {
"ArticleCreationWorkflow\\Hooks": "includes/Hooks.php",
-   "ArticleCreationWorkflow\\SpecialCreatePage": 
"includes/SpecialCreatePage.php",
"ArticleCreationWorkflow\\Workflow": "includes/Workflow.php"
},
"MessagesDirs": {
@@ -25,24 +21,14 @@
"i18n"
]
},
-   "ResourceFileModulePaths": {
-   "localBasePath": "modules",
-   "remoteExtPath": "ArticleCreationWorkflow/modules"
-   },
-   "ResourceModules": {
-   "ext.acw.eventlogging": {
-   "scripts": [
-   "acw.eventlogging.js"
-   ]
-   }
-   },
-   "ExtensionMessagesFiles": {
-   "ArticleCreationWorkflowAliases": 
"ArticleCreationWorkflow.alias.php"
-   },
"config": {
"ArticleCreationWorkflows": {
"description": "Describes conditions when new page 
creation should be intercepted. See doc/config.txt for details.",
"value": []
+   },
+   "ArticleCreationLandingPage": {
+   "description": "The name of the wiki page to which 
users should be redirected if intercepted.",
+   "value": "Project:Article wizard"
}
},
"ConfigRegistry": {
diff --git a/i18n/en.json b/i18n/en.json
index 429564c..19e030c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,5 +1,3 @@
 {
-   "acw-desc": "Customizes new page creation experience for new users",
-   "acw-createpage": "Create page",
-   "acw-no-landing-page": "The $1 message has not been defined."
+   "acw-desc": "Customizes new page creation experience for new users"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 36d3883..dd5c782 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -1,5 +1,3 @@
 {
-   "acw-desc": "{{desc}}",
-   "acw-createpage": "The title of the CreatePage special page.",
-   "acw-no-landing-page": "Message shown when the landing page system 
message does not exist. $1 is the name of the system message."
+   "acw-desc": "{{desc}}"
 }
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 859a973..38fa739 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -4,7 +4,6 @@
 
 use EditPage;
 use MediaWiki\MediaWikiServices;
-use SpecialPage;
 
 /**
  * Hook handlers
@@ -27,7 +26,8 @@
 
if ( $workflow->shouldInterceptEditPage( $editPage ) ) {
$title = $editPage->getTitle();
-   $redirTo = SpecialPage::getTitleFor( 'CreatePage' );
+   // If the landing page didn't exist, we wouldn't have 
intercepted.
+   $redirTo = $workflow->getLandingPageTitle();
$output = $editPage->getContext()->getOutput();
$output->redirect( $redirTo->getFullURL( [ 'page' => 
$title->getPrefixedText() ] ) );
 
diff --git a/includes/SpecialCreatePage.php b/includes/SpecialCreatePage.php
deleted file mode 100644
index 41a86a3..000
--- a/includes/SpecialCreatePage.php
+++ /dev/null
@@ -1,58 +0,0 @@
- in the special page itself, 
and
-* also the name that will be listed in Special:Specialpages.
-* 

[MediaWiki-commits] [Gerrit] mediawiki...BetaFeatures[master]: Don't float betafeatures-auto-enroll checkbox

2017-09-03 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/375724 )

Change subject: Don't float betafeatures-auto-enroll checkbox
..

Don't float betafeatures-auto-enroll checkbox

This prevents the auto-enroll checkbox from being floated left,
because it's messing with things that come after it and there is
no need for it to do this (there is a need only when it's a part
of a feature field).

Bug: T174900
Change-Id: Ia878fa53f8f43f3dff1b461fbea4839dd0ee94fc
---
M resources/betafeatures.nojs.less
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures 
refs/changes/24/375724/1

diff --git a/resources/betafeatures.nojs.less b/resources/betafeatures.nojs.less
index ae09f8e..246bd6c 100644
--- a/resources/betafeatures.nojs.less
+++ b/resources/betafeatures.nojs.less
@@ -118,7 +118,7 @@
margin-bottom: -10px;
 }
 
-.mw-ui-feature-checkbox {
+.mw-ui-feature-field .mw-ui-feature-checkbox {
float: left;
 
.oo-ui-fieldLayout.oo-ui-fieldLayout-align-inline {

-- 
To view, visit https://gerrit.wikimedia.org/r/375724
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia878fa53f8f43f3dff1b461fbea4839dd0ee94fc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Make it possible to inject a different Preferences object

2017-08-28 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/374451 )

Change subject: Make it possible to inject a different Preferences object
..

Make it possible to inject a different Preferences object

This makes some changes relating to subclassing Preferences and
PreferencesForm.

Add a new hook 'PreferencesFactory' that is run in the
Preferences::factory() method, to allow extensions to change the
returned Preferences object however they want. See docs/hooks.txt
for details.

Fix the constructor of SpecialPreferences to match that of its
parent, so subclasses can do the same.

Fix the help link of SpecialPreferences to not be hard-coded to
'Help:Preferences' but instead use the title of the special page.

Move the setting of the submit callback for the PreferencesForm
into SpecialPreferences::getFormObject() so that implementors of
this method can provide their own callback.

Bug: T173476
Change-Id: I3f7e9067c2faa915c2b05a2ae01312c3f2fee2ea
---
M includes/Preferences.php
M includes/specials/SpecialPreferences.php
2 files changed, 28 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/51/374451/1

diff --git a/includes/Preferences.php b/includes/Preferences.php
index c64e8a8..7b8d526 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -67,6 +67,18 @@
];
 
/**
+* Get a new Preferences object.
+* @param User $user The user who owns the preferences.
+* @param IContextSource $contextSource The context in which the 
preferences are being used.
+* @return static
+*/
+   public static function factory( User $user, IContextSource 
$contextSource ) {
+   $preferences = new static();
+   Hooks::run( 'PreferencesFactory', [ $user, $contextSource, 
&$preferences ] );
+   return $preferences;
+   }
+
+   /**
 * @return array
 */
static function getSaveBlacklist() {
@@ -1332,7 +1344,7 @@
$formClass = 'PreferencesForm',
array $remove = []
) {
-   $formDescriptor = self::getPreferences( $user, $context );
+   $formDescriptor = static::getPreferences( $user, $context );
if ( count( $remove ) ) {
$removeKeys = array_flip( $remove );
$formDescriptor = array_diff_key( $formDescriptor, 
$removeKeys );
diff --git a/includes/specials/SpecialPreferences.php 
b/includes/specials/SpecialPreferences.php
index ba5a57e..233615b 100644
--- a/includes/specials/SpecialPreferences.php
+++ b/includes/specials/SpecialPreferences.php
@@ -27,8 +27,16 @@
  * @ingroup SpecialPage
  */
 class SpecialPreferences extends SpecialPage {
-   function __construct() {
-   parent::__construct( 'Preferences' );
+
+   public function __construct(
+   $name = 'Preferences',
+   $restriction = '',
+   $listed = true,
+   $function = false,
+   $file = '',
+   $includable = false
+   ) {
+   parent::__construct( $name, $restriction, $listed, $function, 
$file, $includable );
}
 
public function doesWrites() {
@@ -72,7 +80,7 @@
);
}
 
-   $this->addHelpLink( 'Help:Preferences' );
+   $this->addHelpLink( 'Help:' . $this->getPageTitle()->getText() 
);
 
// Load the user from the master to reduce CAS errors on double 
post (T95839)
if ( $this->getRequest()->wasPosted() ) {
@@ -82,7 +90,6 @@
}
 
$htmlForm = $this->getFormObject( $user, $this->getContext() );
-   $htmlForm->setSubmitCallback( [ 'Preferences', 'tryUISubmit' ] 
);
$sectionTitles = $htmlForm->getPreferenceSections();
 
$prefTabs = '';
@@ -124,7 +131,10 @@
 * @return PreferencesForm|HtmlForm
 */
protected function getFormObject( $user, IContextSource $context ) {
-   return Preferences::getFormObject( $user, $context );
+   $preferences = Preferences::factory( $user, $context );
+   $form = $preferences::getFormObject( $user, $context );
+   $form->setSubmitCallback( [ $preferences, 'tryUISubmit' ] );
+   return $form;
}
 
private function showResetForm() {

-- 
To view, visit https://gerrit.wikimedia.org/r/374451
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f7e9067c2faa915c2b05a2ae01312c3f2fee2ea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Update dependency version numbers and Phabricator link

2017-08-23 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373182 )

Change subject: Update dependency version numbers and Phabricator link
..

Update dependency version numbers and Phabricator link

No need to specify patch-level releases; let Composer handle these.
Also, the Genealogy project now has a Phabricator board.

Change-Id: I966011fe679c08b51d0f2750a06729674ecb279a
---
M composer.json
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/82/373182/1

diff --git a/composer.json b/composer.json
index 05334cc..62b8ac7 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
}
],
"support": {
-   "issues": "https://phabricator.wikimedia.org;,
+   "issues": 
"https://phabricator.wikimedia.org/project/board/2912/;,
"irc": "irc://irc.freenode.net/mediawiki",
"source": 
"https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Genealogy.git;
},
@@ -27,9 +27,9 @@
}
},
"require-dev": {
-   "jakub-onderka/php-parallel-lint": "0.9.2",
-   "mediawiki/mediawiki-codesniffer": "0.11.0",
-   "jakub-onderka/php-console-highlighter": "0.3.2"
+   "jakub-onderka/php-parallel-lint": "^0.9",
+   "mediawiki/mediawiki-codesniffer": "^0.11",
+   "jakub-onderka/php-console-highlighter": "^0.3"
},
"scripts": {
"test": [

-- 
To view, visit https://gerrit.wikimedia.org/r/373182
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I966011fe679c08b51d0f2750a06729674ecb279a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Don't hard-code Preferences page name

2017-08-20 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/372805 )

Change subject: Don't hard-code Preferences page name
..

Don't hard-code Preferences page name

This fixes the restore-prefs link by switching to use whatever
the current title of the PreferencesForm is.

Bug: T173682
Change-Id: I67a13269a63f719a011a2d59a07493d9eb6b653b
---
M includes/Preferences.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/05/372805/1

diff --git a/includes/Preferences.php b/includes/Preferences.php
index c74d6e1..726dda5 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -1682,7 +1682,7 @@
$html = parent::getButtons();
 
if ( $this->getModifiedUser()->isAllowed( 'editmyoptions' ) ) {
-   $t = SpecialPage::getTitleFor( 'Preferences', 'reset' );
+   $t = SpecialPage::getTitleFor( 
$this->getTitle()->getText(), 'reset' );
 
$linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
$html .= "\n" . $linkRenderer->makeLink( $t, 
$this->msg( 'restoreprefs' )->text(),

-- 
To view, visit https://gerrit.wikimedia.org/r/372805
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I67a13269a63f719a011a2d59a07493d9eb6b653b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Make it possible for subclasses to provide a different form

2017-08-10 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371081 )

Change subject: Make it possible for subclasses to provide a different form
..

Make it possible for subclasses to provide a different form

This makes it possible for subclasses of SpecialPreferences to
specify a different HtmlForm to use for the preferences' form.

Bug: T68869
Change-Id: I9d6bbc6383a3d5b5c6839394de49ce9ca81efec9
---
M includes/specials/SpecialPreferences.php
1 file changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/81/371081/1

diff --git a/includes/specials/SpecialPreferences.php 
b/includes/specials/SpecialPreferences.php
index 40b50ea..ba5a57e 100644
--- a/includes/specials/SpecialPreferences.php
+++ b/includes/specials/SpecialPreferences.php
@@ -81,7 +81,7 @@
$user = $this->getUser();
}
 
-   $htmlForm = Preferences::getFormObject( $user, 
$this->getContext() );
+   $htmlForm = $this->getFormObject( $user, $this->getContext() );
$htmlForm->setSubmitCallback( [ 'Preferences', 'tryUISubmit' ] 
);
$sectionTitles = $htmlForm->getPreferenceSections();
 
@@ -117,6 +117,16 @@
$htmlForm->show();
}
 
+   /**
+* Get the preferences form to use.
+* @param User $user The user.
+* @param IContextSource $context The context.
+* @return PreferencesForm|HtmlForm
+*/
+   protected function getFormObject( $user, IContextSource $context ) {
+   return Preferences::getFormObject( $user, $context );
+   }
+
private function showResetForm() {
if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
throw new PermissionsError( 'editmyoptions' );

-- 
To view, visit https://gerrit.wikimedia.org/r/371081
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d6bbc6383a3d5b5c6839394de49ce9ca81efec9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...BoilerPlate[master]: Add new-style configuration values with prefix

2017-08-10 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371077 )

Change subject: Add new-style configuration values with prefix
..

Add new-style configuration values with prefix

This adds a configuration prefix and an example of how to use it.

Bug: T97105
Change-Id: Icbc643487427964e6eee9ba8df78ad78e7b87d14
---
M BoilerPlate.hooks.php
M extension.json
M specials/SpecialHelloWorld.php
3 files changed, 27 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BoilerPlate 
refs/changes/77/371077/1

diff --git a/BoilerPlate.hooks.php b/BoilerPlate.hooks.php
index e96cba0..f850b31 100644
--- a/BoilerPlate.hooks.php
+++ b/BoilerPlate.hooks.php
@@ -8,4 +8,11 @@
 
 class BoilerPlateHooks {
 
+   /**
+* @return GlobalVarConfig
+*/
+   public static function makeConfig() {
+   return new GlobalVarConfig( 'boilerplate' );
+   }
+
 }
diff --git a/extension.json b/extension.json
index 10cde12..852177e 100644
--- a/extension.json
+++ b/extension.json
@@ -12,8 +12,15 @@
"BoilerPlateHooks": "BoilerPlate.hooks.php",
"SpecialHelloWorld": "specials/SpecialHelloWorld.php"
},
+   "config_prefix": "boilerplate",
+   "ConfigRegistry": {
+   "boilerplate": "BoilerPlateHooks::makeConfig"
+   },
"config": {
-   "BoilerPlateEnableFoo": true
+   "EnableFoo": {
+   "value": true,
+   "description": "Whether or not the foo feature is 
enabled."
+   }
},
"ExtensionMessagesFiles": {
"BoilerPlateAlias": "BoilerPlate.i18n.alias.php"
@@ -48,5 +55,5 @@
"SpecialPages": {
"HelloWorld": "SpecialHelloWorld"
},
-   "manifest_version": 1
+   "manifest_version": 2
 }
diff --git a/specials/SpecialHelloWorld.php b/specials/SpecialHelloWorld.php
index 0b5057e..58d4b8a 100644
--- a/specials/SpecialHelloWorld.php
+++ b/specials/SpecialHelloWorld.php
@@ -6,6 +6,8 @@
  * @ingroup Extensions
  */
 
+use MediaWiki\MediaWikiServices;
+
 class SpecialHelloWorld extends SpecialPage {
public function __construct() {
parent::__construct( 'HelloWorld' );
@@ -61,8 +63,13 @@
'label' => 'Weapons to use',
'options' => [ 'Cannons' => 'cannon', 'Swords' 
=> 'sword' ],
'default' => [ 'sword' ],
-   ],
-   'radiolol' => [
+   ]
+   ];
+
+   // If foo is enabled, add another form field.
+   $config = 
MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'boilerplate' 
);
+   if ( $config->get( 'EnableFoo' ) ) {
+   $formDescriptor['radiolol'] = [
'class' => 'HTMLRadioField',
'label' => 'Who do you like?',
'options' => [
@@ -71,8 +78,8 @@
'both' => 'Both'
],
'default' => 'pirates',
-   ],
-   ];
+   ];
+   }
 
// $htmlForm = new HTMLForm( $formDescriptor, 
$this->getContext(), 'testform' );
$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, 
$this->getContext(), 'testform' );

-- 
To view, visit https://gerrit.wikimedia.org/r/371077
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icbc643487427964e6eee9ba8df78ad78e7b87d14
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BoilerPlate
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: [WiP] Move the enable-globally checkboxes to the side of the...

2017-08-04 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370152 )

Change subject: [WiP] Move the enable-globally checkboxes to the side of the 
form
..

[WiP] Move the enable-globally checkboxes to the side of the form

This moves each preference's 'enable this globally?' toggle to
the side of the preferences form to make it easier to see what's
enabled and what's not.

Bug: T68869
Change-Id: I3c10dfeacf02367e90f84a3e572ecf3f4048e02a
---
M extension.json
M i18n/en.json
A includes/GlobalPreferencesForm.php
M includes/Hooks.php
M includes/SpecialGlobalPreferences.php
M resources/ext.GlobalPreferences.special.css
M resources/ext.GlobalPreferences.special.js
M resources/ext.GlobalPreferences.special.nojs.css
8 files changed, 126 insertions(+), 42 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/52/370152/1

diff --git a/extension.json b/extension.json
index 8245339..f39dd87 100644
--- a/extension.json
+++ b/extension.json
@@ -25,7 +25,8 @@
"AutoloadClasses": {
"GlobalPreferences\\GlobalPreferences": 
"includes/GlobalPreferences.php",
"GlobalPreferences\\Hooks": "includes/Hooks.php",
-   "GlobalPreferences\\SpecialGlobalPreferences": 
"includes/SpecialGlobalPreferences.php"
+   "GlobalPreferences\\SpecialGlobalPreferences": 
"includes/SpecialGlobalPreferences.php",
+   "GlobalPreferences\\GlobalPreferencesForm": 
"includes/GlobalPreferencesForm.php"
},
"Hooks": {
"UserLoadOptions": [
diff --git a/i18n/en.json b/i18n/en.json
index 0043b24..4613fe7 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -11,5 +11,6 @@
"globalprefs-notglobal": "Your account is not a global account and 
cannot set global preferences.",
"globalpreferences": "Global preferences",
"globalprefs-info-label": "Global preferences:",
-   "globalprefs-info-link": "Set your global preferences"
+   "globalprefs-info-link": "Set your global preferences",
+   "globalprefs-section-header": "Select which preferences should be 
global."
 }
\ No newline at end of file
diff --git a/includes/GlobalPreferencesForm.php 
b/includes/GlobalPreferencesForm.php
new file mode 100644
index 000..cd010b1
--- /dev/null
+++ b/includes/GlobalPreferencesForm.php
@@ -0,0 +1,41 @@
+displayFormat = 'div';
+   }
+
+   /**
+* Get the whole body of the form,
+* adding the global preferences help text to the top of each section.
+* @return string
+*/
+   function getBody() {
+   foreach ( array_keys( $this->mFieldTree ) as $section ) {
+   $secHeader = Html::element(
+   'p',
+   [ 'class' => 'globalprefs-section-header' ],
+   wfMessage( 'globalprefs-section-header' )
+   );
+   $this->addHeaderText( $secHeader, $section );
+   }
+   return parent::getBody();
+   }
+
+}
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 1f57698..282c67c 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -25,6 +25,8 @@
// @todo Should global edit count instead?
'editcount',
'registrationdate',
+   'nickname',
+   'fancysig',
];
 
/**
@@ -202,27 +204,37 @@
// Just in case the user hasn't been loaded 
yet. Triggers User::loadOptions.
$user->getOption( '' );
}
+
+   $globalPrefs = [];
foreach ( $prefs as $name => $info ) {
-   // FIXME: This whole code section sucks
-   if ( isset( $info['type'] )
-   && substr( $name, -strlen( 'global' ) ) 
!== 'global'
-   && !isset( $prefs["$name-global"] )
-   && !in_array( $info['type'], 
self::$badTypes )
-   && !in_array( $name, self::$badPrefs )
-   ) {
-   $prefs = wfArrayInsertAfter( $prefs, [
-   "$name-global" => [
-   'type' => 'toggle',
-   'label-message' => 
'globalprefs-check-label',
-   'default' => in_array( 
$name, $user->mGlobalPrefs ),
-   'section' => 
$info['section'],
-   'cssclass' => 
'mw-globalprefs-global-check',
-  

[MediaWiki-commits] [Gerrit] mediawiki...ArticleCreationWorkflow[master]: Add a template's contents as the landing page

2017-08-01 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/369592 )

Change subject: Add a template's contents as the landing page
..

Add a template's contents as the landing page

Bug: T172085
Change-Id: If61e089470925be1ea33f1500459f43732546b73
---
M i18n/en.json
M includes/SpecialCreatePage.php
M phpcs.xml
3 files changed, 5 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleCreationWorkflow 
refs/changes/92/369592/1

diff --git a/i18n/en.json b/i18n/en.json
index 19e030c..6b73c28 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,3 +1,5 @@
 {
-   "acw-desc": "Customizes new page creation experience for new users"
+   "acw-desc": "Customizes new page creation experience for new users",
+   "createpage": "Create page",
+   "acw-landing-page-template": "CreatePage landing page"
 }
diff --git a/includes/SpecialCreatePage.php b/includes/SpecialCreatePage.php
index 9dbdabb..84e2b68 100644
--- a/includes/SpecialCreatePage.php
+++ b/includes/SpecialCreatePage.php
@@ -2,7 +2,6 @@
 
 namespace ArticleCreationWorkflow;
 
-use Exception;
 use UnlistedSpecialPage;
 
 /**
@@ -18,7 +17,7 @@
 */
public function execute( $subPage ) {
parent::execute( $subPage );
-
-   throw new Exception( 'Not implemented' );
+   $templateName = wfMessage( 'acw-landing-page-template' );
+   $this->getOutput()->addWikiText( '{{' . $templateName . 
'|page=' . $subPage . '}}' );
}
 }
diff --git a/phpcs.xml b/phpcs.xml
index 60dda4e..dc070b6 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -2,11 +2,8 @@
 
.

-   



-   

-   vendor
 

-- 
To view, visit https://gerrit.wikimedia.org/r/369592
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If61e089470925be1ea33f1500459f43732546b73
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleCreationWorkflow
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...CodeMirror[master]: Switch icons to 'highlighter' symbol

2017-08-01 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/369587 )

Change subject: Switch icons to 'highlighter' symbol
..

Switch icons to 'highlighter' symbol

This adds the new 'highlighter' symbol to the five CodeMirror SVG
icons, and regenerates their PNG counterparts (using Inkscape).

The only changes to the SVG files apart from the paths (and their
positions) are whitespace formatting. I'm not sure all those
gradients need to be there, but I guess someone did that for a
reason. :-)

Bug: T164441
Change-Id: Ibdb8ecf53eb03fb1d1805e788a3e497e4941263a
---
M resources/images/cm-icon.png
M resources/images/cm-icon.svg
M resources/images/cm-off.png
M resources/images/cm-off.svg
M resources/images/cm-on.png
M resources/images/cm-on.svg
M resources/images/old-cm-off.png
M resources/images/old-cm-off.svg
M resources/images/old-cm-on.png
M resources/images/old-cm-on.svg
10 files changed, 141 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeMirror 
refs/changes/87/369587/1

diff --git a/resources/images/cm-icon.png b/resources/images/cm-icon.png
index 3fb98e8..1776503 100644
--- a/resources/images/cm-icon.png
+++ b/resources/images/cm-icon.png
Binary files differ
diff --git a/resources/images/cm-icon.svg b/resources/images/cm-icon.svg
index b8f5eb4..abe4593 100644
--- a/resources/images/cm-icon.svg
+++ b/resources/images/cm-icon.svg
@@ -1 +1,9 @@
-http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink; 
width="24" height="24" viewBox="0 0 24 24">
\ No newline at end of file
+
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; width="24" height="24"
+ viewBox="0 0 24 24">
+
+
+
+
diff --git a/resources/images/cm-off.png b/resources/images/cm-off.png
index 560e02e..ab4ad0e 100644
--- a/resources/images/cm-off.png
+++ b/resources/images/cm-off.png
Binary files differ
diff --git a/resources/images/cm-off.svg b/resources/images/cm-off.svg
index 171bc93..684dea7 100644
--- a/resources/images/cm-off.svg
+++ b/resources/images/cm-off.svg
@@ -1 +1,8 @@
-http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink; 
version="1" width="22" height="22">
\ No newline at end of file
+
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; version="1" width="22" height="22">
+
+
+
+
\ No newline at end of file
diff --git a/resources/images/cm-on.png b/resources/images/cm-on.png
index b63ce26..9dd3332 100644
--- a/resources/images/cm-on.png
+++ b/resources/images/cm-on.png
Binary files differ
diff --git a/resources/images/cm-on.svg b/resources/images/cm-on.svg
index ac3b4c7..0769a5a 100644
--- a/resources/images/cm-on.svg
+++ b/resources/images/cm-on.svg
@@ -1 +1,18 @@
-http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink; 
height="22" width="22" version="1">
\ No newline at end of file
+
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; height="22" width="22" version="1">
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/images/old-cm-off.png b/resources/images/old-cm-off.png
index 29d4f78..8e59e5b 100644
--- a/resources/images/old-cm-off.png
+++ b/resources/images/old-cm-off.png
Binary files differ
diff --git a/resources/images/old-cm-off.svg b/resources/images/old-cm-off.svg
index 696f716..76b39e4 100644
--- a/resources/images/old-cm-off.svg
+++ b/resources/images/old-cm-off.svg
@@ -1 +1,46 @@
-http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink; 
height="22" width="23">
\ No newline at end of file
+
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; height="22" width="23">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/images/old-cm-on.png b/resources/images/old-cm-on.png
index 97325a0..f7d1058 100644
--- a/resources/images/old-cm-on.png
+++ b/resources/images/old-cm-on.png
Binary files differ
diff --git a/resources/images/old-cm-on.svg b/resources/images/old-cm-on.svg
index 672eb93..8f174c5 100644
--- a/resources/images/old-cm-on.svg
+++ b/resources/images/old-cm-on.svg
@@ -1 +1,60 @@
-http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink; 
height="22" width="23">
\ No newline at end of file
+
+http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; height="22" width="23">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+   

[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Update coding standards

2017-08-01 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/368984 )

Change subject: Update coding standards
..

Update coding standards

This doesn't introduce any code changes, just some documentation
and code formatting, in order to pass phpcs.

Change-Id: I6772823a8b47b38c6741d8a58b9a94571bdaafed
---
M .gitignore
M GlobalPreferences.body.php
M GlobalPreferences.hooks.php
M GlobalPreferences.php
M SpecialGlobalPreferences.php
A composer.json
A phpcs.xml
7 files changed, 114 insertions(+), 50 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/84/368984/1

diff --git a/.gitignore b/.gitignore
index 3c3629e..8ec4b92 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
-node_modules
+node_modules/
+vendor/
+composer.lock
diff --git a/GlobalPreferences.body.php b/GlobalPreferences.body.php
index aa7fc53..d681ac5 100644
--- a/GlobalPreferences.body.php
+++ b/GlobalPreferences.body.php
@@ -19,7 +19,7 @@
public static function getPrefsDB( $type = DB_SLAVE ) {
global $wgGlobalPreferencesDB;
if ( $wgGlobalPreferencesDB ) {
-   return wfGetDB( $type, array(), $wgGlobalPreferencesDB 
);
+   return wfGetDB( $type, [], $wgGlobalPreferencesDB );
} else {
return wfGetDB( $type );
}
@@ -27,7 +27,7 @@
 
/**
 * Checks if the user is globalized
-* @param User $user
+* @param User $user The user
 * @return bool
 */
public static function isUserGlobalized( User $user ) {
@@ -42,7 +42,7 @@
/**
 * Gets the user's ID that we're using in the table
 * Returns 0 if the user is not global
-* @param User $user
+* @param User $user The user for whom to get the ID.
 * @return int
 */
public static function getUserID( User $user ) {
@@ -53,37 +53,36 @@
/**
 * Deletes all of a user's global prefs
 * Assumes that the user is globalized
-* @param User $user
+* @param User $user The user.
 */
public static function resetGlobalUserSettings( User $user ) {
if ( !isset( $user->mGlobalPrefs ) ) {
-   $user->getOption( '' ); // Trigger loading
+   // Triggers User::loadOptions.
+   $user->getOption( '' );
}
if ( count( $user->mGlobalPrefs ) ) {
self::getPrefsDB( DB_MASTER )->delete(
'global_preferences',
-   array( 'gp_user' => self::getUserID( $user ) ),
+   [ 'gp_user' => self::getUserID( $user ) ],
__METHOD__
);
}
}
 
/**
-* Convenience function to check if we're on the global
-* prefs page
-* @param IContextSource $context
+* Convenience function to check if we're on the global prefs page.
+* @param IContextSource $context The context to use; if not set main 
request context is used.
 * @return bool
 */
public static function onGlobalPrefsPage( $context = null ) {
$context = $context ?: RequestContext::getMain();
-   return $context->getTitle()
-   && $context->getTitle()->isSpecial( 'GlobalPreferences' );
+   return $context->getTitle() && $context->getTitle()->isSpecial( 
'GlobalPreferences' );
}
 
/**
 * Convenience function to check if we're on the local
 * prefs page
-* @param IContextSource $context
+* @param IContextSource $context The context to use; if not set main 
request context is used.
 * @return bool
 */
public static function onLocalPrefsPage( $context = null ) {
diff --git a/GlobalPreferences.hooks.php b/GlobalPreferences.hooks.php
index 23b4fea..fecc178 100644
--- a/GlobalPreferences.hooks.php
+++ b/GlobalPreferences.hooks.php
@@ -7,23 +7,27 @@
 * Special:GlobalPrefs
 * @var array
 */
-   static $badPrefs = array(
-   'realname', // Stored in user table, doesn't work yet
-   'userid', // @todo Show CA user id / shared user table id?
-   'usergroups', // @todo Show CA global groups instead?
-   'editcount', // @todo Should global edit count instead?
+   protected static $badPrefs = [
+   // Stored in user table, doesn't work yet
+   'realname',
+   // @todo Show CA user id / shared user table id?
+   'userid',
+   // @todo Show CA global groups instead?
+   'usergroups',
+   // @todo Should global edit count instead?

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Switch to fully-quoted identifiers

2017-07-31 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/368687 )

Change subject: Switch to fully-quoted identifiers
..

Switch to fully-quoted identifiers

Instead of trying to reduce page titles to dot-compatible IDs,
just quote all of them (and escape internal double-quotes).

Bug: T172096
Change-Id: If7c242958fcb8ac7e773f7a931771fc9345be962
---
M src/Hooks.php
M src/Person.php
M src/Tree.php
3 files changed, 79 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/87/368687/1

diff --git a/src/Hooks.php b/src/Hooks.php
index 131ee61..3878d5b 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -133,7 +133,7 @@
if ( $tree->hasAncestorsOrDescendants() ) {
$graphviz = $tree->getGraphviz();
$out .= $parser->recursiveTagParse( 
"\n$graphviz\n" );
-   // $out .= $parser->recursiveTagParse( 
"$graphviz" );
+   $out .= $parser->recursiveTagParse( 
"$graphviz" );
}
break;
default:
diff --git a/src/Person.php b/src/Person.php
index 4764559..4db977f 100644
--- a/src/Person.php
+++ b/src/Person.php
@@ -154,6 +154,7 @@
 */
public function getParents() {
$parents = $this->getPropMulti( 'parent' );
+   asort( $parents );
return $parents;
}
 
diff --git a/src/Tree.php b/src/Tree.php
index febf0d9..ff44f48 100644
--- a/src/Tree.php
+++ b/src/Tree.php
@@ -148,7 +148,6 @@
$title = $person->getTitle()->getText();
$personId = $this->esc( $title );
$line = $personId." ["
-   . " label=\"$title$date\", "
. " URL=\"$url\", "
. " tooltip=\"$title\", "
. " fontcolor=\"$colour\" "
@@ -163,22 +162,29 @@
public function visit( Person $person ) {
$this->outputPersonLine( $person );
 
-   $personId = $this->esc( $person->getTitle()->getText() );
+   $personId = $person->getTitle()->getText();
$partnerStyle = 'dashed';
 
// Output links to parents.
if ( $person->getParents() ) {
-   $parentsId = $this->esc( join( '', 
$person->getParents() ) );
-   $this->out( 'partner', $parentsId, $parentsId . ' 
[label="", shape="point"]' );
-   $this->out( 'child', $parentsId.$personId, $parentsId . 
' -> ' . $personId );
+   $parentsId = join( ' & ', $person->getParents() );
+   $this->out( 'partner', $parentsId, $this->esc( 
$parentsId ) . ' [label="", shape="point"]' );
+   $this->outDirectedLine(
+   'child',
+   $parentsId.$personId,
+   $parentsId,
+   $personId
+   );
foreach ( $person->getParents() as $parent ) {
-   $parentId = $this->esc( 
$parent->getTitle()->getText() );
+   $parentId = $parent->getTitle()->getText();
// Add any non-included parent.
$this->outputPersonLine( $parent );
-   $this->out(
+   $this->outDirectedLine(
'partner',
$parentId.$parentsId,
-   $parentId . ' -> ' . $parentsId . " 
[style=$partnerStyle]"
+   $parentId,
+   $parentsId,
+   "style=$partnerStyle"
);
}
}
@@ -186,31 +192,67 @@
// Output links to partners.
foreach ( $person->getPartners() as $partner ) {
// Create a point node for each partnership.
-   $partnerId = $this->esc( 
$partner->getTitle()->getDBkey() );
+   $partnerId = $partner->getTitle()->getText();
$partners = [ $personId, $partnerId ];
sort( $partners );
-   $partnersId = $this->esc( join( '', $partners ) );
-   $this->out( 'partner', $partnersId, $partnersId.' 
[label="", shape="point"]' );
+   $partnersId = join( ' & ', $partners );
+   $this->out( 'partner', $partnersId, $this->esc( 
$partnersId ) .' [label="", 

[MediaWiki-commits] [Gerrit] mediawiki...FlickrAPI[master]: Switch to extension registration system

2017-07-27 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/368129 )

Change subject: Switch to extension registration system
..

Switch to extension registration system

This moves to the new-style extension registration and removes the
old style. Also removes the Git submodule and adds that library
as a (manual) Composer dependency.

Bug: T171819
Change-Id: I46d1a2dd04903b7a3207b9c4a709b80214626fc5
---
D .gitmodules
M FlickrAPI.hooks.php
D FlickrAPI.php
A composer.json
A extension.json
5 files changed, 83 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlickrAPI 
refs/changes/29/368129/1

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 4414c1f..000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "modules/phpflickr"]
-   path = modules/phpflickr
-   url = https://github.com/dan-coulter/phpflickr.git
diff --git a/FlickrAPI.hooks.php b/FlickrAPI.hooks.php
index 1a8645e..b9f420a 100644
--- a/FlickrAPI.hooks.php
+++ b/FlickrAPI.hooks.php
@@ -9,6 +9,17 @@
 class FlickrAPIHooks {
 
/**
+* Hooked to ParserFirstCallInit.
+* @link https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit
+* @param Parser $parser
+* @return bool
+*/
+   public static function onParserFirstCallInit( Parser &$parser ) {
+   $parser->setHook( 'flickr', self::class.'::flickrAPITag' );
+   return true;
+   }
+
+   /**
 * Get output for the  tag
 *
 * @param string $optionsString
diff --git a/FlickrAPI.php b/FlickrAPI.php
deleted file mode 100644
index 9f13c70..000
--- a/FlickrAPI.php
+++ /dev/null
@@ -1,44 +0,0 @@
-http://mediawiki.org/wiki/Extension:FlickrAPI
- *
- * @file
- * @ingroup Extensions
- * @author Ike Hecht, 2015
- * @license GNU General Public Licence 2.0 or later
- */
-
-$wgExtensionCredits['parserhook'][] = array(
-   'path' => __FILE__,
-   'name' => 'FlickrAPI',
-   'author' => array(
-   'Ike Hecht',
-   ),
-   'version' => '1.0.0',
-   'url' => 'https://www.mediawiki.org/wiki/Extension:FlickrAPI',
-   'descriptionmsg' => 'flickrapi-desc',
-);
-
-/* Setup */
-
-// Register files
-$wgAutoloadClasses['FlickrAPIHooks'] = __DIR__ . '/FlickrAPI.hooks.php';
-$wgAutoloadClasses['FlickrAPIUtils'] = __DIR__ . '/FlickrAPIUtils.php';
-$wgAutoloadClasses['FlickrAPICache'] = __DIR__ . '/FlickrAPICache.php';
-/** @todo Spit out better error message if phpflickr module doesn't exist */
-$wgAutoloadClasses['phpFlickr'] = __DIR__ . '/modules/phpflickr/phpFlickr.php';
-
-$wgMessagesDirs['FlickrAPI'] = __DIR__ . '/i18n';
-
-// Register hooks
-$wgHooks['ParserFirstCallInit'][] = function ( &$parser ) {
-   $parser->setHook( 'flickr', 'FlickrAPIHooks::flickrAPITag' );
-   return true;
-};
-
-/* Configuration */
-$wgFlickrAPIKey = '';
-$wgFlickrAPISecret = '';
-$wgFlickrAPIDefaults = array( 'type' => 'frameless', 'location' => 'right', 
'size' => '-' );
diff --git a/composer.json b/composer.json
new file mode 100755
index 000..5ef8acb
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,37 @@
+{
+   "require": {
+   "dan-coulter/phpflickr": "dev-master"
+   },
+   "require-dev": {
+   "jakub-onderka/php-parallel-lint": "^0.9",
+   "mediawiki/mediawiki-codesniffer": "^0.8"
+   },
+   "scripts": {
+   "test": [
+   "parallel-lint . --exclude node_modules --exclude 
vendor",
+   "phpcs -p -s"
+   ],
+   "fix": [
+   "phpcbf"
+   ]
+   },
+   "repositories": [
+   {
+   "type": "package",
+   "package": {
+   "name": "dan-coulter/phpflickr",
+   "version": "dev-master",
+   "source": {
+   "url": 
"https://github.com/dan-coulter/phpflickr.git;,
+   "type": "git",
+   "reference": 
"bc4f2092b15d347e3d40c19fe0dbff8759fc8e51"
+   },
+   "autoload": {
+   "classmap": [
+   "phpFlickr.php"
+   ]
+   }
+   }
+   }
+   ]
+}
diff --git a/extension.json b/extension.json
new file mode 100755
index 000..5ca6384
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,35 @@
+{
+   "name": "FlickrAPI",
+   "version": "2.0.0",
+   "author": [
+   "Ike Hecht",
+   "Sam Wilson"
+   ],
+   "url": 

[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Disable prefs in GlobalPreferences unless they're enabled

2017-07-26 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/367874 )

Change subject: Disable prefs in GlobalPreferences unless they're enabled
..

Disable prefs in GlobalPreferences unless they're enabled

Also highlight the relevant preference labels on hover over
the global checkbox.

Bug: T68869
Change-Id: Icde9ffbda6209fd866415b29774247396119166f
---
M SpecialGlobalPreferences.php
M extension.json
M resources/ext.GlobalPreferences.special.css
A resources/ext.GlobalPreferences.special.js
4 files changed, 44 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/74/367874/1

diff --git a/SpecialGlobalPreferences.php b/SpecialGlobalPreferences.php
index 9d317e0..dd6e888 100644
--- a/SpecialGlobalPreferences.php
+++ b/SpecialGlobalPreferences.php
@@ -16,7 +16,7 @@
$this->setHeaders();
throw new ErrorPageError( 'globalprefs-error-header', 
'globalprefs-notglobal' );
}
-   $this->getOutput()->addModuleStyles( 
'ext.GlobalPreferences.special' );
+   $this->getOutput()->addModules( 'ext.GlobalPreferences.special' 
);
parent::execute( $par );
}
 
diff --git a/extension.json b/extension.json
index 58a4dd7..31434a0 100644
--- a/extension.json
+++ b/extension.json
@@ -50,7 +50,8 @@
},
"ResourceModules": {
"ext.GlobalPreferences.special": {
-   "styles": "ext.GlobalPreferences.special.css"
+   "styles": "ext.GlobalPreferences.special.css",
+   "scripts": "ext.GlobalPreferences.special.js"
}
},
"manifest_version": 1
diff --git a/resources/ext.GlobalPreferences.special.css 
b/resources/ext.GlobalPreferences.special.css
index 7510123..a67ee78 100644
--- a/resources/ext.GlobalPreferences.special.css
+++ b/resources/ext.GlobalPreferences.special.css
@@ -1,6 +1,12 @@
 input.mw-globalprefs-global-check {
-   margin-left: 20px;
+   margin-left: 2em;
 }
 tr.mw-globalprefs-global-check {
-   font-size: 13px;
+   font-size: smaller;
+}
+.globalprefs-disabled {
+   opacity: 0.5;
+}
+.globalprefs-hover {
+   background-color: rgba(255, 224, 97, 0.5);
 }
diff --git a/resources/ext.GlobalPreferences.special.js 
b/resources/ext.GlobalPreferences.special.js
new file mode 100644
index 000..a7623dc
--- /dev/null
+++ b/resources/ext.GlobalPreferences.special.js
@@ -0,0 +1,33 @@
+( function ( mw, $ ) {
+   'use strict';
+
+   $("input.mw-globalprefs-global-check").on('change', function() {
+
+   // Find the name (without the '-global' suffix, but with the 
'wp' prefix).
+   var fullName = $(this).attr( "name" );
+   var name = fullName.substr( 0, fullName.length - 
"-global".length );
+
+   // Is this preferenced enabled globally?
+   var enabled = $(this).prop( "checked" );
+
+   // Disable or enable the related preferences inputs.
+   $( ":input[name='"+name+"']" ).prop( "disabled", !enabled );
+   var labels = $( "label[for^='mw-input-" + name + 
"']:not([for$='-global'])" );
+   if (enabled) {
+   labels.removeClass("globalprefs-disabled");
+   } else {
+   labels.addClass("globalprefs-disabled");
+   }
+
+   // Add a class on hover, to highlight the related labels.
+   $(this).add( "label[for='" + $(this).attr("id") + "']" ).hover( 
function() {
+   // Hover on.
+   $( "label[for^='mw-input-" + name + "']" ).addClass( 
"globalprefs-hover" );
+   }, function() {
+   // Hover off.
+   $( "label[for^='mw-input-" + name + "']" ).removeClass( 
"globalprefs-hover");
+   } );
+
+   } ).change();
+
+}( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/367874
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icde9ffbda6209fd866415b29774247396119166f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GlobalPreferences[master]: Get Central ID for 'raw' audience

2017-07-23 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/367345 )

Change subject: Get Central ID for 'raw' audience
..

Get Central ID for 'raw' audience

This avoids checking the audience-user for hideuser permissions,
and thus the infinite loop that is created (becuase it had to
load the audience-user to check that, and in doing so will try
to run the UserLoadOptions hook again).

Bug: T166430
Change-Id: I24a8c06c3abbb7d973c94f6cccf3952dc692cbfc
---
M GlobalPreferences.body.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/45/367345/1

diff --git a/GlobalPreferences.body.php b/GlobalPreferences.body.php
index 2c15cf9..aa7fc53 100644
--- a/GlobalPreferences.body.php
+++ b/GlobalPreferences.body.php
@@ -47,7 +47,7 @@
 */
public static function getUserID( User $user ) {
$lookup = CentralIdLookup::factory();
-   return $lookup->centralIdFromLocalUser( $user );
+   return $lookup->centralIdFromLocalUser( $user, 
CentralIdLookup::AUDIENCE_RAW );
}
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/367345
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24a8c06c3abbb7d973c94f6cccf3952dc692cbfc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Add relations as template dependencies of pages

2017-06-05 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357187 )

Change subject: Add relations as template dependencies of pages
..

Add relations as template dependencies of pages

Also update CS version.

Change-Id: I1a8de01cab9eddd8a80ca904e2eb5c70cd71f64d
---
M composer.json
M src/Hooks.php
M src/Tree.php
3 files changed, 17 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/87/357187/1

diff --git a/composer.json b/composer.json
index 08e37a1..55f7f5e 100644
--- a/composer.json
+++ b/composer.json
@@ -23,8 +23,8 @@
}
},
"require-dev": {
-   "jakub-onderka/php-parallel-lint": "0.9.2",
-   "mediawiki/mediawiki-codesniffer": "0.7.2",
+   "jakub-onderka/php-parallel-lint": "^0.9",
+   "mediawiki/mediawiki-codesniffer": "^0.8",
"jakub-onderka/php-console-highlighter": "0.3.2"
},
"scripts": {
diff --git a/src/Hooks.php b/src/Hooks.php
index fe64b9a..131ee61 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -90,7 +90,7 @@
} else {
$parent = new Person( $parentTitle );
$out .= $parent->getWikiLink();
-   self::saveProp( $parser, 'parent', 
$params[0] );
+   self::saveProp( $parser, 'parent', 
$parentTitle );
}
break;
case 'siblings':
@@ -105,7 +105,7 @@
$msg = wfMessage( 
'genealogy-invalid-partner-title', $invalidTitle );
$out .= "$msg";
} else {
-   self::saveProp( $parser, 'partner', 
$params[0] );
+   self::saveProp( $parser, 'partner', 
$partnerTitle );
}
break;
case 'partners':
@@ -149,25 +149,32 @@
 * Save a page property.
 * @param Parser $parser The parser object.
 * @param string $prop The property name; it will be prefixed with 
'genealogy '.
-* @param string $val The property value.
+* @param string|Title $val The property value ('full text' will be 
used if this is a Title).
 * @param boolean $multi Whether this property can have multiple values 
(will be stored as
 * multiple properties, with an integer appended to their name.
 */
public static function saveProp( Parser $parser, $prop, $val, $multi = 
true ) {
$output = $parser->getOutput();
+   $valString = ( $val instanceof Title ) ? $val->getFullText() : 
$val;
if ( $multi ) {
// Figure out what number we're up to for this property.
$propNum = 1;
$propVal = $output->getProperty( "genealogy $prop 
$propNum" );
-   while ( $propVal !== false && $propVal !== $val ) {
+   while ( $propVal !== false && $propVal !== $valString ) 
{
$propNum++;
$propVal = $output->getProperty( "genealogy 
$prop $propNum" );
}
// Save the property.
-   $output->setProperty( "genealogy $prop $propNum", $val 
);
+   $output->setProperty( "genealogy $prop $propNum", 
$valString );
} else {
// A single-valued property.
-   $output->setProperty( "genealogy $prop", $val );
+   $output->setProperty( "genealogy $prop", $valString );
+   }
+   // For page-linking properties, add the referenced page as a 
dependency for this page.
+   // 
https://www.mediawiki.org/wiki/Manual:Tag_extensions#How_do_I_disable_caching_for_pages_using_my_extension.3F
+   if ( $val instanceof Title ) {
+   // Register the dependency in templatelinks table.
+   $output->addTemplate( $val, $val->getArticleID(), 
$val->getLatestRevID() );
}
}
 
diff --git a/src/Tree.php b/src/Tree.php
index 3e73dd2..febf0d9 100644
--- a/src/Tree.php
+++ b/src/Tree.php
@@ -104,8 +104,8 @@
 
// Combine all parts of the graph output.
$out = join( "\n", $this->graph_source_code['top'] ) . "\n\n"
-  . "node [ shape=plaintext ]\n"
-  . join( "\n", $this->graph_source_code['person'] ) . 
"\n\n";
+   . "node [ shape=plaintext ]\n"
+   . join( "\n", 

[MediaWiki-commits] [Gerrit] mediawiki...PageTriage[master]: Fix checkbox checkedness setting

2017-05-19 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/354477 )

Change subject: Fix checkbox checkedness setting
..

Fix checkbox checkedness setting

The checked comparison was checking a string against an int,
this change fixes this and adds some function documentation.

Bug: T44254
Change-Id: I4466862ff564388934c35572bb3a0fc45cdfa3c7
---
M modules/ext.pageTriage.views.list/ext.pageTriage.listControlNav.js
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageTriage 
refs/changes/77/354477/1

diff --git a/modules/ext.pageTriage.views.list/ext.pageTriage.listControlNav.js 
b/modules/ext.pageTriage.views.list/ext.pageTriage.listControlNav.js
index c8318d7..4670350 100644
--- a/modules/ext.pageTriage.views.list/ext.pageTriage.listControlNav.js
+++ b/modules/ext.pageTriage.views.list/ext.pageTriage.listControlNav.js
@@ -378,9 +378,15 @@
}
},
 
-   // Update a checkbox in the menu with data from the model
+   /**
+* Update a checkbox in the filter menu with data from the 
model.
+*
+* @param $checkbox JQuery The JQuery object of the input 
element.
+* @param param string The value (i.e. 1 or 0, checked or not).
+* @param message string The message name for the filter.
+*/
menuCheckboxUpdate: function ( $checkbox, param, message ) {
-   $checkbox.prop( 'checked', this.model.getParam( param ) 
=== '1' ? true : false );
+   $checkbox.prop( 'checked', parseInt( 
this.model.getParam( param ) ) === 1 );
if ( this.model.getParam( param ) ) {
this.newFilterStatus.push( mw.msg( message ) );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/354477
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4466862ff564388934c35572bb3a0fc45cdfa3c7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageTriage
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Multiple redirects, and graph names

2017-04-17 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/348674 )

Change subject: Multiple redirects, and graph names
..

Multiple redirects, and graph names

Change-Id: If943810694102a644c35333053b60c998278d822
---
M src/Person.php
M src/Tree.php
M tests/phpunit/PersonTest.php
3 files changed, 20 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/74/348674/1

diff --git a/src/Person.php b/src/Person.php
index ebf3158..4764559 100644
--- a/src/Person.php
+++ b/src/Person.php
@@ -51,8 +51,8 @@
 */
public function getTitle() {
$page = WikiPage::factory( $this->title );
-   if ( $page->isRedirect() ) {
-   return $page->getRedirectTarget();
+   while ( $page->isRedirect() ) {
+   $page = WikiPage::factory( $page->getRedirectTarget() );
}
return $page->getTitle();
}
diff --git a/src/Tree.php b/src/Tree.php
index e714c9f..3e73dd2 100644
--- a/src/Tree.php
+++ b/src/Tree.php
@@ -208,7 +208,7 @@
$this->out( 'partner', $personId.$parentsId, 
$personParentsLine );
$childId = $this->esc( $child->getTitle()->getDBkey() );
$this->out( 'child', $parentsId.$childId, $parentsId.' 
-> ' . $childId );
-   // Add this child in case they don't .
+   // Add this child in case they don't get included 
directly in this tree.
$this->outputPersonLine( $child );
}
}
@@ -238,7 +238,7 @@
 * @return string
 */
private function esc( $title ) {
-   return strtr( $title, '( )-', '' );
+   return strtr( $title, '( )-.', '_' );
}
 
 }
diff --git a/tests/phpunit/PersonTest.php b/tests/phpunit/PersonTest.php
index b719e34..318edb0 100644
--- a/tests/phpunit/PersonTest.php
+++ b/tests/phpunit/PersonTest.php
@@ -108,5 +108,21 @@
'King Charles',

$diana->getPartners()['King_Charles']->getTitle()->getText()
);
+   // Redirect Charles again, and make sure all is okay.
+   $kingChPage->doEditContent( new WikitextContent( '#REDIRECT 
[[King Charles III]]' ), '' );
+   $kingCh3Page = new WikiPage( Title::newFromText( 'King Charles 
III' ) );
+   $kingCh3Page->doEditContent( new WikitextContent( 
'{{#genealogy:partner|Diana}}' ), '' );
+   $this->assertEquals( 'King_Charles_III', 
$charles->getTitle()->getPrefixedDBkey() );
+   $this->assertEquals(
+   [ 'Charles', 'King_Charles', 'King_Charles_III' ],
+   array_keys( $charles->getTitles() )
+   );
+   $this->assertCount( 1, $charles->getPartners() );
+   $this->assertEquals( 'Dianna', 
$charles->getPartners()['Dianna']->getTitle() );
+   $this->assertCount( 1, $diana->getPartners() );
+   $this->assertEquals(
+   'King Charles III',
+   
$diana->getPartners()['King_Charles_III']->getTitle()->getText()
+   );
}
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/348674
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If943810694102a644c35333053b60c998278d822
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...LoginNotify[master]: Fix various docblock formatting

2017-03-22 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344301 )

Change subject: Fix various docblock formatting
..

Fix various docblock formatting

This fixes some errors in docblock formatting to bring things into
line with MediaWiki coding standards (not all of which are yet
caught by phpcs).

Change-Id: I06b7fc3a9fe09e412b3200b597ce01ef7e7d5ae3
---
M LoginNotify.hooks.php
M LoginNotify_body.php
2 files changed, 47 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LoginNotify 
refs/changes/01/344301/1

diff --git a/LoginNotify.hooks.php b/LoginNotify.hooks.php
index f560f0e..7f4a304 100644
--- a/LoginNotify.hooks.php
+++ b/LoginNotify.hooks.php
@@ -16,9 +16,9 @@
/**
 * Add LoginNotify events to Echo
 *
-* @param $notifications array of Echo notifications
-* @param $notificationCategories array of Echo notification categories
-* @param $icons array of icon details
+* @param string[] &$notifications Array of Echo notifications
+* @param string[] &$notificationCategories Array of Echo notification 
categories
+* @param string[] &$icons Array of icon details
 * @return bool
 */
public static function onBeforeCreateEchoEvent(
@@ -83,9 +83,9 @@
 * Old hook for pre 1.27 or wikis with auth manager disabled.
 *
 * @todo Doesn't catcha captcha or throttle failures
-* @param $user User User in question
-* @param $pass String password
-* @param $retval int LoginForm constant (e.g. LoginForm::SUCCESS)
+* @param User $user User in question.
+* @param string $pass The password (parameter not used).
+* @param integer $retval A LoginForm constant (e.g. 
LoginForm::SUCCESS).
 */
public static function onLoginAuthenticateAudit( User $user, $pass, 
$retval ) {
if ( $retval === LoginForm::WRONG_PASS ) {
@@ -98,9 +98,9 @@
/**
 * Hook for login auditing post 1.27
 *
-* @param $ret AuthenticationResponse Is login succesful?
-* @param $user User|null User object on successful auth
-* @param $username String Username for failed attempts.
+* @param AuthenticationResponse $ret Is login successful?
+* @param User|null $user User object on successful auth
+* @param string $username Username for failed attempts.
 */
public static function onAuthManagerLoginAuthenticateAudit(
AuthenticationResponse $ret, $user, $username
@@ -123,6 +123,12 @@
// statuses.
}
 
+   /**
+* Handle a successful login (clear the attempt counter, send a notice, 
and record the
+* current IP address as known).
+*
+* @param User $user The user who logged in.
+*/
public static function doSuccessfulLogin( User $user ) {
$loginNotify = new LoginNotify();
$loginNotify->clearCounters( $user );
@@ -130,6 +136,11 @@
$loginNotify->setCurrentAddressAsKnown( $user );
}
 
+   /**
+* Handle a failed login (record the failure).
+*
+* @param User $user The user that failed to log in.
+*/
public static function doFailedLogin( User $user ) {
$loginNotify = new LoginNotify();
$loginNotify->recordFailure( $user );
@@ -140,8 +151,8 @@
 *
 * Set a cookie saying this is a known computer when creating an 
account.
 *
-* @todo This still sets cookies if user creates account well logged in 
as someone else.
-* @param User $user
+* @todo This still sets cookies if user creates an account while 
logged in as someone else.
+* @param User $user The user that has been created.
 * @param boolean $byMail Account created by email
 */
public static function onAddNewAccount( User $user, $byMail ) {
@@ -173,8 +184,8 @@
 * This is a bit hacky. Used to be able to set a different
 * default for admins then other users
 *
-* @param $user User
-* @param &$options array
+* @param User $user The user in question.
+* @param mixed[] &$options The options.
 * @return bool
 */
public static function onUserLoadOptions( User $user, array &$options ) 
{
@@ -215,8 +226,8 @@
 * @todo This is a bit icky. Need to decide if we really want to do 
this.
 * @todo If someone explicitly enables, gets admin rights, gets 
de-admined,
 *   this will then disable the preference, which is definitely 
non-ideal.
-* @param $user User
-* @param &$options array
+* @param User $user The user that is being saved.
+* @param mixed[] &$options The options.
 * @return 

[MediaWiki-commits] [Gerrit] translatewiki[master]: Add the IA Upload tool

2017-02-26 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/340084 )

Change subject: Add the IA Upload tool
..

Add the IA Upload tool

This adds translation configuration for the IA Upload tool that
uploads DjVu files from the Internet Archive to Commons.

Bug: T158522

Change-Id: Ib314efc90ca5cdadfc89f9d7de01547102602c22
---
M TranslateSettings.php
M bin/EXTERNAL-PROJECTS
M bin/REPONG-PROJECTS
A groups/Wikimedia/ia-upload.yaml
M repoconfig.commit.json
M repoconfig.json
6 files changed, 38 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/translatewiki 
refs/changes/84/340084/1

diff --git a/TranslateSettings.php b/TranslateSettings.php
index f9bf344..3680f65 100644
--- a/TranslateSettings.php
+++ b/TranslateSettings.php
@@ -242,6 +242,7 @@
 $wgTranslateGroupFiles[] = "$GROUPS/Wikimedia/crosswatch.yaml";
 $wgTranslateGroupFiles[] = "$GROUPS/Wikimedia/GapFinder.yaml";
 $wgTranslateGroupFiles[] = "$GROUPS/Wikimedia/jquery.uls.yaml";
+$wgTranslateGroupFiles[] = "$GROUPS/Wikimedia/ia-upload.yaml";
 $wgTranslateGroupAliases['out-jquery-uls'] = 'jquery-uls';
 $wgTranslateGroupFiles[] = "$GROUPS/Wikimedia/Pageviews.yaml";
 $wgTranslateGroupFiles[] = "$GROUPS/Wikimedia/video2commons.yaml";
diff --git a/bin/EXTERNAL-PROJECTS b/bin/EXTERNAL-PROJECTS
index 4bdd657..633d1df 100644
--- a/bin/EXTERNAL-PROJECTS
+++ b/bin/EXTERNAL-PROJECTS
@@ -14,6 +14,7 @@
 gapfinder
 hivejs
 huggle
+ia-upload
 ihris
 inaturalist
 int-dcatap
diff --git a/bin/REPONG-PROJECTS b/bin/REPONG-PROJECTS
index 06a7adc..f9e7458 100644
--- a/bin/REPONG-PROJECTS
+++ b/bin/REPONG-PROJECTS
@@ -13,6 +13,7 @@
 gapfinder
 hivejs
 huggle
+ia-upload
 inaturalist
 intuition
 int-dcatap
diff --git a/groups/Wikimedia/ia-upload.yaml b/groups/Wikimedia/ia-upload.yaml
new file mode 100644
index 000..c90c513
--- /dev/null
+++ b/groups/Wikimedia/ia-upload.yaml
@@ -0,0 +1,17 @@
+---
+BASIC:
+  id: ia-upload
+  label: ia-upload
+  description: "{{Special:MyLanguage/Translations:Group 
descriptions/ia-upload/en}}"
+  class: FileBasedMessageGroup
+  namespace: NS_WIKIMEDIA
+
+MANGLER:
+  class: StringMatcher
+  prefix: gapfinder-
+  patterns:
+- "*"
+
+FILES:
+  class: JsonFFS
+  sourcePattern: "%GROUPROOT%/ia-upload/i18n/%CODE%.json"
diff --git a/repoconfig.commit.json b/repoconfig.commit.json
index 5c32b98..222ed96 100644
--- a/repoconfig.commit.json
+++ b/repoconfig.commit.json
@@ -70,6 +70,15 @@
}
}
},
+   "ia-upload": {
+   "group": "ia-upload",
+   "repos": {
+   "ia-upload": {
+   "type": "github",
+   "url": 
"g...@github.com:wikisource/ia-upload.git"
+   }
+   }
+   },
"intuition": {
"group": "tsint-*",
"export-threshold": 1,
diff --git a/repoconfig.json b/repoconfig.json
index 58c4add..a4f0ae0 100644
--- a/repoconfig.json
+++ b/repoconfig.json
@@ -70,6 +70,15 @@
}
}
},
+   "ia-upload": {
+   "group": "ia-upload",
+   "repos": {
+   "ia-upload": {
+   "type": "github",
+   "url": 
"g...@github.com:wikisource/ia-upload.git"
+   }
+   }
+   },
"intuition": {
"group": "tsint-*",
"export-threshold": 1,

-- 
To view, visit https://gerrit.wikimedia.org/r/340084
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib314efc90ca5cdadfc89f9d7de01547102602c22
Gerrit-PatchSet: 1
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...ExternalArticles[master]: Switch to HTTPS URL

2017-02-21 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/339072 )

Change subject: Switch to HTTPS URL
..

Switch to HTTPS URL

Change-Id: I34caa1304aecf4330ca646d278a242de6fb7a313
---
M extension.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalArticles 
refs/changes/72/339072/1

diff --git a/extension.json b/extension.json
index a5c3421..d9b29d3 100644
--- a/extension.json
+++ b/extension.json
@@ -6,7 +6,7 @@
"Alvinos",
"Sam Wilson"
],
-   "url": "http://www.mediawiki.org/wiki/Extension:ExternalArticles;,
+   "url": "https://www.mediawiki.org/wiki/Extension:ExternalArticles;,
"descriptionmsg": "externalarticles-desc",
"type": "extension",
"AutoloadClasses": {

-- 
To view, visit https://gerrit.wikimedia.org/r/339072
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I34caa1304aecf4330ca646d278a242de6fb7a313
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ExternalArticles
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...ExternalArticles[master]: Add feature to import pages from local directory hierarchy

2017-02-20 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/338916 )

Change subject: Add feature to import pages from local directory hierarchy
..

Add feature to import pages from local directory hierarchy

This adds a maintenance script that scans a directory for files
and imports them. Top-level files are imported into the main
namespace, and files in subdirectories are imported into namespaces
named as those subdirectories.

No file extensions are stripped (in order to be able to import JS
and CSS files etc.).

A 'watch' option is added, which will keep the script running and
monitoring the files for changes. Whenever one is modified it will
be re-imported. This feature relies on the inotify Pecl extension.

Change-Id: I872dddfe43eaf6029d5282ea18e9fca426fd8995
---
M .gitignore
A composer.json
M extension.json
A maintenance/importTextFiles.php
A src/TextFileImporter.php
5 files changed, 221 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalArticles 
refs/changes/16/338916/1

diff --git a/.gitignore b/.gitignore
index 1689d7a..c60b13a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
 *.kate-swp
 .*.swp
 node_modules/**
+/vendor
+/composer.lock
diff --git a/composer.json b/composer.json
new file mode 100644
index 000..968e300
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,25 @@
+{
+   "name": "samwilson/mediawiki-extensions-external-articles",
+   "description": "A MediaWiki extension for loading page text from 
external sources",
+   "type": "mediawiki-extension",
+   "license": "GPL-3.0",
+   "keywords": ["importing", "MediaWiki"],
+   "support": {
+   "issues": "https://phabricator.wikimedia.org;,
+   "irc": "irc://irc.freenode.net/mediawiki",
+   "source": 
"https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ExternalArticles.git;
+   },
+   "require-dev": {
+   "jakub-onderka/php-parallel-lint": "0.9.2",
+   "mediawiki/mediawiki-codesniffer": "0.7.2"
+   },
+   "scripts": {
+   "test": [
+   "parallel-lint . --exclude vendor",
+   "phpcs -p -s"
+   ],
+   "fix": [
+   "phpcbf"
+   ]
+   }
+}
diff --git a/extension.json b/extension.json
index 43050ab..ee08098 100644
--- a/extension.json
+++ b/extension.json
@@ -10,7 +10,8 @@
"descriptionmsg": "externalarticles-desc",
"type": "extension",
"AutoloadClasses": {
-   "MediaWiki\\Extensions\\ExternalArticles\\Hooks": 
"src/Hooks.php"
+   "MediaWiki\\Extensions\\ExternalArticles\\Hooks": 
"src/Hooks.php",
+   "MediaWiki\\Extensions\\ExternalArticles\\TextFileImporter": 
"src/TextFileImporter.php"
},
"MessagesDirs": {
"ExternalArticles": [
diff --git a/maintenance/importTextFiles.php b/maintenance/importTextFiles.php
new file mode 100644
index 000..3fef728
--- /dev/null
+++ b/maintenance/importTextFiles.php
@@ -0,0 +1,29 @@
+requireExtension( 'ExternalArticles' );
+   $this->addOption( 'watch', 'Whether to keep watching the files 
and re-importing whenever one changes', false, false );
+   $this->addArg( 'dir', 'The directory to import', true );
+   }
+
+   /**
+* Run the import.
+*/
+   public function execute() {
+   $this->output( "This is the ExternalArticles extension\n" );
+   $importer = new TextFileImporter( $this->getArg( 0 ), 
$this->getOption( 'watch' ) );
+   $importer->import();
+   }
+}
+
+$maintClass = ExternalArticles_Maintenance_ImportTextFiles::class;
+require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/src/TextFileImporter.php b/src/TextFileImporter.php
new file mode 100644
index 000..26c9178
--- /dev/null
+++ b/src/TextFileImporter.php
@@ -0,0 +1,163 @@
+dir = realpath( $dir );
+   $this->watch = (boolean)$watch && function_exists( 
'inotify_init' );
+   if ( $this->watch ) {
+   $this->inotify = inotify_init();
+   }
+   }
+
+   /**
+*
+*/
+   public function import() {
+   $topLevel = new DirectoryIterator( $this->dir );
+   foreach ( $topLevel as $file ) {
+   if ( $file->isDot() ) {
+   continue;
+   }
+   if ( $file->isDir() ) {
+   // Use the directory names as namespaces.
+   $secondLevel = new DirectoryIterator( 
$this->dir . '/' . $file );
+   foreach ( $secondLevel as $subfile ) {
+   if ( $subfile->isDot() ) {
+   continue;

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Fix no-parameter trees, and multiple trees on one page

2017-02-11 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/337250 )

Change subject: Fix no-parameter trees, and multiple trees on one page
..

Fix no-parameter trees, and multiple trees on one page

This adds a couple more i18n messages; fixes errors when the tree
parser function was called with incorrect (or no) parameters; gives
each tree a unique name for when there is more than one tree on a
page; fixes a bunch of coding-standards errors; and gives better
errors when parents or partners are defined with invalid page
titles.

Change-Id: Id0ededa68281db7b86be6bff57ef7a4085be6569
---
M composer.json
M i18n/en.json
M src/Hooks.php
M src/Person.php
M src/Traverser.php
M src/Tree.php
6 files changed, 75 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/50/337250/1

diff --git a/composer.json b/composer.json
index 8115995..9467fc4 100644
--- a/composer.json
+++ b/composer.json
@@ -8,7 +8,7 @@
{
"name": "Sam Wilson",
"email": "s...@samwilson.id.au",
-   "homepage": "http://samwilson.id.au;,
+   "homepage": "https://samwilson.id.au;,
"role": "developer"
}
],
diff --git a/i18n/en.json b/i18n/en.json
index 246130e..d1a9141 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -16,5 +16,7 @@
"genealogy-person-preload": "Template:Person/preload",
"genealogy-person-list-item": "Template:Person/list-item",
"genealogy-parser-function-not-found": "Genealogy parser function type 
not recognised: $1",
-   "genealogy-existing-partners": "This person already has the following 
{{PLURAL:$1|partner|partners}}: "
+   "genealogy-existing-partners": "This person already has the following 
{{PLURAL:$1|partner|partners}}: ",
+   "genealogy-invalid-parent-title": "Error: invalid parent page title: 
'$1'",
+   "genealogy-invalid-partner-title": "Error: invalid partner page title: 
'$1'"
 }
diff --git a/src/Hooks.php b/src/Hooks.php
index e22b84f..fe64b9a 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -12,7 +12,7 @@
 
/**
 * Hooked to ParserFirstCallInit.
-* @param Parser $parser
+* @param Parser &$parser The parser.
 * @return boolean
 */
public static function onParserFirstCallInit( Parser &$parser ) {
@@ -24,8 +24,8 @@
 * This method is called by the EditPage::showEditForm:initial hook and 
adds a list of the
 * current page's Genealogy partners that *are not* a result of a 
{{#genealogy:partner|…}} call
 * in the current page.
-* @param EditPage $editPage The current page that's being edited.
-* @param OutputPage $output The output.
+* @param EditPage &$editPage The current page that's being edited.
+* @param OutputPage &$output The output.
 * @return void
 */
public static function onEditPageShowEditFormInitial( EditPage 
&$editPage, OutputPage &$output ) {
@@ -46,19 +46,18 @@
 * Render the output of the parser function.
 * The input parameters are wikitext with templates expanded.
 * The output should be wikitext too.
-*
-* @param Parser $parser
-* @param string $type
-* @param string $param2
-* @param string $param3
+* @param Parser $parser The parser.
 * @return string The wikitext with which to replace the parser 
function call.
 */
public static function renderParserFunction( Parser $parser ) {
$params = [];
$args = func_get_args();
-   array_shift( $args ); // Remove $parser
-   $type = array_shift( $args ); // Get param 1, the function type
-   foreach ( $args as $arg ) { // Everything that's left must be 
named
+   // Remove $parser from the args.
+   array_shift( $args );
+   // Get param 1, the function type.
+   $type = array_shift( $args );
+   // Everything that's left must be named.
+   foreach ( $args as $arg ) {
$pair = explode( '=', $arg, 2 );
if ( count( $pair ) == 2 ) {
$name = trim( $pair[0] );
@@ -84,7 +83,10 @@
case 'parent':
$parentTitle = Title::newFromText( $params[0] );
if ( !$parentTitle instanceof Title ) {
-   $out .= "Invalid 
parent page title: '{$params[0]}'";
+   $invalidTitle = '' . $params[0] 
. '';
+   $isHtml = true;
+   $msg = wfMessage( 
'genealogy-invalid-parent-title', 

[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Ignore empty field definitions in cargo_query

2017-01-18 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332945 )

Change subject: Ignore empty field definitions in cargo_query
..

Ignore empty field definitions in cargo_query

If a field list ended in a comma (indicating an empty trailing
field definition) then an "Uninitialized string offset: 0" was
being thrown. This change avoids this by discarding empty field
definitions before processing them.

Change-Id: I7cf9160b3a7ee7d341745c8b2347221502f9c22e
---
M CargoSQLQuery.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/45/332945/1

diff --git a/CargoSQLQuery.php b/CargoSQLQuery.php
index af7fffd..2b0b771 100644
--- a/CargoSQLQuery.php
+++ b/CargoSQLQuery.php
@@ -169,7 +169,7 @@
 */
function setAliasedFieldNames() {
$this->mAliasedFieldNames = array();
-   $fieldStrings = CargoUtils::smartSplit( ',', $this->mFieldsStr 
);
+   $fieldStrings = array_filter( CargoUtils::smartSplit( ',', 
$this->mFieldsStr ) );
// Default is "_pageName".
if ( count( $fieldStrings ) == 0 ) {
$fieldStrings[] = '_pageName';

-- 
To view, visit https://gerrit.wikimedia.org/r/332945
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7cf9160b3a7ee7d341745c8b2347221502f9c22e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: [WIP] Add an expiry to the localStorage replication of the b...

2017-01-17 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332737 )

Change subject: [WIP] Add an expiry to the localStorage replication of the 
block cookie
..

[WIP] Add an expiry to the localStorage replication of the block cookie

The block cookie is replicated to localStorage in order that the cookie
can be recreated if it's removed. However, this would have recreated
the cookie even years after the expiry of the original cookie because
localStorage never expires.

This change adds an expiry time to the localStorage data (by switching
it to be a JSON string with 'data' and 'expiry' keys) and only recreates
the cookie if the expiry time is greater than the current time.

Bug: T152952
Change-Id: Ifb06dc2390f4d648d7fcb39e30267de5eddc6941
---
M includes/EditPage.php
M resources/src/mediawiki/mediawiki.user.blockcookie.js
2 files changed, 52 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/37/332737/1

diff --git a/includes/EditPage.php b/includes/EditPage.php
index 05fa366..102a1c9 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -2331,12 +2331,17 @@
}
 
function setHeaders() {
-   global $wgOut, $wgUser, $wgAjaxEditStash, 
$wgCookieSetOnAutoblock;
+   global $wgOut, $wgUser, $wgAjaxEditStash;
 
$wgOut->addModules( 'mediawiki.action.edit' );
-   if ( $wgCookieSetOnAutoblock === true ) {
+
+   // Add JS for tracking block ID cookies in localStorage.
+   $config = RequestContext::getMain()->getConfig();
+   if ( $config->get( 'CookieSetOnAutoblock' ) === true ) {
$wgOut->addModules( 'mediawiki.user.blockcookie' );
+   $wgOut->addJsConfigVars( 'wgAutoblockExpiry', 
$config->get( 'AutoblockExpiry' ) );
}
+
$wgOut->addModuleStyles( 'mediawiki.action.edit.styles' );
 
if ( $wgUser->getOption( 'showtoolbar' ) ) {
diff --git a/resources/src/mediawiki/mediawiki.user.blockcookie.js 
b/resources/src/mediawiki/mediawiki.user.blockcookie.js
index 039..47f97c5 100644
--- a/resources/src/mediawiki/mediawiki.user.blockcookie.js
+++ b/resources/src/mediawiki/mediawiki.user.blockcookie.js
@@ -1,18 +1,50 @@
-( function ( mw ) {
+(
 
-   // If a user has been autoblocked, a cookie is set.
-   // Its value is replicated here in localStorage to guard against 
cookie-removal.
-   // This module will only be loaded when $wgCookieSetOnAutoblock is true.
-   // Ref: https://phabricator.wikimedia.org/T5233
+/**
+ * If a user has been autoblocked, a cookie is set.
+ * Its value is replicated here in localStorage to guard against 
cookie-removal.
+ * The localStorage item will be removed after $wgAutoblockExpiry (default 
86400 seconds).
+ * This module will only be loaded when $wgCookieSetOnAutoblock is true.
+ * Ref: T5233
+ *
+ * This used to just store the block ID, but for T152952 was changed to also 
store an expiry time in order that the
+ * localStorage data be removed after $wgAutoblockExpiry (default 86400 
seconds).
+ */
+function ( mw ) {
+   var expiry, cookieVal, storageValue, storedObject, storedExpiry;
+
+   // Calculate the expiry time (add milliseconds to current time).
+   expiry = Date.now() + ( mw.config.get( 'wgAutoblockExpiry' ) * 1000 );
+
+   //cookieVal = mw.cookie.get( 'BlockID' );
+   console.log( document.cookie );
+
+   // There are three parts to this next bit:
+   // 1. cookie doesn't exist and there's nothing in localStorage;
+   // 2. cookie does exist and there's nothing in localStorage; and
+   // 3. cookie is blank and there is something in localStorage.
 
if ( !mw.cookie.get( 'BlockID' ) && mw.storage.get( 'blockID' ) ) {
-   // The block ID exists in storage, but not in the cookie.
-   mw.cookie.set( 'BlockID', mw.storage.get( 'blockID' ) );
+   // The block ID exists in storage, but the cookie doesn't 
exist, so we re-create the cookie.
+   // The cookie value is either just the whole stored value, or 
just the 'data' element if it exists.
+   storageValue = mw.storage.get( 'BlockID' );
+   storedObject = JSON.parse( storageValue );
+   if ( ! "data" in storedObject ) {
+   // If there's no 'data' property, this must be an 
old-style localStorage item, so we give it an expiry date.
+   storedObject = { data: storageValue, expiry: expiry }
+   }
+   storedExpiry = new Date( storedObject.expiry );
+   if ( storedExpiry >= new Date() ) {
+   // localStorage data hasn't expired, so use it to 
recreate the cookie.
+   mw.cookie.set( 'BlockID', storedObject.data );
+   }
 
- 

[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Add fields to composer.json

2017-01-10 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/331560 )

Change subject: Add fields to composer.json
..

Add fields to composer.json

This change adds some missing fields to the Composer file.

Change-Id: I6c8b1260a72e6d73273ba3efba8edd24cb017bc3
---
M composer.json
1 file changed, 15 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/60/331560/1

diff --git a/composer.json b/composer.json
index 1c63f9e..2e902f0 100644
--- a/composer.json
+++ b/composer.json
@@ -1,4 +1,19 @@
 {
+   "name": "yaronkoren/cargo",
+   "description": "A MediaWiki extension that allows for the storage and 
querying of data contained within templates.",
+   "type": "mediawiki-extension",
+   "keywords": [ "MediaWiki" ],
+   "homepage": "https://www.mediawiki.org/wiki/Extension:Cargo;,
+   "license": "GPL-2.0+",
+   "authors": [
+   { "name": "Yaron Koren" },
+   { "name": "paladox" }
+   ],
+   "support": {
+   "issues": 
"https://phabricator.wikimedia.org/tag/mediawiki-extensions-cargo/;,
+   "irc": "irc://irc.freenode.net/mediawiki",
+   "source": 
"https://phabricator.wikimedia.org/r/p/mediawiki/extensions/Cargo;browse/master/;
+   },
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.9.2"
},

-- 
To view, visit https://gerrit.wikimedia.org/r/331560
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c8b1260a72e6d73273ba3efba8edd24cb017bc3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...codesniffer[master]: Explicitely check for method structure before using

2017-01-05 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/330846 )

Change subject: Explicitely check for method structure before using
..

Explicitely check for method structure before using

This makes sure a couple of array keys exist before using them.

Bug: T154731
Change-Id: I29bc999ed4ae8dec3e672bea3d394362af8c50a7
---
M MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php
1 file changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer 
refs/changes/46/330846/1

diff --git a/MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php 
b/MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php
index b1e3260..de84420 100644
--- a/MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php
+++ b/MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php
@@ -108,8 +108,13 @@
&& $stackPtr < $this->eligableCls['scope_end']
) {
if ( $currToken['code'] === T_FUNCTION ) {
+   // If this is a function, make sure it's 
eligible
+   // (i.e. not static or abstract, and has a 
body).
$methodProps = $phpcsFile->getMethodProperties( 
$stackPtr );
-   if ( !$methodProps['is_static'] && 
!$methodProps['is_abstract'] ) {
+   $isStaticOrAbstract = $methodProps['is_static'] 
|| $methodProps['is_abstract'];
+   $hasBody = isset( $currToken['scope_opener'] )
+   && isset( $currToken['scope_closer'] );
+   if ( !$isStaticOrAbstract && $hasBody ) {
$funcNamePtr = $phpcsFile->findNext( 
T_STRING, $stackPtr );
$this->eligableFunc = [
'name' => 
$tokens[$funcNamePtr]['content'],

-- 
To view, visit https://gerrit.wikimedia.org/r/330846
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I29bc999ed4ae8dec3e672bea3d394362af8c50a7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...codesniffer[master]: Prevent abstract functions being marked eligable

2017-01-05 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/330834 )

Change subject: Prevent abstract functions being marked eligable
..

Prevent abstract functions being marked eligable

For abstract functions, 'scope_opener' doesn't exist, so a undefined
index notice was being generated.

Tests updated to confirm.

Bug: T154731
Change-Id: Ica991cbe209e0d137d993ec677c15fc3e35430f6
---
M MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php
M MediaWiki/Tests/files/Usage/extend_class_usage.php
M MediaWiki/Tests/files/Usage/extend_class_usage.php.expect
3 files changed, 8 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer 
refs/changes/34/330834/1

diff --git a/MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php 
b/MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php
index b49dee1..b1e3260 100644
--- a/MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php
+++ b/MediaWiki/Sniffs/Usage/ExtendClassUsageSniff.php
@@ -109,7 +109,7 @@
) {
if ( $currToken['code'] === T_FUNCTION ) {
$methodProps = $phpcsFile->getMethodProperties( 
$stackPtr );
-   if ( !$methodProps['is_static'] ) {
+   if ( !$methodProps['is_static'] && 
!$methodProps['is_abstract'] ) {
$funcNamePtr = $phpcsFile->findNext( 
T_STRING, $stackPtr );
$this->eligableFunc = [
'name' => 
$tokens[$funcNamePtr]['content'],
diff --git a/MediaWiki/Tests/files/Usage/extend_class_usage.php 
b/MediaWiki/Tests/files/Usage/extend_class_usage.php
index 56fec82..194f704 100644
--- a/MediaWiki/Tests/files/Usage/extend_class_usage.php
+++ b/MediaWiki/Tests/files/Usage/extend_class_usage.php
@@ -72,7 +72,12 @@
}
 }
 
-class RequestTest extends ContextSource {
+abstract class RequestTest extends ContextSource {
+
+   /**
+* @return mixed
+*/
+   abstract public function abstractFunctionExample();
 
/**
 * @return object the request information.
diff --git a/MediaWiki/Tests/files/Usage/extend_class_usage.php.expect 
b/MediaWiki/Tests/files/Usage/extend_class_usage.php.expect
index 2faf03f..82aca99 100644
--- a/MediaWiki/Tests/files/Usage/extend_class_usage.php.expect
+++ b/MediaWiki/Tests/files/Usage/extend_class_usage.php.expect
@@ -7,7 +7,7 @@
 | | wfMessage() .
  64 | WARNING | Should use function $this->getUser() rather than
 | | variable $wgUser .
- 88 | WARNING | Should use function $this->getRequest() rather than
+ 93 | WARNING | Should use function $this->getRequest() rather than
 | | variable $wgRequest .
 --
 

-- 
To view, visit https://gerrit.wikimedia.org/r/330834
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica991cbe209e0d137d993ec677c15fc3e35430f6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Validate BlockID cookie before use

2017-01-03 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/330368 )

Change subject: Validate BlockID cookie before use
..

Validate BlockID cookie before use

This change adds a HMAC to the block-cookie to prevent someone
spoofing a cookie and so discovering revdeleted users.

Tests are updated, and a new test added (to demonstrate an
inauthentic HMAC).

Bug: T152951
Change-Id: I6a3ef9e91091408c25eaa2d36d58b365d681e8c6
---
M includes/Block.php
M includes/user/User.php
M tests/phpunit/includes/user/UserTest.php
3 files changed, 72 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/68/330368/1

diff --git a/includes/Block.php b/includes/Block.php
index 9d3a2f9..117d615 100644
--- a/includes/Block.php
+++ b/includes/Block.php
@@ -1467,12 +1467,44 @@
}
 
// Set the cookie. Reformat the MediaWiki datetime as a Unix 
timestamp for the cookie.
-   $cookieValue = $setEmpty ? '' : $this->getId();
+   $cookieValue = $setEmpty ? '' : $this->getCookieValue();
$expiryValue = DateTime::createFromFormat( "YmdHis", 
$expiryTime );
$response->setCookie( 'BlockID', $cookieValue, 
$expiryValue->format( "U" ) );
}
 
/**
+* Get the BlockID cookie's value for this block. This is the block ID 
concatenated with an
+* HMAC in order to avoid spoofing (T152951).
+* @return string The concatenation of the block ID, "!", and the HMAC.
+*/
+   public function getCookieValue() {
+   $config = RequestContext::getMain()->getConfig();
+   $id = $this->getId();
+   $hmac = MWCryptHash::hmac( $id, $config->get( 'SecretKey' ), 
false );
+   $cookieValue =  $id . '!' . $hmac;
+   return $cookieValue;
+   }
+
+   /**
+* Get the stored ID from the 'BlockID' cookie. The cookie's value is a 
combination of the ID
+* and a HMAC (see Block::setCookie), so here we check the authenticity 
of the code and return
+* null if it's invalid.
+* @return integer The block ID.
+*/
+   public static function getIdFromCookieValue( $cookieValue ) {
+   $bangPos = strpos( $cookieValue, '!' );
+   $id = substr( $cookieValue, 0, $bangPos );
+   $storedHmac = substr( $cookieValue, $bangPos + 1 );
+   $config = RequestContext::getMain()->getConfig();
+   $calculatedHmac = MWCryptHash::hmac( $id, $config->get( 
'SecretKey' ), false );
+   if ( $calculatedHmac === $storedHmac ) {
+   return $id;
+   } else {
+   return null;
+   }
+   }
+
+   /**
 * Get the key and parameters for the corresponding error message.
 *
 * @since 1.22
diff --git a/includes/user/User.php b/includes/user/User.php
index 562f0d1..3a2b050 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -1615,10 +1615,11 @@
$block = Block::newFromTarget( $this, $ip, !$bFromSlave );
 
// If no block has been found, check for a cookie indicating 
that the user is blocked.
-   $blockCookieVal = (int)$this->getRequest()->getCookie( 
'BlockID' );
-   if ( !$block instanceof Block && $blockCookieVal > 0 ) {
+   $blockCookieVal = $this->getRequest()->getCookie( 'BlockID' );
+   $blockCookieId = Block::getIdFromCookieValue( $blockCookieVal );
+   if ( !$block instanceof Block && $blockCookieId > 0 ) {
// Load the Block from the ID in the cookie.
-   $tmpBlock = Block::newFromID( $blockCookieVal );
+   $tmpBlock = Block::newFromID( $blockCookieId );
if ( $tmpBlock instanceof Block ) {
// Check the validity of the block.
$blockIsValid = $tmpBlock->getType() == 
Block::TYPE_USER
diff --git a/tests/phpunit/includes/user/UserTest.php 
b/tests/phpunit/includes/user/UserTest.php
index 5d9cda7..7090758 100644
--- a/tests/phpunit/includes/user/UserTest.php
+++ b/tests/phpunit/includes/user/UserTest.php
@@ -624,12 +624,13 @@
// Test for the desired cookie name, value, and expiry.
$cookies = $request1->response()->getCookies();
$this->assertArrayHasKey( 'wmsitetitleBlockID', $cookies );
-   $this->assertEquals( $block->getId(), 
$cookies['wmsitetitleBlockID']['value'] );
$this->assertEquals( $expiryFiveHours, 
$cookies['wmsitetitleBlockID']['expire'] );
+   $cookieValue = Block::getIdFromCookieValue( 
$cookies['wmsitetitleBlockID']['value'] );
+   $this->assertEquals( $block->getId(), $cookieValue );
 

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Add warnings for invalid parent or partner page titles

2016-12-20 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/328358 )

Change subject: Add warnings for invalid parent or partner page titles
..

Add warnings for invalid parent or partner page titles

This may still be less than intuitive for some types of input
to the parent or partner parser functions, but at least it gives
a clue and doesn't just fail miserably.

Change-Id: I2cfee41c1500ec40e3598f36377aaa1861cb247c
---
M src/Hooks.php
1 file changed, 13 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/58/328358/1

diff --git a/src/Hooks.php b/src/Hooks.php
index 211cd72..e22b84f 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -83,16 +83,25 @@
break;
case 'parent':
$parentTitle = Title::newFromText( $params[0] );
-   $parent = new Person( $parentTitle );
-   $out .= $parent->getWikiLink();
-   self::saveProp( $parser, 'parent', $params[0] );
+   if ( !$parentTitle instanceof Title ) {
+   $out .= "Invalid 
parent page title: '{$params[0]}'";
+   } else {
+   $parent = new Person( $parentTitle );
+   $out .= $parent->getWikiLink();
+   self::saveProp( $parser, 'parent', 
$params[0] );
+   }
break;
case 'siblings':
$person = new Person( $parser->getTitle() );
$out .= self::peopleList( $parser, 
$person->getSiblings() );
break;
case 'partner':
-   self::saveProp( $parser, 'partner', $params[0] 
);
+   $partnerTitle = Title::newFromText( $params[0] 
);
+   if ( !$partnerTitle instanceof Title ) {
+   $out .= "Invalid 
partner page title: '{$params[0]}'";
+   } else {
+   self::saveProp( $parser, 'partner', 
$params[0] );
+   }
break;
case 'partners':
$person = new Person( $parser->getTitle() );

-- 
To view, visit https://gerrit.wikimedia.org/r/328358
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cfee41c1500ec40e3598f36377aaa1861cb247c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Check for expiry dates in a 10-second window

2016-12-20 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/328354 )

Change subject: Check for expiry dates in a 10-second window
..

Check for expiry dates in a 10-second window

This changes the tests of expiry dates to be 10-second ranges,
to account for slow testing. For example, a test may start and
set the block's expiry in one second, but by the time it is
reading the value from that block's cookie it can sometimes be
the next second. Making it 10 seconds just gives it more room
for being slow.

Bug: T153527
Change-Id: I5efde7785134a75487d31ef3d8b7b14f53b7f5d0
---
M tests/phpunit/includes/user/UserTest.php
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/54/328354/1

diff --git a/tests/phpunit/includes/user/UserTest.php 
b/tests/phpunit/includes/user/UserTest.php
index 0819bf2..74cd846 100644
--- a/tests/phpunit/includes/user/UserTest.php
+++ b/tests/phpunit/includes/user/UserTest.php
@@ -726,7 +726,15 @@
$cookies = $request1->response()->getCookies();
// Calculate the expected cookie expiry date.
$this->assertArrayHasKey( 'wm_infinite_blockBlockID', $cookies 
);
-   $this->assertEquals( time() + $cookieExpiration, 
$cookies['wm_infinite_blockBlockID']['expire'] );
+   // Check for expiry dates in a 10-second window, to account for 
slow testing.
+   $this->assertGreaterThan(
+   time() + $cookieExpiration - 5,
+   $cookies['wm_infinite_blockBlockID']['expire']
+   );
+   $this->assertLessThan(
+   time() + $cookieExpiration + 5,
+   $cookies['wm_infinite_blockBlockID']['expire']
+   );
 
// 3. Change the block's expiry (to 2 days), and the cookie's 
should be changed also.
$newExpiry = time() + 2 * 24 * 60 * 60;
@@ -739,7 +747,9 @@
$user2->mBlock = $block;
$user2->load();
$cookies = $request2->response()->getCookies();
-   $this->assertEquals( $newExpiry, 
$cookies['wm_infinite_blockBlockID']['expire'] );
+   // Check for expiry dates in a 10-second window, to account for 
slow testing.
+   $this->assertGreaterThan( $newExpiry - 5, 
$cookies['wm_infinite_blockBlockID']['expire'] );
+   $this->assertLessThan( $newExpiry + 5, 
$cookies['wm_infinite_blockBlockID']['expire'] );
 
// Clean up.
$block->delete();

-- 
To view, visit https://gerrit.wikimedia.org/r/328354
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5efde7785134a75487d31ef3d8b7b14f53b7f5d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Default block-cookies to 24 hours only

2016-12-20 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/328353 )

Change subject: Default block-cookies to 24 hours only
..

Default block-cookies to 24 hours only

Rather than use wgCookieExpiration as the basis for the maximum
life of a block cookie, just use 1 day.

Tests have been updated also.

Bug: T153347
Change-Id: I3447d97af3170308834f365c5c600430f47c66a7
---
M includes/Block.php
M tests/phpunit/includes/user/UserTest.php
2 files changed, 19 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/53/328353/1

diff --git a/includes/Block.php b/includes/Block.php
index 792bcd9..20cb614 100644
--- a/includes/Block.php
+++ b/includes/Block.php
@@ -1446,8 +1446,7 @@
 
/**
 * Set the 'BlockID' cookie to this block's ID and expiry time. The 
cookie's expiry will be
-* the same as the block's, unless it's greater than 
$wgCookieExpiration in which case
-* $wgCookieExpiration will be used instead (defaults to 30 days).
+* the same as the block's, to a maximum of 24 hours.
 *
 * An empty value can also be set, in order to retain the cookie but 
remove the block ID
 * (e.g. as used in User::getBlockedStatus).
@@ -1457,18 +1456,18 @@
 */
public function setCookie( WebResponse $response, $setEmpty = false ) {
// Calculate the default expiry time.
-   $config = RequestContext::getMain()->getConfig();
-   $defaultExpiry = wfTimestamp() + $config->get( 
'CookieExpiration' );
+   $maxExpiryTime = wfTimestamp( TS_MW, wfTimestamp() + ( 24 * 60 
* 60 ) );
 
// Use the Block's expiry time only if it's less than the 
default.
-   $expiry = wfTimestamp( TS_UNIX, $this->getExpiry() );
-   if ( $expiry > $defaultExpiry ) {
-   // The *default* default expiry is 30 days.
-   $expiry = $defaultExpiry;
+   $expiryTime = $this->getExpiry();
+   if ( $expiryTime === 'infinity' || $expiryTime > $maxExpiryTime 
) {
+   $expiryTime = $maxExpiryTime;
}
 
+   // Set the cookie. Reformat the MediaWiki datetime as a Unix 
timestamp for the cookie.
$cookieValue = $setEmpty ? '' : $this->getId();
-   $response->setCookie( 'BlockID', $cookieValue, $expiry );
+   $expiryValue = DateTime::createFromFormat( "YmdHis", 
$expiryTime );
+   $response->setCookie( 'BlockID', $cookieValue, 
$expiryValue->format( "U" ) );
}
 
/**
diff --git a/tests/phpunit/includes/user/UserTest.php 
b/tests/phpunit/includes/user/UserTest.php
index 0819bf2..70142aa 100644
--- a/tests/phpunit/includes/user/UserTest.php
+++ b/tests/phpunit/includes/user/UserTest.php
@@ -603,10 +603,10 @@
$user1tmp = $this->getTestUser()->getUser();
$request1 = new FauxRequest();
$request1->getSession()->setUser( $user1tmp );
-   $expiryFiveDays = time() + ( 5 * 24 * 60 * 60 );
+   $expiryFiveHours = wfTimestamp() + ( 5 * 60 * 60 );
$block = new Block( [
'enableAutoblock' => true,
-   'expiry' => wfTimestamp( TS_MW, $expiryFiveDays ),
+   'expiry' => wfTimestamp( TS_MW, $expiryFiveHours ),
] );
$block->setTarget( $user1tmp );
$block->insert();
@@ -625,7 +625,7 @@
$cookies = $request1->response()->getCookies();
$this->assertArrayHasKey( 'wmsitetitleBlockID', $cookies );
$this->assertEquals( $block->getId(), 
$cookies['wmsitetitleBlockID']['value'] );
-   $this->assertEquals( $expiryFiveDays, 
$cookies['wmsitetitleBlockID']['expire'] );
+   $this->assertEquals( $expiryFiveHours, 
$cookies['wmsitetitleBlockID']['expire'] );
 
// 2. Create a new request, set the cookies, and see if the 
(anon) user is blocked.
$request2 = new FauxRequest();
@@ -696,14 +696,12 @@
 
/**
 * When a user is autoblocked and a cookie is set to track them, the 
expiry time of the cookie
-* should match the block's expiry. If the block is infinite, the 
cookie expiry time should
-* match $wgCookieExpiration. If the expiry time is changed, the 
cookie's should change with it.
+* should match the block's expiry, to a maximum of 24 hours. If the 
expiry time is changed,
+* the cookie's should change with it.
 */
public function testAutoblockCookieInfiniteExpiry() {
-   $cookieExpiration = 20 * 24 * 60 * 60; // 20 days
$this->setMwGlobals( [
'wgCookieSetOnAutoblock' => true,
-   

[MediaWiki-commits] [Gerrit] mediawiki...PageAssessments[master]: Re-index the array of excluded namespace IDs

2016-12-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/327141 )

Change subject: Re-index the array of excluded namespace IDs
..

Re-index the array of excluded namespace IDs

The NamespaceInputWidget expects an array of IDs to exclude, but
was being passed an object. This is fixed by reindexing the
array that's passed to it, meaning that JS can treat it as an
array.

Bug: T153165
Change-Id: Idb24ca0e470699f4347936db3903fe2ccc1297c6
---
M src/NamespaceSelect.php
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageAssessments 
refs/changes/41/327141/1

diff --git a/src/NamespaceSelect.php b/src/NamespaceSelect.php
index 49a09b4..ccab095 100644
--- a/src/NamespaceSelect.php
+++ b/src/NamespaceSelect.php
@@ -21,9 +21,9 @@
 */
public function getInputOOUI( $value ) {
$nsIds = array_keys( MWNamespace::getCanonicalNamespaces() );
-   $excludedNsIds = array_filter( $nsIds, function( $ns ) {
+   $excludedNsIds = array_keys( array_filter( $nsIds, function( 
$ns ) {
return MWNamespace::isTalk( $ns );
-   } );
+   } ) );
$widget = new NamespaceInputWidget( [
'value' => $value,
'name' => $this->mName,

-- 
To view, visit https://gerrit.wikimedia.org/r/327141
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb24ca0e470699f4347936db3903fe2ccc1297c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageAssessments
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...PageAssessments[master]: Add autocompletion to search fields

2016-12-12 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/326894 )

Change subject: Add autocompletion to search fields
..

Add autocompletion to search fields

Add autocompletion (using jquery.suggestions) to the Project and
Page search fields on the PageAssessments special page.

Change-Id: I7871b83aed492292392a5c3d008c9f82e50eed86
---
M extension.json
A modules/ext.pageassessments.js
M src/NamespaceSelect.php
M src/SpecialPage.php
4 files changed, 43 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageAssessments 
refs/changes/94/326894/1

diff --git a/extension.json b/extension.json
index 015c803..fbc9179 100644
--- a/extension.json
+++ b/extension.json
@@ -51,6 +51,12 @@
"localBasePath": "",
"remoteExtPath": "examples/PageAssessments"
},
+   "ResourceModules": {
+   "ext.pageassessments": {
+   "scripts": "modules/ext.pageassessments.js",
+   "dependencies": "jquery.suggestions"
+   }
+   },
"SpecialPages": {
"PageAssessments": "PageAssessments\\SpecialPage"
},
diff --git a/modules/ext.pageassessments.js b/modules/ext.pageassessments.js
new file mode 100644
index 000..c3402aa
--- /dev/null
+++ b/modules/ext.pageassessments.js
@@ -0,0 +1,30 @@
+( function ( $, mw, OO ) {
+
+   var config = {
+
+   fetch: function ( userInput, response, maxRows ) {
+   var node = this[ 0 ],
+   namespace = OO.ui.infuse( 
'pageassessments-namespace' ),
+   api = api || new mw.Api();
+   $.data( node, 'request', api.get( {
+   action: 'opensearch',
+   namespace: namespace.getValue(),
+   search: userInput
+   } ).done( function ( data ) {
+   response( data[ 1 ] );
+   } ) );
+   },
+
+   cancel: function () {
+   var node = this[ 0 ],
+   request = $.data( node, 'request' );
+   if ( request ) {
+   request.abort();
+   $.removeData( node, 'request' );
+   }
+   }
+   };
+
+   $( 'input[name="page_title"]' ).suggestions( config );
+
+} )( jQuery, mediaWiki, OO );
diff --git a/src/NamespaceSelect.php b/src/NamespaceSelect.php
index 49a09b4..864fac3 100644
--- a/src/NamespaceSelect.php
+++ b/src/NamespaceSelect.php
@@ -21,9 +21,9 @@
 */
public function getInputOOUI( $value ) {
$nsIds = array_keys( MWNamespace::getCanonicalNamespaces() );
-   $excludedNsIds = array_filter( $nsIds, function( $ns ) {
+   $excludedNsIds = array_values( array_filter( $nsIds, function( 
$ns ) {
return MWNamespace::isTalk( $ns );
-   } );
+   } ) );
$widget = new NamespaceInputWidget( [
'value' => $value,
'name' => $this->mName,
diff --git a/src/SpecialPage.php b/src/SpecialPage.php
index 692c857..70da1a1 100644
--- a/src/SpecialPage.php
+++ b/src/SpecialPage.php
@@ -3,6 +3,7 @@
 namespace PageAssessments;
 
 use Html;
+use HTMLComboboxField;
 use HTMLForm;
 use HTMLTextField;
 use IDatabase;
@@ -259,18 +260,22 @@
 * @return HTMLForm
 */
protected function getForm() {
+   $this->getOutput()->addModules( 'ext.pageassessments' );
$formDescriptor = [
'project' => [
+   'id' => 'pageassessments-project',
'class' => HTMLTextField::class,
'name' => 'project',
'label-message' => 'pageassessments-project',
],
'namespace' => [
+   'id' => 'pageassessments-namespace',
'class' => NamespaceSelect::class,
'name' => 'namespace',
'label-message' => 
'pageassessments-page-namespace',
],
'page_title' => [
+   'id' => 'pageassessments-page-title',
'class' => HTMLTextField::class,
'name' => 'page_title',
'label-message' => 'pageassessments-page-title',

-- 
To view, visit https://gerrit.wikimedia.org/r/326894
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: 

[MediaWiki-commits] [Gerrit] mediawiki...PageAssessments[master]: Switch special page to be a QueryPage rather than using an I...

2016-12-11 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/326389 )

Change subject: Switch special page to be a QueryPage rather than using an 
IndexPager
..

Switch special page to be a QueryPage rather than using an IndexPager

Because the page_assessments table has a multi-column PK, IndexPager
doesn't have a field to sort by. So we switch to making the special
page a subclass of QueryPage instead. This makes pagination much easier
but with the downside of there being no pre-built sortable column
headers. So, we borrow the TablePager CSS for this.

The search query parameters remain the same ('project', 'page_title',
'namespace', and 'sort'), but the sort direction changes to 'dir'.

Bug: T152756
Change-Id: I6b70f42a30b4e1a0a4c6ff86986c835b96afeecd
---
D src/Pager.php
M src/SpecialPage.php
2 files changed, 182 insertions(+), 164 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageAssessments 
refs/changes/89/326389/1

diff --git a/src/Pager.php b/src/Pager.php
deleted file mode 100644
index 5a4eb09..000
--- a/src/Pager.php
+++ /dev/null
@@ -1,148 +0,0 @@
- [ 'page_assessments', 
'page_assessments_projects', 'page', 'revision' ],
-   'fields' => [
-   'project' => 'pap_project_title',
-   'class' => 'pa_class',
-   'importance' => 'pa_importance',
-   'timestamp' => 'rev_timestamp',
-   'page_title' => 'page_title',
-   'page_revision' => 'pa_page_revision',
-   'page_namespace' => 'page_namespace',
-   ],
-   'conds' => [],
-   'options' => [],
-   'join_conds' => [
-   'page_assessments_projects' => [ 'JOIN', 
'pa_project_id = pap_project_id' ],
-   'page' => [ 'JOIN', 'pa_page_id = page_id' ],
-   'revision' => [ 'JOIN', 'page_id = rev_page AND 
pa_page_revision = rev_id' ],
-   ],
-   ];
-   // Project.
-   $project = $this->getRequest()->getVal( 'project', false );
-   if ( !empty( $project ) ) {
-   $info['conds']['pap_project_title'] = $project;
-   }
-   // Namespace (if its set, it's either an integer >= 0, 'all', 
or the empty string).
-   $namespace = $this->getRequest()->getVal( 'namespace', false );
-   if ( $namespace !== 'all' && $namespace !== '' ) {
-   $info['conds']['page_namespace'] = $namespace;
-   }
-   $pageTitle = $this->getRequest()->getVal( 'page_title', false );
-   if ( !empty( $pageTitle ) ) {
-   $title = Title::newFromText( $pageTitle )->getDBkey();
-   $info['conds']['page_title'] = $title;
-   }
-   return $info;
-   }
-
-   /**
-* Should the table be sortable? It's not when transcluded.
-* @param boolean $sortable Whether to sort or not.
-*/
-   public function setSortable( $sortable ) {
-   $this->sortable = (bool)$sortable;
-   }
-
-   /**
-* Return true if the named field should be sortable by the UI, false 
otherwise.
-* @param string $field The field in question; matches one returned by 
self::getFieldNames().
-* @return boolean
-*/
-   public function isFieldSortable( $field ) {
-   // Done enable sorting for transcluded pagers, because the 
sorting links will not be to
-   // the current page.
-   if ( $this->sortable === false ) {
-   // Strict check, to avoid false negative when this 
method is used in parent::__construct
-   return false;
-   }
-   $sortable = [
-   'project',
-   'page',
-   'timestamp',
-   ];
-   return in_array( $field, $sortable );
-   }
-
-   /**
-* Format a table cell. The return value should be HTML, but use an 
empty
-* string not  for empty cells. Do not include the  and .
-*
-* The current result row is available as $this->mCurrentRow, in case 
you
-* need more context.
-*
-* @param string $name The database field name
-* @param string $value The value retrieved from the database
-* @return string
-*/
-   public function formatValue( $name, $value ) {
-   $renderer = MediaWikiServices::getInstance()->getLinkRenderer();
-   $pageTitle = Title::newFromText(
-   

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Fix composer validation errors

2016-12-05 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/325518

Change subject: Fix composer validation errors
..

Fix composer validation errors

Change-Id: If9776143ca05a0fd55dea48958818e5a650f2e5d
---
M composer.json
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/18/325518/1

diff --git a/composer.json b/composer.json
index 28a89ae..8115995 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,6 @@
 {
-   "name": "samwilson/mediawiki-extensions-Genealogy",
+   "name": "samwilson/mediawiki-extensions-genealogy",
+   "description": "A MediaWiki extension that adds a parser function to 
assist with linking between genealogical records",
"type": "mediawiki-extension",
"license": "GPL-3.0+",
"keywords": ["genealogy", "family history", "MediaWiki"],

-- 
To view, visit https://gerrit.wikimedia.org/r/325518
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If9776143ca05a0fd55dea48958818e5a650f2e5d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Change vendor name

2016-12-05 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/325517

Change subject: Change vendor name
..

Change vendor name

Change-Id: I36d09ad644ce726f1c1cf715fda6bbe3c90f0c36
---
M composer.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/17/325517/1

diff --git a/composer.json b/composer.json
index 131691b..28a89ae 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,5 @@
 {
-   "name": "wikimedia/mediawiki-extensions-Genealogy",
+   "name": "samwilson/mediawiki-extensions-Genealogy",
"type": "mediawiki-extension",
"license": "GPL-3.0+",
"keywords": ["genealogy", "family history", "MediaWiki"],

-- 
To view, visit https://gerrit.wikimedia.org/r/325517
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I36d09ad644ce726f1c1cf715fda6bbe3c90f0c36
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...PageAssessments[master]: Add new special page for searching assessments

2016-11-30 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324657

Change subject: Add new special page for searching assessments
..

Add new special page for searching assessments

This adds Special:PageAssessments with a basic search form
and results table. The special page can also be transcluded,
in which case the search form isn't shown (all search and sort
parameters must be provided in the transclusion).

Bug: T120407
Change-Id: I6ee898059ffc62bb5f2788ad83a49b650cdb1335
---
M extension.json
M i18n/en.json
M i18n/qqq.json
A src/NamespaceSelect.php
A src/Pager.php
A src/SpecialPage.php
6 files changed, 304 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageAssessments 
refs/changes/57/324657/1

diff --git a/extension.json b/extension.json
index 49a9529..bd8ccd7 100644
--- a/extension.json
+++ b/extension.json
@@ -19,7 +19,10 @@
"PageAssessmentsHooks": "PageAssessments.hooks.php",
"PageAssessmentsBody": "PageAssessmentsBody.php",
"ApiQueryPageAssessments": "api/ApiQueryPageAssessments.php",
-   "ApiQueryProjectPages": "api/ApiQueryProjectPages.php"
+   "ApiQueryProjectPages": "api/ApiQueryProjectPages.php",
+   "PageAssessments\\SpecialPage": "src/SpecialPage.php",
+   "PageAssessments\\Pager": "src/Pager.php",
+   "PageAssessments\\NamespaceSelect": "src/NamespaceSelect.php"
},
"ExtensionMessagesFiles": {
"PageAssessmentsMagic": "PageAssessments.i18n.magic.php"
@@ -47,6 +50,9 @@
"localBasePath": "",
"remoteExtPath": "examples/PageAssessments"
},
+   "SpecialPages": {
+   "PageAssessments": "PageAssessments\\SpecialPage"
+   },
"config": {
"PageAssessmentsOnTalkPages": true
},
diff --git a/i18n/en.json b/i18n/en.json
index f5a0313..2125fc9 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -16,5 +16,13 @@
"apihelp-query+projectpages-param-limit": "The maximum number of pages 
to return.",
"apihelp-query+projectpages-example-simple-1": "Get first 10 pages 
associated with any WikiProject.",
"apihelp-query+projectpages-example-simple-2": "Get first 10 pages 
associated with WikiProject Medicine, including assessment data.",
-   "apihelp-query+projectpages-example-generator": "Get page info for 
first 10 pages associated with WikiProject Textile Arts."
+   "apihelp-query+projectpages-example-generator": "Get page info for 
first 10 pages associated with WikiProject Textile Arts.",
+   "pageassessments-special": "Page assessments",
+   "pageassessments-project": "Project",
+   "pageassessments-page-namespace": "Page namespace",
+   "pageassessments-page-title": "Page title",
+   "pageassessments-search": "Search",
+   "pageassessments-importance": "Importance",
+   "pageassessments-class": "Class",
+   "pageassessments-timestamp": "Timestamp"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 6caf8ec..def5a22 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -16,5 +16,14 @@
"apihelp-query+projectpages-param-limit": 
"{{doc-apihelp-param|query+projectpages|limit}}",
"apihelp-query+projectpages-example-simple-1": 
"{{doc-apihelp-example|query+projectpages}}",
"apihelp-query+projectpages-example-simple-2": 
"{{doc-apihelp-example|query+projectpages}}",
-   "apihelp-query+projectpages-example-generator": 
"{{doc-apihelp-example|query+projectpages}}"
+   "apihelp-query+projectpages-example-generator": 
"{{doc-apihelp-example|query+projectpages}}",
+   "pageassessments-special": "Name of the Special page",
+   "pageassessments-project": "Form label for the WikiProject search field 
and the results table column header",
+   "pageassessments-page-namespace": "Form label for the page namespace 
dropdown select field",
+   "pageassessments-page-title": "Form label for the page title search 
field and the results table column header",
+   "pageassessments-search": "Search form submit button label",
+   "pageassessments-importance": "Label for the search form and the 
results table column header",
+   "pageassessments-class": "Label for the search form and the results 
table column header",
+   "pageassessments-timestamp": "Label for the search form and the results 
table column header"
+
 }
diff --git a/src/NamespaceSelect.php b/src/NamespaceSelect.php
new file mode 100644
index 000..49a09b4
--- /dev/null
+++ b/src/NamespaceSelect.php
@@ -0,0 +1,37 @@
+ $value,
+   'name' => $this->mName,
+   'id' => $this->mID,
+   'includeAllValue' => $this->mAllValue,
+   'exclude' => $excludedNsIds,
+   ] );
+   return $widget;
+

[MediaWiki-commits] [Gerrit] mediawiki...codesniffer[master]: Return earlier when testing scope fields

2016-11-29 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324376

Change subject: Return earlier when testing scope fields
..

Return earlier when testing scope fields

This rearranges when some fields of tokens are checked, to
avoid undefined index errors by returning earlier than was
the case.

Bug: T146439
Change-Id: I1be4e021e559b2a5efd1c1361a8b574e076e11dc
---
M MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
M MediaWiki/Sniffs/WhiteSpace/SpaceBeforeControlStructureBraceSniff.php
2 files changed, 12 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer 
refs/changes/76/324376/1

diff --git a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php 
b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
index f988be4..132f445 100644
--- a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
+++ b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
@@ -101,11 +101,11 @@
$tokens = $phpcsFile->getTokens();
// Skip constructor and destructor.
$methodName = $phpcsFile->getDeclarationName( $stackPtr );
-   $endFunction = $tokens[$stackPtr]['scope_closer'];
// Return if no scope_opener.
if ( !isset( $tokens[$stackPtr]['scope_opener'] ) ) {
return;
}
+   $endFunction = $tokens[$stackPtr]['scope_closer'];
$returnToken = $phpcsFile->findNext( T_RETURN, $stackPtr + 1, 
$endFunction );
// Return if the function has no return.
if ( $returnToken === false ) {
diff --git 
a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeControlStructureBraceSniff.php 
b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeControlStructureBraceSniff.php
index 834bb5e..0523c24 100644
--- a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeControlStructureBraceSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeControlStructureBraceSniff.php
@@ -33,24 +33,25 @@
 */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
-   $closeBracket = $tokens[$stackPtr + 2]['parenthesis_closer'];
-   $openBrace = $tokens[$stackPtr]['scope_opener'];
-   $closeBracketLine = $tokens[$closeBracket]['line'];
-   $openBraceLine = $tokens[$openBrace]['line'];
-   $lineDifference = ( $openBraceLine - $closeBracketLine );
-   if ( isset( $tokens[$stackPtr]['scope_opener'] ) == false ||
-   $tokens[$stackPtr]['scope_opener'] === false ||
-   $tokens[$openBrace]['content'] !== '{'
-   ) {
+   if ( !isset( $tokens[$stackPtr]['scope_opener'] ) ||
+   $tokens[$stackPtr]['scope_opener'] === false ) {
return;
}
-
+   $openBrace = $tokens[$stackPtr]['scope_opener'];
+   if ( $tokens[$openBrace]['content'] !== '{' ) {
+   return;
+   }
if ( $tokens[$stackPtr + 1]['code'] !== T_WHITESPACE
|| $tokens[$stackPtr + 2]['code'] !== T_OPEN_PARENTHESIS
|| $tokens[$stackPtr + 2]['parenthesis_closer'] === null
) {
return;
}
+
+   $closeBracket = $tokens[$stackPtr + 2]['parenthesis_closer'];
+   $closeBracketLine = $tokens[$closeBracket]['line'];
+   $openBraceLine = $tokens[$openBrace]['line'];
+   $lineDifference = ( $openBraceLine - $closeBracketLine );
if ( $lineDifference > 0 ) {
// if brace on new line
$this->processLineDiff( $phpcsFile, $openBrace, 
$closeBracket, $stackPtr );

-- 
To view, visit https://gerrit.wikimedia.org/r/324376
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1be4e021e559b2a5efd1c1361a8b574e076e11dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Add i18n translation descriptions and clean up date display

2016-11-24 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/323499

Change subject: Add i18n translation descriptions and clean up date display
..

Add i18n translation descriptions and clean up date display

The date display wasn't taking into account i18n, so now the years
have been moved in to become parameters for the i18n messages.

No bug in Phabricator.

Change-Id: I81545688cac514ca7f72e767fe4212de4f828cc6
---
D Genealogy.i18n.php
M i18n/en.json
A i18n/qqq.json
M src/Hooks.php
M src/Person.php
5 files changed, 37 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/99/323499/1

diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
deleted file mode 100644
index 9d63d97..000
--- a/Genealogy.i18n.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- */
-$messages['en'] = [
-   'genealogy' => 'Genealogy',
-   'genealogy-desc' => 'Adds a parser function for easier linking between 
genealogical records',
-   'genealogy-born' => 'b.',
-   'genealogy-died' => 'd.',
-   'genealogy-ancestor' => 'Ancestor',
-   'genealogy-ancestors' => 'Ancestors',
-   'genealogy-descendant' => 'Descendant',
-   'genealogy-descendants' => 'Descendants',
-   'genealogy-person-preload' => 'Template:Person/preload',
-   'genealogy-parser-function-not-found' => 'Genealogy parser function 
type not recognised: $1',
-   'genealogy-existing-partners' => 'This person already has the following 
'
-   .'{{PLURAL:$1|partner|partners}}: ',
-   'genealogy-person-list-item' => 'Person/list-item'
-];
diff --git a/i18n/en.json b/i18n/en.json
index 4db81df..246130e 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -6,14 +6,15 @@
},
"genealogy": "Genealogy",
"genealogy-desc": "Adds a parser function for easier linking between 
genealogical records",
-   "genealogy-born": "b.",
-   "genealogy-died": "d.",
+   "genealogy-born": "(b.$1)",
+   "genealogy-died": "(d.$1)",
+   "genealogy-born-and-died": "($1$2)",
"genealogy-ancestor": "Ancestor",
"genealogy-ancestors": "Ancestors",
"genealogy-descendant": "Descendant",
"genealogy-descendants": "Descendants",
"genealogy-person-preload": "Template:Person/preload",
+   "genealogy-person-list-item": "Template:Person/list-item",
"genealogy-parser-function-not-found": "Genealogy parser function type 
not recognised: $1",
-   "genealogy-existing-partners": "This person already has the following 
{{PLURAL:$1|partner|partners}}: ",
-   "genealogy-person-list-item": "Person/list-item"
+   "genealogy-existing-partners": "This person already has the following 
{{PLURAL:$1|partner|partners}}: "
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 000..3206ebe
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,20 @@
+{
+   "@metadata": {
+   "authors": [
+   "Sam Wilson "
+   ]
+   },
+   "genealogy": "The extension title",
+   "genealogy-desc": 
"{{desc|name=Genealogy|url=https://www.mediawiki.org/wiki/Extension:Genealogy}};,
+   "genealogy-born": "The parenthetic abbreviation showing the year of 
birth.",
+   "genealogy-died": "The parenthetic abbreviation showing the year of 
death.",
+   "genealogy-born-and-died": "The parenthetic abbreviation showing both 
the year of birth and year of death.",
+   "genealogy-ancestor": "A singular noun referring to any parent, 
grandparent, etc. of a given person.",
+   "genealogy-ancestors": "A plural noun referring to all parents, 
grandparents, etc. of a given person.",
+   "genealogy-descendant": "A singular noun referring to any child, 
grandchild, etc. of a given person.",
+   "genealogy-descendants": "A plural noun referring to all children, 
grandchildren, etc. of a given person.",
+   "genealogy-person-preload": "A name of the MediaWiki page that contains 
the text that is preloaded when a new Person page is created.",
+   "genealogy-person-list-item": "The template that will be used (if it 
exists) to format each item in any list of people.",
+   "genealogy-parser-function-not-found": "The error message shown when 
the parser function is passed something it doesn't recognise.",
+   "genealogy-existing-partners": "The message that is shown above the 
page-editing form, alerting the user to the fact that the person they're 
editing has already got a defined partner from another page."
+}
diff --git a/src/Hooks.php b/src/Hooks.php
index b322f89..211cd72 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -166,9 +166,9 @@
$out = '';
$index = 1;
$peopleCount = count( $people );
+   $templateExists = Title::newFromText( $templateName->toString() 
)->exists();
 

[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: Make Special:IndexPages transcludable and with parameters

2016-11-23 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/323372

Change subject: Make Special:IndexPages transcludable and with parameters
..

Make Special:IndexPages transcludable and with parameters

The Index page search results can now be transcluded, with three
optional parameters:
* key -- the search term
* order -- whether to order by 'quality', 'size', or 'alpha'
* sortascending -- to reverse the normal sort direction

Bug: T114346
Change-Id: I7636ee00929c4177745fb3dad6cf0d48cf0d88de
---
M SpecialProofreadPages.php
1 file changed, 38 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/72/323372/1

diff --git a/SpecialProofreadPages.php b/SpecialProofreadPages.php
index 2d27998..a457d61 100644
--- a/SpecialProofreadPages.php
+++ b/SpecialProofreadPages.php
@@ -24,10 +24,11 @@
 
public function __construct( $name = 'IndexPages' ) {
parent::__construct( $name );
+   $this->mIncludable = true;
}
 
public function execute( $parameters ) {
-   global $wgDisableTextSearch, $wgScript;
+   global $wgDisableTextSearch;
 
$this->setHeaders();
if ( $this->limit == 0 && $this->offset == 0 ) {
@@ -45,29 +46,12 @@
$this->suppressSqlOffset = false;
 
if ( !$wgDisableTextSearch ) {
-   $orderSelect = new XmlSelect( 'order', 'order', 
$this->queryOrder );
-   $orderSelect->addOption( $this->msg( 
'proofreadpage_index_status' )->text(), 'quality' );
-   $orderSelect->addOption( $this->msg( 
'proofreadpage_index_size' )->text(), 'size' );
-   $orderSelect->addOption( $this->msg( 
'proofreadpage_alphabeticalorder' )->text(), 'alpha' );
 
-   $output->addHTML(
-   Html::openElement( 'form', [ 'action' => 
$wgScript ] ) .
-   Html::hidden( 'title', 
$this->getPageTitle()->getPrefixedText() ) .
-   Html::input( 'limit', $this->limit, 'hidden', 
[] ) .
-   Html::openElement( 'fieldset', [] ) .
-   Html::element( 'legend', null, $this->msg( 
'proofreadpage_specialpage_legend' )->text() ) .
-   Html::openElement( 'p' ) .
-   Html::element( 'label', [ 'for' => 'key' ], 
$this->msg( 'proofreadpage_specialpage_label_key' )->text() )  . ' ' .
-   Html::input( 'key', $this->searchTerm, 
'search', [ 'id' => 'key', 'size' => '50' ] ) .
-   Html::closeElement( 'p' ) .
-   Html::openElement( 'p' ) .
-   Html::element( 'label', [ 'for' => 'order' ], 
$this->msg( 'proofreadpage_specialpage_label_orderby' )->text() ) . ' ' . 
$orderSelect->getHtml() . ' ' .
-   Xml::checkLabel( $this->msg( 
'proofreadpage_specialpage_label_sortascending' )->text(), 'sortascending', 
'sortascending', $this->sortAscending ) . ' ' .
-   Xml::submitButton( $this->msg( 'ilsubmit' 
)->text() ) .
-   Html::closeElement( 'p' ) .
-   Html::closeElement( 'fieldset' ) .
-   Html::closeElement( 'form' )
-   );
+   if ( !$this->including() ) {
+   // Only show the search form when not including 
in another page.
+   $output->addHTML( $this->getSearchForm() );
+   }
+
if ( $this->searchTerm ) {
$indexNamespaceId = 
ProofreadPage::getIndexNamespaceId();
$searchEngine = SearchEngine::create();
@@ -145,6 +129,37 @@
];
}
 
+   /**
+* Get the HTML of the search form.
+* @return string The HTML, with the  as the outermost element.
+*/
+   protected function getSearchForm() {
+   $config = RequestContext::getMain()->getConfig();
+
+   $orderSelect = new XmlSelect( 'order', 'order', 
$this->queryOrder );
+   $orderSelect->addOption( $this->msg( 
'proofreadpage_index_status' )->text(), 'quality' );
+   $orderSelect->addOption( $this->msg( 'proofreadpage_index_size' 
)->text(), 'size' );
+   $orderSelect->addOption( $this->msg( 
'proofreadpage_alphabeticalorder' )->text(), 'alpha' );
+
+   $searchForm = Html::openElement( 'form', [ 'action' => 
$config->get( 'Script' ) ] ) .
+   Html::hidden( 'title', 
$this->getPageTitle()->getPrefixedText() ) .
+   Html::input( 'limit', 

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Don't worry about recursive redirects, just use one

2016-11-22 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/322848

Change subject: Don't worry about recursive redirects, just use one
..

Don't worry about recursive redirects, just use one

The Person's title was following any number of redirects, but as
this optimisation is already done in the database it's not
required.

Change-Id: I5a598cc4e71a6d27c64fafae8cc2c0d881d39aeb
---
M src/Person.php
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/48/322848/1

diff --git a/src/Person.php b/src/Person.php
index 8dfbb51..a794c05 100644
--- a/src/Person.php
+++ b/src/Person.php
@@ -51,8 +51,8 @@
 */
public function getTitle() {
$page = WikiPage::factory( $this->title );
-   while ( $page->isRedirect() ) {
-   $page = WikiPage::factory( $page->getRedirectTarget() );
+   if ( $page->isRedirect() ) {
+   return $page->getRedirectTarget();
}
return $page->getTitle();
}

-- 
To view, visit https://gerrit.wikimedia.org/r/322848
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a598cc4e71a6d27c64fafae8cc2c0d881d39aeb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...GraphViz[master]: Prevent double-encoding of URLs that were output by the 'dot...

2016-11-22 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/322834

Change subject: Prevent double-encoding of URLs that were output by the 'dot' 
command
..

Prevent double-encoding of URLs that were output by the 'dot' command

The output of 'dot -Tcmapx' encodes HTML entities in URLs, and because
this is passed straight to ImageMap::render (which then also encodes
these entities) the final output is double-encoded.

This change fixes this for non-mscgen renderers (i.e. only GraphViz).

Bug: T151294
Change-Id: I31851bfd3a08420eac8b33efd303fb6520370f30
---
M GraphViz_body.php
1 file changed, 10 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GraphViz 
refs/changes/34/322834/1

diff --git a/GraphViz_body.php b/GraphViz_body.php
index c27134c..17df423 100644
--- a/GraphViz_body.php
+++ b/GraphViz_body.php
@@ -1548,6 +1548,16 @@
'href="[$1 $2]"',
$map );
 
+   // Decode character references in URLs because 
the map file output by GraphViz
+   // has already encoded them and we want to pass 
them to ImageMap::render
+   // unencoded.
+   $hrefPattern = '~href="([^"]+)"~';
+   preg_match( $hrefPattern, $map, $matches );
+   if ( isset( $matches[1] ) ) {
+   $decodedHref = 
Sanitizer::decodeCharReferences( $matches[1] );
+   $map = preg_replace( $hrefPattern, 
"href=\"$decodedHref\"", $map );
+   }
+
// reorder map lines to the pattern shape name, 
coordinates, URL
$map = preg_replace( 
'~.+shape="([^"]+).+href="([^"]+).+coords="([^"]+).+~',
'$1 $3 $2',

-- 
To view, visit https://gerrit.wikimedia.org/r/322834
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I31851bfd3a08420eac8b33efd303fb6520370f30
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GraphViz
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Fix hooks, DB usage, etc.

2016-11-21 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/322631

Change subject: Fix hooks, DB usage, etc.
..

Fix hooks, DB usage, etc.

Move all documentation to mediawiki.org, remove redundant unit test
hook, fix the pre-edit-form display hook (removing evil global),
properly output messages, and fix LIKE database clauses.

Change-Id: I4f4ce9ca012eaf29fd8103983ac1a0fa85f55e27
---
M README.md
M extension.json
M src/Hooks.php
M src/Person.php
4 files changed, 19 insertions(+), 114 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/31/322631/1

diff --git a/README.md b/README.md
index 56cfd9e..75ac6c3 100644
--- a/README.md
+++ b/README.md
@@ -2,81 +2,3 @@
 =
 
 All details: https://mediawiki.org/wiki/Extension:Genealogy
-
-
-## Usage summary
-
-This extension creates one parser function: `{{#genealogy: … }}`.
-Its first first parameter is unnamed (i.e. doesn't have an equals sign) but 
all others are.
-
-The following parameters are supported, two for defining data and four for 
reporting data:
-
-2. Define and output a link to a parent:
-   `{{#genealogy:parent | Page Name Here }}`
-3. Define a partner (no output produced; use `partners` to list):
-   `{{#genealogy:partner | Page Name Here |start date=Y-m-d |end date=Y-m-d }}`
-4. List all siblings:
-   `{{#genealogy:siblings}}`
-5. List all partners:
-   `{{#genealogy:partners}}`
-6. List all children:
-   `{{#genealogy:children}}`
-7. Display a tree (a connected graph):
-   `{{#genealogy:tree|ancestors=List|descendants=List}}`
-   where each `List` is a newline-separated list of page titles.
-
-
-## Templates
-
-**Example:**
-For an example template that makes use of these parser functions, see 
`person_template.wikitext`.
-
-**Preload:**
-When this extension creates a link to a page that doesn't yet exist,
-the text of `[[Template:Person/preload]]` is preloaded.
-The location of this preload text can be customised
-by modifying the `genealogy-person-preload` system message.
-
-**Person list-item:**
-Three types of lists of people can be generated: `siblings`, `partners`, and 
`children`.
-The default behaviour is a simple bulleted list,
-but this can be overridden by a template, `Template:Person/list-item`
-(the template name is specified by the `genealogy-person-list-item` system 
message).
-For example, to get a comma-separated one-line list of people, the following 
template code could be used:
-
-```
-{{{link}}}{{#ifeq:{{{index}}}|{{{count}}}|.|,}}
-```
-
-There are four parameters that are available for use in the list-item template:
-* `link` — A wikitext link.
-* `title` — The page title.
-* `index` — The index of this list-item in the full list, starting from 1. 
-* `count` — The total number of items in the full list.
-
-
-## Installation
-
-1. Clone the *Genealogy* and *GraphViz* extensions into your extensions 
directory:
-   ```
-   $ cd extensions
-   $ git clone 
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/GraphViz.git
-   $ git clone 
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ImageMap.git
-   $ git clone 
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Genealogy.git
-   ```
-2. Enable them in your `LocalSettings.php` file:
-   ```
-   require_once "$IP/extensions/GraphViz/GraphViz.php";
-   require_once "$IP/extensions/ImageMap/ImageMap.php";
-   wfLoadExtension( 'Genealogy' );
-   ```
-
-
-## Development
-
-The *Genealogy* extension is developed by Sam Wilson and released under version
-3 of the GPL (see `LICENSE.txt` for details).
-
-You can see this extension in use on [ArchivesWiki](https://archives.org.au).
-
-Please report all bugs via Phabricator: http://phabricator.wikimedia.org/
diff --git a/extension.json b/extension.json
index 7bda702..ca2ebb1 100644
--- a/extension.json
+++ b/extension.json
@@ -20,8 +20,7 @@
},
"Hooks": {
"ParserFirstCallInit": 
"MediaWiki\\Extensions\\Genealogy\\Hooks::onParserFirstCallInit",
-   "UnitTestsList": 
"MediaWiki\\Extensions\\Genealogy\\Hooks::onUnitTestsList",
-   "EditPageBeforeEditToolbar": 
"MediaWiki\\Extensions\\Genealogy\\Hooks::onEditPageBeforeEditToolbar"
+   "EditPage::showEditForm:initial": 
"MediaWiki\\Extensions\\Genealogy\\Hooks::onEditPageShowEditFormInitial"
},
"manifest_version": 1
 }
diff --git a/src/Hooks.php b/src/Hooks.php
index 73d6dc9..bb5fc72 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -3,14 +3,10 @@
 namespace MediaWiki\Extensions\Genealogy;
 
 use EditPage;
-use GraphRenderParms;
-use GraphViz;
-use Linker;
-use MediaWiki\Linker\LinkRendererFactory;
+use MediaWiki\MediaWikiServices;
+use OutputPage;
 use Parser;
 use Title;
-use WikiPage;
-use Xml;
 
 class Hooks {
 
@@ -25,36 +21,24 @@
}
 
/**
-* Hooked to UnitTestsList.
-* @param String[] $files
-   

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Refactor various things

2016-11-15 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321834

Change subject: Refactor various things
..

Refactor various things

This redesigns much of the layout of the extension, but doesn't
change many fundamental ideas of it.

Change-Id: I8e536310a7370f96041471ed790710ca1150bd9a
---
A .gitignore
D Core.php
M Genealogy.i18n.magic.php
M Genealogy.i18n.php
D Genealogy.php
D Person.php
M README.md
D Traverser.php
D Tree.php
M composer.json
A extension.json
A person_template.wikitext
A phpcs.xml
A src/Hooks.php
A src/Person.php
A src/Traverser.php
A src/Tree.php
M tests/phpunit/PersonTest.php
18 files changed, 1,051 insertions(+), 611 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/34/321834/1

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..8b13789
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+
diff --git a/Core.php b/Core.php
deleted file mode 100644
index cdb039b..000
--- a/Core.php
+++ /dev/null
@@ -1,138 +0,0 @@
-setFunctionHook('genealogy', 
'GenealogyCore::RenderParserFunction');
-   return true;
-   }
-
-   /**
-* Hooked to UnitTestsList.
-* @param array|String $files
-* @return boolean
-*/
-   static function onUnitTestsList(&$files) {
-   $files = array_merge($files, glob(__DIR__ . 
'/tests/phpunit/*Test.php'));
-   return true;
-   }
-
-   /**
-* Render the output of the parser function.
-* The input parameters are wikitext with templates expanded.
-* The output should be wikitext too.
-*
-* @param Parser $parser
-* @param string $type
-* @param string $param2
-* @param string $param3
-* @return string The wikitext with which to replace the parser 
function call.
-*/
-   static function RenderParserFunction(Parser $parser) {
-   $params = array();
-   $args = func_get_args();
-   array_shift($args); // Remove $parser
-   $type = array_shift($args); // Get param 1, the function type
-   foreach ($args as $arg) { // Everything that's left must be 
named
-   $pair = explode('=', $arg, 2);
-   if (count($pair) == 2) {
-   $name = trim($pair[0]);
-   $value = trim($pair[1]);
-   $params[$name] = $value;
-   } else {
-   $params[] = $arg;
-   }
-   }
-   $out = ''; //"".print_r($params, true)."";
-   switch ($type) {
-   case 'person':
-   if (isset($params['birth date'])) {
-   $out .= $params['birth date'];
-   self::SaveProp($parser, 'birth date', 
$params['birth date'], false);
-   }
-   if (isset($params['death date'])) {
-   $out .= $params['death date'];
-   self::SaveProp($parser, 'death date', 
$params['death date'], false);
-   }
-   break;
-   case 'parent':
-   $parentTitle = Title::newFromText($params[0]);
-   if ($parentTitle and $parentTitle->exists()) {
-   $person = new 
GenealogyPerson($parentTitle);
-   $out .= $person->getWikiLink();
-   } else {
-   $out .= "[[" . $params[0] . "]]";
-   }
-   self::SaveProp($parser, 'parent', $params[0]);
-   break;
-   case 'siblings':
-   $person = new 
GenealogyPerson($parser->getTitle());
-   $out .= 
self::PeopleList($person->getSiblings());
-   break;
-   case 'partner':
-   //$out .= "[[".$params[0]."]]";
-   self::SaveProp($parser, 'partner', $params[0]);
-   break;
-   case 'partners':
-   $person = new 
GenealogyPerson($parser->getTitle());
-   $out .= 
self::PeopleList($person->getPartners());
-   break;
-   case 'children':
-   $person = new 
GenealogyPerson($parser->getTitle());
-   $out .= 
self::PeopleList($person->getChildren());
-  

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Update git links to new Gerrit repo.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321348

Change subject: Update git links to new Gerrit repo.
..

Update git links to new Gerrit repo.

Change-Id: I980b619145c0ca134118450dc4418501353da15f
---
M README.md
1 file changed, 5 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/48/321348/1

diff --git a/README.md b/README.md
index c86cfd7..7c9a0b8 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,7 @@
 MediaWiki Genealogy extension
 =
 
-All details:
-[mediawiki.org/wiki/Extension:Genealogy](https://mediawiki.org/wiki/Extension:Genealogy)
+All details: https://mediawiki.org/wiki/Extension:Genealogy
 
 
 ## Usage summary
@@ -30,8 +29,7 @@
 ## Templates
 
 **Example:**
-For an example template that makes use of these parser functions,
-see 
[`person_template.wikitext`](https://github.com/samwilson/Genealogy/blob/master/person_template.wikitext)
+For an example template that makes use of these parser functions, see 
`person_template.wikitext`.
 
 **Preload:**
 When this extension creates a link to a page that doesn't yet exist,
@@ -56,12 +54,13 @@
 * `index` — The index of this list-item in the full list, starting from 1. 
 * `count` — The total number of items in the full list.
 
+
 ## Installation
 
 1. Clone the *Genealogy* and *GraphViz* extensions into your extensions 
directory:
```
$ cd extensions
-   $ git clone https://github.com/samwilson/Genealogy.git
+   $ git clone 
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Genealogy.git
$ git clone 
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/GraphViz.git
```
 2. Enable them in your `LocalSettings.php` file:
@@ -78,5 +77,4 @@
 
 You can see this extension in use on [ArchivesWiki](https://archives.org.au).
 
-Please report all bugs via the GitHub issue tracker at
-https://github.com/samwilson/Genealogy/issues
+Please report all bugs via Phabricator: http://phabricator.wikimedia.org/

-- 
To view, visit https://gerrit.wikimedia.org/r/321348
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I980b619145c0ca134118450dc4418501353da15f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] integration/config[master]: Add Genealogy extension with standard testing templates

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321340

Change subject: Add Genealogy extension with standard testing templates
..

Add Genealogy extension with standard testing templates

The Genealogy extension has phpunit tests, and will soon have i18n
files and javascript etc. This change adds the standard extension
testing project templates.

Change-Id: Ieb1e813a12b158c61359b7b4abfdd66e2970320c
---
M zuul/layout.yaml
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/integration/config 
refs/changes/40/321340/1

diff --git a/zuul/layout.yaml b/zuul/layout.yaml
index 9504a09..fb523f6 100644
--- a/zuul/layout.yaml
+++ b/zuul/layout.yaml
@@ -3403,6 +3403,12 @@
   - jsonlint
   - jshint
 
+  - name: mediawiki/extensions/Genealogy
+template:
+  - name: extension-unittests-generic
+  - name: jshint
+  - name: npm
+
   - name: mediawiki/extensions/GeoCrumbs
 template:
   - name: jshint

-- 
To view, visit https://gerrit.wikimedia.org/r/321340
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb1e813a12b158c61359b7b4abfdd66e2970320c
Gerrit-PatchSet: 1
Gerrit-Project: integration/config
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Beginnings of a tree-drawing system (with GraphViz).

2016-11-13 Thread Samwilson (Code Review)
Samwilson has submitted this change and it was merged.

Change subject: Beginnings of a tree-drawing system (with GraphViz).
..


Beginnings of a tree-drawing system (with GraphViz).

Change-Id: If783bc530f0fd1e152871863be62cd7655282532
---
M Core.php
M Genealogy.i18n.php
M Genealogy.php
M Person.php
M README.md
A Traverser.php
A Tree.php
7 files changed, 197 insertions(+), 9 deletions(-)

Approvals:
  Samwilson: Verified; Looks good to me, approved



diff --git a/Core.php b/Core.php
index ba5b80d..9ecc40a 100644
--- a/Core.php
+++ b/Core.php
@@ -47,7 +47,7 @@
break;
case 'parent':
$parentTitle = Title::newFromText($params[0]);
-   if ($parentTitle->exists()) {
+   if ($parentTitle and $parentTitle->exists()) {
$person = new 
GenealogyPerson($parentTitle);
$out .= $person->getWikiLink();
} else {
@@ -71,6 +71,19 @@
$person = new 
GenealogyPerson($parser->getTitle());
$out .= 
self::PeopleList($person->getChildren());
break;
+   case 'tree':
+   $tree = new GenealogyTree();
+   if (isset($params['ancestors'])) {
+   $tree->addAncestors(explode("\n", 
$params['ancestors']));
+   }
+   //$tree->setAncestorDepth($params['ancestor 
depth']);
+   if (isset($params['descendants'])) {
+   $tree->addDescendants(explode("\n", 
$params['descendants']));
+   }
+   //$tree->setDescendantDepth($params['descendant 
depth']);
+   $graphviz = $tree->getGraphviz();
+   $out .= 
$parser->recursiveTagParse("\n$graphviz\n");
+   break;
default:
$out .= ''
. 'Genealogy parser function type not 
recognised: "' . $type . '".'
diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
index 07784f9..44c2ba8 100644
--- a/Genealogy.i18n.php
+++ b/Genealogy.i18n.php
@@ -13,6 +13,10 @@
  * @author Sam Wilson 
  */
 $messages['en'] = array(
-   'genealogy' => "Genealogy",
+   'genealogy'  => "Genealogy",
'genealogy-desc' => "Adds a parser function for easier linking between 
genealogical records",
+   'ancestor'   => 'Ancestor',
+   'descendant' => 'Descendant',
+   'ancestors'  => 'Ancestors',
+   'descendants'=> 'Descendants',
 );
diff --git a/Genealogy.php b/Genealogy.php
index 49e8308..9c1f17d 100644
--- a/Genealogy.php
+++ b/Genealogy.php
@@ -34,13 +34,13 @@
 $wgExtensionMessagesFiles['GenealogyMagic'] = __DIR__ . 
'/Genealogy.i18n.magic.php';
 
 /**
- * Class loading and the Special page
+ * Class loading
  */
-$wgAutoloadClasses['Genealogy'] = __FILE__;
-$wgAutoloadClasses['GenealogyPerson'] = __DIR__ . '/Person.php';
-$wgAutoloadClasses['GenealogySpecial'] = __DIR__ . '/Special.php';
-$wgAutoloadClasses['GenealogyCore'] = __DIR__ . '/Core.php';
-$wgSpecialPages['Genealogy'] = 'GenealogySpecial';
+$wgAutoloadClasses['GenealogyPerson']= __DIR__ . '/Person.php';
+$wgAutoloadClasses['GenealogySpecial']   = __DIR__ . '/Special.php';
+$wgAutoloadClasses['GenealogyCore']  = __DIR__ . '/Core.php';
+$wgAutoloadClasses['GenealogyTree']  = __DIR__ . '/Tree.php';
+$wgAutoloadClasses['GenealogyTraverser'] = __DIR__ . '/Traverser.php';
 
 /**
  * Parser function
diff --git a/Person.php b/Person.php
index 33ebabe..e3e4c9f 100644
--- a/Person.php
+++ b/Person.php
@@ -19,6 +19,15 @@
}
 
/**
+* Get some basic info about this person.
+* @todo Add dates.
+* @return string
+*/
+   public function __toString() {
+   return $this->getTitle()->getPrefixedText();
+   }
+
+   /**
 * Get this person's wiki title.
 *
 * @return Title
diff --git a/README.md b/README.md
index 6412e98..e3d98e1 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
 Its first two parameters are unnamed (i.e. don't have equals signs), but all
 others must be (dates, etc.).
 
-The following functions are supported, three for defining data and three for
+The following functions are supported, three for defining data and four for
 reporting data:
 
 1. Define this person's dates.
@@ -21,6 +21,9 @@
`{{#genealogy:partners}}`
 6. List all children:
`{{#genealogy:children}}`
+7. Display a tree (a connected graph):
+   

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Switch to using page properties for storage.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has submitted this change and it was merged.

Change subject: Switch to using page properties for storage.
..


Switch to using page properties for storage.

Change-Id: Ie781804312cd92332220b66539ba5d08e818f0d8
---
M Genealogy.php
M Person.php
M README.md
3 files changed, 156 insertions(+), 77 deletions(-)

Approvals:
  Samwilson: Verified; Looks good to me, approved



diff --git a/Genealogy.php b/Genealogy.php
index b85f2e6..5dfaae5 100644
--- a/Genealogy.php
+++ b/Genealogy.php
@@ -72,16 +72,19 @@
switch ($type) {
case 'person':
$out .= 'b.'.$params['birth date'];
+   GenealogySaveProp($parser, 'birth date', $params['birth 
date'], FALSE);
break;
case 'parent':
$out .= "[[".$params[0]."]]";
+   GenealogySaveProp($parser, 'parent', $params[0]);
break;
case 'siblings':
$person = new GenealogyPerson($parser->getTitle());
$out .= GenealogyPeopleList($person->getSiblings());
break;
case 'partner':
-   $out .= "[[".$params[0]."]]";
+   //$out .= "[[".$params[0]."]]";
+   GenealogySaveProp($parser, 'partner', $params[0]);
break;
case 'partners':
$person = new GenealogyPerson($parser->getTitle());
@@ -100,6 +103,19 @@
return $out;
 }
 
+function GenealogySaveProp($parser, $prop, $val, $multi = TRUE) {
+   if ($multi) {
+   $propNum = 1;
+   while ($par = $parser->getOutput()->getProperty("genealogy 
$prop $propNum")
+   AND $par != $val) {
+   $propNum++;
+   }
+   $parser->getOutput()->setProperty("genealogy $prop $propNum", 
$val);
+   } else {
+   $parser->getOutput()->setProperty("genealogy $prop", $val);
+   }
+}
+
 /**
  * Get a wikitext list of people.
  * @todo Replace with a proper templating system.
diff --git a/Person.php b/Person.php
index 42b5647..c8bfb81 100644
--- a/Person.php
+++ b/Person.php
@@ -2,6 +2,7 @@
 
 class GenealogyPerson {
 
+   /** @var Title */
private $title;
 
private $parents;
@@ -31,7 +32,7 @@
 * @return boolean
 */
public function hasDates() {
-   return $this->getBirthDate()!==FALSE;
+   return $this->getBirthDate() !== FALSE;
}
 
/**
@@ -41,16 +42,12 @@
 * @return string
 */
public function getBirthDate() {
-   $pattern = '/{{\#'.$this->magicRegex.':\s*person.*birth 
date=([^|}]*)/';
-   preg_match_all($pattern, $this->getText(), $matches);
-   if (!isset($matches[1][0])) {
-   return FALSE;
-   }
-   $time = strtotime($matches[1][0]);
-   if ($time!==FALSE) {
+   $birthDate = $this->getPropSingle('birth date');
+   $time = strtotime($birthDate);
+   if ($time !== FALSE) {
return date('j F Y', $time);
} else {
-   return $matches[1][0];
+   return $birthDate;
}
}
 
@@ -63,15 +60,7 @@
if (is_array($this->parents)) {
return $this->parents;
}
-   $this->parents = array();
-   $pattern = 
'/{{\#'.$this->magicRegex.':\s*parent\s*\|\s*([^|}]*)/';
-   preg_match_all($pattern, $this->getText(), $matches);
-   if (isset($matches[1])) {
-   foreach ($matches[1] as $match) {
-   $parentTitle = Title::newFromText($match);
-   
$this->parents[$parentTitle->getPrefixedDBkey()] = new 
GenealogyPerson($parentTitle);
-   }
-   }
+   $this->parents = $this->getPropMulti('parent');
return $this->parents;
}
 
@@ -102,7 +91,11 @@
if (is_array($this->partners)) {
return $this->partners;
}
-   $this->partners = $this->whatLinksHere('partner');
+   $this->partners = array_merge(
+   $this->getPropInbound('partner'),
+   $this->getPropMulti('partner')
+   );
+   //unset($this->partners[$this->title->getPrefixedDBkey()]);
return $this->partners;
}
 
@@ -115,75 +108,145 @@
if (is_array($this->children)) {
return $this->children;
}
-   $this->children = array();
-   $prefexedTitle = 

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Move core functions to their own class, add Composer support...

2016-11-13 Thread Samwilson (Code Review)
Samwilson has submitted this change and it was merged.

Change subject: Move core functions to their own class, add Composer support, 
and fix dates and links.
..


Move core functions to their own class, add Composer support, and fix dates and 
links.

Change-Id: I2b43f32028d76bbaa2a75158553d495588b5e0e7
---
A Core.php
M Genealogy.i18n.php
M Genealogy.php
M Person.php
A composer.json
5 files changed, 190 insertions(+), 151 deletions(-)

Approvals:
  Samwilson: Verified; Looks good to me, approved



diff --git a/Core.php b/Core.php
new file mode 100644
index 000..ba5b80d
--- /dev/null
+++ b/Core.php
@@ -0,0 +1,110 @@
+setFunctionHook('genealogy', 
'GenealogyCore::RenderParserFunction');
+   return true;
+   }
+
+   /**
+* Render the output of the parser function.
+* The input parameters are wikitext with templates expanded.
+* The output should be wikitext too.
+*
+* @param Parser $parser
+* @param string $type
+* @param string $param2
+* @param string $param3
+* @return string The wikitext with which to replace the parser 
function call.
+*/
+   static function RenderParserFunction(Parser $parser) {
+   $params = array();
+   $args = func_get_args();
+   array_shift($args); // Remove $parser
+   $type = array_shift($args); // Get param 1, the function type
+   foreach ($args as $arg) { // Everything that's left must be 
named
+   $pair = explode('=', $arg, 2);
+   if (count($pair) == 2) {
+   $name = trim($pair[0]);
+   $value = trim($pair[1]);
+   $params[$name] = $value;
+   } else {
+   $params[] = $arg;
+   }
+   }
+   $out = ''; //"".print_r($params, true)."";
+   switch ($type) {
+   case 'person':
+   if (isset($params['birth date'])) {
+   $out .= 'b.' . $params['birth 
date'];
+   self::SaveProp($parser, 'birth date', 
$params['birth date'], false);
+   }
+   if (isset($params['death date'])) {
+   $out .= 'd.' . $params['death 
date'];
+   self::SaveProp($parser, 'death date', 
$params['death date'], false);
+   }
+   break;
+   case 'parent':
+   $parentTitle = Title::newFromText($params[0]);
+   if ($parentTitle->exists()) {
+   $person = new 
GenealogyPerson($parentTitle);
+   $out .= $person->getWikiLink();
+   } else {
+   $out .= "[[" . $params[0] . "]]";
+   }
+   self::SaveProp($parser, 'parent', $params[0]);
+   break;
+   case 'siblings':
+   $person = new 
GenealogyPerson($parser->getTitle());
+   $out .= 
self::PeopleList($person->getSiblings());
+   break;
+   case 'partner':
+   //$out .= "[[".$params[0]."]]";
+   self::SaveProp($parser, 'partner', $params[0]);
+   break;
+   case 'partners':
+   $person = new 
GenealogyPerson($parser->getTitle());
+   $out .= 
self::PeopleList($person->getPartners());
+   break;
+   case 'children':
+   $person = new 
GenealogyPerson($parser->getTitle());
+   $out .= 
self::PeopleList($person->getChildren());
+   break;
+   default:
+   $out .= ''
+   . 'Genealogy parser function type not 
recognised: "' . $type . '".'
+   . '';
+   break;
+   }
+   return $out;
+   }
+
+   static function SaveProp($parser, $prop, $val, $multi = true) {
+   if ($multi) {
+   $propNum = 1;
+   while ($par = 
$parser->getOutput()->getProperty("genealogy $prop $propNum")
+   and $par != $val) {
+   $propNum++;
+ 

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: A start on person metadata, but it's not working well yet.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has submitted this change and it was merged.

Change subject: A start on person  metadata, but it's not working well yet.
..


A start on person  metadata, but it's not working well yet.

Change-Id: I2062c1a2e215ad2c0c9d0586c626795d93da3a0c
---
M Genealogy.php
M Person.php
M README.md
3 files changed, 89 insertions(+), 23 deletions(-)

Approvals:
  Samwilson: Verified; Looks good to me, approved



diff --git a/Genealogy.php b/Genealogy.php
index 2ba4348..b85f2e6 100644
--- a/Genealogy.php
+++ b/Genealogy.php
@@ -53,28 +53,46 @@
  * @param string $param3
  * @return string The wikitext with which to replace the parser function call.
  */
-function GenealogyRenderParserFunction(Parser $parser, $type = '', $one = '', 
$two = '') {
+function GenealogyRenderParserFunction(Parser $parser) {
+   $params = array();
+   $args = func_get_args();
+   array_shift($args); // Remove $parser
+   $type = array_shift($args); // Get param 1, the function type
+   foreach ( $args as $arg ) { // Everything that's left must be named
+   $pair = explode('=', $arg, 2);
+   if ( count( $pair ) == 2 ) {
+   $name = trim($pair[0]);
+   $value = trim($pair[1]);
+   $params[$name] = $value;
+   } else {
+   $params[] = $arg;
+   }
+   }
+   $out = ''; //"".print_r($params, true)."";
switch ($type) {
+   case 'person':
+   $out .= 'b.'.$params['birth date'];
+   break;
case 'parent':
-   $out = "[[$one]]";
+   $out .= "[[".$params[0]."]]";
break;
case 'siblings':
$person = new GenealogyPerson($parser->getTitle());
-   $out = GenealogyPeopleList($person->getSiblings());
+   $out .= GenealogyPeopleList($person->getSiblings());
break;
case 'partner':
-   $out = "[[$one]]";
+   $out .= "[[".$params[0]."]]";
break;
case 'partners':
$person = new GenealogyPerson($parser->getTitle());
-   $out = GenealogyPeopleList($person->getPartners());
+   $out .= GenealogyPeopleList($person->getPartners());
break;
case 'children':
$person = new GenealogyPerson($parser->getTitle());
-   $out = GenealogyPeopleList($person->getChildren());
+   $out .= GenealogyPeopleList($person->getChildren());
break;
default:
-   $out = ''
+   $out .= ''
.'Genealogy parser function type not 
recognised: "'.$type.'".'
.'';
break;
@@ -91,7 +109,8 @@
 function GenealogyPeopleList($people) {
$out = '';
foreach ($people as $person) {
-   $out .= "* [[".$person->getTitle()->getPrefixedText()."]]\n";
+   $date = ($person->hasDates()) ? " 
(".$person->getBirthDate().")" : "";
+   $out .= "* 
[[".$person->getTitle()->getPrefixedText()."]]$date\n";
}
return $out;
 }
diff --git a/Person.php b/Person.php
index 37b0bf1..42b5647 100644
--- a/Person.php
+++ b/Person.php
@@ -27,6 +27,34 @@
}
 
/**
+* Whether or not this person has a birth or death date.
+* @return boolean
+*/
+   public function hasDates() {
+   return $this->getBirthDate()!==FALSE;
+   }
+
+   /**
+* Get the birth date of this person, or false if it's not defined. If 
strtotime recognises the
+* format, the date will be converted to the standard wiki date format; 
if it doesn't, the
+* value defined in the page will be returned.
+* @return string
+*/
+   public function getBirthDate() {
+   $pattern = '/{{\#'.$this->magicRegex.':\s*person.*birth 
date=([^|}]*)/';
+   preg_match_all($pattern, $this->getText(), $matches);
+   if (!isset($matches[1][0])) {
+   return FALSE;
+   }
+   $time = strtotime($matches[1][0]);
+   if ($time!==FALSE) {
+   return date('j F Y', $time);
+   } else {
+   return $matches[1][0];
+   }
+   }
+
+   /**
 * Get all parents.
 *
 * @return array|GenealogyPerson An array of parents, possibly empty.
@@ -36,10 +64,8 @@
return $this->parents;
}
$this->parents = array();
-   

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Reduce line lengths for codesniffer conformance.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has submitted this change and it was merged.

Change subject: Reduce line lengths for codesniffer conformance.
..


Reduce line lengths for codesniffer conformance.

Change-Id: Ica44043b8bdd35567aa71970ab37d8eec5812e7e
---
M Genealogy.i18n.php
M Genealogy.php
2 files changed, 5 insertions(+), 2 deletions(-)

Approvals:
  Samwilson: Verified; Looks good to me, approved



diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
index 9760c99..ce9bf78 100644
--- a/Genealogy.i18n.php
+++ b/Genealogy.i18n.php
@@ -14,5 +14,6 @@
  */
 $messages['en'] = array(
'genealogy' => "Genealogy",
-   'genealogy-desc' => "Adds a parser function for reducing redundancy 
when linking between genealogical records",
+   'genealogy-desc' => "Adds a parser function for reducing redundancy '"
+   ."when linking between genealogical 
records",
 );
diff --git a/Genealogy.php b/Genealogy.php
index 987fe54..2ba4348 100644
--- a/Genealogy.php
+++ b/Genealogy.php
@@ -74,7 +74,9 @@
$out = GenealogyPeopleList($person->getChildren());
break;
default:
-   $out = 'Genealogy parser function 
type not recognised: "' . $type . '".';
+   $out = ''
+   .'Genealogy parser function type not 
recognised: "'.$type.'".'
+   .'';
break;
}
return $out;

-- 
To view, visit https://gerrit.wikimedia.org/r/321202
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ica44043b8bdd35567aa71970ab37d8eec5812e7e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 
Gerrit-Reviewer: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: First draft, linking people's pages only. Dates etc. still t...

2016-11-13 Thread Samwilson (Code Review)
Samwilson has submitted this change and it was merged.

Change subject: First draft, linking people's pages only. Dates etc. still to 
come.
..


First draft, linking people's pages only. Dates etc. still to come.

Change-Id: I23c455c23fba6efee145fa5ad19625153f1e2eb7
---
A Genealogy.i18n.magic.php
A Genealogy.i18n.php
A Genealogy.php
A LICENSE.txt
A Person.php
A README.md
6 files changed, 586 insertions(+), 0 deletions(-)

Approvals:
  Samwilson: Verified; Looks good to me, approved



diff --git a/Genealogy.i18n.magic.php b/Genealogy.i18n.magic.php
new file mode 100644
index 000..d05cc70
--- /dev/null
+++ b/Genealogy.i18n.magic.php
@@ -0,0 +1,17 @@
+
+ */
+$magicWords['en'] = array(
+   'genealogy' => array(0, 'genealogy'),
+);
diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
new file mode 100644
index 000..acf91fb
--- /dev/null
+++ b/Genealogy.i18n.php
@@ -0,0 +1,18 @@
+
+ */
+$messages['en'] = array(
+   'genealogy' => "Genealogy",
+   'genealogy-desc' => "The Genealogy extension.",
+);
diff --git a/Genealogy.php b/Genealogy.php
new file mode 100644
index 000..987fe54
--- /dev/null
+++ b/Genealogy.php
@@ -0,0 +1,95 @@
+ __FILE__,
+   'name' => 'Genealogy',
+   'author' => "Sam Wilson <[mailto:s...@samwilson.id.au 
s...@samwilson.id.au]>",
+   'url' => "http://www.mediawiki.org/wiki/Extension:Genealogy;,
+   'descriptionmsg' => 'genealogy-desc',
+   'license-name' => 'GPL-3.0+',
+   'version' => '0.1.0',
+);
+
+/**
+ * Messages
+ */
+$wgExtensionMessagesFiles['Genealogy'] = __DIR__ . '/Genealogy.i18n.php';
+$wgExtensionMessagesFiles['GenealogyMagic'] = __DIR__ . 
'/Genealogy.i18n.magic.php';
+
+/**
+ * Class loading and the Special page
+ */
+$wgAutoloadClasses['Genealogy'] = __FILE__;
+$wgAutoloadClasses['GenealogyPerson'] = __DIR__ . '/Person.php';
+$wgAutoloadClasses['GenealogySpecial'] = __DIR__ . '/Special.php';
+$wgSpecialPages['Genealogy'] = 'GenealogySpecial';
+
+/**
+ * Parser function
+ */
+$wgHooks['ParserFirstCallInit'][] = 'GenealogySetupParserFunction';
+
+function GenealogySetupParserFunction(Parser &$parser) {
+   $parser->setFunctionHook('genealogy', 'GenealogyRenderParserFunction');
+   return true;
+}
+
+/**
+ * Render the output of the parser function.
+ * The input parameters are wikitext with templates expanded.
+ * The output should be wikitext too.
+ *
+ * @param Parser $parser
+ * @param string $type
+ * @param string $param2
+ * @param string $param3
+ * @return string The wikitext with which to replace the parser function call.
+ */
+function GenealogyRenderParserFunction(Parser $parser, $type = '', $one = '', 
$two = '') {
+   switch ($type) {
+   case 'parent':
+   $out = "[[$one]]";
+   break;
+   case 'siblings':
+   $person = new GenealogyPerson($parser->getTitle());
+   $out = GenealogyPeopleList($person->getSiblings());
+   break;
+   case 'partner':
+   $out = "[[$one]]";
+   break;
+   case 'partners':
+   $person = new GenealogyPerson($parser->getTitle());
+   $out = GenealogyPeopleList($person->getPartners());
+   break;
+   case 'children':
+   $person = new GenealogyPerson($parser->getTitle());
+   $out = GenealogyPeopleList($person->getChildren());
+   break;
+   default:
+   $out = 'Genealogy parser function 
type not recognised: "' . $type . '".';
+   break;
+   }
+   return $out;
+}
+
+/**
+ * Get a wikitext list of people.
+ * @todo Replace with a proper templating system.
+ * @param array|GenealogyPerson $people
+ * @return string
+ */
+function GenealogyPeopleList($people) {
+   $out = '';
+   foreach ($people as $person) {
+   $out .= "* [[".$person->getTitle()->getPrefixedText()."]]\n";
+   }
+   return $out;
+}
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 000..dfbc0cb
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,283 @@
+The Genealogy extension is copyright  2014 Sam Wilson and licenced under
+the GPL version 3 or later, as given below.
+
+== GNU GENERAL PUBLIC LICENSE ==
+
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+=== Preamble ===
+
+The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for 

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: New beta release.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321209

Change subject: New beta release.
..

New beta release.

Change-Id: I592697ec4779b750733c29dd150aee6f514063a8
---
M Genealogy.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/09/321209/1

diff --git a/Genealogy.php b/Genealogy.php
index ea3ce10..9ca5711 100644
--- a/Genealogy.php
+++ b/Genealogy.php
@@ -24,7 +24,7 @@
'url' => "http://www.mediawiki.org/wiki/Extension:Genealogy;,
'descriptionmsg' => 'genealogy-desc',
'license-name' => 'GPL-3.0+',
-   'version' => '0.1.0',
+   'version' => '0.2.0',
 );
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/321209
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I592697ec4779b750733c29dd150aee6f514063a8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Templates for list items

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321223

Change subject: Templates for list items
..

Templates for list items

Change-Id: I7197fc93abad50dc2fc7309bc32a96be52cc47e2
---
M Genealogy.i18n.php
M README.md
M src/Hooks.php
M src/Person.php
M tests/phpunit/PersonTest.php
5 files changed, 105 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/23/321223/1

diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
index 9df2339..9d63d97 100644
--- a/Genealogy.i18n.php
+++ b/Genealogy.i18n.php
@@ -25,4 +25,5 @@
'genealogy-parser-function-not-found' => 'Genealogy parser function 
type not recognised: $1',
'genealogy-existing-partners' => 'This person already has the following 
'
.'{{PLURAL:$1|partner|partners}}: ',
+   'genealogy-person-list-item' => 'Person/list-item'
 ];
diff --git a/README.md b/README.md
index 131e546..c86cfd7 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,7 @@
 All details:
 
[mediawiki.org/wiki/Extension:Genealogy](https://mediawiki.org/wiki/Extension:Genealogy)
 
+
 ## Usage summary
 
 This extension creates one parser function: `{{#genealogy: … }}`.
@@ -25,6 +26,7 @@
`{{#genealogy:tree|ancestors=List|descendants=List}}`
where each `List` is a newline-separated list of page titles.
 
+
 ## Templates
 
 **Example:**
@@ -35,20 +37,40 @@
 When this extension creates a link to a page that doesn't yet exist,
 the text of `[[Template:Person/preload]]` is preloaded.
 The location of this preload text can be customised
-by modifying the `[[MediaWiki:genealogy-person-preload]]` system message.
+by modifying the `genealogy-person-preload` system message.
+
+**Person list-item:**
+Three types of lists of people can be generated: `siblings`, `partners`, and 
`children`.
+The default behaviour is a simple bulleted list,
+but this can be overridden by a template, `Template:Person/list-item`
+(the template name is specified by the `genealogy-person-list-item` system 
message).
+For example, to get a comma-separated one-line list of people, the following 
template code could be used:
+
+```
+{{{link}}}{{#ifeq:{{{index}}}|{{{count}}}|.|,}}
+```
+
+There are four parameters that are available for use in the list-item template:
+* `link` — A wikitext link.
+* `title` — The page title.
+* `index` — The index of this list-item in the full list, starting from 1. 
+* `count` — The total number of items in the full list.
 
 ## Installation
 
-1. Clone into your extensions directory:
+1. Clone the *Genealogy* and *GraphViz* extensions into your extensions 
directory:
```
$ cd extensions
$ git clone https://github.com/samwilson/Genealogy.git
+   $ git clone 
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/GraphViz.git
```
-2. Enable it in your `LocalSettings.php` file:
+2. Enable them in your `LocalSettings.php` file:
```
wfLoadExtension( 'Genealogy' );
+   wfLoadExtension( 'GraphViz' );
```
 
+
 ## Development
 
 The *Genealogy* extension is developed by Sam Wilson and released under version
diff --git a/src/Hooks.php b/src/Hooks.php
index 9c2e888..f7d7e88 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -84,7 +84,7 @@
$params[] = $arg;
}
}
-   $out = ''; // "".print_r($params, true)."";
+   $out = '';
$isHtml = false;
switch ( $type ) {
case 'person':
@@ -99,30 +99,31 @@
break;
case 'parent':
$parentTitle = Title::newFromText( $params[0] );
-   if ( $parentTitle && $parentTitle->exists() ) {
-   $parent = new Person( $parentTitle );
-   $out .= $parent->getWikiLink();
-   } else {
-   $query = [ 'preload' => wfMessage( 
'genealogy-person-preload' ) ];
-   $out .= Linker::link( $parentTitle, 
null, [], $query );
-   $isHtml = true;
-   }
+   $parent = new Person( $parentTitle );
+   $out .= $parent->getWikiLink();
+// if ( $parentTitle && $parentTitle->exists() ) {
+// $out .= $parent->getWikiLink();
+// } else {
+// $query = [ 'preload' => wfMessage( 
'genealogy-person-preload' ) ];
+// $out .= Linker::link( $parentTitle, 
null, [], $query );
+// $isHtml = true;
+// }
 

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Switch to using page properties for storage.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321204

Change subject: Switch to using page properties for storage.
..

Switch to using page properties for storage.

Change-Id: Ie781804312cd92332220b66539ba5d08e818f0d8
---
M Genealogy.php
M Person.php
M README.md
3 files changed, 156 insertions(+), 77 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/04/321204/1

diff --git a/Genealogy.php b/Genealogy.php
index b85f2e6..5dfaae5 100644
--- a/Genealogy.php
+++ b/Genealogy.php
@@ -72,16 +72,19 @@
switch ($type) {
case 'person':
$out .= 'b.'.$params['birth date'];
+   GenealogySaveProp($parser, 'birth date', $params['birth 
date'], FALSE);
break;
case 'parent':
$out .= "[[".$params[0]."]]";
+   GenealogySaveProp($parser, 'parent', $params[0]);
break;
case 'siblings':
$person = new GenealogyPerson($parser->getTitle());
$out .= GenealogyPeopleList($person->getSiblings());
break;
case 'partner':
-   $out .= "[[".$params[0]."]]";
+   //$out .= "[[".$params[0]."]]";
+   GenealogySaveProp($parser, 'partner', $params[0]);
break;
case 'partners':
$person = new GenealogyPerson($parser->getTitle());
@@ -100,6 +103,19 @@
return $out;
 }
 
+function GenealogySaveProp($parser, $prop, $val, $multi = TRUE) {
+   if ($multi) {
+   $propNum = 1;
+   while ($par = $parser->getOutput()->getProperty("genealogy 
$prop $propNum")
+   AND $par != $val) {
+   $propNum++;
+   }
+   $parser->getOutput()->setProperty("genealogy $prop $propNum", 
$val);
+   } else {
+   $parser->getOutput()->setProperty("genealogy $prop", $val);
+   }
+}
+
 /**
  * Get a wikitext list of people.
  * @todo Replace with a proper templating system.
diff --git a/Person.php b/Person.php
index 42b5647..c8bfb81 100644
--- a/Person.php
+++ b/Person.php
@@ -2,6 +2,7 @@
 
 class GenealogyPerson {
 
+   /** @var Title */
private $title;
 
private $parents;
@@ -31,7 +32,7 @@
 * @return boolean
 */
public function hasDates() {
-   return $this->getBirthDate()!==FALSE;
+   return $this->getBirthDate() !== FALSE;
}
 
/**
@@ -41,16 +42,12 @@
 * @return string
 */
public function getBirthDate() {
-   $pattern = '/{{\#'.$this->magicRegex.':\s*person.*birth 
date=([^|}]*)/';
-   preg_match_all($pattern, $this->getText(), $matches);
-   if (!isset($matches[1][0])) {
-   return FALSE;
-   }
-   $time = strtotime($matches[1][0]);
-   if ($time!==FALSE) {
+   $birthDate = $this->getPropSingle('birth date');
+   $time = strtotime($birthDate);
+   if ($time !== FALSE) {
return date('j F Y', $time);
} else {
-   return $matches[1][0];
+   return $birthDate;
}
}
 
@@ -63,15 +60,7 @@
if (is_array($this->parents)) {
return $this->parents;
}
-   $this->parents = array();
-   $pattern = 
'/{{\#'.$this->magicRegex.':\s*parent\s*\|\s*([^|}]*)/';
-   preg_match_all($pattern, $this->getText(), $matches);
-   if (isset($matches[1])) {
-   foreach ($matches[1] as $match) {
-   $parentTitle = Title::newFromText($match);
-   
$this->parents[$parentTitle->getPrefixedDBkey()] = new 
GenealogyPerson($parentTitle);
-   }
-   }
+   $this->parents = $this->getPropMulti('parent');
return $this->parents;
}
 
@@ -102,7 +91,11 @@
if (is_array($this->partners)) {
return $this->partners;
}
-   $this->partners = $this->whatLinksHere('partner');
+   $this->partners = array_merge(
+   $this->getPropInbound('partner'),
+   $this->getPropMulti('partner')
+   );
+   //unset($this->partners[$this->title->getPrefixedDBkey()]);
return $this->partners;
}
 
@@ -115,75 +108,145 @@
if (is_array($this->children)) {
return $this->children;
}
-

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Correct autoloading

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321222

Change subject: Correct autoloading
..

Correct autoloading

Change-Id: If388299246ffcd5d63bddb34eede8c17d689e708
---
M extension.json
M src/Hooks.php
2 files changed, 7 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/22/321222/1

diff --git a/extension.json b/extension.json
index bbfc903..2791e39 100644
--- a/extension.json
+++ b/extension.json
@@ -13,13 +13,13 @@
"GenealogyMagic": "Genealogy.i18n.magic.php"
},
"AutoloadClasses": {
-   "\\Samwilson\\Genealogy\\Person": "src/Person.php",
-   "\\Samwilson\\Genealogy\\Traverser": "src/Traverser.php",
-   "\\Samwilson\\Genealogy\\Tree": "src/Tree.php",
-   "\\Samwilson\\Genealogy\\Hooks": "src/Hooks.php"
+   "Samwilson\\Genealogy\\Person": "src/Person.php",
+   "Samwilson\\Genealogy\\Traverser": "src/Traverser.php",
+   "Samwilson\\Genealogy\\Tree": "src/Tree.php",
+   "Samwilson\\Genealogy\\Hooks": "src/Hooks.php"
},
"Hooks": {
-   "ParserFirstCallInit": 
"\\Samwilson\\Genealogy\\Hooks::onParserFirstCallInit",
+   "ParserFirstCallInit": 
"Samwilson\\Genealogy\\Hooks::onParserFirstCallInit",
"UnitTestsList": "Samwilson\\Genealogy\\Hooks::onUnitTestsList",
"EditPageBeforeEditToolbar": 
"Samwilson\\Genealogy\\Hooks::onEditPageBeforeEditToolbar"
},
diff --git a/src/Hooks.php b/src/Hooks.php
index c54fef6..9c2e888 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -29,7 +29,7 @@
 * @param String[] $files
 * @return boolean
 */
-   static function onUnitTestsList( &$files ) {
+   public static function onUnitTestsList( &$files ) {
$files = array_merge( $files, glob( __DIR__ . 
'/tests/phpunit/*Test.php' ) );
return true;
 
@@ -69,7 +69,7 @@
 * @param string $param3
 * @return string The wikitext with which to replace the parser 
function call.
 */
-   static function renderParserFunction( Parser $parser ) {
+   public static function renderParserFunction( Parser $parser ) {
$params = [];
$args = func_get_args();
array_shift( $args ); // Remove $parser

-- 
To view, visit https://gerrit.wikimedia.org/r/321222
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If388299246ffcd5d63bddb34eede8c17d689e708
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: New extension registration system

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321210

Change subject: New extension registration system
..

New extension registration system

Change-Id: I65cc461886956d3549dfdb09200509baa05b0285
---
A .gitignore
D Genealogy.php
M README.md
M composer.json
A extension.json
R src/Person.php
A src/Special.php
R src/Traverser.php
R src/Tree.php
R src/Util.php
10 files changed, 99 insertions(+), 87 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/10/321210/1

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..fcac4a7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/vendor
+
diff --git a/Genealogy.php b/Genealogy.php
deleted file mode 100644
index 9ca5711..000
--- a/Genealogy.php
+++ /dev/null
@@ -1,49 +0,0 @@
- __FILE__,
-   'name' => 'Genealogy',
-   'author' => "Sam Wilson <[mailto:s...@samwilson.id.au 
s...@samwilson.id.au]>",
-   'url' => "http://www.mediawiki.org/wiki/Extension:Genealogy;,
-   'descriptionmsg' => 'genealogy-desc',
-   'license-name' => 'GPL-3.0+',
-   'version' => '0.2.0',
-);
-
-/**
- * Messages
- */
-$wgExtensionMessagesFiles['Genealogy'] = __DIR__ . '/Genealogy.i18n.php';
-$wgExtensionMessagesFiles['GenealogyMagic'] = __DIR__ . 
'/Genealogy.i18n.magic.php';
-
-/**
- * Class loading
- */
-$wgAutoloadClasses['GenealogyPerson']= __DIR__ . '/Person.php';
-$wgAutoloadClasses['GenealogySpecial']   = __DIR__ . '/Special.php';
-$wgAutoloadClasses['GenealogyCore']  = __DIR__ . '/Core.php';
-$wgAutoloadClasses['GenealogyTree']  = __DIR__ . '/Tree.php';
-$wgAutoloadClasses['GenealogyTraverser'] = __DIR__ . '/Traverser.php';
-
-/**
- * Hooks
- */
-$wgHooks['ParserFirstCallInit'][] = 'GenealogyCore::onParserFirstCallInit';
-$wgHooks['UnitTestsList'][] = 'GenealogyCore::onUnitTestsList';
diff --git a/README.md b/README.md
index e3d98e1..0f982f2 100644
--- a/README.md
+++ b/README.md
@@ -3,8 +3,8 @@
 ## Usage
 
 There is only one parser function, `{{#genealogy:}}`.
-Its first two parameters are unnamed (i.e. don't have equals signs), but all
-others must be (dates, etc.).
+Its first two parameters are unnamed (i.e. don't have equals signs),
+but all others must be (dates, etc.).
 
 The following functions are supported, three for defining data and four for
 reporting data:
diff --git a/composer.json b/composer.json
index 8eab5b5..16b7334 100644
--- a/composer.json
+++ b/composer.json
@@ -16,11 +16,9 @@
"irc": "irc://irc.freenode.net/mediawiki",
"source": "https://github.com/samwilson/Genealogy;
},
-   "require": {
-   },
"autoload": {
-   "files" : [
-   "Genealogy.php"
-   ]
+   "psr-4": {
+   "Samwilson\\Genealogy\\": "src/"
+   }
}
 }
diff --git a/extension.json b/extension.json
new file mode 100644
index 000..4ee70c5
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,23 @@
+{
+   "name": "Genealogy",
+   "namemsg": "desc-genealogy",
+   "author": [
+   "Sam Wilson"
+   ],
+   "url": "https://www.mediawiki.org/wiki/Extension:Genealogy;,
+   "descriptionmsg": "genealogy-extension-desc",
+   "license-name": "GPL-3.0+",
+   "type": "extension",
+   "ExtensionMessagesFiles": {
+   "Genealogy": "Genealogy.i18n.php",
+   "GenealogyMagic": "Genealogy.i18n.magic.php"
+   },
+   "AutoloadClasses": {
+   "\\Samwilson\\Genealogy\\Genealogy": "Genealogy.php"
+   },
+   "Hooks": {
+   "ParserFirstCallInit": 
"\\Samwilson\\Genealogy\\Util::onParserFirstCallInit",
+   "UnitTestsList": "Samwilson\\Genealogy\\Util::onUnitTestsList"
+   },
+   "manifest_version": 2
+}
diff --git a/Person.php b/src/Person.php
similarity index 87%
rename from Person.php
rename to src/Person.php
index 3f21c80..34e338a 100644
--- a/Person.php
+++ b/src/Person.php
@@ -1,6 +1,11 @@
 parents)) {
@@ -115,7 +120,7 @@
/**
 * Get all siblings.
 *
-* @return array|GenealogyPerson An array of siblings, possibly empty.
+* @return Person[] An array of siblings, possibly empty.
 */
public function getSiblings() {
if (is_array($this->siblings)) {
@@ -133,7 +138,7 @@
/**
 * Get all partners.
 *
-* @return array|GenealogyPerson An array of partners, possibly empty.
+* @return Person[] An array of partners, possibly empty.
 */
public function getPartners() {
if (is_array($this->partners)) {
@@ -150,7 +155,7 @@
/**
 * Get all children.
 *
-* @return array|GenealogyPerson An array of children, possibly empty.
+* @return Person[] An array of children, possibly empty.
 */

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Invalid page names etc.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321213

Change subject: Invalid page names etc.
..

Invalid page names etc.

Change-Id: Ia46ebd7105fccf8bd729b1a75efe766a3f46270d
---
M README.md
M src/Person.php
M src/Util.php
3 files changed, 13 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/13/321213/1

diff --git a/README.md b/README.md
index 0f982f2..0dda15b 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
 
 1. Define this person's dates.
   `{{#genealogy:person |birth date=Y-m-d |death date=Y-m-d }}`
-2. Define a parent:
+2. Define and output a link to a parent:
`{{#genealogy:parent | Page Name Here }}`
 3. Define a partner (no output produced; use `partners` to list):
`{{#genealogy:partner | Page Name Here |start date=Y-m-d |end date=Y-m-d }}`
diff --git a/src/Person.php b/src/Person.php
index 292d0fe..a3f76b9 100644
--- a/src/Person.php
+++ b/src/Person.php
@@ -222,6 +222,10 @@
);
foreach ( $results as $result ) {
$title = Title::newFromText( $result->pp_value );
+   if ( is_null( $title ) ) {
+   // Do nothing, if this isn't a valid title.
+   continue;
+   }
$out[$title->getPrefixedDBkey()] = new Person( $title );
}
return $out;
diff --git a/src/Util.php b/src/Util.php
index 688dcbf..6a71126 100644
--- a/src/Util.php
+++ b/src/Util.php
@@ -32,10 +32,10 @@
 * This method is called by the editFormInitialText hook and adds a 
list of the current page's
 * Genealogy partners that *aren't* a result of a 
{{#genealogy:partner}} call in the current
 * page.
-* @param EditPage $editPage
+* @param string $formInitialText The existing initial text of the form
 * @return void
 */
-   public static function onEditFormInitialText( EditPage &$editPage ) {
+   public static function onEditFormInitialText( &$formInitialText ) {
global $wgTitle;
$person = new Person( $wgTitle );
$peopleList = [];
@@ -44,8 +44,11 @@
.$partner->getTitle()->getText()
."";
}
-   $editPage = 'This person is listed as the partner of the 
following people: '
-   .join( ', ', $peopleList ).''.$editPage;
+   if ( count( $peopleList ) > 0 ) {
+   $formInitialText =
+   'This person is listed as the partner of the 
following people: ' .
+   join( ', ', $peopleList ) . '' . 
$formInitialText;
+   }
}
 
/**
@@ -150,7 +153,7 @@
// Figure out what number we're up to for this property.
$propNum = 1;
$propVal = $output->getProperty( "genealogy $prop 
$propNum" );
-   while ( $propVal !== $val ) {
+   while ( $propVal !== false && $propVal !== $val ) {
$propNum++;
$propVal = $output->getProperty( "genealogy 
$prop $propNum" );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/321213
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia46ebd7105fccf8bd729b1a75efe766a3f46270d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Better tree drawing

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321215

Change subject: Better tree drawing
..

Better tree drawing

Change-Id: I9c5fad962b52e0dcb64038935ee84b15c7a1f6fb
---
M Genealogy.i18n.php
M README.md
A person_template.wikitext
M src/Person.php
M src/Traverser.php
M src/Tree.php
M src/Util.php
M tests/phpunit/PersonTest.php
8 files changed, 224 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/15/321215/1

diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
index db0617a..9a74409 100644
--- a/Genealogy.i18n.php
+++ b/Genealogy.i18n.php
@@ -13,12 +13,14 @@
  * @author Sam Wilson 
  */
 $messages['en'] = [
-   'genealogy'  => "Genealogy",
-   'genealogy-desc' => "Adds a parser function for easier linking between 
genealogical records",
+   'genealogy' => 'Genealogy',
+   'genealogy-desc' => 'Adds a parser function for easier linking between 
genealogical records',
'genealogy-born' => 'b.',
'genealogy-died' => 'd.',
-   'genealogy-ancestor'   => 'Ancestor',
-   'genealogy-descendant' => 'Descendant',
-   'genealogy-ancestors'  => 'Ancestors',
-   'genealogy-descendants'=> 'Descendants',
+   'genealogy-ancestor' => 'Ancestor',
+   'genealogy-ancestors' => 'Ancestors',
+   'genealogy-descendant' => 'Descendant',
+   'genealogy-descendants' => 'Descendants',
+   'genealogy-person-preload' => 'Template:Person/preload',
+   'genealogy-parser-function-not-found' => 'Genealogy parser function 
type not recognised: $1',
 ];
diff --git a/README.md b/README.md
index 0dda15b..49b4935 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,14 @@
-# MediaWiki Genealogy extension
+MediaWiki Genealogy extension
+=
 
-## Usage
+All details:
+[mediawiki.org/wiki/Extension:Genealogy](https://mediawiki.org/wiki/Extension:Genealogy)
 
-There is only one parser function, `{{#genealogy:}}`.
-Its first two parameters are unnamed (i.e. don't have equals signs),
-but all others must be (dates, etc.).
+## Usage summary
+
+This extension creates one parser function: `{{#genealogy: … }}`.
+Its first two parameters are unnamed (i.e. don't have equals signs)
+but all others are (the dates, etc.).
 
 The following functions are supported, three for defining data and four for
 reporting data:
@@ -25,10 +29,24 @@
`{{#genealogy:tree|ancestors=List|descendants=List}}`
where each `List` is a newline-separated list of page titles.
 
+## Templates
+
+**Example:**
+For an example template that makes use of these parser functions,
+see [`person_template.wikitext`](https://github.com/samwilson/Genealogy)
+
+**Preload:**
+When this extension creates a link to a page that doesn't yet exist,
+the text of `[[Template:Person/preload]]` is preloaded.
+The location of this preload text can be customised
+by modifying the `[[MediaWiki:genealogy-person-preload]]` system message.
+
 ## Development
 
 The *Genealogy* extension is developed by Sam Wilson and released under version
 3 of the GPL (see `LICENSE.txt` for details).
 
+You can see this extension in use on [ArchivesWiki](https://archives.org.au).
+
 Please report all bugs via the GitHub issue tracker at
 https://github.com/samwilson/Genealogy/issues
diff --git a/person_template.wikitext b/person_template.wikitext
new file mode 100644
index 000..0717ecb
--- /dev/null
+++ b/person_template.wikitext
@@ -0,0 +1,43 @@
+{|class=wikitable
+|+ {{PAGENAME}}
+|-
+! Birth:
+| {{{birth_date|}}} {{{birth_place|}}}
+|-
+! Death:
+| {{{death_date|}}} {{{death_place|}}}
+|-
+! Parents:
+|
+{{#if: {{{parent1|}}} | * {{#genealogy:parent | {{{parent1}}} }} }}
+{{#if: {{{parent2|}}} | * {{#genealogy:parent | {{{parent2}}} }} }}
+{{#if: {{{parent3|}}} | * {{#genealogy:parent | {{{parent3}}} }} }}
+|-
+! Siblings:
+| {{#genealogy:siblings}}
+|-
+! Partners:
+| {{#genealogy:partners}}
+{{#if: {{{partner1|}}} | {{#genealogy:partner | {{{partner1}}} }} }}
+{{#if: {{{partner2|}}} | {{#genealogy:partner | {{{partner2}}} }} }}
+{{#if: {{{partner3|}}} | {{#genealogy:partner | {{{partner3}}} }} }}
+|-
+! Children:
+| {{#genealogy:children}}
+|}[[Category:People]]
+This template is used to define and display a summary table on a biography 
article.
+
+It adds articles to the [[:Category:People|People]] category.
+
+== Usage ==
+
+
+{{person
+ | parent1 = Person 1 Name
+ | parent2 = Person 2 Name
+ | parent3 = Person 3 Name
+ | partner1 = Person 4 Name
+ | partner2 = Person 5 Name
+ | partner3 = Person 6 Name
+}}
+
diff --git a/src/Person.php b/src/Person.php
index 905fe3f..b1b5242 100644
--- a/src/Person.php
+++ b/src/Person.php
@@ -2,7 +2,9 @@
 
 namespace Samwilson\Genealogy;
 
+use Linker;
 use MagicWord;
+use MediaWiki\Linker\LinkRenderer;
 use Parser;
 use Title;
 use WikiPage;
@@ -145,11 +147,9 @@

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Fix hook loading

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321221

Change subject: Fix hook loading
..

Fix hook loading

Change-Id: If497009e03bcfb9c4e135deefcd7ac6421d18335
---
M extension.json
R src/Hooks.php
2 files changed, 12 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/21/321221/1

diff --git a/extension.json b/extension.json
index 98d640a..bbfc903 100644
--- a/extension.json
+++ b/extension.json
@@ -19,9 +19,9 @@
"\\Samwilson\\Genealogy\\Hooks": "src/Hooks.php"
},
"Hooks": {
-   "ParserFirstCallInit": 
"\\Samwilson\\Genealogy\\Util::onParserFirstCallInit",
-   "UnitTestsList": "Samwilson\\Genealogy\\Util::onUnitTestsList",
-   "EditPageBeforeEditToolbar": 
"Samwilson\\Genealogy\\Util::onEditFormInitialText"
+   "ParserFirstCallInit": 
"\\Samwilson\\Genealogy\\Hooks::onParserFirstCallInit",
+   "UnitTestsList": "Samwilson\\Genealogy\\Hooks::onUnitTestsList",
+   "EditPageBeforeEditToolbar": 
"Samwilson\\Genealogy\\Hooks::onEditPageBeforeEditToolbar"
},
"manifest_version": 1
 }
diff --git a/src/Util.php b/src/Hooks.php
similarity index 91%
rename from src/Util.php
rename to src/Hooks.php
index b87b737..c54fef6 100644
--- a/src/Util.php
+++ b/src/Hooks.php
@@ -12,7 +12,7 @@
 use WikiPage;
 use Xml;
 
-class Util {
+class Hooks {
 
/**
 * Hooked to ParserFirstCallInit.
@@ -36,25 +36,25 @@
}
 
/**
-* This method is called by the editFormInitialText hook and adds a 
list of the current page's
-* Genealogy partners that *aren't* a result of a 
{{#genealogy:partner}} call in the current
-* page.
-* @param string $formInitialText The existing initial text of the form
+* This method is called by the EditPageBeforeEditToolbar hook and adds 
a list of the current
+* page's Genealogy partners that *aren't* a result of a 
{{#genealogy:partner|…}} call in the
+* current page.
+* @param string $toolbarHtml The existing toolbar HTMl.
 * @return void
 */
-   public static function onEditFormInitialText( &$formInitialText ) {
+   public static function onEditPageBeforeEditToolbar( &$toolbarHtml ) {
global $wgTitle;
$person = new Person( $wgTitle );
$peopleList = [];
foreach ( $person->getPartners( true ) as $partner ) {
$peopleList[] = ''
-   .$partner->getTitle()->getText()
-   ."";
+   .$partner->getTitle()->getText()
+   ."";
}
if ( count( $peopleList ) > 0 ) {
$msg = wfMessage( 'genealogy-existing-partners', count( 
$peopleList ) );
$successBox = '' . $msg. join( ', 
', $peopleList ) . '';
-   $formInitialText = $successBox . $formInitialText;
+   $toolbarHtml = $successBox . $toolbarHtml;
}
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/321221
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If497009e03bcfb9c4e135deefcd7ac6421d18335
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Better message

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321217

Change subject: Better message
..

Better message

Change-Id: I39adea671dfe44e7aa27a4c0bc3634bc1e6fdfb6
---
M Genealogy.i18n.php
M README.md
M extension.json
M src/Util.php
4 files changed, 7 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/17/321217/1

diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
index 9a74409..9df2339 100644
--- a/Genealogy.i18n.php
+++ b/Genealogy.i18n.php
@@ -23,4 +23,6 @@
'genealogy-descendants' => 'Descendants',
'genealogy-person-preload' => 'Template:Person/preload',
'genealogy-parser-function-not-found' => 'Genealogy parser function 
type not recognised: $1',
+   'genealogy-existing-partners' => 'This person already has the following 
'
+   .'{{PLURAL:$1|partner|partners}}: ',
 ];
diff --git a/README.md b/README.md
index 49b4935..360eede 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@
 
 **Example:**
 For an example template that makes use of these parser functions,
-see [`person_template.wikitext`](https://github.com/samwilson/Genealogy)
+see 
[`person_template.wikitext`](https://github.com/samwilson/Genealogy/blob/master/person_template.wikitext)
 
 **Preload:**
 When this extension creates a link to a page that doesn't yet exist,
diff --git a/extension.json b/extension.json
index 23a8a74..4a85ef5 100644
--- a/extension.json
+++ b/extension.json
@@ -20,5 +20,5 @@
"UnitTestsList": "Samwilson\\Genealogy\\Util::onUnitTestsList",
"EditPageBeforeEditToolbar": 
"Samwilson\\Genealogy\\Util::onEditFormInitialText"
},
-   "manifest_version": 2
+   "manifest_version": 1
 }
diff --git a/src/Util.php b/src/Util.php
index 0f7e49b..c9054cf 100644
--- a/src/Util.php
+++ b/src/Util.php
@@ -48,9 +48,9 @@
."";
}
if ( count( $peopleList ) > 0 ) {
-   $formInitialText =
-   'This person is recorded as a partner of the 
following people: ' .
-   join( ', ', $peopleList ) . '' . 
$formInitialText;
+   $msg = wfMessage( 'genealogy-existing-partners', count( 
$peopleList ) );
+   $successBox = '' . $msg. join( ', 
', $peopleList ) . '';
+   $formInitialText = $successBox . $formInitialText;
}
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/321217
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I39adea671dfe44e7aa27a4c0bc3634bc1e6fdfb6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Different date handling, and a start on some tests.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321208

Change subject: Different date handling, and a start on some tests.
..

Different date handling, and a start on some tests.

Change-Id: I9bc4c01775b77448539872af7df85d070cd327db
---
M Core.php
M Genealogy.i18n.php
M Genealogy.php
M Person.php
A tests/phpunit/PersonTest.php
5 files changed, 90 insertions(+), 88 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/08/321208/1

diff --git a/Core.php b/Core.php
index 9ecc40a..cdb039b 100644
--- a/Core.php
+++ b/Core.php
@@ -2,8 +2,23 @@
 
 class GenealogyCore {
 
-   static function SetupParserFunction(Parser &$parser) {
+   /**
+* Hooked to ParserFirstCallInit.
+* @param Parser $parser
+* @return boolean
+*/
+   static function onParserFirstCallInit(Parser &$parser) {
$parser->setFunctionHook('genealogy', 
'GenealogyCore::RenderParserFunction');
+   return true;
+   }
+
+   /**
+* Hooked to UnitTestsList.
+* @param array|String $files
+* @return boolean
+*/
+   static function onUnitTestsList(&$files) {
+   $files = array_merge($files, glob(__DIR__ . 
'/tests/phpunit/*Test.php'));
return true;
}
 
@@ -37,11 +52,11 @@
switch ($type) {
case 'person':
if (isset($params['birth date'])) {
-   $out .= 'b.' . $params['birth 
date'];
+   $out .= $params['birth date'];
self::SaveProp($parser, 'birth date', 
$params['birth date'], false);
}
if (isset($params['death date'])) {
-   $out .= 'd.' . $params['death 
date'];
+   $out .= $params['death date'];
self::SaveProp($parser, 'death date', 
$params['death date'], false);
}
break;
diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
index 44c2ba8..0e9f241 100644
--- a/Genealogy.i18n.php
+++ b/Genealogy.i18n.php
@@ -15,8 +15,10 @@
 $messages['en'] = array(
'genealogy'  => "Genealogy",
'genealogy-desc' => "Adds a parser function for easier linking between 
genealogical records",
-   'ancestor'   => 'Ancestor',
-   'descendant' => 'Descendant',
-   'ancestors'  => 'Ancestors',
-   'descendants'=> 'Descendants',
+   'genealogy-born' => 'b.',
+   'genealogy-died' => 'd.',
+   'genealogy-ancestor'   => 'Ancestor',
+   'genealogy-descendant' => 'Descendant',
+   'genealogy-ancestors'  => 'Ancestors',
+   'genealogy-descendants'=> 'Descendants',
 );
diff --git a/Genealogy.php b/Genealogy.php
index 9c1f17d..ea3ce10 100644
--- a/Genealogy.php
+++ b/Genealogy.php
@@ -43,6 +43,7 @@
 $wgAutoloadClasses['GenealogyTraverser'] = __DIR__ . '/Traverser.php';
 
 /**
- * Parser function
+ * Hooks
  */
-$wgHooks['ParserFirstCallInit'][] = 'GenealogyCore::SetupParserFunction';
+$wgHooks['ParserFirstCallInit'][] = 'GenealogyCore::onParserFirstCallInit';
+$wgHooks['UnitTestsList'][] = 'GenealogyCore::onUnitTestsList';
diff --git a/Person.php b/Person.php
index ac7a695..3f21c80 100644
--- a/Person.php
+++ b/Person.php
@@ -37,15 +37,15 @@
}
 
public function getWikiLink() {
-   $birthYear = $this->getBirthDate('Y');
-   $deathYear = $this->getDeathDate('Y');
+   $birthYear = $this->getDateYear($this->getBirthDate());
+   $deathYear = $this->getDateYear($this->getDeathDate());
$dateString = '';
if (!empty($birthYear) && !empty($deathYear)) {
$dateString = "($birthYear$deathYear)";
} elseif (!empty($birthYear) && empty($deathYear)) {
-   $dateString = "(b.$birthYear)";
+   $dateString = 
"(".wfMessage('genealogy-born')."$birthYear)";
} elseif (empty($birthYear) && !empty($deathYear)) {
-   $dateString = "(d.$deathYear)";
+   $dateString = 
"(".wfMessage('genealogy-died')."$deathYear)";
}
$date = ($this->hasDates()) ? " $dateString" : "";
return "[[" . $this->getTitle()->getPrefixedText() . "]]$date";
@@ -56,41 +56,44 @@
 * @return boolean
 */
public function hasDates() {
-   return $this->getBirthDate() !== false;
+   return $this->getBirthDate() !== false || $this->getDeathDate() 
!== false;
}
 
/**
-* Get the birth date of this person. 
-  

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: Depth limits

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321219

Change subject: Depth limits
..

Depth limits

Change-Id: If3971637e909923eb9b6be6a50c282e0529f0fab
---
M src/Tree.php
M src/Util.php
2 files changed, 33 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/19/321219/1

diff --git a/src/Tree.php b/src/Tree.php
index 9222ec9..3aaa034 100644
--- a/src/Tree.php
+++ b/src/Tree.php
@@ -21,23 +21,44 @@
/** @var integer */
protected $descendant_depth;
 
+   /**
+* Set the number of levels the tree will go up to from the ancestors' 
starting points.
+* @param integer $ancestor_depth
+*/
public function setAncestorDepth( $ancestor_depth ) {
$this->ancestor_depth = $ancestor_depth;
}
 
+   /**
+* Set the number of levels the tree will go down to from the 
descendants' starting points.
+* @param integer $descendant_depth
+*/
public function setDescendantDepth( $descendant_depth ) {
$this->descendant_depth = $descendant_depth;
}
 
+   /**
+* Add ancestor starting points to this tree, from which to traverse 
upwards.
+* @param string[] $ancestors Array of page titles.
+*/
public function addAncestors( $ancestors ) {
$this->addAncestorsOrDescendants( 'ancestors', $ancestors );
}
 
+   /**
+* Add descendant starting points to this tree, from which to traverse 
downwards.
+* @param string[] $descendants Array of page titles.
+*/
public function addDescendants( $descendants ) {
$this->addAncestorsOrDescendants( 'descendants', $descendants );
}
 
-   private function addAncestorsOrDescendants( $type, $list ) {
+   /**
+* Add ancestor or descendant starting points to this tree.
+* @param string $type
+* @param string[] $list
+*/
+   protected function addAncestorsOrDescendants( $type, $list ) {
foreach ( $list as $a ) {
$title = Title::newFromText( $a );
if ( $title ) {
@@ -47,6 +68,10 @@
}
}
 
+   /**
+* Get the Dot source code for the graph of this tree.
+* @return string
+*/
public function getGraphviz() {
$this->out( 'top', 'start', 'digraph GenealogyTree {' );
$this->out( 'top', 'graph-attrs', 'graph [rankdir=LR]' );
diff --git a/src/Util.php b/src/Util.php
index f5e453b..b87b737 100644
--- a/src/Util.php
+++ b/src/Util.php
@@ -129,14 +129,18 @@
if ( isset( $params['ancestors'] ) ) {
$tree->addAncestors( explode( "\n", 
$params['ancestors'] ) );
}
-   // $tree->setAncestorDepth($params['ancestor 
depth']);
+   if ( isset( $params['ancestor depth'] ) ) {
+   $tree->setAncestorDepth( 
$params['ancestor depth'] );
+   }
if ( isset( $params['descendants'] ) ) {
$tree->addDescendants( explode( "\n", 
$params['descendants'] ) );
}
-   // 
$tree->setDescendantDepth($params['descendant depth']);
+   if ( isset( $params['descendant depth'] ) ) {
+   $tree->setDescendantDepth( 
$params['descendant depth'] );
+   }
$graphviz = $tree->getGraphviz();
$out .= $parser->recursiveTagParse( 
"\n$graphviz\n" );
-   $out .= $parser->recursiveTagParse( 
"$graphviz" );
+   // $out .= $parser->recursiveTagParse( 
"$graphviz" );
break;
default:
$msg = wfMessage( 
'genealogy-parser-function-not-found', [ $type ] );

-- 
To view, visit https://gerrit.wikimedia.org/r/321219
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If3971637e909923eb9b6be6a50c282e0529f0fab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: First draft, linking people's pages only. Dates etc. still t...

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321200

Change subject: First draft, linking people's pages only. Dates etc. still to 
come.
..

First draft, linking people's pages only. Dates etc. still to come.

Change-Id: I23c455c23fba6efee145fa5ad19625153f1e2eb7
---
A Genealogy.i18n.magic.php
A Genealogy.i18n.php
A Genealogy.php
A LICENSE.txt
A Person.php
A README.md
6 files changed, 586 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/00/321200/1

diff --git a/Genealogy.i18n.magic.php b/Genealogy.i18n.magic.php
new file mode 100644
index 000..d05cc70
--- /dev/null
+++ b/Genealogy.i18n.magic.php
@@ -0,0 +1,17 @@
+
+ */
+$magicWords['en'] = array(
+   'genealogy' => array(0, 'genealogy'),
+);
diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
new file mode 100644
index 000..acf91fb
--- /dev/null
+++ b/Genealogy.i18n.php
@@ -0,0 +1,18 @@
+
+ */
+$messages['en'] = array(
+   'genealogy' => "Genealogy",
+   'genealogy-desc' => "The Genealogy extension.",
+);
diff --git a/Genealogy.php b/Genealogy.php
new file mode 100644
index 000..987fe54
--- /dev/null
+++ b/Genealogy.php
@@ -0,0 +1,95 @@
+ __FILE__,
+   'name' => 'Genealogy',
+   'author' => "Sam Wilson <[mailto:s...@samwilson.id.au 
s...@samwilson.id.au]>",
+   'url' => "http://www.mediawiki.org/wiki/Extension:Genealogy;,
+   'descriptionmsg' => 'genealogy-desc',
+   'license-name' => 'GPL-3.0+',
+   'version' => '0.1.0',
+);
+
+/**
+ * Messages
+ */
+$wgExtensionMessagesFiles['Genealogy'] = __DIR__ . '/Genealogy.i18n.php';
+$wgExtensionMessagesFiles['GenealogyMagic'] = __DIR__ . 
'/Genealogy.i18n.magic.php';
+
+/**
+ * Class loading and the Special page
+ */
+$wgAutoloadClasses['Genealogy'] = __FILE__;
+$wgAutoloadClasses['GenealogyPerson'] = __DIR__ . '/Person.php';
+$wgAutoloadClasses['GenealogySpecial'] = __DIR__ . '/Special.php';
+$wgSpecialPages['Genealogy'] = 'GenealogySpecial';
+
+/**
+ * Parser function
+ */
+$wgHooks['ParserFirstCallInit'][] = 'GenealogySetupParserFunction';
+
+function GenealogySetupParserFunction(Parser &$parser) {
+   $parser->setFunctionHook('genealogy', 'GenealogyRenderParserFunction');
+   return true;
+}
+
+/**
+ * Render the output of the parser function.
+ * The input parameters are wikitext with templates expanded.
+ * The output should be wikitext too.
+ *
+ * @param Parser $parser
+ * @param string $type
+ * @param string $param2
+ * @param string $param3
+ * @return string The wikitext with which to replace the parser function call.
+ */
+function GenealogyRenderParserFunction(Parser $parser, $type = '', $one = '', 
$two = '') {
+   switch ($type) {
+   case 'parent':
+   $out = "[[$one]]";
+   break;
+   case 'siblings':
+   $person = new GenealogyPerson($parser->getTitle());
+   $out = GenealogyPeopleList($person->getSiblings());
+   break;
+   case 'partner':
+   $out = "[[$one]]";
+   break;
+   case 'partners':
+   $person = new GenealogyPerson($parser->getTitle());
+   $out = GenealogyPeopleList($person->getPartners());
+   break;
+   case 'children':
+   $person = new GenealogyPerson($parser->getTitle());
+   $out = GenealogyPeopleList($person->getChildren());
+   break;
+   default:
+   $out = 'Genealogy parser function 
type not recognised: "' . $type . '".';
+   break;
+   }
+   return $out;
+}
+
+/**
+ * Get a wikitext list of people.
+ * @todo Replace with a proper templating system.
+ * @param array|GenealogyPerson $people
+ * @return string
+ */
+function GenealogyPeopleList($people) {
+   $out = '';
+   foreach ($people as $person) {
+   $out .= "* [[".$person->getTitle()->getPrefixedText()."]]\n";
+   }
+   return $out;
+}
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 000..dfbc0cb
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,283 @@
+The Genealogy extension is copyright  2014 Sam Wilson and licenced under
+the GPL version 3 or later, as given below.
+
+== GNU GENERAL PUBLIC LICENSE ==
+
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+=== Preamble ===
+
+The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom 

[MediaWiki-commits] [Gerrit] mediawiki...Genealogy[master]: A start on person metadata, but it's not working well yet.

2016-11-13 Thread Samwilson (Code Review)
Samwilson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321203

Change subject: A start on person  metadata, but it's not working well yet.
..

A start on person  metadata, but it's not working well yet.

Change-Id: I2062c1a2e215ad2c0c9d0586c626795d93da3a0c
---
M Genealogy.php
M Person.php
M README.md
3 files changed, 89 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy 
refs/changes/03/321203/1

diff --git a/Genealogy.php b/Genealogy.php
index 2ba4348..b85f2e6 100644
--- a/Genealogy.php
+++ b/Genealogy.php
@@ -53,28 +53,46 @@
  * @param string $param3
  * @return string The wikitext with which to replace the parser function call.
  */
-function GenealogyRenderParserFunction(Parser $parser, $type = '', $one = '', 
$two = '') {
+function GenealogyRenderParserFunction(Parser $parser) {
+   $params = array();
+   $args = func_get_args();
+   array_shift($args); // Remove $parser
+   $type = array_shift($args); // Get param 1, the function type
+   foreach ( $args as $arg ) { // Everything that's left must be named
+   $pair = explode('=', $arg, 2);
+   if ( count( $pair ) == 2 ) {
+   $name = trim($pair[0]);
+   $value = trim($pair[1]);
+   $params[$name] = $value;
+   } else {
+   $params[] = $arg;
+   }
+   }
+   $out = ''; //"".print_r($params, true)."";
switch ($type) {
+   case 'person':
+   $out .= 'b.'.$params['birth date'];
+   break;
case 'parent':
-   $out = "[[$one]]";
+   $out .= "[[".$params[0]."]]";
break;
case 'siblings':
$person = new GenealogyPerson($parser->getTitle());
-   $out = GenealogyPeopleList($person->getSiblings());
+   $out .= GenealogyPeopleList($person->getSiblings());
break;
case 'partner':
-   $out = "[[$one]]";
+   $out .= "[[".$params[0]."]]";
break;
case 'partners':
$person = new GenealogyPerson($parser->getTitle());
-   $out = GenealogyPeopleList($person->getPartners());
+   $out .= GenealogyPeopleList($person->getPartners());
break;
case 'children':
$person = new GenealogyPerson($parser->getTitle());
-   $out = GenealogyPeopleList($person->getChildren());
+   $out .= GenealogyPeopleList($person->getChildren());
break;
default:
-   $out = ''
+   $out .= ''
.'Genealogy parser function type not 
recognised: "'.$type.'".'
.'';
break;
@@ -91,7 +109,8 @@
 function GenealogyPeopleList($people) {
$out = '';
foreach ($people as $person) {
-   $out .= "* [[".$person->getTitle()->getPrefixedText()."]]\n";
+   $date = ($person->hasDates()) ? " 
(".$person->getBirthDate().")" : "";
+   $out .= "* 
[[".$person->getTitle()->getPrefixedText()."]]$date\n";
}
return $out;
 }
diff --git a/Person.php b/Person.php
index 37b0bf1..42b5647 100644
--- a/Person.php
+++ b/Person.php
@@ -27,6 +27,34 @@
}
 
/**
+* Whether or not this person has a birth or death date.
+* @return boolean
+*/
+   public function hasDates() {
+   return $this->getBirthDate()!==FALSE;
+   }
+
+   /**
+* Get the birth date of this person, or false if it's not defined. If 
strtotime recognises the
+* format, the date will be converted to the standard wiki date format; 
if it doesn't, the
+* value defined in the page will be returned.
+* @return string
+*/
+   public function getBirthDate() {
+   $pattern = '/{{\#'.$this->magicRegex.':\s*person.*birth 
date=([^|}]*)/';
+   preg_match_all($pattern, $this->getText(), $matches);
+   if (!isset($matches[1][0])) {
+   return FALSE;
+   }
+   $time = strtotime($matches[1][0]);
+   if ($time!==FALSE) {
+   return date('j F Y', $time);
+   } else {
+   return $matches[1][0];
+   }
+   }
+
+   /**
 * Get all parents.
 *
 * @return array|GenealogyPerson An array of parents, possibly empty.
@@ -36,10 +64,8 @@
return $this->parents;
 

  1   2   >