r103932 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103931‎ | r103932 | r103933 >
Date:18:13, 22 November 2011
Author:kipcool
Status:deferred (Comments)
Tags:
Comment:
Also disable modifying textboxes for unauthorised users.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/forms.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/forms.php
@@ -2,13 +2,18 @@
33
44 require_once( 'languages.php' );
55
6 -function getTextBox( $name, $value = "", $onChangeHandler = "" ) {
 6+function getTextBox( $name, $value = "", $onChangeHandler = "", $disabled = false ) {
77 if ( $onChangeHandler != "" )
88 $onChangeAttribute = ' onchange="' . $onChangeHandler . '"';
99 else
1010 $onChangeAttribute = '';
1111
12 - return '<input type="text" id="' . $name . '" name="' . $name . '" value="' . htmlspecialchars( $value ) . '"' . $onChangeAttribute . ' style="width: 100%; padding: 0px; margin: 0px;"/>';
 12+ $disableText = $disabled ? 'disabled="disabled" ' : '' ;
 13+ $inputHTML = '<input ' . $disableText . 'type="text" id="' . $name . '" name="' . $name .
 14+ '" value="' . htmlspecialchars( $value ) . '"' . $onChangeAttribute .
 15+ ' style="width: 100%; padding: 0px; margin: 0px;"/>' ;
 16+
 17+ return $inputHTML ;
1318 }
1419
1520 function getTextArea( $name, $text = "", $rows = 5, $columns = 80, $disabled = false ) {
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -1228,9 +1228,19 @@
12291229 }
12301230
12311231 public function getEditHTML( IdStack $idPath, $value ) {
1232 - return getTextBox( $this->updateId( $idPath->getId() ), $value, $this->onChangeHandler );
 1232+ global $wgUser;
 1233+ $dc = wdGetDataSetContext();
 1234+ if ( ($dc == "uw") and (! $wgUser->isAllowed( 'deletewikidata-uw' ) ) ) {
 1235+ // disable
 1236+ return getTextBox( $this->updateId( $idPath->getId() ), $value, $this->onChangeHandler, true );
 1237+ } else {
 1238+ return getTextBox( $this->updateId( $idPath->getId() ), $value, $this->onChangeHandler );
 1239+ }
12331240 }
 1241+
12341242
 1243+ }
 1244+
12351245 public function add( IdStack $idPath ) {
12361246 if ( $this->isAddField )
12371247 return getTextBox( $this->addId( $idPath->getId() ), "", $this->onChangeHandler );

Comments

#Comment by Nikerabbit (talk | contribs)   07:58, 23 November 2011

Is Wikidata not able to work with recent version of MediaWiki, or why is the html constructed manually?

Status & tagging log