Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByAttribute.php |
— | — | @@ -1,157 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * @author Denny Vrandecic |
5 | | - * |
6 | | - * This special page for Semantic MediaWiki implements a |
7 | | - * view on a relation-object pair, i.e. a typed baclink. |
8 | | - * For example, it shows me all persons born in Croatia, |
9 | | - * or all winners of the Academy Award for best actress. |
10 | | - */ |
11 | | - |
12 | | -if (!defined('MEDIAWIKI')) die(); |
13 | | - |
14 | | -global $IP, $smwgIP; |
15 | | - |
16 | | -require_once( "$IP/includes/SpecialPage.php" ); |
17 | | -require_once( "$smwgIP/includes/storage/SMW_Store.php" ); |
18 | | - |
19 | | -function doSpecialSearchByAttribute($query = '') { |
20 | | - SMW_SearchByAttribute::execute($query); |
21 | | -} |
22 | | - |
23 | | -SpecialPage::addPage( new SpecialPage('SearchByAttribute','',true,'doSpecialSearchByAttribute',false) ); |
24 | | - |
25 | | -class SMW_SearchByAttribute { |
26 | | - |
27 | | - static function execute($query = '') { |
28 | | - global $wgRequest, $wgOut, $wgUser, $smwgQMaxInlineLimit; |
29 | | - $skin = $wgUser->getSkin(); |
30 | | - |
31 | | - // get the GET parameters |
32 | | - $attributestring = $wgRequest->getVal( 'attribute' ); |
33 | | - $valuestring = $wgRequest->getVal( 'value' ); |
34 | | - // no GET parameters? Then try the URL |
35 | | - if (('' == $attributestring) && ('' == $valuestring)) { |
36 | | - $queryparts = explode(':=', $query); |
37 | | - $attributestring = $query; |
38 | | - if (count($queryparts) == 2) { |
39 | | - $attributestring = $queryparts[0]; |
40 | | - $valuestring = str_replace("_", " ", $queryparts[1]); |
41 | | - } |
42 | | - } |
43 | | - $attribute = Title::newFromText( $attributestring, SMW_NS_ATTRIBUTE ); |
44 | | - if (NULL == $attribute) { $attributestring = ''; } else { $attributestring = $attribute->getText(); } |
45 | | - |
46 | | - $limit = $wgRequest->getVal( 'limit' ); |
47 | | - if ('' == $limit) $limit = 20; |
48 | | - $offset = $wgRequest->getVal( 'offset' ); |
49 | | - if ('' == $offset) $offset = 0; |
50 | | - $html = ''; |
51 | | - $spectitle = Title::makeTitle( NS_SPECIAL, 'SearchByAttribute' ); |
52 | | - |
53 | | - if ('' == $attributestring) { // empty page. If no attribute given the value does not matter |
54 | | - $html .= wfMsg('smw_sbv_docu') . "\n"; |
55 | | - } else { |
56 | | - // Now that we have an attribute, let's figure out the datavalue |
57 | | - $value = SMWDataValueFactory::newPropertyObjectValue( $attribute, $valuestring ); |
58 | | - if ( $value->isValid() == FALSE ) { // no value understood |
59 | | - $html .= wfMSG('smw_sbv_novalue', $skin->makeLinkObj($attribute, $attribute->getText())); |
60 | | - $valuestring = ''; |
61 | | - } else { // everything is given |
62 | | - $wgOut->setPagetitle( $attribute->getText() . ' ' . $value->getShortHTMLText(NULL) ); |
63 | | - $valuestring = $value->getWikiValue(); |
64 | | - |
65 | | - $options = new SMWRequestOptions(); |
66 | | - $options->limit = $limit+1; |
67 | | - $options->offset = $offset; |
68 | | - |
69 | | - $res = &smwfGetStore()->getPropertySubjects( $attribute, $value, $options ); |
70 | | - $count = count($res); |
71 | | - |
72 | | - |
73 | | - $html .= wfMsg('smw_sbv_displayresult', $skin->makeLinkObj($attribute, $attribute->getText()), $value->getShortHTMLText($skin)) . "<br />\n"; |
74 | | - |
75 | | - // prepare navigation bar |
76 | | - if ($offset > 0) |
77 | | - $navigation = '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByAttribute','offset=' . max(0,$offset-$limit) . '&limit=' . $limit . '&attribute=' . urlencode($attribute->getText()) .'&value=' . urlencode($value->getWikiValue()))) . '">' . wfMsg('smw_result_prev') . '</a>'; |
78 | | - else |
79 | | - $navigation = wfMsg('smw_result_prev'); |
80 | | - |
81 | | - $navigation .= ' <b>' . wfMsg('smw_result_results') . ' ' . ($offset+1) . '– ' . ($offset + min($count, $limit)) . '</b> '; |
82 | | - |
83 | | - if ($count>$limit) { |
84 | | - $navigation .= ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByAttribute', 'offset=' . ($offset+$limit) . '&limit=' . $limit . '&attribute=' . urlencode($attribute->getText()) . '&value=' . urlencode($value->getWikiValue()))) . '">' . wfMsg('smw_result_next') . '</a>'; |
85 | | - } else { |
86 | | - $navigation .= wfMsg('smw_result_next'); |
87 | | - } |
88 | | - |
89 | | - $max = false; $first=true; |
90 | | - foreach (array(20,50,100,250,500) as $l) { |
91 | | - if ($max) continue; |
92 | | - if ($first) { |
93 | | - $navigation .= ' ('; |
94 | | - $first = false; |
95 | | - } else |
96 | | - $navigation .= ' | '; |
97 | | - if ($l > $smwgQMaxInlineLimit) { |
98 | | - $l = $smwgQMaxInlineLimit; |
99 | | - $max = true; |
100 | | - } |
101 | | - if ( $limit != $l ) { |
102 | | - $navigation .= '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByAttribute','offset=' . $offset . '&limit=' . $l . '&attribute=' . urlencode($attribute->getText()) . '&value=' . urlencode($value->getWikiValue()))) . '">' . $l . '</a>'; |
103 | | - } else { |
104 | | - $navigation .= '<b>' . $l . '</b>'; |
105 | | - } |
106 | | - } |
107 | | - $navigation .= ')'; |
108 | | - |
109 | | -// TODO The following code can be turned into a list of similar result, instead of |
110 | | -// exact results one day. It is unclear, if this should go over the iq or if rather |
111 | | -// the storage API should be extended. The iq part is outlined here, but does not |
112 | | -// really work, and would require another query printer as it is outlined here. |
113 | | - |
114 | | -// if ($count < ($limit/2)) { // if there is only a small number of results |
115 | | -// $iqoptions = array(); |
116 | | -// $iqoptions['limit'] = $limit/2+$count; |
117 | | -// $iqoptions['sort'] = $attribute->getText(); |
118 | | -// $iqoptions['order'] = 'DESC'; |
119 | | -// $iqoptions['format'] = 'ul'; |
120 | | -// $iqoptions['headers'] = 'hide'; |
121 | | -// $iq = new SMWInlineQuery($iqoptions, FALSE); |
122 | | -// $html .= $iq->getHTMLResult("[[" . $attribute->getText() . ":=<" . $value->getUserValue() . "]] [[" . $attribute->getText() . ":=*]]"); |
123 | | -// $iqoptions['offset'] = $count; |
124 | | -// $iqoptions['order'] = 'ASC'; |
125 | | -// $iqoptions['limit'] = $limit/2-$count; |
126 | | -// $iq = new SMWInlineQuery($iqoptions, FALSE); |
127 | | -// $html .= $iq->getHTMLResult("[[" . $attribute->getText() . ":=>" . $value->getUserValue() . "]] [[" . $attribute->getText() . ":=*]]"); |
128 | | -// } |
129 | | - |
130 | | - if ($count == 0) { |
131 | | - $html .= wfMsg( 'smw_result_noresults' ); |
132 | | - } else { // if there are plenty of results anyway |
133 | | - // no need to show the navigation bars when there is not enough to navigate |
134 | | - if (($offset>0) || ($count>$limit)) $html .= '<br />' . $navigation; |
135 | | - $html .= "<ul>\n"; |
136 | | - foreach ($res as $t) { |
137 | | - $browselink = SMWInfolink::newBrowsingLink('+',$t->getPrefixedText()); |
138 | | - $html .= '<li>' . $skin->makeKnownLinkObj($t) . ' ' . $browselink->getHTML($skin) . "</li> \n"; |
139 | | - } |
140 | | - $html .= "</ul>\n"; |
141 | | - if (($offset>0) || ($count>$limit)) $html .= $navigation; |
142 | | - } |
143 | | - } |
144 | | - } |
145 | | - |
146 | | - // display query form |
147 | | - $html .= '<p> </p>'; |
148 | | - $html .= '<form name="searchbyattribute" action="' . $spectitle->escapeLocalURL() . '" method="get">' . "\n" . |
149 | | - '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>' ; |
150 | | - $html .= wfMsg('smw_sbv_attribute') . ' <input type="text" name="attribute" value="' . htmlspecialchars($attributestring) . '" />' . " \n"; |
151 | | - $html .= wfMsg('smw_sbv_value') . ' <input type="text" name="value" value="' . htmlspecialchars($valuestring) . '" />' . "\n"; |
152 | | - $html .= '<input type="submit" value="' . wfMsg('smw_sbv_submit') . "\"/>\n</form>\n"; |
153 | | - |
154 | | - $wgOut->addHTML($html); |
155 | | - } |
156 | | - |
157 | | -} |
158 | | - |
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByRelation.php |
— | — | @@ -1,135 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * @author Denny Vrandecic |
5 | | - * |
6 | | - * This special page for Semantic MediaWiki implements a |
7 | | - * view on a relation-object pair, i.e. a typed baclink. |
8 | | - * For example, it shows me all persons born in Croatia, |
9 | | - * or all winners of the Academy Award for best actress. |
10 | | - */ |
11 | | - |
12 | | -if (!defined('MEDIAWIKI')) die(); |
13 | | - |
14 | | -global $IP, $smwgIP; |
15 | | -require_once( "$IP/includes/SpecialPage.php" ); |
16 | | -require_once( "$smwgIP/includes/storage/SMW_Store.php" ); |
17 | | - |
18 | | - |
19 | | -function doSpecialSearchByRelation($query = '') { |
20 | | - SMW_SearchByRelation::execute($query); |
21 | | -} |
22 | | - |
23 | | -SpecialPage::addPage( new SpecialPage('SearchByRelation','',true,'doSpecialSearchByRelation',false) ); |
24 | | - |
25 | | - |
26 | | - |
27 | | -class SMW_SearchByRelation { |
28 | | - |
29 | | - static function execute($query = '') { |
30 | | - global $wgRequest, $wgOut, $wgUser, $smwgQMaxInlineLimit; |
31 | | - $skin = $wgUser->getSkin(); |
32 | | - |
33 | | - // get the GET parameters |
34 | | - $type = $wgRequest->getVal( 'type' ); |
35 | | - $target = $wgRequest->getVal( 'target' ); |
36 | | - // no GET parameters? Then try the URL |
37 | | - if (('' == $type) && ('' == $target)) { |
38 | | - $queryparts = explode('::', $query); |
39 | | - $type = $query; |
40 | | - if (count($queryparts) > 1) { |
41 | | - $type = $queryparts[0]; |
42 | | - $target = implode('::', array_slice($queryparts, 1)); |
43 | | - } |
44 | | - } |
45 | | - $relation = Title::newFromText( $type, SMW_NS_RELATION ); |
46 | | - if (NULL != $relation) { $type = $relation->getText(); } else { $type = ''; } |
47 | | - $object = Title::newFromText( $target ); |
48 | | - if (NULL != $object) { $target = $object->getText(); } else { $target = ''; } |
49 | | - $limit = $wgRequest->getVal( 'limit' ); |
50 | | - if ('' == $limit) $limit = 20; |
51 | | - $offset = $wgRequest->getVal( 'offset' ); |
52 | | - if ('' == $offset) $offset = 0; |
53 | | - $html = ''; |
54 | | - $spectitle = Title::makeTitle( NS_SPECIAL, 'SearchByRelation' ); |
55 | | - |
56 | | - if (('' == $type) && ('' == $target)) { // empty page. No relation and no object given. |
57 | | - $html .= wfMsg('smw_tb_docu') . "\n"; |
58 | | - } elseif ('' == $type) { // no relation given |
59 | | - $wlhtitle = Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ); |
60 | | - $wlhlink = htmlspecialchars($skin->makeSpecialUrl('Whatlinkshere/' . $object->getPrefixedURL())); |
61 | | - $html .= wfMsg('smw_tb_notype', $object->getPrefixedText(), $wlhlink); |
62 | | - } elseif ('' == $target) { // no object given |
63 | | - $html .= wfMSG('smw_tb_notarget', $skin->makeLinkObj($relation, $relation->getText())); |
64 | | - } else { // everything is given |
65 | | - $wgOut->setPagetitle($relation->getText() . ' ' . $object->getFullText()); |
66 | | - $options = new SMWRequestOptions(); |
67 | | - $options->limit = $limit+1; |
68 | | - $options->offset = $offset; |
69 | | - // get results (get one more, to see if we have to add a link to more) |
70 | | - $results = &smwfGetStore()->getRelationSubjects($relation, $object, $options); |
71 | | - |
72 | | - $html .= wfMsg('smw_tb_displayresult', $skin->makeLinkObj($relation, $relation->getText()), $skin->makeLinkObj($object)) . "<br />\n"; |
73 | | - |
74 | | - // prepare navigation bar |
75 | | - if ($offset > 0) |
76 | | - $navigation = '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByRelation','offset=' . max(0,$offset-$limit) . '&limit=' . $limit . '&type=' . urlencode($type) .'&target=' . urlencode($target))) . '">' . wfMsg('smw_result_prev') . '</a>'; |
77 | | - else |
78 | | - $navigation = wfMsg('smw_result_prev'); |
79 | | - |
80 | | - $navigation .= ' <b>' . wfMsg('smw_result_results') . ' ' . ($offset+1) . '– ' . ($offset + min(count($results), $limit)) . '</b> '; |
81 | | - |
82 | | - if (count($results)==($limit+1)) |
83 | | - $navigation .= ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByRelation', 'offset=' . ($offset+$limit) . '&limit=' . $limit . '&type=' . urlencode($type) . '&target=' . urlencode($target))) . '">' . wfMsg('smw_result_next') . '</a>'; |
84 | | - else |
85 | | - $navigation .= wfMsg('smw_result_next'); |
86 | | - |
87 | | - $max = false; $first=true; |
88 | | - foreach (array(20,50,100,250,500) as $l) { |
89 | | - if ($max) continue; |
90 | | - if ($first) { |
91 | | - $navigation .= ' ('; |
92 | | - $first = false; |
93 | | - } else |
94 | | - $navigation .= ' | '; |
95 | | - if ($l > $smwgQMaxInlineLimit) { |
96 | | - $l = $smwgQMaxInlineLimit; |
97 | | - $max = true; |
98 | | - } |
99 | | - if ( $limit != $l ) { |
100 | | - $navigation .= '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByRelation','offset=' . $offset . '&limit=' . $l . '&type=' . urlencode($type) . '&target=' . urlencode($target))) . '">' . $l . '</a>'; |
101 | | - } else { |
102 | | - $navigation .= '<b>' . $l . '</b>'; |
103 | | - } |
104 | | - } |
105 | | - $navigation .= ')'; |
106 | | - |
107 | | - // no need to show the navigation bars when there is not enough to navigate |
108 | | - if (($offset>0) || (count($results)>$limit)) |
109 | | - $html .= '<br />' . $navigation; |
110 | | - if (count($results) == 0) |
111 | | - $html .= wfMsg( 'smw_result_noresults' ); |
112 | | - else { |
113 | | - $html .= "<ul>\n"; |
114 | | - foreach ($results as $result) { |
115 | | - $browselink = SMWInfolink::newBrowsingLink('+',$result->getPrefixedText()); |
116 | | - $html .= '<li>' . $skin->makeKnownLinkObj($result) . ' ' . $browselink->getHTML($skin) . "</li> \n"; |
117 | | - } |
118 | | - $html .= "</ul>\n"; |
119 | | - } |
120 | | - if (($offset>0) || (count($results)>$limit)) |
121 | | - $html .= $navigation; |
122 | | - } |
123 | | - |
124 | | - // display query form |
125 | | - $html .= '<p> </p>'; |
126 | | - $html .= '<form name="searchbyrelation" action="' . $spectitle->escapeLocalURL() . '" method="get">' . "\n" . |
127 | | - '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>' ; |
128 | | - $html .= wfMsg('smw_tb_linktype') . ' <input type="text" name="type" value="' . htmlspecialchars($type) . '" />' . " \n"; |
129 | | - $html .= wfMsg('smw_tb_linktarget') . ' <input type="text" name="target" value="' . htmlspecialchars($target) . '" />' . "\n"; |
130 | | - $html .= '<input type="submit" value="' . wfMsg('smw_tb_submit') . "\"/>\n</form>\n"; |
131 | | - |
132 | | - $wgOut->addHTML($html); |
133 | | - } |
134 | | - |
135 | | -} |
136 | | - |
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php |
— | — | @@ -0,0 +1,157 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * @author Denny Vrandecic |
| 5 | + * |
| 6 | + * This special page for Semantic MediaWiki implements a |
| 7 | + * view on a relation-object pair, i.e. a typed baclink. |
| 8 | + * For example, it shows me all persons born in Croatia, |
| 9 | + * or all winners of the Academy Award for best actress. |
| 10 | + */ |
| 11 | + |
| 12 | +if (!defined('MEDIAWIKI')) die(); |
| 13 | + |
| 14 | +global $IP, $smwgIP; |
| 15 | + |
| 16 | +require_once( "$IP/includes/SpecialPage.php" ); |
| 17 | +require_once( "$smwgIP/includes/storage/SMW_Store.php" ); |
| 18 | + |
| 19 | +function doSpecialSearchByProperty($query = '') { |
| 20 | + SMW_SearchByProperty::execute($query); |
| 21 | +} |
| 22 | + |
| 23 | +SpecialPage::addPage( new SpecialPage('SearchByProperty','',true,'doSpecialSearchByProperty',false) ); |
| 24 | + |
| 25 | +class SMW_SearchByProperty { |
| 26 | + |
| 27 | + static function execute($query = '') { |
| 28 | + global $wgRequest, $wgOut, $wgUser, $smwgQMaxInlineLimit; |
| 29 | + $skin = $wgUser->getSkin(); |
| 30 | + |
| 31 | + // get the GET parameters |
| 32 | + $attributestring = $wgRequest->getVal( 'property' ); |
| 33 | + $valuestring = $wgRequest->getVal( 'value' ); |
| 34 | + // no GET parameters? Then try the URL |
| 35 | + if (('' == $attributestring) && ('' == $valuestring)) { |
| 36 | + $queryparts = explode(':=', $query); |
| 37 | + $attributestring = $query; |
| 38 | + if (count($queryparts) == 2) { |
| 39 | + $attributestring = $queryparts[0]; |
| 40 | + $valuestring = str_replace("_", " ", $queryparts[1]); |
| 41 | + } |
| 42 | + } |
| 43 | + $attribute = Title::newFromText( $attributestring, SMW_NS_ATTRIBUTE ); |
| 44 | + if (NULL == $attribute) { $attributestring = ''; } else { $attributestring = $attribute->getText(); } |
| 45 | + |
| 46 | + $limit = $wgRequest->getVal( 'limit' ); |
| 47 | + if ('' == $limit) $limit = 20; |
| 48 | + $offset = $wgRequest->getVal( 'offset' ); |
| 49 | + if ('' == $offset) $offset = 0; |
| 50 | + $html = ''; |
| 51 | + $spectitle = Title::makeTitle( NS_SPECIAL, 'SearchByProperty' ); |
| 52 | + |
| 53 | + if ('' == $attributestring) { // empty page. If no attribute given the value does not matter |
| 54 | + $html .= wfMsg('smw_sbv_docu') . "\n"; |
| 55 | + } else { |
| 56 | + // Now that we have an attribute, let's figure out the datavalue |
| 57 | + $value = SMWDataValueFactory::newPropertyObjectValue( $attribute, $valuestring ); |
| 58 | + if ( $value->isValid() == FALSE ) { // no value understood |
| 59 | + $html .= wfMSG('smw_sbv_novalue', $skin->makeLinkObj($attribute, $attribute->getText())); |
| 60 | + $valuestring = ''; |
| 61 | + } else { // everything is given |
| 62 | + $wgOut->setPagetitle( $attribute->getText() . ' ' . $value->getShortHTMLText(NULL) ); |
| 63 | + $valuestring = $value->getWikiValue(); |
| 64 | + |
| 65 | + $options = new SMWRequestOptions(); |
| 66 | + $options->limit = $limit+1; |
| 67 | + $options->offset = $offset; |
| 68 | + |
| 69 | + $res = &smwfGetStore()->getPropertySubjects( $attribute, $value, $options ); |
| 70 | + $count = count($res); |
| 71 | + |
| 72 | + |
| 73 | + $html .= wfMsg('smw_sbv_displayresult', $skin->makeLinkObj($attribute, $attribute->getText()), $value->getShortHTMLText($skin)) . "<br />\n"; |
| 74 | + |
| 75 | + // prepare navigation bar |
| 76 | + if ($offset > 0) |
| 77 | + $navigation = '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty','offset=' . max(0,$offset-$limit) . '&limit=' . $limit . '&attribute=' . urlencode($attribute->getText()) .'&value=' . urlencode($value->getWikiValue()))) . '">' . wfMsg('smw_result_prev') . '</a>'; |
| 78 | + else |
| 79 | + $navigation = wfMsg('smw_result_prev'); |
| 80 | + |
| 81 | + $navigation .= ' <b>' . wfMsg('smw_result_results') . ' ' . ($offset+1) . '– ' . ($offset + min($count, $limit)) . '</b> '; |
| 82 | + |
| 83 | + if ($count>$limit) { |
| 84 | + $navigation .= ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty', 'offset=' . ($offset+$limit) . '&limit=' . $limit . '&attribute=' . urlencode($attribute->getText()) . '&value=' . urlencode($value->getWikiValue()))) . '">' . wfMsg('smw_result_next') . '</a>'; |
| 85 | + } else { |
| 86 | + $navigation .= wfMsg('smw_result_next'); |
| 87 | + } |
| 88 | + |
| 89 | + $max = false; $first=true; |
| 90 | + foreach (array(20,50,100,250,500) as $l) { |
| 91 | + if ($max) continue; |
| 92 | + if ($first) { |
| 93 | + $navigation .= ' ('; |
| 94 | + $first = false; |
| 95 | + } else |
| 96 | + $navigation .= ' | '; |
| 97 | + if ($l > $smwgQMaxInlineLimit) { |
| 98 | + $l = $smwgQMaxInlineLimit; |
| 99 | + $max = true; |
| 100 | + } |
| 101 | + if ( $limit != $l ) { |
| 102 | + $navigation .= '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty','offset=' . $offset . '&limit=' . $l . '&attribute=' . urlencode($attribute->getText()) . '&value=' . urlencode($value->getWikiValue()))) . '">' . $l . '</a>'; |
| 103 | + } else { |
| 104 | + $navigation .= '<b>' . $l . '</b>'; |
| 105 | + } |
| 106 | + } |
| 107 | + $navigation .= ')'; |
| 108 | + |
| 109 | +// TODO The following code can be turned into a list of similar result, instead of |
| 110 | +// exact results one day. It is unclear, if this should go over the iq or if rather |
| 111 | +// the storage API should be extended. The iq part is outlined here, but does not |
| 112 | +// really work, and would require another query printer as it is outlined here. |
| 113 | + |
| 114 | +// if ($count < ($limit/2)) { // if there is only a small number of results |
| 115 | +// $iqoptions = array(); |
| 116 | +// $iqoptions['limit'] = $limit/2+$count; |
| 117 | +// $iqoptions['sort'] = $attribute->getText(); |
| 118 | +// $iqoptions['order'] = 'DESC'; |
| 119 | +// $iqoptions['format'] = 'ul'; |
| 120 | +// $iqoptions['headers'] = 'hide'; |
| 121 | +// $iq = new SMWInlineQuery($iqoptions, FALSE); |
| 122 | +// $html .= $iq->getHTMLResult("[[" . $attribute->getText() . ":=<" . $value->getUserValue() . "]] [[" . $attribute->getText() . ":=*]]"); |
| 123 | +// $iqoptions['offset'] = $count; |
| 124 | +// $iqoptions['order'] = 'ASC'; |
| 125 | +// $iqoptions['limit'] = $limit/2-$count; |
| 126 | +// $iq = new SMWInlineQuery($iqoptions, FALSE); |
| 127 | +// $html .= $iq->getHTMLResult("[[" . $attribute->getText() . ":=>" . $value->getUserValue() . "]] [[" . $attribute->getText() . ":=*]]"); |
| 128 | +// } |
| 129 | + |
| 130 | + if ($count == 0) { |
| 131 | + $html .= wfMsg( 'smw_result_noresults' ); |
| 132 | + } else { // if there are plenty of results anyway |
| 133 | + // no need to show the navigation bars when there is not enough to navigate |
| 134 | + if (($offset>0) || ($count>$limit)) $html .= '<br />' . $navigation; |
| 135 | + $html .= "<ul>\n"; |
| 136 | + foreach ($res as $t) { |
| 137 | + $browselink = SMWInfolink::newBrowsingLink('+',$t->getPrefixedText()); |
| 138 | + $html .= '<li>' . $skin->makeKnownLinkObj($t) . ' ' . $browselink->getHTML($skin) . "</li> \n"; |
| 139 | + } |
| 140 | + $html .= "</ul>\n"; |
| 141 | + if (($offset>0) || ($count>$limit)) $html .= $navigation; |
| 142 | + } |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + // display query form |
| 147 | + $html .= '<p> </p>'; |
| 148 | + $html .= '<form name="searchbyproperty" action="' . $spectitle->escapeLocalURL() . '" method="get">' . "\n" . |
| 149 | + '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>' ; |
| 150 | + $html .= wfMsg('smw_sbv_property') . ' <input type="text" name="property" value="' . htmlspecialchars($attributestring) . '" />' . " \n"; |
| 151 | + $html .= wfMsg('smw_sbv_value') . ' <input type="text" name="value" value="' . htmlspecialchars($valuestring) . '" />' . "\n"; |
| 152 | + $html .= '<input type="submit" value="' . wfMsg('smw_sbv_submit') . "\"/>\n</form>\n"; |
| 153 | + |
| 154 | + $wgOut->addHTML($html); |
| 155 | + } |
| 156 | + |
| 157 | +} |
| 158 | + |
Property changes on: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 159 | + native |