ok, I have a sort-of fix, by adding a function hook in SMW_SpecialAsk:

here's the code:
     * Constructor
    public function __construct() {

        global $wgHooks;
        $wgHooks['LinkerMakeExternalLink'][] = array($this,"doLinkerMakeExternalLink");

    public function doLinkerMakeExternalLink($url, $text, $link, $attribs, $linktype){
      $isImageUrl = true;
        $link = "<a href='$url'><img src='$url' alt='$text' border='0'></a>"; 
        // if it's an image, render it as an image. Otherwise, don't change it.
        return false;
      return true;

Obviously, one problem is that it turns EVERY link into an image link, which is obviously wrong. I was about to write a regex to resolve this, but then I realized MW must have its own regex for determining if a link is an image, so I should piggyback on that. Anyone know the best way to do that?

Aside from that, anyone see any additional problems with this solution?


From: don undeen <donundeen@yahoo.com>
To: Yaron Koren <yaron57@gmail.com>
Cc: smw dev list <semediawiki-devel@lists.sourceforge.net>; smw list <semediawiki-user@lists.sourceforge.net>
Sent: Thu, May 27, 2010 11:47:57 AM
Subject: Re: [SMW-devel] [Semediawiki-user] Fw: "further results" of inline query to display images?

I've been looking at this, tracking code all over the place.

The problem seems to be, that in the initial {{#ask query page, the function hook doAsk is called, and the results are passed along for additional wiki parsing. IE, it may return a peice of text for a result, that looks like [http://servername/image.jpg] .
This is because the queryResultPrinter's getResult method, is called with the outputmode SMW_OUTPUT_WIKI.
Then, farther up the stack, that will get recognized as an image, and rendered as such.

On a Special:Ask, page, howerever, the processesing is different.
in SMW_SpecialAsk.php, roughly line 270 (I've got too much debug code in there to be sure of exact line numbers),
the queryResultPrinter's getResult method is called with outpputmode SMW_OUTPUT_HTML, which allows the links (properties of type "_uri" to get rendered as links; there's no check to see if the links are images and should be rendered as such.

and the results don't go through any additional wiki parsing. So I can't just change the output mode to SMW_OUTPUT_WIKI there, unless there's a line I can insert to say "do additional wiki link parsing"

When calling getResult with outputmode SMW_OUTPUT_HTML, the url ultimately gets passed through Linker->makeExternalLink .

That method has a function hook call, LinkerMakeExternalLink, which makes me think maybe we could override the functionality here somehow. What do you think of that?

basically, the initial query results page, and the "further results" page , are executed within very different contexts.

From: Yaron Koren <yaron57@gmail.com>
To: don undeen <donundeen@yahoo.com>
Cc: smw list <semediawiki-user@lists.sourceforge.net>
Sent: Wed, May 26, 2010 4:57:39 PM
Subject: Re: [Semediawiki-user] Fw: "further results" of inline query to display images?

That sounds like a bug in Special:Ask - it's meant to basically replicate exactly what shows up when you run inline queries in other pages, but it doesn't always. If you're willing to look into it, that would be great - all the relevant code is in /specials/SpecialAsk/SMW_SpecialAsk.php.


On Wed, May 26, 2010 at 3:46 PM, don undeen <donundeen@yahoo.com> wrote:
[sorry, mean to send this to the whole list...]

Is that a bug or a feature? :)
I could work on fixing that, if it's possible and desired.
Seems to me, that if you're looking at the query results on a page, and you click "further results", the expected result would be that the results look like they're in the same format as the initial set of results.

But, since this is redirecting to a different page, I can see how there would be complications.

From: Jeroen De Dauw <jeroendedauw@gmail.com>
To: don undeen <donundeen@yahoo.com>
Sent: Wed, May 26, 2010 1:57:04 PM
Subject: Re: [Semediawiki-user] "further results" of inline query to display  images?

I don't think you can do that. You can however modify the target of the 'further results' link to a page containing a query of your own design.

Jeroen De Dauw
* http://blog.bn2vs.com
* http://wiki.bn2vs.com
Don't panic. Don't be evil. 50 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!

On 19 May 2010 22:56, don undeen <donundeen@yahoo.com> wrote:

>Hi guys,
>>I've got a query in my page that looks like:
>>{{#ask: [[Category:Art Object]]
>>[[Has family map coordinates::+]]
>>| ?has image url
>>| ?-HighlightsObject
>>| ?Made by
>>| format=table
>>| merge=false
>>the "has image url" is a uri-type property, and when the first page of results shows, each url is rendered as an image, which is what I want.
>>however, when I click on "further results" - it goes to the special:ask page, and in my results, only the image url is displayed, not the image itself.
>>Is there any way to fix this, so I see teh image itself on the Special:ask page?
>>version info:
>>MediaWiki 1.15.1
>>PHP 5.3.0 (apache2handler)
>>MySQL 5.1.36-community-log Semantic MediaWiki (Version 1.5.0)
>>SMWHalo Extension (Version 1.4.6-for-SMW-1.4.3)
>>Semantic Result Formats (Version 1.4.6)
>>and a handful of unrelated extensions.
>>thanks for your help all, and sorry if this has been covered in the past. I couldn't find any references
>>(btw, is there a searchable SMW-users archive?)
>>Semediawiki-user mailing list

Semediawiki-user mailing list

WikiWorks MediaWiki Consulting http://wikiworks.com