r25443 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25442‎ | r25443 | r25444 >
Date:16:14, 3 September 2007
Author:proes
Status:old
Tags:
Comment:
Renamed confusing objectId parameter to definedMeaningId in SpecialSuggest.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/suggest.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php
@@ -37,15 +37,13 @@
3838
3939
4040 function getSuggestions() {
41 -
42 -
4341 $o=OmegaWikiAttributes::getInstance();
4442 global $wgUser;
4543 $dc=wdGetDataSetContext();
4644 @$search = ltrim($_GET['search-text']);
4745 @$prefix = $_GET['prefix'];
4846 @$query = $_GET['query'];
49 - @$objectId = $_GET['objectId'];
 47+ @$definedMeaningId = $_GET['definedMeaningId'];
5048 @$offset = $_GET['offset'];
5149 @$attributesLevel = $_GET['attributesLevel'];
5250 $sql='';
@@ -64,16 +62,16 @@
6563 $sql=constructSQLWithFallback($sqlActual, $sqlFallback, array("member_mid", "spelling", "collection_mid"));
6664 break;
6765 case 'option-attribute':
68 - $sql = getSQLToSelectPossibleAttributes($objectId, $attributesLevel, 'OPTN');
 66+ $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, 'OPTN');
6967 break;
7068 case 'translated-text-attribute':
71 - $sql = getSQLToSelectPossibleAttributes($objectId, $attributesLevel, 'TRNS');
 69+ $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, 'TRNS');
7270 break;
7371 case 'text-attribute':
74 - $sql = getSQLToSelectPossibleAttributes($objectId, $attributesLevel, 'TEXT');
 72+ $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, 'TEXT');
7573 break;
7674 case 'link-attribute':
77 - $sql = getSQLToSelectPossibleAttributes($objectId, $attributesLevel, 'URL');
 75+ $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, 'URL');
