Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMWQueryPage.php |
— | — | @@ -1,102 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * @author Markus Krötzsch |
5 | | - * |
6 | | - * An abstract query page base class that supports array-based |
7 | | - * data retrieval instead of the SQL-based access used by MW. |
8 | | - */ |
9 | | - |
10 | | -if (!defined('MEDIAWIKI')) die(); |
11 | | - |
12 | | -global $IP; |
13 | | -require_once( "$IP/includes/SpecialPage.php" ); |
14 | | -require_once( "$IP/includes/Title.php" ); |
15 | | -require_once( "$IP/includes/QueryPage.php"); |
16 | | - |
17 | | -/** |
18 | | - * Abstract base class for SMW's variant of the MW QueryPage. |
19 | | - * Subclasses must implement getResults() and formatResult(), as |
20 | | - * well as some other standard functions of QueryPage. |
21 | | - */ |
22 | | -abstract class SMWQueryPage extends QueryPage { |
23 | | - |
24 | | - /** |
25 | | - * Implemented by subclasses to provide concrete functions. |
26 | | - */ |
27 | | - abstract function getResults($requestoptions); |
28 | | - |
29 | | - /** |
30 | | - * Clear the cache and save new results |
31 | | - */ |
32 | | - function recache( $limit, $ignoreErrors = true ) { |
33 | | - ///TODO |
34 | | - } |
35 | | - |
36 | | - /** |
37 | | - * This is the actual workhorse. It does everything needed to make a |
38 | | - * real, honest-to-gosh query page. |
39 | | - * Alas, we need to overwrite the whole beast since we do not assume |
40 | | - * an SQL-based storage backend. |
41 | | - * |
42 | | - * @param $offset database query offset |
43 | | - * @param $limit database query limit |
44 | | - * @param $shownavigation show navigation like "next 200"? |
45 | | - */ |
46 | | - function doQuery( $offset, $limit, $shownavigation=true ) { |
47 | | - global $wgUser, $wgOut, $wgLang, $wgContLang; |
48 | | - |
49 | | - $options = new SMWRequestOptions(); |
50 | | - $options->limit = $limit; |
51 | | - $options->offset = $offset; |
52 | | - $options->sort = true; |
53 | | - $res = $this->getResults($options); |
54 | | - $num = count($res); |
55 | | - |
56 | | - $sk = $wgUser->getSkin(); |
57 | | - $sname = $this->getName(); |
58 | | - |
59 | | - if($shownavigation) { |
60 | | - $wgOut->addHTML( $this->getPageHeader() ); |
61 | | - |
62 | | - // if list is empty, show it |
63 | | - if( $num == 0 ) { |
64 | | - $wgOut->addHTML( '<p>' . wfMsgHTML('specialpage-empty') . '</p>' ); |
65 | | - return; |
66 | | - } |
67 | | - |
68 | | - $top = wfShowingResults( $offset, $num); |
69 | | - $wgOut->addHTML( "<p>{$top}\n" ); |
70 | | - |
71 | | - // often disable 'next' link when we reach the end |
72 | | - $atend = $num < $limit; |
73 | | - |
74 | | - $sl = wfViewPrevNext( $offset, $limit , |
75 | | - $wgContLang->specialPage( $sname ), |
76 | | - wfArrayToCGI( $this->linkParameters() ), $atend ); |
77 | | - $wgOut->addHTML( "<br />{$sl}</p>\n" ); |
78 | | - } |
79 | | - if ( $num > 0 ) { |
80 | | - $s = array(); |
81 | | - if ( ! $this->listoutput ) |
82 | | - $s[] = $this->openList( $offset ); |
83 | | - |
84 | | - foreach ($res as $r) { |
85 | | - $format = $this->formatResult( $sk, $r ); |
86 | | - if ( $format ) { |
87 | | - $s[] = $this->listoutput ? $format : "<li>{$format}</li>\n"; |
88 | | - } |
89 | | - } |
90 | | - |
91 | | - if ( ! $this->listoutput ) |
92 | | - $s[] = $this->closeList(); |
93 | | - $str = $this->listoutput ? $wgContLang->listToText( $s ) : implode( '', $s ); |
94 | | - $wgOut->addHTML( $str ); |
95 | | - } |
96 | | - if($shownavigation) { |
97 | | - $wgOut->addHTML( "<p>{$sl}</p>\n" ); |
98 | | - } |
99 | | - return $num; |
100 | | - } |
101 | | - |
102 | | -} |
103 | | - |
Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialProperties.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | if (!defined('MEDIAWIKI')) die(); |
10 | 10 | |
11 | 11 | global $smwgIP; |
12 | | -include_once( "$smwgIP/specials/QueryPages/SMWQueryPage.php" ); |
| 12 | +include_once( "$smwgIP/specials/QueryPages/SMW_QueryPage.php" ); |
13 | 13 | |
14 | 14 | class PropertiesPage extends SMWQueryPage { |
15 | 15 | |
Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_QueryPage.php |
— | — | @@ -0,0 +1,102 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * @author Markus Krötzsch |
| 5 | + * |
| 6 | + * An abstract query page base class that supports array-based |
| 7 | + * data retrieval instead of the SQL-based access used by MW. |
| 8 | + */ |
| 9 | + |
| 10 | +if (!defined('MEDIAWIKI')) die(); |
| 11 | + |
| 12 | +global $IP; |
| 13 | +require_once( "$IP/includes/SpecialPage.php" ); |
| 14 | +require_once( "$IP/includes/Title.php" ); |
| 15 | +require_once( "$IP/includes/QueryPage.php"); |
| 16 | + |
| 17 | +/** |
| 18 | + * Abstract base class for SMW's variant of the MW QueryPage. |
| 19 | + * Subclasses must implement getResults() and formatResult(), as |
| 20 | + * well as some other standard functions of QueryPage. |
| 21 | + */ |
| 22 | +abstract class SMWQueryPage extends QueryPage { |
| 23 | + |
| 24 | + /** |
| 25 | + * Implemented by subclasses to provide concrete functions. |
| 26 | + */ |
| 27 | + abstract function getResults($requestoptions); |
| 28 | + |
| 29 | + /** |
| 30 | + * Clear the cache and save new results |
| 31 | + */ |
| 32 | + function recache( $limit, $ignoreErrors = true ) { |
| 33 | + ///TODO |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * This is the actual workhorse. It does everything needed to make a |
| 38 | + * real, honest-to-gosh query page. |
| 39 | + * Alas, we need to overwrite the whole beast since we do not assume |
| 40 | + * an SQL-based storage backend. |
| 41 | + * |
| 42 | + * @param $offset database query offset |
| 43 | + * @param $limit database query limit |
| 44 | + * @param $shownavigation show navigation like "next 200"? |
| 45 | + */ |
| 46 | + function doQuery( $offset, $limit, $shownavigation=true ) { |
| 47 | + global $wgUser, $wgOut, $wgLang, $wgContLang; |
| 48 | + |
| 49 | + $options = new SMWRequestOptions(); |
| 50 | + $options->limit = $limit; |
| 51 | + $options->offset = $offset; |
| 52 | + $options->sort = true; |
| 53 | + $res = $this->getResults($options); |
| 54 | + $num = count($res); |
| 55 | + |
| 56 | + $sk = $wgUser->getSkin(); |
| 57 | + $sname = $this->getName(); |
| 58 | + |
| 59 | + if($shownavigation) { |
| 60 | + $wgOut->addHTML( $this->getPageHeader() ); |
| 61 | + |
| 62 | + // if list is empty, show it |
| 63 | + if( $num == 0 ) { |
| 64 | + $wgOut->addHTML( '<p>' . wfMsgHTML('specialpage-empty') . '</p>' ); |
| 65 | + return; |
| 66 | + } |
| 67 | + |
| 68 | + $top = wfShowingResults( $offset, $num); |
| 69 | + $wgOut->addHTML( "<p>{$top}\n" ); |
| 70 | + |
| 71 | + // often disable 'next' link when we reach the end |
| 72 | + $atend = $num < $limit; |
| 73 | + |
| 74 | + $sl = wfViewPrevNext( $offset, $limit , |
| 75 | + $wgContLang->specialPage( $sname ), |
| 76 | + wfArrayToCGI( $this->linkParameters() ), $atend ); |
| 77 | + $wgOut->addHTML( "<br />{$sl}</p>\n" ); |
| 78 | + } |
| 79 | + if ( $num > 0 ) { |
| 80 | + $s = array(); |
| 81 | + if ( ! $this->listoutput ) |
| 82 | + $s[] = $this->openList( $offset ); |
| 83 | + |
| 84 | + foreach ($res as $r) { |
| 85 | + $format = $this->formatResult( $sk, $r ); |
| 86 | + if ( $format ) { |
| 87 | + $s[] = $this->listoutput ? $format : "<li>{$format}</li>\n"; |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + if ( ! $this->listoutput ) |
| 92 | + $s[] = $this->closeList(); |
| 93 | + $str = $this->listoutput ? $wgContLang->listToText( $s ) : implode( '', $s ); |
| 94 | + $wgOut->addHTML( $str ); |
| 95 | + } |
| 96 | + if($shownavigation) { |
| 97 | + $wgOut->addHTML( "<p>{$sl}</p>\n" ); |
| 98 | + } |
| 99 | + return $num; |
| 100 | + } |
| 101 | + |
| 102 | +} |
| 103 | + |
Property changes on: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_QueryPage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 104 | + native |