[MediaWiki-commits] [Gerrit] Support aliases in SpecialNewEntity - change (mediawiki...Wikibase)

2015-07-27 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Support aliases in SpecialNewEntity
..


Support aliases in SpecialNewEntity

Bug: T74316
Change-Id: I6b99deabcda6e2e10cabf47a4dbce28f69bc1123
---
M repo/i18n/en.json
M repo/i18n/qqq.json
M repo/includes/specials/SpecialNewEntity.php
3 files changed, 46 insertions(+), 8 deletions(-)

Approvals:
  Jonas Kress (WMDE): Looks good to me, but someone else must approve
  Addshore: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index 53133fe..26bbfb4 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -41,6 +41,7 @@
"wikibase-description-empty": "No description defined",
"wikibase-description-edit-placeholder": "enter a description",
"wikibase-description-edit-placeholder-language-aware": "enter a 
description in $1",
+   "wikibase-aliases-edit-placeholder-language-aware": "enter some aliases 
in $1",
"wikibase-diffview-reference": "reference",
"wikibase-diffview-rank": "rank",
"wikibase-diffview-rank-preferred": "Preferred rank",
@@ -167,6 +168,7 @@
"wikibase-newitem-not-recognized-siteid": "The provided site identifier 
was not recognized.",
"wikibase-newentity-label": "Label:",
"wikibase-newentity-description": "Description:",
+   "wikibase-newentity-aliases": "Aliases, pipe-separated:",
"wikibase-newentity-submit": "Create",
"special-setlabel": "Set a label",
"wikibase-setlabel-introfull": "You are setting the label in $2 for 
[[$1]].",
diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json
index f52dc12..445414c 100644
--- a/repo/i18n/qqq.json
+++ b/repo/i18n/qqq.json
@@ -70,6 +70,7 @@
"wikibase-description-empty": "Placeholder message displayed instead of 
the item's description in case no description has been specified yet.  This 
message is displayed only when the user has JavaScript disabled. (When 
JavaScript is enabled, an input box will be displayed instead.)",
"wikibase-description-edit-placeholder": "[[File:Screenshot 
WikidataRepo 2012-05-13 G.png|right|0x150px]]\nThis is a generic text used as a 
placeholder while editing a new description. See also the Wikidata glossary on 
[[d:Wikidata:Glossary#languageattribute-description|description]].",
"wikibase-description-edit-placeholder-language-aware": "Like 
{{msg-mw|Wikibase-description-edit-placeholder}}, but language ($1) aware.",
+   "wikibase-aliases-edit-placeholder-language-aware": "Like 
{{msg-mw|Wikibase-alias-edit-placeholder}}, but for multiple pipe-separated 
aliases and language ($1) aware.",
"wikibase-diffview-reference": "Label within the header of a 
diff-operation on the entity diff view to describe that the diff-operation 
affects a reference. Will be shown as e.g. \"claim / property q1 / 
reference\".\n{{Identical|Reference}}",
"wikibase-diffview-rank": "Label within the header of a diff-operation 
on the entity diff view to describe that the diff-operation affects the rank of 
the statement. Will be shown as e.g. \"claim / property q1 / 
rank\".\n{{Identical|Rank}}",
"wikibase-diffview-rank-preferred": "The 
[[d:Wikidata:Glossary#Rank-preferred|Preferred Rank]] to be shown in diffs.",
@@ -195,6 +196,7 @@
"wikibase-newitem-not-recognized-siteid": "Error message shown when a 
user tries to add a link to a site with an unknown identifier.\n\nSee also:\n* 
{{msg-mw|Wikibase-api-not-recognized-siteid}}",
"wikibase-newentity-label": "Label for the \"label\" textfield holding 
the label of the new item.\n{{Identical|Label}}",
"wikibase-newentity-description": "Label for the \"description\" 
textfield holding the description of the new item.\n{{Identical|Description}}",
+   "wikibase-newentity-aliases": "Label for the \"aliases\" textfield 
holding the pipe-separated aliases of the new item.",
"wikibase-newentity-submit": "Text for the submit button on the 
CreateItem special page.\n{{Identical|Create}}",
"special-setlabel": "{{doc-special|SetLabel}}\nThe special page allows 
the user to set an entity's label in a particular language.",
"wikibase-setlabel-introfull": "Intro text when label is to be set. 
Parameters:\n* $1 - the ID that links to the entity\n* $2 - the translated 
language name (possibly autonym) label, description and aliases are to be set 
in.",
diff --git a/repo/includes/specials/SpecialNewEntity.php 
b/repo/includes/specials/SpecialNewEntity.php
index 6e57ca2..3c3f767 100644
--- a/repo/includes/specials/SpecialNewEntity.php
+++ b/repo/includes/specials/SpecialNewEntity.php
@@ -155,6 +155,8 @@
'description',
isset( $this->parts[1] ) ? $this->parts[1] : ''
);
+   $aliases = $this->getRequest()->getVal( 'aliases' );
+   $this->aliase

[MediaWiki-commits] [Gerrit] Support aliases in SpecialNewEntity - change (mediawiki...Wikibase)

2015-07-26 Thread Ricordisamoa (Code Review)
Ricordisamoa has uploaded a new change for review.

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

Change subject: Support aliases in SpecialNewEntity
..

Support aliases in SpecialNewEntity

Bug: T74316
Change-Id: I6b99deabcda6e2e10cabf47a4dbce28f69bc1123
---
M repo/i18n/en.json
M repo/includes/specials/SpecialNewEntity.php
2 files changed, 41 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/85/227185/1

diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index 53133fe..26bbfb4 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -41,6 +41,7 @@
"wikibase-description-empty": "No description defined",
"wikibase-description-edit-placeholder": "enter a description",
"wikibase-description-edit-placeholder-language-aware": "enter a 
description in $1",
+   "wikibase-aliases-edit-placeholder-language-aware": "enter some aliases 
in $1",
"wikibase-diffview-reference": "reference",
"wikibase-diffview-rank": "rank",
"wikibase-diffview-rank-preferred": "Preferred rank",
@@ -167,6 +168,7 @@
"wikibase-newitem-not-recognized-siteid": "The provided site identifier 
was not recognized.",
"wikibase-newentity-label": "Label:",
"wikibase-newentity-description": "Description:",
+   "wikibase-newentity-aliases": "Aliases, pipe-separated:",
"wikibase-newentity-submit": "Create",
"special-setlabel": "Set a label",
"wikibase-setlabel-introfull": "You are setting the label in $2 for 
[[$1]].",
diff --git a/repo/includes/specials/SpecialNewEntity.php 
b/repo/includes/specials/SpecialNewEntity.php
index 6e57ca2..f7b6265 100644
--- a/repo/includes/specials/SpecialNewEntity.php
+++ b/repo/includes/specials/SpecialNewEntity.php
@@ -155,6 +155,8 @@
'description',
isset( $this->parts[1] ) ? $this->parts[1] : ''
);
+   $aliases = $this->getRequest()->getVal( 'aliases' );
+   $this->aliases = ( $aliases === null ? array() : explode( '|', 
$aliases ) );
$this->contentLanguage = Language::factory( 
$this->getRequest()->getVal(
'lang',
$this->getLanguage()->getCode()
@@ -170,7 +172,8 @@
 */
protected function hasSufficientArguments() {
return $this->stringNormalizer->trimWhitespace( $this->label ) 
!== ''
-   || $this->stringNormalizer->trimWhitespace( 
$this->description ) !== '';
+   || $this->stringNormalizer->trimWhitespace( 
$this->description ) !== ''
+   || implode( '', array_map( 
$this->stringNormalizer->trimWhitespace, $this->aliases ) ) !== '';
}
 
/**
@@ -197,6 +200,9 @@
if ( $this->description !== '' ) {
$entity->setDescription( $contentLanguageCode, 
$this->description );
}
+   if ( count( $this->aliases ) !== 0 ) {
+   $entity->setAliases( $contentLanguageCode, 
$this->aliases );
+   }
return \Status::newGood();
}
 
@@ -208,9 +214,12 @@
 * @return string Formatted HTML for inclusion in the form
 */
protected function additionalFormElements() {
+   $langCode = $this->contentLanguage->getCode();
+   $langName = Language::fetchLanguageName( $langCode );
+   $langDir = $this->contentLanguage->getDir();
return Html::hidden(
'lang',
-   $this->contentLanguage->getCode()
+   $langCode
)
. Html::element(
'label',
@@ -227,11 +236,11 @@
array(
'id' => 'wb-newentity-label',
'class' => 'wb-input',
-   'lang' => $this->contentLanguage->getCode(),
-   'dir' => $this->contentLanguage->getDir(),
+   'lang' => $langCode,
+   'dir' => $langDir,
'placeholder' => $this->msg(

'wikibase-label-edit-placeholder-language-aware',
-   Language::fetchLanguageName( 
$this->contentLanguage->getCode() )
+   $langName
)->text(),
)
)
@@ -250,11 +259,33 @@
array(
'id' => 'wb-newentity-description',
'class' => 'wb-input',
-   'lang' => $this->contentLanguage->getCode(),
-   'dir' => $this->contentLanguage-