r40377 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40376‎ | r40377 | r40378 >
Date:11:41, 3 September 2008
Author:vrandezo
Status:old
Tags:
Comment:
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php
@@ -67,6 +67,8 @@
6868 if ($this->propertystring == '') $this->propertystring = current($params);
6969 if ($this->valuestring == '') $this->valuestring = next($params);
7070
 71+ $this->valuestring = str_replace(" ", " ", $this->valuestring);
 72+
7173 $this->property = Title::newFromText( $this->propertystring, SMW_NS_PROPERTY );
7274 if (null === $this->property) {
7375 $this->propertystring = '';
@@ -86,7 +88,7 @@
8789 if (is_numeric($offsetstring)) $this->offset = intval($offsetstring);
8890
8991 $wgOut->addHTML($this->displaySearchByProperty());
90 - $wgOut->addHTML($this->queryFormAutocomplete());
 92+ $wgOut->addHTML($this->queryForm());
9193 }
9294
9395 /**
@@ -171,7 +173,7 @@
172174 if (!$first && ($number > 0)) while ( count($results) > $number ) array_pop($results);
173175 while ( $results && $number != 0) {
174176 $result = array_pop( $results );
175 - $thing = $skin->makeKnownLinkObj( $result[0]->getTitle() );
 177+ $thing = $skin->makeKnownLinkObj( $result[0]->getTitle(), $result[0]->getText() );
176178 $browselink = SMWInfolink::newBrowsingLink('+', $result[0]->getShortHTMLText())->getHTML($skin);
177179 $val = $result[1]->getLongHTMLText( $skin );
178180 $html .= '<li>' . $thing . '&nbsp;&nbsp;' . $browselink;
@@ -311,101 +313,4 @@
312314 return $html;
313315 }
314316
315 - private function queryFormAutocomplete() {
316 - global $wgAjaxExportList;
317 - $wgAjaxExportList[] = 'smwfGetValues';
318 - $javascript_text =<<<END
319 -
320 -var last_property = null;
321 -
322 -function suggestValues(){
323 - var suggestdiv = document.getElementById("suggestedvalues");
324 - var x = document.getElementById("smw_searchbyprop_value").value;
325 - var z = document.getElementById("searchInput2").value;
326 -
327 - if (z == last_property) {
328 - return;
329 - }
330 - last_property = z;
331 -
332 - if (z.value != "" && z.length > 3) {
333 - sajax_do_call("smwfGetValues", [z,x], suggestdiv);
334 - }
335317 }
336 -
337 -function start_value_suggestion_onload(){
338 - var z = document.getElementById('searchInput2');
339 - var y = document.getElementById('smw_searchbyprop_value');
340 - y.onfocus = function() { suggestValues(); };
341 -
342 - if(z.value != "" && y.value == "") {
343 - suggestValues();
344 - }
345 -}
346 -
347 -function setValues(){
348 - document.getElementById("smw_searchbyprop_value").value = document.getElementById("smw_suggestedvalueselection").options[document.getElementById("smw_suggestedvalueselection").selectedIndex].value;
349 -}
350 -END;
351 - global $wgJsMimeType, $wgOut;
352 - $spectitle = Title::makeTitle( NS_SPECIAL, 'SearchByProperty' );
353 - $wgOut->addScript('<script type="' . $wgJsMimeType . '" >' . $javascript_text . '</script>');
354 - $wgOut->addScript('<script type="' . $wgJsMimeType . '"> hookEvent("load", start_value_suggestion_onload);</script>');
355 -
356 - // display query form
357 - $html = '<p>&nbsp;' .
358 - '<form id="searchform2" action ="' . $spectitle->escapeLocalURL() . '" method="get">' .
359 - '<table>' .
360 - '<tr>' .
361 - '<td>' .
362 - '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '" />' .
363 - '<input type="hidden" name="ns'.SMW_NS_PROPERTY.'" value="1" />'. //defines the namespace for mwsuggest
364 - wfMsg('smw_sbv_property') . '' .
365 - ' <input id="searchInput2" type="text" name="property" value="' . htmlspecialchars($this->propertystring) . '" />'.
366 - '</td>' .
367 - '<td>' . '&nbsp;&nbsp;&nbsp;' . wfMsg('smw_sbv_value') .
368 - '</td>' .
369 - '<td>' .
370 - '<input id ="smw_searchbyprop_value" type="text" name="value" value="' . htmlspecialchars($this->valuestring) . '" style="width:100%;" />'.
371 - '</td>' .
372 - '<td>' .
373 - '&nbsp;&nbsp;&nbsp;<input type="submit" value="' . wfMsg('smw_sbv_submit') . '" />' .
374 - '</td>'.
375 - '</tr>' .
376 - '<tr>' .
377 - '<td></td>' .
378 - '<td></td>' .
379 - '<td><div id="suggestedvalues"></div></td>' .
380 - '<td></td>' .
381 - '</tr>' .
382 - '</table>' .
383 - '</form>'.
384 - '</p>';
385 -
386 - return $html;
387 - }
388 -
389 - // @todo doc
390 - static function getSuggestedValues($property, $value) {
391 - //replace white space with underscore
392 - $property = str_replace(' ', '_', $property);
393 - $propertytitle = Title::newFromText($property, SMW_NS_PROPERTY );
394 - $values = array();
395 - $values = smwfGetStore()->getPropertyValues(null, $propertytitle);
396 -
397 - $r = '';
398 - foreach($values as $datavalue){
399 - $r .= '<option>' .$datavalue->getWikiValue() . "</option>";
400 - }
401 - $number = sizeof($values);
402 - if ($number > 5)
403 - $number = 5;
404 - if ($number == 0) {
405 - $html = wfMsg('smw_sbv_novaluesuggest');
406 - } else {
407 - $html = '<form><select id="smw_suggestedvalueselection" size="' . $number . '" onfocus="setValues()" onchange="setValues()" style="width:100%;">' . $r . '</select></form>';
408 - }
409 - return $html;
410 - }
411 -
412 -}
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -210,8 +210,9 @@
211211 * @return A string containing the HTML with the subject line
212212 */
213213 private function displayHead() {
214 - global $wgUser;
 214+ global $wgUser, $wgOut;
215215 $skin = $wgUser->getSkin();
 216+ $wgOut->setHTMLTitle($this->subject->getTitle());
216217 $html = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n";
217218 $html .= "<tr class=\"smwb-title\"><td colspan=\"2\">\n";
218219 $html .= $skin->makeLinkObj($this->subject->getTitle()) . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility

Status & tagging log