Index: trunk/extensions/Wikidata/App.php |
— | — | @@ -48,7 +48,6 @@ |
49 | 49 | global $wgOut,$wgScriptPath; |
50 | 50 | $dc=wdGetDataSetContext(); |
51 | 51 | $wgOut->addScript("<script type='text/javascript' src='{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest.js'></script>"); |
52 | | - $wgOut->addScript("<script type='text/javascript'>var dataset='$dc';</script>"); |
53 | 52 | $wgOut->addLink(array('rel'=>'stylesheet','type'=>'text/css','media'=>'screen, projection','href'=>"{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest.css")); |
54 | 53 | $wgOut->addLink(array('rel'=>'stylesheet','type'=>'text/css','media'=>'screen, projection','href'=>"{$wgScriptPath}/extensions/Wikidata/OmegaWiki/tables.css")); |
55 | 54 | return true; |
Index: trunk/extensions/Wikidata/OmegaWiki/forms.php |
— | — | @@ -52,10 +52,25 @@ |
53 | 53 | return $result . '</select>'; |
54 | 54 | } |
55 | 55 | |
56 | | -function getSuggest($name, $query, $parameters = array(), $value=0, $label='', $displayLabelColumns = array(0)) { |
| 56 | +/** |
| 57 | + * |
| 58 | + * Returns HTML for an autocompleted form field. |
| 59 | + * |
| 60 | + * @param String unique identifier for this form field |
| 61 | + * @param String type of query to run |
| 62 | + * @param Integer Default value |
| 63 | + * @param String How default value will be shown |
| 64 | + * @param Array Override column titles |
| 65 | + * @param DataSet Override standard dataset |
| 66 | + * |
| 67 | +*/ |
| 68 | +function getSuggest($name, $query, $parameters = array(), $value=0, $label='', $displayLabelColumns = array(0), DataSet $dc=null) { |
57 | 69 | global |
58 | 70 | $wgScriptPath; |
59 | 71 | |
| 72 | + if(is_null($dc)) { |
| 73 | + $dc=wdGetDataSetContext(); |
| 74 | + } |
60 | 75 | if ($label == "") |
61 | 76 | $label = ' '; |
62 | 77 | |
— | — | @@ -64,7 +79,8 @@ |
65 | 80 | '<input type="hidden" id="'. $name .'-suggest-query" value="'. $query .'"/>' . |
66 | 81 | '<input type="hidden" id="'. $name .'-suggest-offset" value="0"/>' . |
67 | 82 | '<input type="hidden" id="'. $name .'-suggest-label-columns" value="'. implode(', ', $displayLabelColumns) .'"/>' . |
68 | | - '<input type="hidden" id="'. $name .'" name="'. $name .'" value="'. $value .'"/>'; |
| 83 | + '<input type="hidden" id="'. $name .'" name="'. $name .'" value="'. $value .'"/>' . |
| 84 | + '<input type="hidden" id="'.$name.'-suggest-dataset" value="'.$dc.'"/>'; |
69 | 85 | |
70 | 86 | foreach ($parameters as $parameter => $parameterValue) |
71 | 87 | $result .= |
Index: trunk/extensions/Wikidata/OmegaWiki/suggest.js |
— | — | @@ -38,13 +38,13 @@ |
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | | -function updateSuggestions(suggestPrefix, dataSetOverride) { |
| 42 | +function updateSuggestions(suggestPrefix) { |
43 | 43 | var http = getHTTPObject(); |
44 | 44 | var table = document.getElementById(suggestPrefix + "table"); |
45 | 45 | var suggestQuery = document.getElementById(suggestPrefix + "query").value; |
46 | 46 | var suggestOffset = document.getElementById(suggestPrefix + "offset").value; |
47 | | - var currentDataSet = dataset; |
48 | | - |
| 47 | + var dataSet = document.getElementById(suggestPrefix + "dataset").value; |
| 48 | + |
49 | 49 | suggestText = document.getElementById(suggestPrefix + "text"); |
50 | 50 | suggestText.className = "suggest-loading"; |
51 | 51 | |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | '&prefix=' + encodeURI(suggestPrefix) + |
65 | 65 | '&query=' + encodeURI(suggestQuery) + |
66 | 66 | '&offset=' + encodeURI(suggestOffset) + |
67 | | - '&dataset='+currentDataSet; |
| 67 | + '&dataset='+dataSet; |
68 | 68 | |
69 | 69 | if((suggestAttributesLevel != null) && (suggestObjectId != null)) |
70 | 70 | URL = |
— | — | @@ -190,11 +190,10 @@ |
191 | 191 | stopEventHandling(event); |
192 | 192 | } |
193 | 193 | |
194 | | -function suggestNextClicked(event, suggestNext) { |
| 194 | +function suggestNextClicked(event, suggestNext, dataSetOverride) { |
195 | 195 | var suggestPrefix = getSuggestPrefix(suggestNext, 'next'); |
196 | 196 | var suggestOffset = document.getElementById(suggestPrefix + 'offset'); |
197 | 197 | suggestOffset.value = parseInt(suggestOffset.value) + 10; |
198 | | - updateSuggestions(suggestPrefix); |
199 | 198 | stopEventHandling(event); |
200 | 199 | } |
201 | 200 | |
— | — | @@ -202,7 +201,6 @@ |
203 | 202 | var suggestPrefix = getSuggestPrefix(suggestPrevious, 'previous'); |
204 | 203 | var suggestOffset = document.getElementById(suggestPrefix + 'offset'); |
205 | 204 | suggestOffset.value = Math.max(parseInt(suggestOffset.value) - 10, 0); |
206 | | - updateSuggestions(suggestPrefix); |
207 | 205 | stopEventHandling(event); |
208 | 206 | } |
209 | 207 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php |
— | — | @@ -33,8 +33,13 @@ |
34 | 34 | } |
35 | 35 | |
36 | 36 | function execute( $par ) { |
37 | | - global $wgOut, $wgRequest, $wgTitle, $wgUser; |
| 37 | + global $wgOut, $wgRequest, $wgTitle, $wgUser, $wdTermDBDataSet; |
38 | 38 | $wgOut->setPageTitle("ConceptMapping"); |
| 39 | + |
| 40 | + if(!$wgUser->isAllowed('editwikidata-'.$wdTermDBDataSet)) { |
| 41 | + $wgOut->addHTML("Permission denied."); |
| 42 | + return false; |
| 43 | + } |
39 | 44 | $action=$wgRequest->getText('action'); |
40 | 45 | if(!$action) { |
41 | 46 | $this->ui(); |
— | — | @@ -74,9 +79,9 @@ |
75 | 80 | if($rq[$set]) { |
76 | 81 | $dmModel=new DefinedMeaningModel($rq[$set],null,$setObject); |
77 | 82 | $defaultSel=$dmModel->getSyntransByLanguageCode($lang); |
78 | | - $options[$setObject->fetchName()]=getSuggest("set_$set", 'defined-meaning',array(), $rq[$set], $defaultSel); |
| 83 | + $options[$setObject->fetchName()]=getSuggest("set_$set", 'defined-meaning',array(), $rq[$set], $defaultSel, array(0), $setObject); |
79 | 84 | } else { |
80 | | - $options[$setObject->fetchName()]=getSuggest("set_$set", 'defined-meaning'); |
| 85 | + $options[$setObject->fetchName()]=getSuggest("set_$set", 'defined-meaning', array(), null, null, array(0), $setObject); |
81 | 86 | } |
82 | 87 | |
83 | 88 | } |