7876 break;
7977 case 'language':
8078 require_once('languages.php');
@@ -226,19 +224,19 @@
227225 return $sql;
228226 }
229227
230 -function getSQLToSelectPossibleAttributes($objectId, $attributesLevel, $attributesType) {
 228+function getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, $attributesType) {
231229 global
232230 $wgUser;
233231
234 - $sqlActual = getSQLToSelectPossibleAttributesForLanguage($objectId, $attributesLevel, $attributesType, $wgUser->getOption('language'));
235 - $sqlFallback = getSQLToSelectPossibleAttributesForLanguage($objectId, $attributesLevel, $attributesType, 'en');
 232+ $sqlActual = getSQLToSelectPossibleAttributesForLanguage($definedMeaningId, $attributesLevel, $attributesType, $wgUser->getOption('language'));
 233+ $sqlFallback = getSQLToSelectPossibleAttributesForLanguage($definedMeaningId, $attributesLevel, $attributesType, 'en');
236234
237235 return constructSQLWithFallback($sqlActual, $sqlFallback, array("attribute_mid", "spelling"));
238236 }
239237
240238 # language is the 2 letter wikimedia code. use "<ANY>" if you don't want language filtering
241239 # (any does set limit 1 hmph)
242 -function getSQLToSelectPossibleAttributesForLanguage($objectId, $attributesLevel, $attributesType, $language="<ANY>") {
 240+function getSQLToSelectPossibleAttributesForLanguage($definedMeaningId, $attributesLevel, $attributesType, $language="<ANY>") {
243241 global $wgDefaultClassMids;
244242 global $wgUser;
245243 $dc=wdGetDataSetContext();
@@ -274,7 +272,7 @@
275273 " AND ({$dc}_class_attributes.class_mid IN (" .
276274 ' SELECT class_mid ' .
277275 " FROM {$dc}_class_membership" .
278 - " WHERE {$dc}_class_membership.class_member_mid = " . $objectId .
 276+ " WHERE {$dc}_class_membership.class_member_mid = " . $definedMeaningId .
279277 ' AND ' . getLatestTransactionRestriction("{$dc}_class_membership") .
280278 ' )'.
281279 $defaultClassRestriction .
Index: trunk/extensions/Wikidata/OmegaWiki/suggest.js
@@ -46,8 +46,8 @@
4747 suggestText = document.getElementById(suggestPrefix + "text");
4848 suggestText.className = "suggest-loading";
4949
50 - var suggestAttributesLevel = document.getElementById(suggestPrefix + "parameter-attributesLevel");
51 - var suggestObjectId = document.getElementById(suggestPrefix + "parameter-attributesObjectId");
 50+ var suggestAttributesLevel = document.getElementById(suggestPrefix + "parameter-level");
 51+ var suggestDefinedMeaningId = document.getElementById(suggestPrefix + "parameter-definedMeaningId");
5252
5353 var URL = 'index.php';
5454 var location = "" + document.location;
@@ -63,11 +63,11 @@
6464 '&offset=' + encodeURI(suggestOffset) +
6565 '&dataset='+dataSet;
6666
67 - if((suggestAttributesLevel != null) && (suggestObjectId != null))
 67+ if((suggestAttributesLevel != null) && (suggestDefinedMeaningId != null))
6868 URL =
6969 URL +
7070 '&attributesLevel=' + encodeURI(suggestAttributesLevel.value) +
71 - '&objectId=' + encodeURI(suggestObjectId.value);
 71+ '&definedMeaningId=' + encodeURI(suggestDefinedMeaningId.value);
7272 http.open('GET', URL, true);
7373 http.onreadystatechange = function() {
7474 if (http.readyState == 4) {
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -1263,8 +1263,8 @@
12641264 public function add(IdStack $idPath) {
12651265 if ($this->isAddField) {
12661266 $parameters = array(
1267 - "attributesLevel" => $this->attributesLevelName,
1268 - "attributesObjectId" => $idPath->getDefinedMeaningId()
 1267+ "level" => $this->attributesLevelName,
 1268+ "definedMeaningId" => $idPath->getDefinedMeaningId()
12691269 );
12701270
12711271 return getSuggest($this->addId($idPath->getId()), $this->suggestType(), $parameters);
@@ -1274,7 +1274,7 @@
12751275 }
12761276
12771277 public function getEditHTML(IdStack $idPath, $value) {
1278 - $parameters = array("attributesLevel" => $this->attributesLevelName);
 1278+ $parameters = array("level" => $this->attributesLevelName);
12791279 return getSuggest($this->updateId($idPath->getId()), $this->suggestType(), $parameters);
12801280 }
12811281 }
@@ -1307,9 +1307,9 @@
13081308 $syntransId = $idPath->getKeyStack()->peek(0)->syntransId;
13091309
13101310 $parameters = array(
1311 - 'attributesLevel' => $this->attributesLevelName,
1312 - 'attributesObjectId' => $idPath->getDefinedMeaningId(),
1313 - 'onUpdate' => 'updateSelectOptions(\'' . $this->addId($idPath->getId()) . '-option\',' . $syntransId
 1311+ "level" => $this->attributesLevelName,
 1312+ "definedMeaningId" => $idPath->getDefinedMeaningId(),
 1313+ "onUpdate" => 'updateSelectOptions(\'' . $this->addId($idPath->getId()) . '-option\',' . $syntransId
13141314 );
13151315 return getSuggest($this->addId($idPath->getId()), $this->suggestType(), $parameters);
13161316 }
@@ -1319,8 +1319,8 @@
13201320
13211321 public function getEditHTML(IdStack $idPath, $value) {
13221322 $parameters = array(
1323 - 'attributesLevel' => $this->attributesLevelName,
1324 - 'onUpdate' => 'updateSelectOptions(\'' . $this->updateId($idPath->getId()) . '-option\''
 1323+ "level" => $this->attributesLevelName,
 1324+ "onUpdate" => 'updateSelectOptions(\'' . $this->updateId($idPath->getId()) . '-option\''
13251325 );
13261326
13271327 return getSuggest($this->updateId($idPath->getId()), $this->suggestType(), $parameters);

Status & tagging log