Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/191596
Change subject: Simplify code in SpecialModifyEntity
......................................................................
Simplify code in SpecialModifyEntity
* Extract some duplicate code to variables.
* Use specific Html::... methods if possible.
* More descriptive variable names.
* Drop meaningless brackets.
Change-Id: Ib3aaf49be6b02b82cbc7f2573c18293472bdd3b9
---
M repo/includes/specials/SpecialModifyEntity.php
1 file changed, 14 insertions(+), 25 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/96/191596/1
diff --git a/repo/includes/specials/SpecialModifyEntity.php
b/repo/includes/specials/SpecialModifyEntity.php
index abe9293..6b0fd7a 100644
--- a/repo/includes/specials/SpecialModifyEntity.php
+++ b/repo/includes/specials/SpecialModifyEntity.php
@@ -116,20 +116,17 @@
* @param string $subPage
*/
protected function prepareArguments( $subPage ) {
- $parts = ( $subPage === '' ) ? array() : explode( '/',
$subPage, 2 );
+ $parts = $subPage === '' ? array() : explode( '/', $subPage, 2
);
- // Get id
- $rawId = $this->getRequest()->getVal( 'id', isset( $parts[0] )
? $parts[0] : null );
+ $idString = $this->getRequest()->getVal( 'id', isset( $parts[0]
) ? $parts[0] : null );
- if ( !$rawId ) {
+ if ( !$idString ) {
return;
}
- $id = $this->parseEntityId( $rawId );
-
- $this->entityRevision = $this->loadEntity( $id );
+ $entityId = $this->parseEntityId( $idString );
+ $this->entityRevision = $this->loadEntity( $entityId );
}
-
/**
* @todo could factor this out into a special page form builder and
renderer
@@ -142,7 +139,6 @@
);
$html = $copyrightView->getHtml( $this->getLanguage() );
-
$this->getOutput()->addHTML( $html );
}
@@ -220,16 +216,15 @@
*
* @param Entity $entity
*
- * @return string
+ * @return string HTML
*/
protected function getFormElements( Entity $entity = null ) {
- return Html::element(
- 'label',
- array(
- 'for' => 'wb-modifyentity-id',
- 'class' => 'wb-label'
- ),
- $this->msg( 'wikibase-modifyentity-id' )->text()
+ $id = 'wb-modifyentity-id';
+
+ return Html::label(
+ $this->msg( 'wikibase-modifyentity-id' )->text(),
+ $id,
+ array( 'class' => 'wb-label' )
)
. Html::input(
'id',
@@ -237,7 +232,7 @@
'text',
array(
'class' => 'wb-input',
- 'id' => 'wb-modifyentity-id'
+ 'id' => $id
)
)
. Html::element( 'br' );
@@ -266,13 +261,7 @@
* continue by calling modifyEntity().
*/
protected function validateInput() {
- $request = $this->getRequest();
-
- if ( $this->entityRevision === null || !$request->wasPosted() )
{
- return false;
- }
-
- return true;
+ return $this->entityRevision !== null &&
$this->getRequest()->wasPosted();
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/191596
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3aaf49be6b02b82cbc7f2573c18293472bdd3b9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits