0

I have some MediaWiki article that will look like:

===Section===
Text Here, some lists, and some other text
===Section2===
{{#ask Query for a Table}}
===Section3===
{{#ask Query for a JQPlot}}

I would like to get the page data, on a per section basis and then process the query in PHP, making a custom parser. I made a page which extends SpecialPage.

$title = Title::newFromText($page);
$article = new Article($title);
$parserOptions = ParserOptions::newFromUser($wgUser);
$article->getRawText();

Currently, I can getRawText() which will return Some Text Here===Section1===More===Section2==={{#ask:Query}}===Section3==={{#ask:Query}}.

How do I process each query (get raw data from the database) so I can parse the data and create a custom output for each query? Moreso, how do I process it on a per section basis? From the documentation, it appears I can use extractSections() but this is assuming I know how many sections there are. Did I miss something?

Nemo
  • 2,441
  • 2
  • 29
  • 63
Rijvi Rajib
  • 1,080
  • 2
  • 11
  • 27
  • What do you want to do with the queries? This might not be the easiest approach to whatever problem you are trying to solve. Have you thought about using a custom result format for the queries, to make them look like you want? – leo Oct 23 '14 at 06:59
  • The problem is, the queries I'm being passed will not have these custom results formats set up. Instead, I'll get `format=jqplot` which I can't use for exporting to PowerPoint. I want to process the query (or send the query to a result parser) that would process the data itself and return slides of the data. However, I'd also need to pass in the section content as well. So my idea was to getContent() of the Article, regex parse out ===TITLE=== as a section, and anything after it until another ===SECTION=== will all go on one slide presentation. Queries would then go through a custom parser. – Rijvi Rajib Oct 23 '14 at 13:48
  • @RijviRajib, sounds like you want to write your own [result format](http://semantic-mediawiki.org/wiki/Help:Result_formats). There are several extensions providing one, among which Semantic Result Formats is the most common. You can inspire your own to those. – Nemo May 02 '15 at 21:17
  • Thanks Nemo, I got an answer for it from the IRC. – Rijvi Rajib May 05 '15 at 07:30

0 Answers0