Index: trunk/extensions/SemanticWebBrowser/SemanticWebBrowser.alias.php |
— | — | @@ -0,0 +1,15 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Aliases for special pages |
| 5 | + * |
| 6 | + * @author Anna Kantorovitch and Benedikt K�mpgen |
| 7 | + * @ingroup Extensions |
| 8 | + * @ingroup SWBLanguage |
| 9 | + */ |
| 10 | + |
| 11 | + |
| 12 | +/** English (English) */ |
| 13 | + |
| 14 | +$specialPageAliases['en'] = array( |
| 15 | + 'BrowseWiki' => array( 'BrowseWiki' ), |
| 16 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticWebBrowser/SemanticWebBrowser.alias.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 17 | + native |
Added: svn:keywords |
2 | 18 | + LastChangedDate LastChangedRevision LastChangedBy Id |
Index: trunk/extensions/SemanticWebBrowser/specials/SearchTriple/SWB_SpecialBrowseWiki.php |
— | — | @@ -6,30 +6,22 @@ |
7 | 7 | * |
8 | 8 | * A factbox like view on an article, implemented by a special page. |
9 | 9 | * |
10 | | - * @author Anna Kantorovitch |
| 10 | + * |
11 | 11 | */ |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * A factbox view on one specific article, showing all the Semantic data about it |
15 | | - * |
16 | | - * @ingroup SMWSpecialPage |
| 15 | + *@author Anna Kantorovitch |
| 16 | + *@author Benedikt Kämpgen |
| 17 | + * |
17 | 18 | * @ingroup SpecialPage |
18 | 19 | */ |
| 20 | + |
19 | 21 | global $swbgIP; |
20 | | -// require_once "$swbgIP/EasyRDF/lib/EasyRdf.php"; |
21 | | -// require_once "$swbgIP/EasyRDF/examples/html_tag_helpers.php"; |
22 | | -// set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/'); |
23 | | -// require_once ($swbgIP.'EasyRDF/examples/html_tag_helpers.php'); |
24 | | -// require_once "EasyRdf.php"; |
25 | | -// require_once "html_tag_helpers.php"; |
26 | | -set_include_path($swbgIP.'lib/'); |
27 | | -/** |
28 | | - * Here, we need EasyRDF. |
29 | | - */ |
30 | | -require_once ($swbgIP.'lib/EasyRdf.php'); |
31 | 22 | |
| 23 | +set_include_path($swbgIP . 'lib/'); |
| 24 | +require_once ($swbgIP . 'lib/EasyRdf.php'); |
32 | 25 | |
33 | | -//require_once( "$swbgIP/Graphite.php" ); |
34 | 26 | |
35 | 27 | class SWBSpecialBrowseWiki extends SpecialPage { |
36 | 28 | /// int How many incoming values should be asked for |
— | — | @@ -48,6 +40,8 @@ |
49 | 41 | private $offset = 0; |
50 | 42 | ///if searchwindow is created or not |
51 | 43 | private $windowCreated=false; |
| 44 | + |
| 45 | + private $title; |
52 | 46 | |
53 | 47 | /** |
54 | 48 | * Constructor |
— | — | @@ -68,30 +62,18 @@ |
69 | 63 | * @param[in] $query string Given by MediaWiki |
70 | 64 | */ |
71 | 65 | public function execute( $query ) { |
72 | | - global $wgRequest, $wgOut, $smwgBrowseShowAll,$wgContLang; |
73 | | - |
| 66 | + global $wgRequest, $wgOut, $smwgBrowseShowAll, $wgContLang; |
74 | 67 | $this->setHeaders(); |
75 | 68 | |
76 | 69 | // get the GET parameters |
77 | 70 | $this->articletext = $wgRequest->getVal( 'article' ); |
78 | | - |
| 71 | + $this->title = $wgOut->getTitle(); |
79 | 72 | // no GET parameters? Then try the URL |
80 | 73 | if ( $this->articletext == '' ) { |
81 | 74 | $params = SMWInfolink::decodeParameters( $query, false ); |
82 | 75 | reset( $params ); |
83 | 76 | $this->articletext = current( $params ); |
84 | 77 | } |
85 | | - |
86 | | - // if page existing in the wiki, I want that one instead |
87 | | - $uriPageName = $this->getInternalMapping( $this->articletext ); |
88 | | - |
89 | | - if (!isset($uriPageName) && $uriPageName == null ) { |
90 | | - // get subject |
91 | | - $this->subject = SMWDataValueFactory::newTypeIDValue( '_wpg', $this->articletext ); |
92 | | - } else { |
93 | | - $this->subject = SMWDataValueFactory::newTypeIDValue( '_wpg', $uriPageName ); |
94 | | - } |
95 | | - |
96 | 78 | $offsettext = $wgRequest->getVal( 'offset' ); |
97 | 79 | $this->offset = ( $offsettext == '' ) ? 0:intval( $offsettext ); |
98 | 80 | $dir = $wgRequest->getVal( 'dir' ); |
— | — | @@ -104,136 +86,14 @@ |
105 | 87 | if ( $dir == 'in' ) $this->showoutgoing = false; |
106 | 88 | if ( $dir == 'out' ) $this->showincoming = false; |
107 | 89 | |
108 | | - // Why do we need different variants? Removed... |
109 | | - |
110 | | - // Why do we need to input query form? Removed... |
111 | | - |
112 | | - // print OutputPage |
| 90 | + // print OutputPage |
| 91 | + |
113 | 92 | $wgOut->addHTML( $this->displayBrowse() ); |
114 | 93 | SMWOutputs::commitToOutputPage( $wgOut ); // make sure locally collected output data is pushed to the output! |
115 | 94 | |
116 | 95 | } |
117 | 96 | |
118 | | - //new function for search swb actually not used |
119 | | - function wfSpecialSearch( $par = '' ) { |
120 | | - global $wgRequest, $wgUser, $wgOut; |
121 | | - $wgOut->allowClickjacking(); |
122 | 97 | |
123 | | - // Strip underscores from title parameter; most of the time we'll want |
124 | | - // text form here. But don't strip underscores from actual text params! |
125 | | - $titleParam = str_replace( '_', ' ', $par ); |
126 | | - //echo "par='".$par."'"; |
127 | | - // Fetch the search term |
128 | | - $search = str_replace( "\n", " ", $wgRequest->getText( 'search', $titleParam ) ); |
129 | | - //echo "search='".$search."'"; |
130 | | - $searchPage = new SpecialSearch( $wgRequest, $wgUser ); |
131 | | - if( $wgRequest->getVal( 'fulltext' ) |
132 | | - || !is_null( $wgRequest->getVal( 'offset' )) |
133 | | - || !is_null( $wgRequest->getVal( 'searchx' )) ) |
134 | | - { |
135 | | - $searchPage->showResults( $search ); |
136 | | - } else { |
137 | | - $searchPage->goResult( $search ); |
138 | | - } |
139 | | - } |
140 | | - /** New function for browsing SWB |
141 | | - * actually not used |
142 | | - * based on lodpuller.php |
143 | | - * Function getPagesByAlias doesn't work |
144 | | - * |
145 | | - * @param unknown_type $label |
146 | | - * @param unknown_type $lang |
147 | | - */ |
148 | | - private function checkSearch($label, $lang){ |
149 | | - global $wgOut, $wgScriptPath; |
150 | | - $pages = SWBCreatePage::getPagesByAlias( $label, $lang ); |
151 | | - |
152 | | - if (count($pages) === 0) { |
153 | | - // Do nothing |
154 | | - } elseif (count($pages) === 1) { |
155 | | - // Go to that page directly |
156 | | - $wgOut->redirect( "$wgScriptPath/topic/$lang/$pages[0]" ); |
157 | | - return; |
158 | | - } else { |
159 | | - global $wgSitename; |
160 | | - $wgOut->setHTMLTitle( wfMsg('swb-disambiguation') . ':' . $label . ' - ' . $wgSitename ); |
161 | | - $wgOut->setPageTitle( $label ); |
162 | | - $wgOut->addWikiText( wfMsg('swb-disambiguationpage', $label) ); |
163 | | - foreach ($pages as $page) { |
164 | | - $plabel = SWBCreatePage::getLabel($page, $lang); |
165 | | - $pdescription = SWBCreatePage::getDescription($page, $lang); |
166 | | - $wgOut->addWikiText( "* '''[[$page|$plabel]]''': $pdescription" ); |
167 | | - } |
168 | | - $wgOut->addWikiText( "\n\n" ); |
169 | | - } |
170 | | - |
171 | | - //list($wphits, $wpsuggest, $wpresults) = SWBSemanticSearchByLabel::getWikipediaSearch( $label, $lang ); |
172 | | - list($wphits, $wpsuggest, $wpresults) = SWBSpecialBrowseWiki::getWikiSearch( $label, $lang ); |
173 | | - $exactmatch = false; |
174 | | - if (count($wpresults)) { |
175 | | - $wgOut->addWikiText( wfMsg('swb-wpsearchresults' ) ); |
176 | | - $wgOut->addHTML('<ul>'); |
177 | | - foreach($wpresults as $title => $snippet) { |
178 | | - if ($title == $label) $exactmatch = true; |
179 | | - $target = str_replace(' ', '_', $title); |
180 | | - $wgOut->addHTML("<li><a href=\"$wgServer$wgScriptPath/wikipedia/$lang/$target\">$title</a><br> <em>$snippet</em></li>"); |
181 | | - } |
182 | | - $wgOut->addHTML('</ul>'); |
183 | | - $wgOut->addWikiText( "\n\n" ); |
184 | | - } |
185 | | - |
186 | | - if ($wpsuggest) { |
187 | | - $wgOut->addWikiText( wfMsg('swb-didyoumean') ); |
188 | | - $target = str_replace(' ', '_', $wpsuggest); |
189 | | - $wgOut->addHTML("<ul><li><a href=\"$wgServer$wgScriptPath/$lang/$target\">$wpsuggest</a></li></ul>"); |
190 | | - $wgOut->addWikiText( "\n\n" ); |
191 | | - } |
192 | | - |
193 | | - // If nothing was found |
194 | | - if ((count($pages)===0) && (!$exactmatch)) { |
195 | | - $title = Title::newFromText( $label ); |
196 | | - if ($title->exists()) { |
197 | | - // If the page exists (but not with the title) |
198 | | - $wgOut->addWikiText( wfMsg('swb-pagenameexists' )); |
199 | | - $langlabel = SWBCreatePage::getLabel( $label, $lang ); |
200 | | - $displaylabel = $langlabel ? $langlabel : $label; |
201 | | - $target = str_replace(' ', '_', $label); |
202 | | - $wgOut->addHtml("<ul><li><a href=\"$wgServer$wgScriptPath/topic/$lang/$target\">$displaylabel</a></li></ul>"); |
203 | | - } else { |
204 | | - // If such a page does not exist at all, enable its creation |
205 | | - $wgOut->addWikiText( wfMsg('swb-createpage' )); |
206 | | - $target = str_replace(' ', '_', $label); |
207 | | - $wgOut->addHtml("<ul><li><a href=\"$wgServer$wgScriptPath/topic/$lang/$target\">$label</a></li></ul>"); |
208 | | - } |
209 | | - } |
210 | | - } |
211 | | - |
212 | | - private function getWikiSearch($term, $lang){ |
213 | | - $term = urlencode($term); |
214 | | - $ch = curl_init(); |
215 | | - curl_setopt($ch, CURLOPT_URL, "http://$lang.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=$term"); |
216 | | - curl_setopt($ch, CURLOPT_USERAGENT, "swbspecialbrowsewiki"); |
217 | | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
218 | | - $output = curl_exec($ch); |
219 | | - curl_close($ch); |
220 | | - |
221 | | - $answer = json_decode($output); |
222 | | - $hits = $answer->query->searchinfo->totalhits; |
223 | | - $results = array(); |
224 | | - $suggestion = ''; |
225 | | - if ($hits === 0) { |
226 | | - if (property_exists($answer->query->searchinfo, 'suggestion')) |
227 | | - $suggestion = $answer->query->searchinfo->suggestion; |
228 | | - } else { |
229 | | - foreach( $answer->query->search as $hit ) { |
230 | | - $results[$hit->title] = $hit->snippet; |
231 | | - } |
232 | | - } |
233 | | - return array($hits, $suggestion, $results); |
234 | | - |
235 | | - |
236 | | - } |
237 | | - ########################END of checkSearch######################## |
238 | 98 | /** |
239 | 99 | * Create and output HTML including the complete factbox, based on the extracted |
240 | 100 | * parameters in the execute comment. |
— | — | @@ -244,12 +104,11 @@ |
245 | 105 | global $wgContLang, $wgOut; |
246 | 106 | $html = "\n"; |
247 | 107 | $leftside = !( $wgContLang->isRTL() ); // For right to left languages, all is mirrored |
248 | | - |
249 | | - // TODO: What does valid mean, here? |
| 108 | + //get subject type SMWWikiPage |
| 109 | + $this->subject = SMWDataValueFactory::newTypeIDValue( '_wpg', $this->articletext ); |
250 | 110 | if ( $this->subject->isValid() ) { |
251 | 111 | |
252 | | - // Here, we can distinguish |
253 | | - /* |
| 112 | + /** Here, we can distinguish |
254 | 113 | * 1. We have an existing page + any number of equivalent URIs |
255 | 114 | * 2. We have a non-existing page, which is a URI |
256 | 115 | */ |
— | — | @@ -257,9 +116,9 @@ |
258 | 117 | $wgOut->addStyle( '../extensions/SemanticMediaWiki/skins/SMW_custom.css' ); |
259 | 118 | |
260 | 119 | $html .= $this->displayHead(); |
| 120 | + // $data is of type SMWSemanticData |
| 121 | + $data = smwfGetStore()->getSemanticData( $this->subject->getDataItem() ); |
261 | 122 | if ( $this->showoutgoing ) { |
262 | | - // $data is of type SMWSemanticData |
263 | | - $data = smwfGetStore()->getSemanticData( $this->subject->getDataItem() ); |
264 | 123 | $html .= $this->displayData( $data, $leftside ); |
265 | 124 | $html .= $this->displayCenter(); |
266 | 125 | } |
— | — | @@ -275,145 +134,203 @@ |
276 | 135 | |
277 | 136 | // Now, we can display data from the Semantic Web |
278 | 137 | |
279 | | - // Two possibilities: 1. Existing page with equivalent uris 2. Non-existing page with URL |
280 | | - |
281 | | - //$equivalentURI = SMWPropertyValue::makeUserProperty( "equivalent URI" ); |
282 | | - //$equivalentURI = SMWPropertyValue::makeProperty( "__spu" ); |
283 | | - $equivalentURI = new SMWDIProperty("_URI"); |
| 138 | + /** Two possibilities: |
| 139 | + * 1. Existing page with equivalent uris |
| 140 | + * 2. Non-existing page with URL |
| 141 | + */ |
| 142 | + $equivalentURI = new SMWDIProperty( "_URI" ); |
284 | 143 | $arr_equi_values = $data->getPropertyValues($equivalentURI); |
285 | 144 | |
286 | 145 | // If no equivalentURIs, then maybe the article itself |
287 | 146 | if (empty($arr_equi_values)) { |
288 | | - // http://harth.org/andreas/foaf#ah |
| 147 | + |
289 | 148 | $info = parse_url($this->articletext); |
290 | | - (!isset($info['scheme'])) ? $scheme = "" : $scheme = $info['scheme']; |
291 | | - (!isset($info['host'])) ? $host = "" : $host = "//".$info['host']; |
292 | | - (!isset($info['path'])) ? $path = "" : $path = $info['path']; |
293 | | - (!isset($info['query'])) ? $query = "" : $query = $info['query']; |
294 | | - (!isset($info['fragment'])) ? $fragment = "" : $fragment = $info['fragment']; |
295 | | - $arr_equi_values[] = new SMWDIUri($scheme, $host.$path, $query, $fragment); |
| 149 | + (!isset( $info['scheme']) ) ? $scheme = "" : $scheme = $info['scheme']; |
| 150 | + (!isset( $info['host']) ) ? $host = "" : $host = "//".$info['host']; |
| 151 | + (!isset( $info['path']) ) ? $path = "" : $path = $info['path']; |
| 152 | + (!isset( $info['query']) ) ? $query = "" : $query = $info['query']; |
| 153 | + (!isset( $info['fragment'])) ? $fragment = "" : $fragment = $info['fragment']; |
| 154 | + |
| 155 | + if($scheme=="" || $host.$path==""){ |
| 156 | + // in this case SMWDIUri becomes Exception |
| 157 | + }else{ |
| 158 | + $arr_equi_values[] = new SMWDIUri($scheme, $host.$path, $query, $fragment); } |
296 | 159 | } |
297 | | - |
298 | 160 | foreach ($arr_equi_values as $uri) { |
299 | 161 | // Two possibilities: 1. No URL 2. URL |
300 | | - |
301 | | - // Build the graph |
302 | | - $graph = new EasyRdf_Graph($uri->getURI()); |
303 | | - $graph->load(); |
304 | | - |
305 | | - // Now, we resolve this URI and store the rdf |
306 | | - |
307 | | - $html .= $this->displaySemanticHead($uri->getURI()); |
308 | | - if ( $this->showoutgoing ) { |
309 | | - // should be: $data is of type SMWSemanticData |
310 | | - $swdata = $this->getSemanticWebData($graph, $uri->getURI() ); |
311 | | - $html .= $this->displaySemanticWebData( $swdata, $leftside ); |
312 | | - $html .= $this->displayCenter(); |
313 | | - } |
314 | | - if ( $this->showincoming ) { |
315 | | - // TODO: Make work |
316 | | - list( $indata, $more ) = $this->getSemanticWebInData($graph, $uri->getURI() ); |
317 | | - global $smwgBrowseShowInverse; |
318 | | - if ( !$smwgBrowseShowInverse ) $leftside = !$leftside; |
319 | | - $html .= $this->displaySemanticWebData( $indata, $leftside, true ); |
320 | | - $html .= $this->displayBottom( $more ); |
321 | | - // We need to switch browse inverse, again |
322 | | - $leftside = !$leftside; |
323 | | - } |
| 162 | + if( $uri === null ){ |
| 163 | + }else{ |
| 164 | + // Build the graph |
| 165 | + $uriprint = $uri->getURI(); |
| 166 | + if( !isset($uriprint) ){ |
| 167 | + }else{ |
| 168 | + //create object for graph |
| 169 | + $graph = new EasyRdf_Graph($uri->getURI()); |
| 170 | + $html .= $this->displayGraph($graph, $uri, $leftside); |
| 171 | + } |
| 172 | + } |
324 | 173 | } |
325 | 174 | |
326 | | - // Apparently, it is here that the hash # gets removed, therefore removed. |
327 | | - //$this->articletext = $this->subject->getWikiValue(); |
328 | | - |
329 | 175 | // Add a bit space between the factbox and the query form |
330 | 176 | if ( !$this->including() ) $html .= "<p>   </p>\n"; |
331 | 177 | } |
332 | 178 | if ( !$this->including() ) $html .= $this->queryForm(); |
333 | 179 | $wgOut->addHTML( $html ); |
334 | 180 | } |
335 | | - |
| 181 | + |
| 182 | + /** |
| 183 | + * Create and output HTML including the complete factbox, based on the extracted |
| 184 | + * parameters in the execute comment. |
| 185 | + * for one Graph object |
| 186 | + * @return string A HTML string with the factbox |
| 187 | + * @return leftside in parameter |
| 188 | + */ |
| 189 | + public function displayGraph($graph, $uri, &$leftside){ |
| 190 | + $graph->load(); |
| 191 | + $html = ""; |
| 192 | + // Now, we resolve this URI and store the rdf |
| 193 | + $html .= $this->displaySemanticHead( $uri->getURI() ); |
| 194 | + if ( $this->showoutgoing ) { |
| 195 | + // should be: $data is of type SMWSemanticData |
| 196 | + $swdata = $this->getSemanticWebData( $graph, $uri->getURI() ); |
| 197 | + $html .= $this->displaySemanticWebData( $swdata, $leftside ); |
| 198 | + $html .= $this->displayCenter(); |
| 199 | + } |
| 200 | + if ( $this->showincoming ) { |
| 201 | + list( $indata, $more ) = $this->getSemanticWebInData( $graph, $uri->getURI() ); |
| 202 | + global $smwgBrowseShowInverse; |
| 203 | + if ( !$smwgBrowseShowInverse ) $leftside = !$leftside; |
| 204 | + $html .= $this->displaySemanticWebData( $indata, $leftside, true ); |
| 205 | + $html .= $this->displayBottom( $more ); |
| 206 | + // We need to switch browse inverse, again |
| 207 | + $leftside = !$leftside; |
| 208 | + } |
| 209 | + return $html; |
| 210 | + } |
| 211 | + |
| 212 | + |
336 | 213 | /** |
337 | 214 | * |
338 | 215 | * Similar to getInData(), but in this case regarding the Semantic Web. |
339 | 216 | */ |
340 | | - private function getSemanticWebInData($graph, $uri) { |
341 | | - |
| 217 | + private function getSemanticWebInData( $graph, $uri ) { |
342 | 218 | $indata = new SMWSemanticData( $this->subject->getDataItem() ); |
343 | | - |
344 | 219 | $options = new SMWRequestOptions(); |
345 | 220 | $options->sort = true; |
346 | 221 | $options->limit = SWBSpecialBrowseWiki::$incomingpropertiescount; |
347 | 222 | if ( $this->offset > 0 ) $options->offset = $this->offset; |
348 | 223 | |
349 | | - // I need all incoming properties |
350 | | - //$inproperties = $this->getSemanticInProperties($graph, $this->subject->getDataItem(), $options ); |
351 | | - $inproperties = $this->getSemanticInProperties($graph, $uri, $options ); |
352 | | - |
353 | | - if ( count( $inproperties ) == SWBSpecialBrowseWiki::$incomingpropertiescount ) { |
| 224 | + $triples = $this->getSemanticInfos( $graph, null, null, $uri ); |
| 225 | + if ( count( $triples ) >= SWBSpecialBrowseWiki::$incomingpropertiescount ) { |
354 | 226 | $more = true; |
355 | | - array_pop( $inproperties ); // drop the last one |
| 227 | + array_pop( $triples ); // drop the last one |
356 | 228 | } else { |
357 | 229 | $more = false; |
358 | 230 | } |
359 | | - |
360 | | - $valoptions = new SMWRequestOptions(); |
361 | | - $valoptions->sort = true; |
362 | | - $valoptions->limit = SWBSpecialBrowseWiki::$incomingvaluescount; |
363 | | - |
364 | | - // For each incoming property, I run getArraySubjects. |
365 | | - foreach ( $inproperties as $property ) { |
366 | | - |
367 | | - // $values = smwfGetStore()->getPropertySubjects( $property, $this->subject->getDataItem(), $valoptions ); |
368 | | - $values = $this->getSemanticPropertySubjects($graph, $property, $this->subject->getDataItem(), $valoptions ); |
369 | | - foreach ( $values as $value ) { |
370 | | - $indata->addPropertyObjectValue( $property, $value ); |
| 231 | + |
| 232 | + //get each triple with subject, property, object . All are strings |
| 233 | + foreach ( $triples as $triple ) { |
| 234 | + list( $subject, $property, $object ) = $triple; |
| 235 | + $propertyPageName = $this->getInternalMapping( $property ); |
| 236 | + $dataProperty = null; |
| 237 | + if( !isset($propertyPageName) || $propertyPageName == null){ |
| 238 | + $dataProperty = SMWDIProperty::newFromUserLabel( $property ); |
| 239 | + //$dataProperty=new SMWDIProperty( $property, false); |
| 240 | + }else{ |
| 241 | + $dataProperty = SMWDIProperty::newFromUserLabel( $propertyPageName ); |
371 | 242 | } |
| 243 | + |
| 244 | + $subjectPageName = $this->getInternalMapping( $subject ); |
| 245 | + $wikipage = null; |
| 246 | + if( !isset( $subjectPageName ) || $subjectPageName == null){ |
| 247 | + $wikipage = new SMWDIWikiPage( $subject, NS_MAIN, ''); |
| 248 | + }else{ |
| 249 | + $wikipage = new SMWDIWikiPage( $subjectPageName, NS_MAIN, ''); |
| 250 | + } |
| 251 | + |
| 252 | + $indata->addPropertyObjectValue( $dataProperty, $wikipage ); |
372 | 253 | } |
373 | | - |
374 | 254 | return array( $indata, $more ); |
375 | 255 | } |
376 | | - |
| 256 | + |
| 257 | + |
377 | 258 | /** |
378 | 259 | * Get an array of all properties for which there is some subject that |
379 | | - * relates to the given value. The result is an array of SMWDIWikiPage |
| 260 | + * relates to the given value. The result is an array of SMWDIProperty |
380 | 261 | * objects. |
381 | 262 | */ |
382 | | - private function getSemanticInProperties($graph, $uri, $requestoptions = null) { |
383 | | - |
384 | | - // Why not properties? |
385 | | - $arr_wpgs = array(); |
386 | | - |
387 | | - |
| 263 | + |
| 264 | + private function getSemanticInProperties( $graph, $uri, $requestoptions = null ) { |
| 265 | + $arr_objs = array(); |
| 266 | + $arr_props = array(); |
388 | 267 | // Now, ask for all incoming uris |
389 | | - //anna |
390 | | - //$theIncomingProperties = $graph->reversePropertyUris($object); |
391 | | - $theIncomingProperties = $graph->reversePropertyUris($uri); |
392 | | - foreach ($theIncomingProperties as $inProp) { |
393 | | - //$inPropResult = $this->getArraySubjects($graph, $inProp, $theResource); |
394 | | - $inPropResult = $this->getArraySubjects($graph, $inProp, $uri); |
395 | | - // TODO create $data |
| 268 | + $theIncomingProperties = $graph->reversePropertyUris( $uri ); |
| 269 | + foreach ( $theIncomingProperties as $inProp ) { |
| 270 | + |
| 271 | + //getArraySubject :: get all subjects (from RDF) which have the needed property and |
| 272 | + //its uri is a reference to given object |
| 273 | + $inPropResult = $this->getArraySubjects( $graph, $inProp, $uri ); |
| 274 | + foreach( $inPropResult as $inPropSubject ){ |
| 275 | + $uriPageName = $this->getInternalMapping( $inProp ); |
| 276 | + $label = $inPropSubject['value']; |
| 277 | + $dataProperty = SMWDIProperty::newFromUserLabel( $label ); |
| 278 | + $arr_objs[] = $dataProperty; |
| 279 | + $arr_props[] = $inProp; |
| 280 | + } |
396 | 281 | } |
397 | | - |
398 | | - return $arr_wpgs; |
| 282 | + return array ( $arr_objs, $arr_props ); |
399 | 283 | } |
400 | 284 | |
| 285 | + |
| 286 | + /** |
| 287 | + * Finds all subjects, properties and objects which are equal to needed subject, property and object |
| 288 | + * The result is an array each element has subject, property, object (all string) |
| 289 | + * |
| 290 | + * |
| 291 | + */ |
| 292 | + private function getSemanticInfos( $graph,$sSubject, $sProperty, $sObject,$requestoptions = null ) { |
| 293 | + $arr_triples = array(); |
| 294 | + $subjects = $graph->toArray(); |
| 295 | + |
| 296 | + foreach ( $subjects as $subject=>$properties ){ |
| 297 | + if( $sSubject == null || $subject == $sSubject ){ |
| 298 | + foreach( $properties as $property => $values ){ |
| 299 | + if( $sProperty == null || $sProperty == $property ){ |
| 300 | + foreach( $values as $object ){ |
| 301 | + if( $this->isURI( $object['value'] ) ){ |
| 302 | + if( $sObject==null || $object['value'] == $sObject ){ |
| 303 | + $arr_triples[] = array( $subject, $property, $object['value'] ); |
| 304 | + } |
| 305 | + } |
| 306 | + } |
| 307 | + |
| 308 | + } |
| 309 | + } |
| 310 | + } |
| 311 | + } |
| 312 | + return $arr_triples; |
| 313 | + } |
401 | 314 | /** |
402 | | - * Get an array of all subjects that have the given value for the given |
403 | | - * property. The result is an array of SMWDIWikiPage objects. If null |
404 | | - * is given as a value, all subjects having that property are returned. |
| 315 | + * Check uri, uri as http://... |
| 316 | + * @param string $uri |
| 317 | + * return true if uri in normal format, else in other cases |
405 | 318 | */ |
406 | | - private function getSemanticPropertySubjects($graph, SMWDIProperty $property, $value, $requestoptions = null ) { |
407 | | - $arr_wpgs = array(); |
408 | | - |
409 | | - return $arr_wpgs; |
| 319 | + public static function isURI( $uri ){ |
| 320 | + $info = parse_url( $uri ); |
| 321 | + ( !isset( $info['scheme'] ) ) ? $scheme = "" : $scheme = $info['scheme']; |
| 322 | + ( !isset( $info['host'] ) ) ? $host = "" : $host = "//".$info['host']; |
| 323 | + ( !isset( $info['path'] ) ) ? $path = "" : $path = $info['path']; |
| 324 | + ( !isset( $info['query'] ) ) ? $query = "" : $query = $info['query']; |
| 325 | + ( !isset($info['fragment']) ) ? $fragment = "" : $fragment = $info['fragment']; |
| 326 | + if( $scheme == "" || $host.$path == "" )return false; |
| 327 | + else return true; |
410 | 328 | } |
411 | | - |
412 | 329 | /** |
413 | 330 | * |
414 | 331 | * Similar to getSemanticData(), but in this case regarding the Semantic Web. |
415 | 332 | * @param String $uri |
416 | 333 | */ |
417 | | - private function getSemanticWebData($graph, $uri) { |
| 334 | + private function getSemanticWebData( $graph, $uri ) { |
418 | 335 | // Several possibilities: URI with redirect to RDF, URL with RDFa (but talking about what?),... |
419 | 336 | |
420 | 337 | // $data is of type SMWSemanticData |
— | — | @@ -422,38 +339,29 @@ |
423 | 340 | // I want to show all incoming and outcoming links |
424 | 341 | // ...ideally in the same style |
425 | 342 | // Get the representation of the URI |
426 | | - $theResource = $graph->resource($uri); |
427 | | - |
| 343 | + $theResource = $graph->resource( $uri ); |
428 | 344 | // Outgoing |
429 | | - $theOutgoingProperties = $graph->propertyUris($theResource); |
430 | | - |
| 345 | + $theOutgoingProperties = $graph->propertyUris( $theResource ); |
431 | 346 | // for each, ask for the objects |
432 | | - foreach ($theOutgoingProperties as $outProp) { |
433 | | - |
434 | | - $outPropResult = $this->getArrayObjects($graph, $theResource, $outProp); |
435 | | - |
| 347 | + foreach ( $theOutgoingProperties as $outProp ) { |
| 348 | + $outPropResult = $this->getArrayObjects( $graph, $theResource, $outProp ); |
436 | 349 | // now, we have the subject, the property, the object (uri/literal) |
437 | | - foreach ($outPropResult as $outPropObject) { |
| 350 | + foreach ( $outPropResult as $outPropObject ) { |
438 | 351 | |
439 | 352 | /* |
440 | 353 | * The question now is, what kind of propert. |
441 | | - * |
442 | 354 | * If there is a page in the wiki, we simply use it as property. |
443 | | - * |
444 | 355 | * Otherwise, we need to invent a new page with the URI as name |
445 | | - * |
446 | 356 | */ |
447 | 357 | $uriPageName = $this->getInternalMapping( $outProp ); |
448 | | - |
449 | 358 | $dataProperty = null; |
450 | | - if (!isset($uriPageName) || $uriPageName == null) { |
| 359 | + if ( !isset( $uriPageName ) || $uriPageName == null) { |
451 | 360 | // There is no, we create a new property page |
452 | 361 | /* |
453 | 362 | * TODO: maybe register new property type that can display the property more |
454 | 363 | * conveniently, e.g., with browse further: smwInitProperties |
455 | 364 | */ |
456 | | - $dataProperty = SMWDIProperty::newFromUserLabel( $outProp );; |
457 | | - |
| 365 | + $dataProperty = SMWDIProperty::newFromUserLabel( $outProp ); |
458 | 366 | } else { |
459 | 367 | $dataProperty = SMWDIProperty::newFromUserLabel( $uriPageName ); |
460 | 368 | } |
— | — | @@ -462,7 +370,7 @@ |
463 | 371 | // TODO: Maybe distinguish more, later, e.g., language |
464 | 372 | $dataValue = null; |
465 | 373 | |
466 | | - if ($outPropObject["type"] == "uri") { |
| 374 | + if ( $outPropObject["type"] == "uri" ) { |
467 | 375 | |
468 | 376 | /* |
469 | 377 | * If there is a page in the wiki with the value as equivalent URI, we |
— | — | @@ -470,34 +378,25 @@ |
471 | 379 | */ |
472 | 380 | $uriPageName = $this->getInternalMapping( $outPropObject["value"] ); |
473 | 381 | |
474 | | - if (!isset($uriPageName) && $uriPageName == null ) { |
475 | | - |
476 | | - // We could create a link that would lead to SemanticWebBrowser |
477 | | - // $info = parse_url($outPropObject["value"]); |
478 | | - //(!isset($info['scheme'])) ? $scheme = "" : $scheme = $info['scheme']; |
479 | | - //(!isset($info['host'])) ? $host = "" : $host = "//".$info['host']; |
480 | | - //(!isset($info['path'])) ? $path = "" : $path = $info['path']; |
481 | | - //(!isset($info['query'])) ? $query = "" : $query = $info['query']; |
482 | | - //(!isset($info['fragment'])) ? $fragment = "" : $fragment = $info['fragment']; |
483 | | - //$dataItem = new SMWDIUri($scheme, $host.$path, $query, $fragment); |
484 | | - //$dataItem = SMWDataValueFactory::newTypeIDValue( '_wpg', $outPropObject["value"] ); |
485 | | - |
| 382 | + if ( !isset( $uriPageName ) && $uriPageName == null ) { |
486 | 383 | // URI value |
487 | | - // TODO: Make custom value type work, it is not used, yet. |
488 | | - //$dataValue = SMWDataValueFactory::newTypeIDValue( '_rur', $outPropObject["value"], $property = $dataProperty ); |
489 | | - $dataValue = SMWDataValueFactory::newTypeIDValue( '_uri', $outPropObject["value"], $property = $dataProperty ); |
| 384 | + $dataValue = SMWDataValueFactory::newTypeIDValue( '_rur', $outPropObject["value"], $property = $dataProperty ); |
490 | 385 | } else { |
491 | | - |
492 | 386 | $dataValue = SMWDataValueFactory::newTypeIDValue( '_wpg', $uriPageName, $property = $dataProperty ); |
493 | | - //$dataItem = SMWDIWikiPage::newFromTitle(Title::newFromText($uriPageName)); |
494 | 387 | } |
495 | 388 | |
496 | 389 | } else { |
497 | 390 | // literal |
| 391 | + $this->debug($outPropObject["value"],"vis:"); |
498 | 392 | $dataValue = SMWDataValueFactory::newTypeIDValue( '_txt', $outPropObject["value"], $property = $dataProperty ); |
499 | 393 | //$dataItem = new SMWDIString($outPropObject["value"]); |
500 | 394 | } |
501 | | - $semanticDataResult->addPropertyObjectValue( $dataProperty, $dataValue->getDataItem() ); |
| 395 | + // some objects have invalid type and print warning triangle instead of object info |
| 396 | + //in this case object has class SMWDIError |
| 397 | + // in this case this object wouldn't be printed |
| 398 | + if( !( get_class( $dataValue->getDataItem() ) == "SMWDIError" ) ){ |
| 399 | + $semanticDataResult->addPropertyObjectValue( $dataProperty, $dataValue->getDataItem() ); |
| 400 | + } |
502 | 401 | } |
503 | 402 | } |
504 | 403 | return $semanticDataResult; |
— | — | @@ -512,49 +411,47 @@ |
513 | 412 | */ |
514 | 413 | public static function getInternalMapping( $uri ) { |
515 | 414 | |
516 | | - // Watch out correct spelling: [[equivalent URI::X]] |
517 | | - $equivalentURI = new SMWDIProperty("_URI"); |
| 415 | + // Watch out correct spelling: [[equivalent URI::XXX]] |
| 416 | + $equivalentURI = new SMWDIProperty( "_URI" ); |
518 | 417 | $urivalue = SMWDataValueFactory::newPropertyObjectValue( $equivalentURI, $uri ); |
519 | 418 | |
520 | 419 | // $values = smwfGetStore()->getPropertySubjects( $property, $this->subject->getDataItem(), $valoptions ); |
521 | 420 | $results = smwfGetStore()->getPropertySubjects( $equivalentURI, $urivalue->getDataItem() ); |
522 | 421 | |
523 | 422 | $mappings = array(); |
524 | | - foreach($results as $result) { |
| 423 | + foreach( $results as $result ) { |
525 | 424 | //$mappings[] = $result->getWikiValue(); |
526 | 425 | $mappings[] = $result->getTitle()->getText(); |
527 | 426 | } |
528 | | - if (count($mappings) === 0) return null; |
| 427 | + if ( count( $mappings ) === 0) return null; |
529 | 428 | return $mappings[0]; // TODO Only returns one. There never should be more than one. |
530 | 429 | } |
531 | 430 | |
532 | | - private function getArrayObjects($graph, $subject, $property) { |
| 431 | + private function getArrayObjects( $graph, $subject, $property ) { |
533 | 432 | |
534 | 433 | $arr_objects = array(); |
535 | 434 | |
536 | 435 | // TODO: ignore bnodes, language tags, for now. |
537 | 436 | |
538 | | - $theOutgoingProperties = $graph->propertyUris($subject); |
| 437 | + $theOutgoingProperties = $graph->propertyUris( $subject ); |
539 | 438 | |
540 | 439 | // For each outgoing uri, get the resources/literals |
541 | 440 | |
542 | | - $theOutgoingUriValues = $graph->allResources($subject, $property); |
543 | | - foreach ($theOutgoingUriValues as $uri) { |
| 441 | + $theOutgoingUriValues = $graph->allResources( $subject, $property ); |
| 442 | + foreach ( $theOutgoingUriValues as $uri ) { |
544 | 443 | // only non-bnodes |
545 | | - if (!$uri->isBnode()) { |
546 | | - $res = array("type" => "uri", "value" => $uri->getUri()); |
| 444 | + if ( !$uri->isBnode() ) { |
| 445 | + $res = array( "type" => "uri", "value" => $uri->getUri() ); |
547 | 446 | $arr_objects[] = $res; |
548 | 447 | } |
549 | 448 | } |
550 | 449 | |
551 | | - $theOutgoingLiteralValues = $graph->allLiterals($subject, $property ); |
552 | | - foreach ($theOutgoingLiteralValues as $literal) { |
553 | | - |
554 | | - // TODO: Display more nicely. |
555 | | - if ($literal instanceof EasyRdf_Literal_Date || $literal instanceof EasyRdf_Literal_DateTime) { |
556 | | - $res = array("type" => "literal", "value" => $literal->dumpValue(false)); |
| 450 | + $theOutgoingLiteralValues = $graph->allLiterals( $subject, $property ); |
| 451 | + foreach ( $theOutgoingLiteralValues as $literal ) { |
| 452 | + if ( $literal instanceof EasyRdf_Literal_Date || $literal instanceof EasyRdf_Literal_DateTime ) { |
| 453 | + $res = array( "type" => "literal", "value" => $literal->dumpValue( false ) ); |
557 | 454 | } else { |
558 | | - $res = array("type" => "literal", "value" => $literal->getValue()); |
| 455 | + $res = array( "type" => "literal", "value" => $literal->getValue() ); |
559 | 456 | } |
560 | 457 | |
561 | 458 | $arr_objects[] = $res; |
— | — | @@ -562,9 +459,16 @@ |
563 | 460 | |
564 | 461 | return $arr_objects; |
565 | 462 | } |
| 463 | +/** |
| 464 | + * |
| 465 | + * get all subjects (from RDF) which have the needed $property and its uri is a reference to needed object |
| 466 | + * |
| 467 | + * @param unknown_type $graph |
| 468 | + * @param unknown_type $property |
| 469 | + * @param unknown_type $object |
| 470 | + */ |
| 471 | + private function getArraySubjects( $graph, $property, $object ) { |
566 | 472 | |
567 | | - private function getArraySubjects($graph, $property, $object) { |
568 | | - |
569 | 473 | $arr_subjects = array(); |
570 | 474 | |
571 | 475 | // For each incoming uri, get the resources ( |
— | — | @@ -576,16 +480,14 @@ |
577 | 481 | $allResources = $graph->resources(); |
578 | 482 | |
579 | 483 | // for each resource, get the values for each of the incoming properties |
580 | | - foreach ($allResources as $aResource) { |
581 | | - $allSpecResources = $graph->allResources($aResource, $property); |
| 484 | + foreach ( $allResources as $aResource ) { |
| 485 | + $allSpecResources = $graph->allResources( $aResource, $property ); |
582 | 486 | |
583 | 487 | // For each resource, check if our $object |
584 | | - |
585 | | - foreach ($allSpecResources as $aSpecResource) { |
586 | | - if (!$aSpecResource->isBnode()) { |
587 | | - if ($aSpecResource->getUri() == $object) { |
588 | | - |
589 | | - $res = array("type" => "uri", "value" => $aSpecResource->getUri()); |
| 488 | + foreach ( $allSpecResources as $aSpecResource ) { |
| 489 | + if ( !$aSpecResource->isBnode() ) { |
| 490 | + if ( $aSpecResource->getUri() == $object ) { |
| 491 | + $res = array( "type" => "uri", "value" => $aSpecResource->getUri() ); |
590 | 492 | $arr_subjects[] = $res; |
591 | 493 | } |
592 | 494 | } |
— | — | @@ -595,120 +497,8 @@ |
596 | 498 | return $arr_subjects; |
597 | 499 | } |
598 | 500 | |
| 501 | + |
599 | 502 | /** |
600 | | - * Creates the HTML table displaying the data of one subject. |
601 | | - *based on displayData |
602 | | - * @param[in] $data SMWSemanticData The data to be displayed |
603 | | - * @param[in] $left bool Should properties be displayed on the left side? |
604 | | - * @param[in] $incoming bool Is this an incoming? Or an outgoing? |
605 | | - * |
606 | | - * @return A string containing the HTML with the factbox |
607 | | - * |
608 | | - * @deprecated Replaced by displaySemanticWebData |
609 | | - */ |
610 | | - private function getProperty( SMWSemanticData $data,$propertyName, $left = true, $incoming = false ) { |
611 | | - // Some of the CSS classes are different for the left or the right side. |
612 | | - // In this case, there is an "i" after the "smwb-". This is set here. |
613 | | - $ccsPrefix = $left ? 'smwb-' : 'smwb-i'; |
614 | | - $returnvalues=array(); |
615 | | - $html = "<table class=\"{$ccsPrefix}factbox\" cellpadding=\"0\" cellspacing=\"0\">\n"; |
616 | | - |
617 | | - $diProperties = $data->getProperties(); |
618 | | - $noresult = true; |
619 | | - foreach ( $diProperties as $diProperty ) { |
620 | | - $label=''; |
621 | | - $dvProperty = SMWDataValueFactory::newDataItemValue( $diProperty, null ); |
622 | | - echo "================================================================\n "; |
623 | | - if ( $dvProperty->isVisible() ) { |
624 | | - $label=$this->getPropertyLabel( $dvProperty, $incoming ); |
625 | | - //echo "Label='".$label."'\n"; |
626 | | - //echo "PropertyNamel='".$propertyName."'\n"; |
627 | | - $dvProperty->setCaption( $this->getPropertyLabel( $dvProperty, $incoming ) ); |
628 | | - $proptext = $dvProperty->getShortHTMLText( smwfGetLinker() ) . "\n"; |
629 | | - echo "Proptext1='".$proptext."'\n"; |
630 | | - } elseif ( $diProperty->getKey() == '_INST' ) { |
631 | | - $proptext = smwfGetLinker()->specialLink( 'Categories' ); |
632 | | - echo "Proptext2='".$proptext."'"; |
633 | | - } elseif ( $diProperty->getKey() == '_REDI' ) { |
634 | | - $proptext = smwfGetLinker()->specialLink( 'Listredirects', 'isredirect' ); |
635 | | - echo "Proptext3='".$proptext."'"; |
636 | | - } else { |
637 | | - continue; // skip this line |
638 | | - } |
639 | | - |
640 | | - |
641 | | - $head = "<th>" . $proptext . "</th>\n"; |
642 | | - |
643 | | - $body = "<td>\n"; |
644 | | - |
645 | | - $values = $data->getPropertyValues( $diProperty ); |
646 | | - |
647 | | - //Check on needed property name and safe its values |
648 | | - |
649 | | - |
650 | | - if ( $incoming && ( count( $values ) >= SWBSpecialBrowseWiki::$incomingvaluescount ) ) { |
651 | | - $moreIncoming = true; |
652 | | - array_pop( $values ); |
653 | | - } else { |
654 | | - $moreIncoming = false; |
655 | | - } |
656 | | - |
657 | | - $first = true; |
658 | | - foreach ( $values as $di ) { |
659 | | - if ( $first ) { |
660 | | - $first = false; |
661 | | - } else { |
662 | | - $body .= ', '; |
663 | | - } |
664 | | - |
665 | | - if ( $incoming ) { |
666 | | - $dv = SMWDataValueFactory::newDataItemValue( $di, null ); |
667 | | - } else { |
668 | | - $dv = SMWDataValueFactory::newDataItemValue( $di, $diProperty ); |
669 | | - } |
670 | | - $value=$this->displayValue( $dvProperty, $dv, $incoming ); |
671 | | - //$text=$value->getValue(); |
672 | | - echo " GetProperty.Value='".$value."'"; |
673 | | - if(strpos($label,$propertyName)>0){ |
674 | | - echo "index ok"; |
675 | | - array_push($returnvalues,$value); |
676 | | - } |
677 | | - // echo "Text='".$text."'"; |
678 | | - $body .= "<span class=\"{$ccsPrefix}value\">" . |
679 | | - $this->displayValue( $dvProperty, $dv, $incoming ) . "</span>\n"; |
680 | | - } |
681 | | - |
682 | | - if ( $moreIncoming ) { // link to the remaining incoming pages: |
683 | | - $body .= Html::element( |
684 | | - 'a', |
685 | | - array( |
686 | | - 'href' => SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL( array( |
687 | | - 'property' => $dvProperty->getWikiValue(), |
688 | | - 'value' => $this->subject->getWikiValue() |
689 | | - ) ) |
690 | | - ), |
691 | | - wfMsg( "smw_browse_more" ) |
692 | | - ); |
693 | | - |
694 | | - } |
695 | | - |
696 | | - $body .= "</td>\n"; |
697 | | - |
698 | | - // display row |
699 | | - $html .= "<tr class=\"{$ccsPrefix}propvalue\">\n" . |
700 | | - ( $left ? ( $head . $body ):( $body . $head ) ) . "</tr>\n"; |
701 | | - $noresult = false; |
702 | | - } // end foreach properties |
703 | | - |
704 | | - if ( $noresult ) { |
705 | | - $html .= "<tr class=\"smwb-propvalue\"><th>   </th><td><em>" . |
706 | | - wfMsg( $incoming ? 'swb_browse_no_incoming':'swb_browse_no_outgoing' ) . "</em></td></tr>\n"; |
707 | | - } |
708 | | - $html .= "</table>\n"; |
709 | | - return $returnvalues; |
710 | | - } |
711 | | - |
712 | | - /** |
713 | 503 | * Creates the HTML table displaying the Semantic Web data of one uri |
714 | 504 | * |
715 | 505 | * @param SMWSemanticData $data |
— | — | @@ -717,11 +507,11 @@ |
718 | 508 | * |
719 | 509 | * @return A string containing the HTML with the factbox |
720 | 510 | */ |
721 | | - private function displaySemanticWebData (SMWSemanticData $data, $left = true, $incoming = false ) { |
| 511 | + private function displaySemanticWebData ( SMWSemanticData $data, $left = true, $incoming = false ) { |
722 | 512 | // Some of the CSS classes are different for the left or the right side. |
723 | 513 | // In this case, there is an "i" after the "smwb-". This is set here. |
724 | 514 | $ccsPrefix = $left ? 'smwb-' : 'smwb-i'; |
725 | | - |
| 515 | + |
726 | 516 | $html = "<table class=\"{$ccsPrefix}factbox\" cellpadding=\"0\" cellspacing=\"0\">\n"; |
727 | 517 | |
728 | 518 | $diProperties = $data->getProperties(); |
— | — | @@ -737,7 +527,7 @@ |
738 | 528 | |
739 | 529 | // Typically, we have a URI. Provide link to further browse the SW. |
740 | 530 | // Always type 11 for prop: echo "dipropType:".$diProperty->getDIType(); |
741 | | - |
| 531 | + |
742 | 532 | } elseif ( $diProperty->getKey() == '_INST' ) { |
743 | 533 | $proptext = smwfGetLinker()->specialLink( 'Categories' ); |
744 | 534 | } elseif ( $diProperty->getKey() == '_REDI' ) { |
— | — | @@ -769,14 +559,12 @@ |
770 | 560 | if ( $incoming ) { |
771 | 561 | $dv = SMWDataValueFactory::newDataItemValue( $di, null ); |
772 | 562 | } else { |
773 | | - //$dv = SMWDataValueFactory::newDataItemValue( $di, $diProperty ); |
774 | 563 | // We do have values of different types, therefore not specific property. |
775 | 564 | // TODO: Later, we could look into property, whether specific type to override. |
776 | 565 | $dv = SMWDataValueFactory::newDataItemValue( $di, null ); |
777 | 566 | } |
778 | 567 | |
779 | 568 | $body .= "<span class=\"{$ccsPrefix}value\">" . |
780 | | - //$this->displayValue( $dvProperty, $dv, $incoming ) . "</span>\n"; |
781 | 569 | $this->displaySemanticValue( $dvProperty, $dv, $incoming ) . "</span>\n"; |
782 | 570 | } |
783 | 571 | |
— | — | @@ -785,11 +573,11 @@ |
786 | 574 | 'a', |
787 | 575 | array( |
788 | 576 | 'href' => SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL( array( |
789 | | - 'property' => $dvProperty->getWikiValue(), |
| 577 | + 'property' => $dvProperty->getWikiValue(), |
790 | 578 | 'value' => $this->subject->getWikiValue() |
791 | 579 | ) ) |
792 | 580 | ), |
793 | | - wfMsg( "smw_browse_more" ) |
| 581 | + wfMsg( "swb_browse_more" ) |
794 | 582 | ); |
795 | 583 | |
796 | 584 | } |
— | — | @@ -800,13 +588,14 @@ |
801 | 589 | $html .= "<tr class=\"{$ccsPrefix}propvalue\">\n" . |
802 | 590 | ( $left ? ( $head . $body ):( $body . $head ) ) . "</tr>\n"; |
803 | 591 | $noresult = false; |
804 | | - } // end foreach properties |
| 592 | + } |
805 | 593 | |
806 | 594 | if ( $noresult ) { |
807 | 595 | $html .= "<tr class=\"smwb-propvalue\"><th>   </th><td><em>" . |
808 | 596 | wfMsg( $incoming ? 'swb_browse_no_incoming':'swb_browse_no_outgoing' ) . "</em></td></tr>\n"; |
809 | 597 | } |
810 | 598 | $html .= "</table>\n"; |
| 599 | + |
811 | 600 | return $html; |
812 | 601 | } |
813 | 602 | |
— | — | @@ -822,15 +611,15 @@ |
823 | 612 | private function displayData( SMWSemanticData $data, $left = true, $incoming = false ) { |
824 | 613 | // Some of the CSS classes are different for the left or the right side. |
825 | 614 | // In this case, there is an "i" after the "smwb-". This is set here. |
| 615 | + $arr_uris = array(); |
826 | 616 | $ccsPrefix = $left ? 'smwb-' : 'smwb-i'; |
827 | 617 | |
828 | 618 | $html = "<table class=\"{$ccsPrefix}factbox\" cellpadding=\"0\" cellspacing=\"0\">\n"; |
829 | | - |
| 619 | + |
830 | 620 | $diProperties = $data->getProperties(); |
831 | 621 | $noresult = true; |
832 | 622 | foreach ( $diProperties as $diProperty ) { |
833 | 623 | $dvProperty = SMWDataValueFactory::newDataItemValue( $diProperty, null ); |
834 | | - |
835 | 624 | if ( $dvProperty->isVisible() ) { |
836 | 625 | $dvProperty->setCaption( $this->getPropertyLabel( $dvProperty, $incoming ) ); |
837 | 626 | $proptext = $dvProperty->getShortHTMLText( smwfGetLinker() ) . "\n"; |
— | — | @@ -856,6 +645,16 @@ |
857 | 646 | |
858 | 647 | $first = true; |
859 | 648 | foreach ( $values as $di ) { |
| 649 | + if( get_class( $di ) == "SMWDIWikiPage" ){ |
| 650 | + $this->debug( "[WIKIPage]" ); |
| 651 | + |
| 652 | + }elseif( get_class ( $di ) == "SMWDITime" ){ |
| 653 | + $this->debug ( "[SMWTime]" ); |
| 654 | + }elseif( get_class ( $di ) == "SMWDIUri" ){ |
| 655 | + $this->debug ( "[DiURI]" ); |
| 656 | + }else{ |
| 657 | + $this->debug( "[nothing]" ); |
| 658 | + } |
860 | 659 | if ( $first ) { |
861 | 660 | $first = false; |
862 | 661 | } else { |
— | — | @@ -876,11 +675,11 @@ |
877 | 676 | 'a', |
878 | 677 | array( |
879 | 678 | 'href' => SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL( array( |
880 | | - 'property' => $dvProperty->getWikiValue(), |
| 679 | + 'property' => $dvProperty->getWikiValue(), |
881 | 680 | 'value' => $this->subject->getWikiValue() |
882 | 681 | ) ) |
883 | 682 | ), |
884 | | - wfMsg( "smw_browse_more" ) |
| 683 | + wfMsg( "swb_browse_more" ) |
885 | 684 | ); |
886 | 685 | |
887 | 686 | } |
— | — | @@ -912,10 +711,8 @@ |
913 | 712 | */ |
914 | 713 | private function displaySemanticValue( SMWPropertyValue $property, SMWDataValue $dataValue, $incoming ) { |
915 | 714 | $linker = smwfGetLinker(); |
916 | | - |
917 | 715 | $html = $dataValue->getLongHTMLText( $linker ); |
918 | 716 | |
919 | | - // TODO: How to I trigger autoload if extends? |
920 | 717 | SMWInfolink::decodeParameters(); |
921 | 718 | if ( $dataValue->getTypeID() == '_wpg' ) { |
922 | 719 | $html .= " " . SWBInfolink::newBrowsingLink( '+', $dataValue->getLongWikiText() )->getHTML( $linker ); |
— | — | @@ -928,8 +725,6 @@ |
929 | 726 | // Provide link for browsing |
930 | 727 | $html .= " " . SWBInfolink::newBrowsingLink( '+', $dataValue->getLongWikiText() )->getHTML( $linker ); |
931 | 728 | } |
932 | | - |
933 | | - // TODO: Literal possibly visualized different also |
934 | 729 | } |
935 | 730 | |
936 | 731 | return $html; |
— | — | @@ -969,11 +764,21 @@ |
970 | 765 | */ |
971 | 766 | private function displayHead() { |
972 | 767 | global $wgOut; |
973 | | - |
| 768 | + |
| 769 | + /** |
| 770 | + * if subject(that is currently browsed to) contains a "_" so |
| 771 | + * this symbols are replaced in this subject by SMWDataValueFactory with a blank. |
| 772 | + * for solve this problem we replace string $this->subject->getTitle() to |
| 773 | + * the original title($this->articletext) |
| 774 | + */ |
| 775 | + $getTitle = smwfGetLinker()->makeLinkObj( $this->subject->getTitle() ); |
| 776 | + $replaceTitle = str_replace( $this->subject->getTitle(), $this->articletext, $getTitle ); |
| 777 | + |
974 | 778 | $wgOut->setHTMLTitle( $this->subject->getTitle() ); |
975 | 779 | $html = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n"; |
976 | 780 | $html .= "<tr class=\"smwb-title\"><td colspan=\"2\">\n"; |
977 | | - $html .= smwfGetLinker()->makeLinkObj( $this->subject->getTitle() ) . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility |
| 781 | + //$html .= smwfGetLinker()->makeLinkObj( $this->subject->getTitle() ) . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility |
| 782 | + $html .= $replaceTitle . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility |
978 | 783 | $html .= "</td></tr>\n"; |
979 | 784 | $html .= "</table>\n"; |
980 | 785 | |
— | — | @@ -991,7 +796,7 @@ |
992 | 797 | $wgOut->setHTMLTitle( $this->subject->getTitle() ); |
993 | 798 | $html = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n"; |
994 | 799 | $html .= "<tr class=\"smwb-title\"><td colspan=\"2\">\n"; |
995 | | - // No link but full URI should be shown |
| 800 | + // TODO: No link but full URI should be shown |
996 | 801 | $html .= $uri. "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility |
997 | 802 | $html .= "</td></tr>\n"; |
998 | 803 | $html .= "</table>\n"; |
— | — | @@ -1009,8 +814,8 @@ |
1010 | 815 | "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n" . |
1011 | 816 | "<tr class=\"smwb-center\"><td colspan=\"2\">\n" . |
1012 | 817 | ( $this->showincoming ? |
1013 | | - $this->linkHere( wfMsg( 'smw_browse_hide_incoming' ), true, false, 0 ): |
1014 | | - $this->linkHere( wfMsg( 'smw_browse_show_incoming' ), true, true, $this->offset ) ) . |
| 818 | + $this->linkHere( wfMsg( 'swb_browse_hide_incoming' ), true, false, 0 ): |
| 819 | + $this->linkHere( wfMsg( 'swb_browse_show_incoming' ), true, true, $this->offset ) ) . |
1015 | 820 | " \n" . "</td></tr>\n" . "</table>\n"; |
1016 | 821 | } |
1017 | 822 | |
— | — | @@ -1031,7 +836,7 @@ |
1032 | 837 | $this->linkHere( wfMsg( 'smw_result_prev' ), $this->showoutgoing, true, $offset ); |
1033 | 838 | $offset = $this->offset + SWBSpecialBrowseWiki::$incomingpropertiescount - 1; |
1034 | 839 | $html .= "     <strong>" . wfMsg( 'smw_result_results' ) . " " . ( $this->offset + 1 ) . |
1035 | | - " – " . ( $offset ) . "</strong>     "; |
| 840 | + " – " . ( $offset ) . "</strong>     "; |
1036 | 841 | $html .= $more ? $this->linkHere( wfMsg( 'smw_result_next' ), $this->showoutgoing, true, $offset ):wfMsg( 'smw_result_next' ); |
1037 | 842 | } |
1038 | 843 | } |
— | — | @@ -1115,10 +920,10 @@ |
1116 | 921 | global $smwgBrowseShowInverse; |
1117 | 922 | |
1118 | 923 | if ( $incoming && $smwgBrowseShowInverse ) { |
1119 | | - $oppositeprop = SMWPropertyValue::makeUserProperty( wfMsg( 'smw_inverse_label_property' ) ); |
| 924 | + $oppositeprop = SMWPropertyValue::makeUserProperty( wfMsg( 'swb_inverse_label_property' ) ); |
1120 | 925 | $labelarray = &smwfGetStore()->getPropertyValues( $property->getDataItem()->getDiWikiPage(), $oppositeprop->getDataItem() ); |
1121 | 926 | $rv = ( count( $labelarray ) > 0 ) ? $labelarray[0]->getLongWikiText(): |
1122 | | - wfMsg( 'smw_inverse_label_default', $property->getWikiValue() ); |
| 927 | + wfMsg( 'swb_inverse_label_default', $property->getWikiValue() ); |
1123 | 928 | } else { |
1124 | 929 | $rv = $property->getWikiValue(); |
1125 | 930 | } |
— | — | @@ -1131,17 +936,18 @@ |
1132 | 937 | * |
1133 | 938 | * @return A string containing the HTML for the form |
1134 | 939 | */ |
| 940 | + |
1135 | 941 | private function queryForm() { |
1136 | 942 | self::addAutoComplete(); |
1137 | 943 | $title = SpecialPage::getTitleFor( 'BrowseWiki' ); |
1138 | 944 | return ' <form name="smwbrowse" action="' . $title->escapeLocalURL() . '" method="get">' . "\n" . |
1139 | 945 | ' <input type="hidden" name="title" value="' . $title->getPrefixedText() . '"/>' . |
1140 | | - wfMsg( 'smw_browse_article' ) . "<br />\n" . |
| 946 | + wfMsg( 'swb_browse_article' ) . "<br />\n" . |
1141 | 947 | ' <input type="text" name="article" id="page_input_box" value="' . htmlspecialchars( $this->articletext ) . '" />' . "\n" . |
1142 | | - ' <input type="submit" value="' . wfMsg( 'smw_browse_go' ) . "\"/>\n" . |
| 948 | + ' <input type="submit" value="' . wfMsg( 'swb_browse_go' ) . "\"/>\n" . |
1143 | 949 | " </form>\n"; |
1144 | 950 | } |
1145 | | - |
| 951 | + |
1146 | 952 | /** |
1147 | 953 | * Creates the JS needed for adding auto-completion to queryForm(). Uses the |
1148 | 954 | * MW API to fetch suggestions. |
— | — | @@ -1167,7 +973,31 @@ |
1168 | 974 | |
1169 | 975 | SMWOutputs::requireScript( 'smwAutocompleteSpecialBrowse', $javascript_autocomplete_text ); |
1170 | 976 | } |
| 977 | + |
| 978 | + |
| 979 | + /** |
| 980 | + * Creates the JS needed for |
| 981 | + */ |
| 982 | + private static function setStartMenu(){ |
| 983 | + SMWOutputs::requireResource( 'jquery.ui.autocomplete' ); |
1171 | 984 | |
| 985 | + $javascript_autocomplete_text = <<<END |
| 986 | +<script type="text/javascript"> |
| 987 | +jQuery(document).ready(function(){ |
| 988 | + var xxx="hallo"; |
| 989 | + echo "xxx=".xxx; |
| 990 | + druck = window.open ('', 'fenster', xxx); |
| 991 | + druck.print(); |
| 992 | + |
| 993 | +}); |
| 994 | +</script> |
| 995 | + |
| 996 | +END; |
| 997 | + |
| 998 | + SMWOutputs::requireScript( 'smwAutocompleteSpecialBrowse', $javascript_autocomplete_text ); |
| 999 | + } |
| 1000 | + |
| 1001 | + |
1172 | 1002 | /** |
1173 | 1003 | * Replace the last two space characters with unbreakable spaces for beautification. |
1174 | 1004 | * |
— | — | @@ -1180,77 +1010,17 @@ |
1181 | 1011 | return $count > 2 ? preg_replace( '/($nonBreakingSpace)/u', ' ', $text, max( 0, $count - 2 ) ):$text; |
1182 | 1012 | } |
1183 | 1013 | |
| 1014 | + |
| 1015 | +/* can be used for testing |
| 1016 | + * 1.parameter is the text to display |
| 1017 | + * 2.parameter is the name of the text |
| 1018 | + */ |
1184 | 1019 | |
1185 | | - //Add Test Foaf-Info |
| 1020 | +public static function debug( $displaytext,$name=""){ |
| 1021 | + //echo $name; |
| 1022 | + //echo $name."='".$displaytext."' "."<br />"; |
| 1023 | + } |
1186 | 1024 | |
1187 | | - /** |
1188 | | - * |
1189 | | - * create object EaysRDF Graph based on uri |
1190 | | - * load graph |
1191 | | - * load information about person |
1192 | | - * get information about person |
1193 | | - * safe information together and return this information |
1194 | | - * @param unknown_type $uri |
1195 | | - * @param unknown_type $html |
1196 | | - */ |
1197 | | - |
1198 | | - private function foafInfo($uri){ |
1199 | | - global $wgOut; |
1200 | | - $html="\n"; |
1201 | | - if (isset($uri)) { |
1202 | | - if ( $uri != '' ) { |
1203 | | - $graph = new EasyRdf_Graph($uri); |
1204 | | - $graph->load(); |
1205 | | - if ($graph->type() == 'foaf:PersonalProfileDocument') { |
1206 | | - $person = $graph->primaryTopic(); |
1207 | | - }elseif ($graph->type() == 'foaf:Person') { |
1208 | | - $person = $graph->resource(); |
1209 | | - } |
1210 | | - } |
1211 | | - } |
1212 | | - $html.=$this->displayHead(); |
1213 | | - if (isset($person)) { |
1214 | | - $Name=$person->get('foaf:name'); |
1215 | | - $Homepage=link_to( $person->get('foaf:homepage') ); |
1216 | | - $Description=$person->get(array('dc:description','dc11:description')); |
1217 | | - $html.="Name:".$Name."<br />"; |
1218 | | - $html.="Homepage:".$Homepage."<br />"; |
1219 | | - $html.="Description:".$Description."<br />"; |
1220 | | - |
1221 | | - $wgOut->addHTML("Name:".$Name); |
1222 | | - $wgOut->addHTML("Homepage:".$Homepage); |
1223 | | - $wgOut->addHTML("Description:".$Description); |
1224 | | - |
1225 | | - //echo "<h2>Known Persons</h2>\n"; |
1226 | | - //echo "<ul>\n"; |
1227 | | - $html.="<h2>Known Persons</h2>\n"; |
1228 | | - $html.="<ul>\n"; |
1229 | | - foreach ($person->all('foaf:knows') as $friend) { |
1230 | | - $label = $friend->label(); |
1231 | | - if (!$label) { |
1232 | | - $label = $friend->getUri(); |
1233 | | - } |
1234 | | - |
1235 | | - if ($friend->isBnode()) { |
1236 | | - //echo "<li>$label</li>"; |
1237 | | - $html.="<li>$label</li>"; |
1238 | | - } else { |
1239 | | - $html.="<li>".link_to_self( $label, 'uri='.urlencode($friend) )."</li>"; |
1240 | | - // echo "<li>".link_to_self( $label, 'uri='.urlencode($friend) )."</li>"; |
1241 | | - } |
1242 | | - } |
1243 | | - // echo "</ul>\n"; |
1244 | | - $html.="</ul>\n"; |
1245 | | - } |
1246 | | - |
1247 | | - if (isset($graph)) { |
1248 | | - //echo "<br />"; |
1249 | | - // echo $graph->dump(); |
1250 | | - $html.="<br />"; |
1251 | | - $html.=$graph->dump(); |
1252 | | - } |
1253 | | - return $html; |
1254 | | - } |
1255 | | - |
| 1025 | + |
1256 | 1026 | } |
1257 | 1027 | |
Index: trunk/extensions/SemanticWebBrowser/includes/SWB_CreatePage.php |
— | — | @@ -1,529 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Class implementing extension for pulling in LOD data |
5 | | - * based on LODPuller |
6 | | - * @ingroup SWB |
7 | | - * @author Anna Kantorovitch |
8 | | - */ |
9 | | - |
10 | | -class SWBCreatePage { |
11 | | - static function render( &$out, &$sk ) { |
12 | | - $new = new SWBCreatePage(); |
13 | | - return $new->getPage( $out, $sk ); |
14 | | - } |
15 | | - |
16 | | - private $title = null; |
17 | | - private $pagename = ''; |
18 | | - private $sames = array(); |
19 | | - private $localurl = ''; |
20 | | - |
21 | | - function getPage( &$out, &$sk ) { |
22 | | - $this->title = $out->getTitle(); |
23 | | - $this->pagename = $this->title->getPrefixedText(); |
24 | | - if (!(($this->title->getNamespace() === NS_MAIN) || ($this->title->getNamespace() === SMW_NS_PROPERTY) || ($this->title->getNamespace() === SMW_NS_TYPE))) return true; |
25 | | - $this->localurl = $this->title->getPrefixedURL(); |
26 | | - if ($this->localurl === 'Main_Page') return true; |
27 | | - global $wgRequest; |
28 | | - if (!(($wgRequest->getText( 'action' ) === 'view') || ($wgRequest->getText( 'action' ) === 'purge') || ($wgRequest->getText( 'action' ) == ''))) return true; |
29 | | - |
30 | | - $out->includeJQuery(); |
31 | | - global $swbgIP; |
32 | | - $lodpullerScriptPath=$swbgIP; |
33 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/jquery.jeditable.js' ); |
34 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/jquery.loadmask.min.js' ); |
35 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/jquery.autocomplete.js' ); |
36 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/jquery.translate-NCT,core,NCT-adapter,ui,progress.min.js' ); |
37 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/jqModal.js' ); |
38 | | - |
39 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/LODPullerAPI.js' ); |
40 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/LODUtil.js' ); |
41 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/LODSame.js' ); |
42 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/LODContent.js' ); |
43 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/LODLinks.js' ); |
44 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/WikiFacts.js' ); |
45 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/Wikipedia.js' ); |
46 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/WikiLabels.js' ); |
47 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/WikiFacts.js' ); |
48 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/LODPuller.js' ); |
49 | | - $out->addScriptFile( $lodpullerScriptPath . 'js/main.js' ); |
50 | | - |
51 | | - $out->addExtensionStyle( $lodpullerScriptPath . 'css/jquery.autocomplete.css' ); |
52 | | - $out->addExtensionStyle( $lodpullerScriptPath . 'css/jquery.loadmask.css' ); |
53 | | - $out->addExtensionStyle( $lodpullerScriptPath . 'css/lodpuller.css' ); |
54 | | - |
55 | | - global $wgParser; |
56 | | - if (isset($wgParser->lodpuller)) { |
57 | | - global $wgLang; |
58 | | - $label = $wgParser->lodpuller->getLabel($this->title->getPrefixedText(), $wgLang->getCode()); |
59 | | - if ($label) { |
60 | | - global $wgSitename; |
61 | | - $out->setHTMLTitle($label . " - " . $wgSitename); |
62 | | - $out->setPageTitle($label); |
63 | | - } |
64 | | - } |
65 | | - |
66 | | - |
67 | | - // Page gets created completely new |
68 | | - $old = $out->getHTML(); |
69 | | - $out->clearHTML(); |
70 | | - |
71 | | - //$out->addHTML( "<div id=\"lod-main\">\n" ); |
72 | | - $this->renderMain( $old, $out ); |
73 | | - //$out->addHTML( "</div>\n" ); // lod-main; |
74 | | - |
75 | | - //$out->addHTML( "<div id=\"lod-side\">\n" ); |
76 | | - $this->renderSidebar( $out ); |
77 | | - //$out->addHTML( "</div>" ); // lod-side |
78 | | - |
79 | | - return true; |
80 | | - } |
81 | | - |
82 | | - /** |
83 | | - * Create the main part of the page, with the text and the |
84 | | - * and Wikipedia page. |
85 | | - * |
86 | | - * @param OutputPage $out Coming from the page renderer |
87 | | - * @return null |
88 | | - */ |
89 | | - private function renderMain( &$old, &$out ) { |
90 | | - $out->addHTML( $old ); |
91 | | - // TODO simply renders the current page, should render the descriptive blurb |
92 | | - |
93 | | - if (($this->title->getNamespace() === SMW_NS_PROPERTY) || ($this->title->getNamespace() === SMW_NS_TYPE)) return; |
94 | | - |
95 | | - $out->addHTML( '<h2>' . wfMsg('swb-facts') . '</h2>' ); |
96 | | - $out->addWikiText( '<div id="main-facts"></div>' ); |
97 | | - |
98 | | - $out->addHTML( '<h2>' . wfMsg('swb-webofdata') . '</h2>' ); |
99 | | - $out->addHTML( '<div id="lod-content"></div>' ); |
100 | | - |
101 | | -// $out->addHTML( '<h2>' . wfMsg('lodpuller-wikipedia') . '</h2>' ); |
102 | | - |
103 | | -// $out->addHTML( "<div id=\"wikipedia-content\"></div>\n" ); |
104 | | - $out->addHTML( '<h2>' . wfMsg('swb-links') . '</h2>' ); |
105 | | - //$this->getFaviki( $out ); |
106 | | - $out->addHTML( "<div id=\"swb-links\"></div>\n" ); |
107 | | - |
108 | | - } |
109 | | - |
110 | | - private function getFaviki( &$out ) { |
111 | | - $ch = curl_init(); |
112 | | - |
113 | | - // TODO change. this should actually take the local part of the dbpedia |
114 | | - // link, not just the name of the page! |
115 | | - |
116 | | - $termenc = urlencode( $this->pagename ); |
117 | | -// $url = "http://www.faviki.com/api/get/"; |
118 | | - //$out->addWikiText( $url ); |
119 | | - curl_setopt($ch, CURLOPT_URL, $url); |
120 | | - curl_setopt($ch, CURLOPT_HEADER, 0); |
121 | | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
122 | | - curl_setopt($ch, CURLOPT_POST, true); |
123 | | - //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST' ); |
124 | | - curl_setopt($ch, CURLOPT_POSTFIELDS, array('api_key' => '562a065ae6317a8100bc40e2e895bfb4', 'tag' => $this->pagename)); |
125 | | - //curl_setopt($ch, CURLOPT_HTTPHEADER, array ( "Accept: application/json" )); |
126 | | - $xmlanswer = curl_exec($ch); |
127 | | - curl_close($ch); |
128 | | - |
129 | | - $xmlanswer = preg_replace('/&[^; ]{0,6}.?/e', "((substr('\\0',-1) == ';') ? '\\0' : '&'.substr('\\0',1))", $xmlanswer); |
130 | | - //$out->addWikiText( " " . $xmlanswer ); |
131 | | - |
132 | | - libxml_use_internal_errors(true); |
133 | | - $xml = simplexml_load_string( $xmlanswer ); |
134 | | - $error = false; |
135 | | - foreach(libxml_get_errors() as $error) { |
136 | | - $out->addWikiText( $error->message ); |
137 | | - $error = true; |
138 | | - } |
139 | | - if ($error) return; |
140 | | - //$out->addWikiText($xml['status']); |
141 | | - //$out->addWikiText(print_r($xml, true)); |
142 | | - |
143 | | - if ($xml->webpages) { |
144 | | - // TODO Change. Make prettier, i.e. add a faviki icon or something |
145 | | - $out->addHTML('<h4>From <a href="http://www.faviki.com">faviki</a> — tags that make sense</h4>'); |
146 | | - $out->addHTML('<ul>'); |
147 | | - $i = 0; |
148 | | - foreach($xml->webpages->webpage as $webpage) { |
149 | | - $i = $i + 1; |
150 | | - if ($i > 6) break; |
151 | | - $out->addHTML( "<li><a href=\"$webpage->url\">$webpage->title</a></li>"); |
152 | | - } |
153 | | - $out->addHTML("<li><a href=\"http://www.faviki.com/tag/$this->pagename\">More on faviki</a></li>"); |
154 | | - $out->addHTML('</ul>'); |
155 | | - $out->addHTML('<h4>Links saved in Shortipedia</h4>'); |
156 | | - } |
157 | | - |
158 | | - return; |
159 | | - } |
160 | | - |
161 | | - /** |
162 | | - * Checks if the URI is known and an equivalent URI to any of the already |
163 | | - * existing pages. If so, it returns the name of the page, otherwise null. |
164 | | - * |
165 | | - * @param string $uri Identifier for an entity |
166 | | - * @return string The name of the page describing the entity, otherwise null |
167 | | - */ |
168 | | - public static function getInternalMapping( $uri ) { |
169 | | - $equivalentURI = SMWPropertyValue::makeUserProperty( "equivalent URI" ); |
170 | | - $urivalue = SMWDataValueFactory::newPropertyObjectValue( $equivalentURI, $uri ); |
171 | | - |
172 | | - $results = &smwfGetStore()->getPropertySubjects( $equivalentURI, $urivalue ); |
173 | | - |
174 | | - $mappings = array(); |
175 | | - foreach($results as $result) { |
176 | | - $mappings[] = $result->getWikiValue(); |
177 | | - } |
178 | | - if (count($mappings) === 0) return ""; |
179 | | - return $mappings[0]; // TODO Only returns one. There never should be more than one. |
180 | | - } |
181 | | - |
182 | | - |
183 | | - /** |
184 | | - * Returns an array of strings with all URIs the given page is equivalent |
185 | | - * to. |
186 | | - * |
187 | | - * @param $pagename Name of the page |
188 | | - * @return array_of_string List of URIs of the entity described by the page |
189 | | - */ |
190 | | - public static function getExternalMappings( $pagename ) { |
191 | | - $subject = SMWDataValueFactory::newTypeIDValue( '_wpg', $pagename ); |
192 | | - $pagename = $subject->isValid() ? $subject->getText():''; |
193 | | - if ($pagename === '') return array(); |
194 | | - $equivalentURI = SMWPropertyValue::makeUserProperty( "equivalent URI" ); |
195 | | - |
196 | | - $results = &smwfGetStore()->getPropertyValues( $subject, $equivalentURI ); |
197 | | - |
198 | | - $mappings = array(); |
199 | | - foreach($results as $result) { |
200 | | - $mappings[] = $result->getWikiValue(); |
201 | | - } |
202 | | - return $mappings; |
203 | | - } |
204 | | - |
205 | | - public static function getDifferents( $pagename ) { |
206 | | - $subject = SMWDataValueFactory::newTypeIDValue( '_wpg', $pagename ); |
207 | | - $pagename = $subject->isValid() ? $subject->getText():''; |
208 | | - if ($pagename === '') return array(); |
209 | | - $differentFrom = SMWPropertyValue::makeUserProperty( "Different from" ); |
210 | | - |
211 | | - $results = &smwfGetStore()->getPropertyValues( $subject, $differentFrom ); |
212 | | - |
213 | | - $differents = array(); |
214 | | - foreach($results as $result) { |
215 | | - $differents[] = $result->getWikiValue(); |
216 | | - } |
217 | | - return $differents; |
218 | | - } |
219 | | - |
220 | | - /** |
221 | | - * Returns an array of pagenames that have the given label in the given |
222 | | - * language. |
223 | | - * |
224 | | - * @param $label Name of the page |
225 | | - * @param $lang Language. Assumes user language if none is given. |
226 | | - * @return array_of_string List of pagenames |
227 | | - */ |
228 | | - public static function getPagesByLabel( $label, $lang = '' ) { |
229 | | - if ($lang === '') { |
230 | | - global $wgLang; |
231 | | - $lang = $wgLang->getCode(); |
232 | | - } |
233 | | - if ($label === '') return array(); |
234 | | - $labelprop = SMWPropertyValue::makeUserProperty( 'label' ); |
235 | | - $labelvalue = SMWDataValueFactory::newPropertyObjectValue( $labelprop, "$label;$lang" ); |
236 | | - |
237 | | - $results = &smwfGetStore()->getPropertySubjects( $labelprop, $labelvalue ); |
238 | | - |
239 | | - $pages = array(); |
240 | | - foreach($results as $result) { |
241 | | - $pages[] = $result->getWikiValue(); |
242 | | - } |
243 | | - return $pages; |
244 | | - } |
245 | | - |
246 | | - /** |
247 | | - * Returns an array of pagenames that have the given alias in the given |
248 | | - * language. |
249 | | - * |
250 | | - * @param $label Alias of the page |
251 | | - * @param $lang Language. Assumes user language if none is given. |
252 | | - * @return array_of_string List of pagenames |
253 | | - */ |
254 | | - public static function getPagesByAlias( $label, $lang = '' ) { |
255 | | - if ($lang === '') { |
256 | | - global $wgLang; |
257 | | - $lang = $wgLang->getCode(); |
258 | | - } |
259 | | - if ($label === '') return array(); |
260 | | - //$propertyDv = SMWPropertyValue::makeUserProperty( $propertyName ); |
261 | | - //$propertyDi = $propertyDv->getDataItem(); |
262 | | - //$result = SMWDataValueFactory::newPropertyObjectValue( $propertyDi, $value, $caption ); |
263 | | - |
264 | | - $propertyDv = SMWPropertyValue::makeUserProperty( 'alias' ); |
265 | | - $propertyDi = $propertyDv->getDataItem(); |
266 | | - $labelvalue = SMWDataValueFactory::newPropertyObjectValue( $propertyDi, "$label;$lang" ); |
267 | | - |
268 | | - $results = &smwfGetStore()->getPropertySubjects( $propertyDi, $labelvalue ); |
269 | | - |
270 | | - $pages = array(); |
271 | | - foreach($results as $result) { |
272 | | - $pages[] = $result->getWikiValue(); |
273 | | - } |
274 | | - return $pages; |
275 | | - } |
276 | | - |
277 | | - /** |
278 | | - * Returns the page that is linked to the given Wikipedia article |
279 | | - * |
280 | | - * @param $articlename Name of the article |
281 | | - * @param $lang Language. Assumes user language if none is given. |
282 | | - * @return string Resulting page |
283 | | - */ |
284 | | - public static function getPageByWikipediaLink( $articlename, $lang = '' ) { |
285 | | - if ($lang === '') { |
286 | | - global $wgLang; |
287 | | - $lang = $wgLang->getCode(); |
288 | | - } |
289 | | - if ($articlename === '') return array(); |
290 | | - $labelprop = SMWPropertyValue::makeUserProperty( 'Wikipedia' ); |
291 | | - $labelvalue = SMWDataValueFactory::newPropertyObjectValue( $labelprop, "$articlename;$lang" ); |
292 | | - |
293 | | - $results = &smwfGetStore()->getPropertySubjects( $labelprop, $labelvalue ); |
294 | | - |
295 | | - $pages = array(); |
296 | | - foreach($results as $result) { |
297 | | - return $result->getWikiValue(); |
298 | | - } |
299 | | - return ''; |
300 | | - } |
301 | | - |
302 | | - /** |
303 | | - * Returns the label of a page in the given language. If no language is |
304 | | - * given, the user language is assumed. |
305 | | - * |
306 | | - * @param $pagename Name of the page |
307 | | - * @param $lang Language (as the usual Wikipedia codes) |
308 | | - * @return string Label, or empty string if none is set |
309 | | - */ |
310 | | - public static function getLabel( $pagename, $lang = '' ) { |
311 | | - return SWBCreatePage::getI18nData( 'Label', $pagename, $lang ); |
312 | | - } |
313 | | - |
314 | | - /** |
315 | | - * Returns the description of a page in the given language. If no language is |
316 | | - * given, the user language is assumed. |
317 | | - * |
318 | | - * @param $pagename Name of the page |
319 | | - * @param $lang Language (as the usual Wikipedia codes) |
320 | | - * @return string Description, or empty string if none is set |
321 | | - */ |
322 | | - public static function getDescription( $pagename, $lang = '' ) { |
323 | | - return SWBCreatePage::getI18nData( 'Description', $pagename, $lang ); |
324 | | - } |
325 | | - |
326 | | - /** |
327 | | - * Returns the wikipedia link of a page in the given language. If no |
328 | | - * language is given, the user language is assumed. |
329 | | - * |
330 | | - * @param $pagename Name of the page |
331 | | - * @param $lang Language (as the usual Wikipedia codes) |
332 | | - * @return string Label, or empty string if none is set |
333 | | - */ |
334 | | - public static function getWikipediaLink( $pagename, $lang = '' ) { |
335 | | - return SWBCreatePage::getI18nData( 'Wikipedia', $pagename, $lang ); |
336 | | - } |
337 | | - |
338 | | - /** |
339 | | - * Implementation for the getLabel and getWikipediaLink methods. |
340 | | - * |
341 | | - * @param string $type One of 'label' or 'wikipedia' |
342 | | - * @param string $pagename Target page name |
343 | | - * @param string $lang Language to use |
344 | | - * @return string Result from database, dependent on type |
345 | | - */ |
346 | | - private static function getI18nData( $type, $pagename, $lang ) { |
347 | | - $alllangs = ($lang==='all'); |
348 | | - if ($lang === '') { |
349 | | - global $wgLang; |
350 | | - $lang = $wgLang->getCode(); |
351 | | - } |
352 | | - $subject = SMWDataValueFactory::newTypeIDValue( '_wpg', $pagename ); |
353 | | - $pagename = $subject->isValid() ? $subject->getText():''; |
354 | | - if ($pagename === '') return $alllangs ? array() : ''; |
355 | | - $prop = SMWPropertyValue::makeUserProperty( $type ); |
356 | | - |
357 | | - $results = &smwfGetStore()->getPropertyValues( $subject, $prop ); |
358 | | - |
359 | | - // We get back an array of SMWRecordValues, where the first value is |
360 | | - // the label and the second the language. As soon as we find the |
361 | | - // correct language, return the label |
362 | | - $content = array(); |
363 | | - foreach($results as $result) { |
364 | | - $dvs = $result->getDVs(); |
365 | | - if (count($dvs) != 2) continue; |
366 | | - if ($alllangs) { |
367 | | - $content[$dvs[1]->getWikiValue()] = $dvs[0]->getWikiValue(); |
368 | | - } else { |
369 | | - if ($lang === $dvs[1]->getWikiValue()) |
370 | | - return $dvs[0]->getWikiValue(); |
371 | | - } |
372 | | - } |
373 | | - return $alllangs ? $content : ''; |
374 | | - } |
375 | | - |
376 | | - static public function getWikipediaLinks( $pagename ) { |
377 | | - return SWBCreatePage::getI18nData( 'Wikipedia', $pagename, 'all' ); |
378 | | - } |
379 | | - |
380 | | - static public function getType( $pagename ) { |
381 | | - $property = SMWPropertyValue::makeUserProperty( $pagename ); |
382 | | - if ($property == null) return ''; |
383 | | - return $property->getTypesValue()->getWikiValue(); |
384 | | - } |
385 | | - |
386 | | - /** |
387 | | - * Checks if a the given language is one of the languages known to the |
388 | | - * system. |
389 | | - * |
390 | | - * @param string $lang Language code to be checked |
391 | | - * @return bool true if a known language, else false |
392 | | - */ |
393 | | - static public function validLanguage( $lang ) { |
394 | | - global $lodpullerAllLanguages; |
395 | | - return (array_key_exists($lang, $lodpullerAllLanguages)); |
396 | | - } |
397 | | - |
398 | | - /** |
399 | | - * Create the sidebar with the facts from the system, the possible matches, |
400 | | - * and the external facts. |
401 | | - * |
402 | | - * @param OutputPage $out Coming from the page renderer |
403 | | - * @return null |
404 | | - */ |
405 | | - private function renderSidebar( &$out ) { |
406 | | - global $wgLang; |
407 | | - |
408 | | - if ($this->title->getNamespace() === SMW_NS_PROPERTY) { |
409 | | - $currenttype = 'Type:' . SWBCreatePage::getType( $this->pagename ); |
410 | | - $out->addHTML( '<h3>' . wfMsg('lodpuller-propertytype') . '</h3>' ); |
411 | | - $out->addHTML( '<form id="propertytypeform"><select id="propertytype" value="' . $currenttype .'">' ); |
412 | | - $types = $this->getTypes( $wgLang->getCode() ); |
413 | | - foreach($types as $type => $label) { |
414 | | - $selected = ($type == $currenttype)? ' selected="selected"' : ''; |
415 | | - $out->addHTML( "<option value=\"$type\"$selected>$label</option>" ); |
416 | | - } |
417 | | - $out->addHTML( '</select></form>' ); |
418 | | - } |
419 | | - |
420 | | - $out->addHTML( '<h2>' . wfMsg('lodpuller-labels') . '</h2>' ); |
421 | | - $out->addHTML( '<div id="sidebar-labels"></div>' ); |
422 | | - |
423 | | - return; |
424 | | - } |
425 | | - |
426 | | - static private function getTypes( $lang ) { |
427 | | - // Create the query |
428 | | - $parser = new SMWQueryParser(); |
429 | | - $description = $parser->getQueryDescription( '[[Type:+]]' ); |
430 | | - $labelprop = SMWPropertyValue::makeUserProperty( 'Label' ); |
431 | | - $labelpr = new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, 'Label', $labelprop ); |
432 | | - $description->addPrintRequest( $labelpr ); |
433 | | - $query = new SMWQuery( $description ); |
434 | | - |
435 | | - $results = &smwfGetStore()->getQueryResult( $query ); |
436 | | - |
437 | | - $types = array(); |
438 | | - while($result = $results->getNext()) { |
439 | | - $title = $result[0]->getResultSubject()->getWikiValue(); |
440 | | - if (in_array($title, array('Type:Record', 'Type:Annotation URI', 'Type:Code', 'Type:Text'))) continue; |
441 | | - |
442 | | - $label = ''; |
443 | | - while($labelrecord = $result[0]->getNextObject()) { |
444 | | - $dvs = $labelrecord->getDVs(); |
445 | | - if ($dvs[1]->getWikiValue() === $lang) |
446 | | - $label = $dvs[0]->getWikiValue(); |
447 | | - } |
448 | | - $types[$title] = $label ? $label : $title; |
449 | | - } |
450 | | - |
451 | | - return $types; |
452 | | - } |
453 | | - |
454 | | - static public function preferences( $user, &$preferences ) { |
455 | | - |
456 | | - $preferences['lodpuller-lang'] = array( |
457 | | - 'type' => 'toggle', |
458 | | - 'label-message' => 'lodpuller-usecustomlang', |
459 | | - 'section' => 'personal/i18n' |
460 | | - ); |
461 | | - |
462 | | - global $lodpullerAllLanguages; |
463 | | - foreach ( $lodpullerAllLanguages as $code => $name ) { |
464 | | - $preferences['lodpuller-lang-' . $code] = array( |
465 | | - 'type' => 'toggle', |
466 | | - 'label' => $code . ' - ' . $name, |
467 | | - 'section' => 'language' |
468 | | - ); |
469 | | - } |
470 | | - |
471 | | - // TODO Change the yourlanguage label in preferences info/i18n to "User Interface Language" |
472 | | - return true; |
473 | | - } |
474 | | - |
475 | | - /** |
476 | | - * Function hooked to MakeGlobalVariablesScript. Add all the variables that |
477 | | - * are needed for the JavaScript. |
478 | | - * See http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript |
479 | | - * |
480 | | - * @param array $vars variable (or multiple variables) to be added into the output of Skin::makeVariablesScript |
481 | | - * @return bool true if everything went OK |
482 | | - */ |
483 | | - static public function addJSVariables( &$vars ) { |
484 | | - global $wgParser; |
485 | | - $vars['lodpullerfacts'] = isset($wgParser->lodpuller) ? $wgParser->lodpuller->getResultObject() : array(); |
486 | | - |
487 | | - // List of all messages that need to be made available to the JS |
488 | | - $lodpullerJSMessages = array( |
489 | | - 'loadingwikipedia', 'loadingwebofdata', |
490 | | - 'browse', 'go', 'cancel', 'hide', 'show', 'load', 'saving', 'close', |
491 | | - 'showalllanguages', 'hidesomelanguages', |
492 | | - 'addfact', 'removefact', 'addingfact', 'removingfact', |
493 | | - 'source', 'sources', 'addsource', 'removesource', 'addingsource', 'removingsource', |
494 | | - 'map', 'unmap', 'maping', 'unmapping', 'addmapping', |
495 | | - 'morefrom', 'nodata', 'loadinglinkeddata', 'addlabel', 'adddescription', 'addlink', |
496 | | - 'addinglabel', 'addingdescription', 'addfacts', 'removefacts', |
497 | | - 'mapwikipedia', 'mapotherwikipedia', 'unmapwikipedia', 'addwikipedia', |
498 | | - 'alias', 'aliases', 'addalias', 'removealias', 'addingalias', 'removingalias', |
499 | | - 'removelod', 'hideproperty', |
500 | | - 'help-title', 'help-add-fact' |
501 | | - ); |
502 | | - foreach($lodpullerJSMessages as $key) { |
503 | | - $lodpullermessages[$key] = wfMsg('lodpuller-' . $key); |
504 | | - } |
505 | | - $vars['lpMsgs'] = $lodpullermessages; |
506 | | - $vars['lpLanguages'] = SWBCreatePage::getLanguageLabels(); |
507 | | - return true; |
508 | | - } |
509 | | - |
510 | | - static public function getLanguageLabels() { |
511 | | - global $wgParser, $lodpullerDefaultLanguages, $lodpullerAllLanguages, $wgUser, $wgLang; |
512 | | - $languages = array(); |
513 | | - foreach ( $lodpullerAllLanguages as $code => $name ) { |
514 | | - $label = $description = ''; |
515 | | - if ($wgUser->getBoolOption( 'lodpuller-lang' )) |
516 | | - $show = $wgUser->getBoolOption( 'lodpuller-lang-' . $code); |
517 | | - else |
518 | | - $show = in_array($code, $lodpullerDefaultLanguages); |
519 | | - if ($code === $wgLang->getCode()) $show = true; |
520 | | - if (isset($wgParser->lodpuller)) |
521 | | - $label = $wgParser->lodpuller->getLabel($wgParser->getTitle()->getPrefixedText(), $code ); |
522 | | - if (isset($wgParser->lodpuller)) |
523 | | - $description = $wgParser->lodpuller->getDescription($wgParser->getTitle()->getPrefixedText(), $code ); |
524 | | - $lang = array("lang"=>array($code, $name, $show), "label"=>$label, "desc"=>$description); |
525 | | - array_push($languages, $lang); |
526 | | - } |
527 | | - return $languages; |
528 | | - } |
529 | | -} |
530 | | - |
Index: trunk/extensions/SemanticWebBrowser/includes/SWB_Setup.php |
— | — | @@ -1,62 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Global functions used for setting up the Semantic WebBrowser extension. |
6 | | - * @author Benedikt K�mpgen and Anna Kantorovitch |
7 | | - * @file SWB_Setup.php |
8 | | - * @ingroup SWB |
9 | | - */ |
10 | | -//include for toolbox |
11 | | -global $swbgToolboxBrowseSemWeb; |
12 | | - |
13 | | -$wgExtensionMessagesFiles['SemanticWebBrowser'] = $swbgIP . 'languages/SWB_Messages.php'; // register messages (requires MW=>1.11) |
14 | | - |
15 | | -// Register special pages aliases file |
16 | | -$wgExtensionAliasesFiles['SemanticWebBrowser'] = $swbgIP . 'languages/SWB_Aliases.php'; |
17 | | - |
18 | | -/** |
19 | | - * create Special Page for Browse Wiki |
20 | | - */ |
21 | | -$wgAutoloadClasses['SWBSpecialBrowseWiki'] = $swbgIP . 'specials/SearchTriple/SWB_SpecialBrowseWiki.php'; |
22 | | -$wgSpecialPages['BrowseWiki'] = 'SWBSpecialBrowseWiki'; |
23 | | -$wgSpecialPageGroups['BrowseWiki'] = 'smw_group'; |
24 | | - |
25 | | -// InfoLink |
26 | | -$wgAutoloadClasses['SWBInfolink'] = $swbgIP . 'includes/SWB_Infolink.php'; |
27 | | - |
28 | | -// Data values |
29 | | -$wgAutoloadClasses['SWBResolvableUriValue'] = $swbgIP . 'includes/datavalues/SWBResolvableUriValue.php'; |
30 | | - |
31 | | -$wgHooks['smwInitProperties'][] = 'registerPropertyTypes'; |
32 | | - |
33 | | - |
34 | | -function registerPropertyTypes() { |
35 | | - // 5 means uri |
36 | | - SMWDataValueFactory::registerDatatype( "_rur", "SWBResolvableUriValue", SMWDataItem::TYPE_URI, $label = false ); |
37 | | - |
38 | | - return true; |
39 | | -} |
40 | | - |
41 | | -//include in toolbox direcly link to Browsing Semantic Web |
42 | | - |
43 | | -if ( $swbgToolboxBrowseSemWeb ) { |
44 | | - $wgHooks['SkinTemplateToolboxEnd'][] = 'swbfShowBrowseSemWeb'; |
45 | | -} |
46 | | - |
47 | | -/** |
48 | | - * Add a link to the toolbox to view the properties of the current page in |
49 | | - * Special:Browse. The links has the CSS id "t-swbbrowsesemweb" so that it can be |
50 | | - * skinned or hidden with all standard mechanisms (also by individual users |
51 | | - * with custom CSS). |
52 | | - */ |
53 | | -function swbfShowBrowseSemWeb( $skintemplate ) { |
54 | | - if ( $skintemplate->data['isarticle'] ) { |
55 | | - smwfLoadExtensionMessages( 'SemanticWebBrowser' ); |
56 | | - |
57 | | - $browsesemweb = SWBInfolink::newBrowsingSemWeb( wfMsg( 'swb_browse_semantic_web' ), |
58 | | - $skintemplate->data['titleprefixeddbkey'], false ); |
59 | | - echo '<li id="t-swbbrowsesemweb">' . $browsesemweb->getHTML() . '</li>'; |
60 | | - } |
61 | | - return true; |
62 | | -} |
63 | | - |
Index: trunk/extensions/SemanticWebBrowser/includes/SWB_SemanticSearchByLabel.php |
— | — | @@ -1,129 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * based on LODPullerByLabel |
5 | | - * @group SWB |
6 | | - * @author Anna |
7 | | - * |
8 | | - */ |
9 | | -class SWBSemanticSearchByLabel extends SpecialPage { |
10 | | - function __construct() { |
11 | | - parent::__construct( 'SWBSemanticSearchByLabel' ); |
12 | | - } |
13 | | - |
14 | | - function execute( $par ) { |
15 | | - global $wgRequest, $wgOut, $wgScriptPath, $wgServer; |
16 | | - |
17 | | - $this->setHeaders(); // check if really needed, i.e. for a redirect |
18 | | - |
19 | | - # Get request data: $lang and $label |
20 | | - // TODO if no lang or label is given, maybe a form should appear to ask for both |
21 | | - $lang = $wgRequest->getText('uselang'); |
22 | | - if ($lang) { |
23 | | - if (!SWBCreatePage::validLanguage($lang)) { |
24 | | - $wgOut->addWikiText("Specified language unknown to the system."); |
25 | | - // No I18n since we would not know in which language, obviously |
26 | | - return; |
27 | | - } |
28 | | - } else { |
29 | | - global $wgLang; |
30 | | - $lang = $wgLang->getCode(); |
31 | | - } |
32 | | - |
33 | | - $label = $par; |
34 | | - if (!$par) { |
35 | | - $label = $wgRequest->getText('label'); |
36 | | - if (!$label) { |
37 | | - $wgOut->addWikiText( wfMsg('swb-nolabelgiven') ); |
38 | | - return; |
39 | | - } |
40 | | - } |
41 | | - |
42 | | - $pages = SWBCreatePage::getPagesByAlias( $label, $lang ); |
43 | | - |
44 | | - if (count($pages) === 0) { |
45 | | - // Do nothing |
46 | | - } elseif (count($pages) === 1) { |
47 | | - // Go to that page directly |
48 | | - $wgOut->redirect( "$wgScriptPath/topic/$lang/$pages[0]" ); |
49 | | - return; |
50 | | - } else { |
51 | | - global $wgSitename; |
52 | | - $wgOut->setHTMLTitle( wfMsg('swb-disambiguation') . ':' . $label . ' - ' . $wgSitename ); |
53 | | - $wgOut->setPageTitle( $label ); |
54 | | - $wgOut->addWikiText( wfMsg('swb-disambiguationpage', $label) ); |
55 | | - foreach ($pages as $page) { |
56 | | - $plabel = SWBCreatePage::getLabel($page, $lang); |
57 | | - $pdescription = SWBCreatePage::getDescription($page, $lang); |
58 | | - $wgOut->addWikiText( "* '''[[$page|$plabel]]''': $pdescription" ); |
59 | | - } |
60 | | - $wgOut->addWikiText( "\n\n" ); |
61 | | - } |
62 | | - |
63 | | - list($wphits, $wpsuggest, $wpresults) = SWBSemanticSearchByLabel::getWikipediaSearch( $label, $lang ); |
64 | | - |
65 | | - $exactmatch = false; |
66 | | - if (count($wpresults)) { |
67 | | - $wgOut->addWikiText( wfMsg('swb-wpsearchresults' ) ); |
68 | | - $wgOut->addHTML('<ul>'); |
69 | | - foreach($wpresults as $title => $snippet) { |
70 | | - if ($title == $label) $exactmatch = true; |
71 | | - $target = str_replace(' ', '_', $title); |
72 | | - $wgOut->addHTML("<li><a href=\"$wgServer$wgScriptPath/wikipedia/$lang/$target\">$title</a><br> <em>$snippet</em></li>"); |
73 | | - } |
74 | | - $wgOut->addHTML('</ul>'); |
75 | | - $wgOut->addWikiText( "\n\n" ); |
76 | | - } |
77 | | - |
78 | | - if ($wpsuggest) { |
79 | | - $wgOut->addWikiText( wfMsg('swb-didyoumean') ); |
80 | | - $target = str_replace(' ', '_', $wpsuggest); |
81 | | - $wgOut->addHTML("<ul><li><a href=\"$wgServer$wgScriptPath/$lang/$target\">$wpsuggest</a></li></ul>"); |
82 | | - $wgOut->addWikiText( "\n\n" ); |
83 | | - } |
84 | | - |
85 | | - |
86 | | - // If nothing was found |
87 | | - if ((count($pages)===0) && (!$exactmatch)) { |
88 | | - $title = Title::newFromText( $label ); |
89 | | - if ($title->exists()) { |
90 | | - // If the page exists (but not with the title) |
91 | | - $wgOut->addWikiText( wfMsg('swb-pagenameexists' )); |
92 | | - $langlabel = SWBCreatePage::getLabel( $label, $lang ); |
93 | | - $displaylabel = $langlabel ? $langlabel : $label; |
94 | | - $target = str_replace(' ', '_', $label); |
95 | | - $wgOut->addHtml("<ul><li><a href=\"$wgServer$wgScriptPath/topic/$lang/$target\">$displaylabel</a></li></ul>"); |
96 | | - } else { |
97 | | - // If such a page does not exist at all, enable its creation |
98 | | - $wgOut->addWikiText( wfMsg('swb-createpage' )); |
99 | | - $target = str_replace(' ', '_', $label); |
100 | | - $wgOut->addHtml("<ul><li><a href=\"$wgServer$wgScriptPath/topic/$lang/$target\">$label</a></li></ul>"); |
101 | | - } |
102 | | - } |
103 | | - } |
104 | | - |
105 | | - // TODO See also LODPullerSuggestAPI::getWikipediaSearch |
106 | | - private static function getWikipediaSearch( $term, $lang ) { |
107 | | - $term = urlencode($term); |
108 | | - $ch = curl_init(); |
109 | | - curl_setopt($ch, CURLOPT_URL, "http://$lang.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=$term"); |
110 | | - curl_setopt($ch, CURLOPT_USERAGENT, "lodpuller"); |
111 | | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
112 | | - $output = curl_exec($ch); |
113 | | - curl_close($ch); |
114 | | - |
115 | | - $answer = json_decode($output); |
116 | | - $hits = $answer->query->searchinfo->totalhits; |
117 | | - $results = array(); |
118 | | - $suggestion = ''; |
119 | | - if ($hits === 0) { |
120 | | - if (property_exists($answer->query->searchinfo, 'suggestion')) |
121 | | - $suggestion = $answer->query->searchinfo->suggestion; |
122 | | - } else { |
123 | | - foreach( $answer->query->search as $hit ) { |
124 | | - $results[$hit->title] = $hit->snippet; |
125 | | - } |
126 | | - } |
127 | | - return array($hits, $suggestion, $results); |
128 | | - } |
129 | | - |
130 | | -} |
Index: trunk/extensions/SemanticWebBrowser/includes/SWB_ControlProperties.php |
— | — | @@ -1,535 +0,0 @@ |
2 | | -<?php /** |
3 | | - * Helper class to save some data in the parser. Will be added to the parser |
4 | | - * when called. |
5 | | - * based on LODParseHelper |
6 | | - * @ingroup SWB |
7 | | - * @author Anna |
8 | | - */ |
9 | | -class SWBControlProperties { |
10 | | - public $lastproperty = ""; |
11 | | - public $lastvalue = ""; |
12 | | - public $title = ""; |
13 | | - public $deflang = ""; |
14 | | - |
15 | | - public $facts = array(); |
16 | | - public $mappings = array(); |
17 | | - public $different = array(); |
18 | | - public $labels = array(); |
19 | | - public $aliases = array(); |
20 | | - public $descriptions = array(); |
21 | | - public $wikipedias = array(); |
22 | | - public $links = array(); |
23 | | - public $type = ''; |
24 | | - |
25 | | - public function __construct( &$parser ) { |
26 | | - $this->title = $parser->getTitle()->getPrefixedText(); |
27 | | - global $wgLang; |
28 | | - $this->deflang = $wgLang->getCode(); |
29 | | - $this->labelize($this->title, $this->deflang); |
30 | | - } |
31 | | - |
32 | | - public function addPropertyValue($property, $value, $lang="") { |
33 | | - $property = ucfirst($property); |
34 | | - if (strpos($property, 'Property:')!==0) $property = 'Property:' . $property; |
35 | | - if (SWBControlProperties::forbiddenProperty($property)) return; |
36 | | - if (!array_key_exists($property, $this->facts)) |
37 | | - $this->facts[$property] = array(); |
38 | | - if (!array_key_exists($value, $this->facts[$property])) |
39 | | - $this->facts[$property][$value] = array(); |
40 | | - |
41 | | - $this->labelize($property, $lang); |
42 | | - $this->labelize($value, $lang); |
43 | | - } |
44 | | - |
45 | | - public static function forbiddenProperty($property) { |
46 | | - $forbidden = array('Property:Label', 'Property:Alias', |
47 | | - 'Property:Wikipedia', 'Property:Has type', 'Property:Description', |
48 | | - 'Property:Equivalent URI', 'Property:Modification date', |
49 | | - 'Property:Different from'); |
50 | | - $property = ucfirst($property); |
51 | | - if (strpos($property, 'Property:')!==0) $property = 'Property:' . $property; |
52 | | - return in_array($property, $forbidden); |
53 | | - } |
54 | | - |
55 | | - public function removePropertyValue($property, $value, $lang="") { |
56 | | - $property = ucfirst($property); |
57 | | - if (strpos($property, 'Property:')!==0) $property = 'Property:' . $property; |
58 | | - if (!array_key_exists($property, $this->facts)) |
59 | | - return; |
60 | | - if (!array_key_exists($value, $this->facts[$property])) |
61 | | - return; |
62 | | - unset($this->facts[$property][$value]); |
63 | | - if (count($this->facts[$property]) === 0) { |
64 | | - unset($this->facts[$property]); |
65 | | - return; |
66 | | - } |
67 | | - } |
68 | | - |
69 | | - public function addSource($property, $value, $source, $lang="") { |
70 | | - $property = ucfirst($property); |
71 | | - if (strpos($property, 'Property:')!==0) $property = 'Property:' . $property; |
72 | | - if (SWBControlProperties::forbiddenProperty($property)) return; |
73 | | - if (!array_key_exists($property, $this->facts)) |
74 | | - $this->facts[$property] = array(); |
75 | | - if (!array_key_exists($value, $this->facts[$property])) |
76 | | - $this->facts[$property][$value] = array(); |
77 | | - if (!in_array($source, $this->facts[$property][$value])) |
78 | | - $this->facts[$property][$value][] = $source; |
79 | | - |
80 | | - $this->labelize($property, $lang); |
81 | | - $this->labelize($value, $lang); |
82 | | - } |
83 | | - |
84 | | - public function removeSource($property, $value, $source, $lang="") { |
85 | | - $property = ucfirst($property); |
86 | | - if (strpos($property, 'Property:')!==0) $property = 'Property:' . $property; |
87 | | - if (!array_key_exists($property, $this->facts)) |
88 | | - return; |
89 | | - if (!array_key_exists($value, $this->facts[$property])) |
90 | | - return; |
91 | | - $key = array_search($source, $this->facts[$property][$value]); |
92 | | - if ($key === false) return; |
93 | | - unset($this->facts[$property][$value][$key]); |
94 | | - $this->facts[$property][$value] = array_values($this->facts[$property][$value]); |
95 | | - } |
96 | | - |
97 | | - public function addMapping($uri, $title = '', $lang="") { |
98 | | - if ($title === '') $title = $this->title; |
99 | | - $this->mappings[$uri] = $title; |
100 | | - |
101 | | - $this->labelize($title, $lang); |
102 | | - } |
103 | | - |
104 | | - public function removeMapping($uri, $title = '', $lang="") { |
105 | | - if (array_key_exists($uri, $this->mappings)) |
106 | | - unset($this->mappings[$uri]); |
107 | | - } |
108 | | - |
109 | | - public function addDifferent($uri, $title = '', $lang = '') { |
110 | | - if ($title === '') $title = $this->title; |
111 | | - if (in_array($uri, $this->different)) |
112 | | - return; |
113 | | - $this->different[] = $uri; |
114 | | - } |
115 | | - |
116 | | - public function removeDifferent($uri, $title = '', $lang = '') { |
117 | | - $key = array_search($uri, $this->different); |
118 | | - if ($key === false) |
119 | | - return; |
120 | | - unset($this->different[$key]); |
121 | | - } |
122 | | - |
123 | | - public function addLabel($entity, $label, $lang) { |
124 | | - if (!SWBCreatePage::validLanguage($lang)) |
125 | | - return; |
126 | | - if (!array_key_exists($lang, $this->labels)) |
127 | | - $this->labels[$lang] = array(); |
128 | | - $this->labels[$lang][$entity] = $label; |
129 | | - } |
130 | | - |
131 | | - public function removeLabel($entity, $label, $lang) { |
132 | | - if (!array_key_exists($lang, $this->labels)) |
133 | | - return; |
134 | | - unset($this->labels[$lang][$entity]); |
135 | | - } |
136 | | - |
137 | | - public function getLabel($entity, $lang) { |
138 | | - if (!array_key_exists($lang, $this->labels)) |
139 | | - return ""; |
140 | | - if (!array_key_exists($entity, $this->labels[$lang])) |
141 | | - return ""; |
142 | | - return $this->labels[$lang][$entity]; |
143 | | - } |
144 | | - |
145 | | - public function addAlias($entity, $alias, $lang) { |
146 | | - if (!SWBCreatePage::validLanguage($lang)) |
147 | | - return; |
148 | | - if (!array_key_exists($lang, $this->aliases)) |
149 | | - $this->aliases[$lang] = array(); |
150 | | - if (!in_array($alias, $this->aliases[$lang])) |
151 | | - $this->aliases[$lang][] = $alias; |
152 | | - } |
153 | | - |
154 | | - public function removeAlias($entity, $alias, $lang) { |
155 | | - if (!array_key_exists($lang, $this->aliases)) |
156 | | - return; |
157 | | - $key = array_search($alias, $this->aliases[$lang]); |
158 | | - if ($key === false) |
159 | | - return; |
160 | | - unset($this->aliases[$lang][$key]); |
161 | | - } |
162 | | - |
163 | | - public function addDescription($entity, $description, $lang) { |
164 | | - if (!SWBCreatePage::validLanguage($lang)) |
165 | | - return; |
166 | | - if (!array_key_exists($lang, $this->descriptions)) |
167 | | - $this->descriptions[$lang] = array(); |
168 | | - $this->descriptions[$lang][$entity] = $description; |
169 | | - |
170 | | - $this->labelize($entity, $lang); |
171 | | - } |
172 | | - |
173 | | - public function removeDescription($entity, $description, $lang) { |
174 | | - if (!array_key_exists($lang, $this->descriptions)) |
175 | | - return; |
176 | | - unset($this->descriptions[$lang][$entity]); |
177 | | - } |
178 | | - |
179 | | - public function getDescription($entity, $lang) { |
180 | | - if (!array_key_exists($lang, $this->descriptions)) |
181 | | - return ""; |
182 | | - if (!array_key_exists($entity, $this->descriptions[$lang])) |
183 | | - return ""; |
184 | | - return $this->descriptions[$lang][$entity]; |
185 | | - } |
186 | | - |
187 | | - public function addWikipedia($entity, $wikipedia, $lang) { |
188 | | - if (!SWBCreatePage::validLanguage($lang)) |
189 | | - return; |
190 | | - $this->wikipedias[$lang] = $wikipedia; |
191 | | - } |
192 | | - |
193 | | - public function removeWikipedia($entity, $wikipedia, $lang) { |
194 | | - if (!array_key_exists($lang, $this->wikipedias)) |
195 | | - return; |
196 | | - unset($this->wikipedias[$lang]); |
197 | | - } |
198 | | - |
199 | | - public function getWikipedia($entity, $lang) { |
200 | | - if (!array_key_exists($lang, $this->wikipedias)) |
201 | | - return ""; |
202 | | - return $this->wikipedias[$lang]; |
203 | | - } |
204 | | - |
205 | | - public function addLink( $link ) { |
206 | | - if (in_array($link, $this->links)) |
207 | | - return; |
208 | | - $linkvalue = SMWDataValueFactory::newTypeIDValue( '_uri', $link ); |
209 | | - if ($linkvalue->isValid()) |
210 | | - $this->links[] = $link; |
211 | | - } |
212 | | - |
213 | | - public function removeLink( $link ) { |
214 | | - $key = array_search($link, $this->links); |
215 | | - if ($key === false) return; |
216 | | - unset($this->links[$key]); |
217 | | - } |
218 | | - |
219 | | - public function addType( $type ) { |
220 | | - $this->type = $type; |
221 | | - } |
222 | | - |
223 | | - private function labelize($name, $lang) { |
224 | | - $lang = ($lang==='')? $this->deflang: $lang; |
225 | | - if (!array_key_exists($lang, $this->labels)) |
226 | | - $this->labels[$lang] = array(); |
227 | | - |
228 | | - if (array_key_exists($name, $this->labels[$lang])) return; |
229 | | - $this->labels[$lang][$name] = SWBCreatePage::getLabel($name, $lang); |
230 | | - } |
231 | | - |
232 | | - function isKnown($property, $object, $objecttype, $source) { |
233 | | - if (!array_key_exists($property, $this->mappings)) return false; |
234 | | - if (!array_key_exists($this->mappings[$property], $this->facts)) return false; |
235 | | - $literal = ($objecttype === 'literal'); |
236 | | - if ($literal) { |
237 | | - if (!array_key_exists($object, $this->facts[$this->mappings[$property]])) return false; |
238 | | - $sources = $this->facts[$this->mappings[$property]][$object]; |
239 | | - } else { |
240 | | - if (!array_key_exists($object, $this->mappings)) return false; |
241 | | - if (!array_key_exists($this->mappings[$object], $this->facts[$this->mappings[$property]])) return false; |
242 | | - $sources = $this->facts[$this->mappings[$property]][$this->mappings[$object]]; |
243 | | - } |
244 | | - return in_array($source, $sources); |
245 | | - } |
246 | | - |
247 | | - /** |
248 | | - * Deals with the #property parser function, i.e. by creating the text for |
249 | | - * the factbox (within the Parser object) and by adding the annotation |
250 | | - * link to the text. Will be called by the parser. |
251 | | - * |
252 | | - * @param $parser |
253 | | - * @return replacement text for the parserfunction |
254 | | - */ |
255 | | - static public function doProperty( &$parser ) { |
256 | | - $params = func_get_args(); |
257 | | - $prop = $params[1]; |
258 | | - |
259 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
260 | | - |
261 | | - $parser->lodpuller->lastproperty = $prop; |
262 | | - $parser->lodpuller->lastvalue = ''; |
263 | | - |
264 | | - return ''; |
265 | | - } |
266 | | - |
267 | | - /** |
268 | | - * Deals with the #value parser function, i.e. by creating the text for |
269 | | - * the factbox (within the Parser object) and by adding the annotation |
270 | | - * link to the text. Will be called by the parser. |
271 | | - * |
272 | | - * @param $parser |
273 | | - * @return replacement text for the parserfunction |
274 | | - */ |
275 | | - static public function doValue( &$parser ) { |
276 | | - $params = func_get_args(); |
277 | | - $val = $params[1]; |
278 | | - |
279 | | - if (!isset($parser->lodpuller)) return ''; |
280 | | - if ($parser->lodpuller->lastproperty === '') return ''; |
281 | | - |
282 | | - $prop = $parser->lodpuller->lastproperty; |
283 | | - $parser->lodpuller->lastvalue = $val; |
284 | | - |
285 | | - $parser->lodpuller->addPropertyValue( $prop, $val ); |
286 | | - |
287 | | - if (SWBControlProperties::forbiddenProperty($prop)) return ''; |
288 | | - |
289 | | - $text = "[[$prop::$val| ]]"; |
290 | | - return $text; |
291 | | - } |
292 | | - |
293 | | - /** |
294 | | - * Deals with the #source parser function. Currently nothing happens to the |
295 | | - * source, but it is at least saved. Eventually, the source should be |
296 | | - * exported. // TODO implement saving and exporting the source. somehow :P |
297 | | - * |
298 | | - * @param $parser |
299 | | - * @return replacement text for the parserfunction |
300 | | - */ |
301 | | - static public function doSource( &$parser ) { |
302 | | - $params = func_get_args(); |
303 | | - $source = $params[1]; |
304 | | - |
305 | | - if (!isset($parser->lodpuller)) return ""; |
306 | | - if ($parser->lodpuller->lastproperty === "") return ""; |
307 | | - if ($parser->lodpuller->lastvalue === "") return ""; |
308 | | - |
309 | | - $parser->lodpuller->addSource( $parser->lodpuller->lastproperty, $parser->lodpuller->lastvalue, $source ); |
310 | | - |
311 | | - return ""; |
312 | | - } |
313 | | - |
314 | | - static public function doMapping( &$parser ) { |
315 | | - $params = func_get_args(); |
316 | | - $uri = $params[1]; |
317 | | - |
318 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
319 | | - |
320 | | - $parser->lodpuller->addMapping( $uri ); |
321 | | - |
322 | | - $text = "[[Equivalent URI::$uri| ]]"; |
323 | | - return $text; |
324 | | - } |
325 | | - |
326 | | - static public function doDifferent( &$parser ) { |
327 | | - $params = func_get_args(); |
328 | | - $uri = $params[1]; |
329 | | - |
330 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
331 | | - |
332 | | - $parser->lodpuller->addDifferent( $uri ); |
333 | | - |
334 | | - $text = "[[Different from::$uri| ]]"; |
335 | | - return $text; |
336 | | - } |
337 | | - |
338 | | - static public function doLabel ( &$parser ) { |
339 | | - $params = func_get_args(); |
340 | | - $lang = $params[1]; |
341 | | - $content = $params[2]; |
342 | | - |
343 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
344 | | - |
345 | | - $parser->lodpuller->addLabel( $parser->getTitle()->getPrefixedText(), $content, $lang ); |
346 | | - |
347 | | - $text = "[[Label::$content;$lang| ]][[Alias::$content;$lang| ]]"; |
348 | | - return $text; |
349 | | - } |
350 | | - |
351 | | - static public function doAlias ( &$parser ) { |
352 | | - $params = func_get_args(); |
353 | | - $lang = $params[1]; |
354 | | - $content = $params[2]; |
355 | | - |
356 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
357 | | - |
358 | | - $parser->lodpuller->addAlias( $parser->getTitle()->getPrefixedText(), $content, $lang ); |
359 | | - |
360 | | - $text = "[[Alias::$content;$lang| ]]"; |
361 | | - return $text; |
362 | | - } |
363 | | - |
364 | | - static public function doDescription ( &$parser ) { |
365 | | - $params = func_get_args(); |
366 | | - $lang = $params[1]; |
367 | | - $content = $params[2]; |
368 | | - |
369 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
370 | | - |
371 | | - $parser->lodpuller->addDescription( $parser->getTitle()->getPrefixedText(), $content, $lang ); |
372 | | - |
373 | | - $text = "[[Description::$content;$lang| ]]"; |
374 | | - return $text; |
375 | | - } |
376 | | - |
377 | | - static public function doWikipedia ( &$parser ) { |
378 | | - $params = func_get_args(); |
379 | | - $lang = $params[1]; |
380 | | - $content = $params[2]; |
381 | | - |
382 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
383 | | - |
384 | | - $parser->lodpuller->addWikipedia( $parser->getTitle()->getPrefixedText(), $content, $lang ); |
385 | | - |
386 | | - $text = "[[Wikipedia::$content;$lang| ]]"; |
387 | | - return $text; |
388 | | - } |
389 | | - |
390 | | - static public function doType( &$parser ) { |
391 | | - $params = func_get_args(); |
392 | | - $content = $params[1]; |
393 | | - |
394 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
395 | | - |
396 | | - $parser->lodpuller->addType( $content ); |
397 | | - |
398 | | - $text = "[[Has type::$content| ]]"; |
399 | | - return $text; |
400 | | - } |
401 | | - |
402 | | - static public function doLink( &$parser ) { |
403 | | - $params = func_get_args(); |
404 | | - $content = $params[1]; |
405 | | - |
406 | | - if (!isset($parser->lodpuller)) $parser->lodpuller = new SWBControlProperties( $parser ); |
407 | | - |
408 | | - $parser->lodpuller->addLink( $content ); |
409 | | - |
410 | | - $text = "[[Link::$content| ]]"; |
411 | | - return $text; |
412 | | - } |
413 | | - |
414 | | - public function getWikiText() { |
415 | | - $retval = ''; |
416 | | - $labels = $this->removeEmpty($this->labels); |
417 | | - foreach($this->labels as $lang => $labels) { |
418 | | - if (array_key_exists($this->title, $labels)) { |
419 | | - $label = $labels[$this->title]; |
420 | | - if ($label) |
421 | | - $retval .= "{{#label:$lang|$label}}"; |
422 | | - } |
423 | | - } |
424 | | - foreach($this->aliases as $lang => $aliases) { |
425 | | - foreach($aliases as $alias) { |
426 | | - $retval .= "{{#alias:$lang|$alias}}"; |
427 | | - } |
428 | | - } |
429 | | - foreach($this->descriptions as $lang => $descriptions) { |
430 | | - if (array_key_exists($this->title, $descriptions)) { |
431 | | - $description = $descriptions[$this->title]; |
432 | | - if ($description) |
433 | | - $retval .= "{{#description:$lang|$description}}"; |
434 | | - } |
435 | | - } |
436 | | - foreach($this->wikipedias as $lang => $wikipedia) { |
437 | | - if ($wikipedia) |
438 | | - $retval .= "{{#wikipedia:$lang|$wikipedia}}"; |
439 | | - } |
440 | | - foreach($this->mappings as $uri => $mapping) { |
441 | | - $retval .= "{{#mapping:$uri}}"; |
442 | | - } |
443 | | - foreach($this->different as $uri) { |
444 | | - $retval .= "{{#different:$uri}}"; |
445 | | - } |
446 | | - foreach($this->facts as $property => $values) { |
447 | | - $retval .= "{{#property:$property}}"; |
448 | | - foreach($values as $value => $sources) { |
449 | | - $retval .="{{#value:$value}}"; |
450 | | - foreach ($sources as $source) { |
451 | | - $retval .= "{{#source:$source}}"; |
452 | | - } |
453 | | - } |
454 | | - } |
455 | | - if ($this->type) { |
456 | | - $retval .= "{{#type:$this->type}}"; |
457 | | - } |
458 | | - foreach($this->links as $link) { |
459 | | - $retval .= "{{#link:$link}}"; |
460 | | - } |
461 | | - return $retval; |
462 | | - } |
463 | | - |
464 | | - private function removeEmpty($arr) { |
465 | | - $result = array(); |
466 | | - foreach($arr as $index => $value) |
467 | | - if ($value !== null) $result[$index] = $value; |
468 | | - return $result; |
469 | | - } |
470 | | - |
471 | | - public function getResultObject( $lang = '' ) { |
472 | | - if ($lang === '') { |
473 | | - global $wgLang; |
474 | | - $lang = $wgLang->getCode(); |
475 | | - } |
476 | | - $stuff = array(); |
477 | | - //$stuff['facts'] = $this->facts; |
478 | | - $facts = array(); |
479 | | - global $wgUser, $wgScriptPath, $wgServer; |
480 | | - $skin = $wgUser->getSkin(); |
481 | | - |
482 | | - foreach ($this->facts as $property => $valsource) { |
483 | | - foreach ($valsource as $value => $sources) { |
484 | | - $fact = array(); |
485 | | - $fact['property'] = $property; |
486 | | - $propertyObj = SMWPropertyValue::makeUserProperty( $property ); |
487 | | - $typesvalue = $propertyObj->getTypesValue(); |
488 | | - $literal = ($typesvalue->getWikiValue() !== 'Page'); |
489 | | - $fact['propertytype'] = $typesvalue->getWikiValue(); |
490 | | - $propertylabel = SWBCreatePage::getLabel($property, $lang); |
491 | | - $fact['propertylabel'] = $propertylabel ? $propertylabel : $property; |
492 | | - $fact['value'] = $value; |
493 | | - $fact['valuetype'] = $literal ? 'literal' : 'entity'; |
494 | | - if ($literal) { |
495 | | - $valuelabel = $value; |
496 | | - } else { |
497 | | - $valuelabel = SWBCreatePage::getLabel($value, $lang); |
498 | | - if ($valuelabel == '') $valuelabel = 'Topic:' . $value; |
499 | | - } |
500 | | - $fact['valuelabel'] = $valuelabel; |
501 | | - $valueObj = SMWDataValueFactory::newPropertyObjectValue( $propertyObj, $value, $valuelabel ); |
502 | | - $long = $valueObj->getShortHTMLText( $skin ); |
503 | | - $short = $valueObj->getLongHTMLText( $skin ); |
504 | | - if ($literal) { |
505 | | - $valueliteral = (($typesvalue->getWikiValue() == 'Number') && (is_string($short))) ? $short : $long; |
506 | | - } else { |
507 | | - $valueliteral = ( "<a href=\"$wgServer$wgScriptPath/topic/$lang/$value\" class=\"lodlink\">$valuelabel</a>" ); |
508 | | - } |
509 | | - |
510 | | - $fact['valueliteral'] = $valueliteral; |
511 | | - //$fact['valueliterallong'] = $long; |
512 | | - //$fact['valueliteralshort'] = $short; |
513 | | - $fact['sources'] = $sources; |
514 | | - $facts[] = $fact; |
515 | | - } |
516 | | - } |
517 | | - $stuff['facts'] = $facts; |
518 | | - $stuff['mappings'] = $this->mappings; |
519 | | - if ($lang == '') $lang = $this->deflang; |
520 | | - |
521 | | - // get the label for all entities in the requested language |
522 | | - $stuff['labels'] = array_key_exists($lang, $this->labels) ? $this->removeEmpty($this->labels[$lang]) : null; |
523 | | - $stuff['aliases'] = $this->aliases; |
524 | | - $stuff['links'] = $this->links; |
525 | | - $stuff['thistype'] = $this->type; |
526 | | - |
527 | | - // get the label for the main entity in all languages |
528 | | - $stuff['thislabel'] = array(); |
529 | | - foreach($this->labels as $l => $a) |
530 | | - if (array_key_exists($this->title, $a)) |
531 | | - $stuff['thislabel'][$l] = $a[$this->title]; |
532 | | - |
533 | | - $stuff['descriptions'] = array_key_exists($lang, $this->descriptions) ? $this->descriptions[$lang] : null; |
534 | | - return $stuff; |
535 | | - } |
536 | | -} |
Index: trunk/extensions/SemanticWebBrowser/includes/datavalues/SWBResolvableUriValue.php |
— | — | @@ -8,10 +8,8 @@ |
9 | 9 | * This datavalue implements URL/URI/ANNURI/PHONE/EMAIL datavalues suitable for |
10 | 10 | * defining the respective types of properties. |
11 | 11 | * |
12 | | - * @author Nikolas Iwan |
13 | | - * @author Markus Krötzsch |
14 | | - * @ingroup SMWDataValues |
15 | | - * @bug Correctly create safe HTML and Wiki text. |
| 12 | + * @author Anna Kantorovitch |
| 13 | + * @author Benedikt Kämpgen |
16 | 14 | */ |
17 | 15 | class SWBResolvableUriValue extends SMWDataValue { |
18 | 16 | |
— | — | @@ -28,7 +26,8 @@ |
29 | 27 | private $m_mode; |
30 | 28 | |
31 | 29 | protected function parseUserValue( $value ) { |
32 | | - |
| 30 | + // echo "parseUserValue"; |
| 31 | + |
33 | 32 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
34 | 33 | $value = trim( $value ); |
35 | 34 | $this->m_wikitext = $value; |
— | — | @@ -85,7 +84,8 @@ |
86 | 85 | |
87 | 86 | // Now create the URI data item: |
88 | 87 | try { |
89 | | - $this->m_dataitem = new SMWDIUri( $scheme, $hierpart, $query, $fragment, $this->m_typeid); |
| 88 | + SWBSpecialBrowseWiki:: debug( $this->m_typeid, "typeid" ); |
| 89 | + $this->m_dataitem = new SMWDIUri( $scheme, $hierpart, $query, $fragment, $this->m_typeid ); |
90 | 90 | } catch ( SMWDataItemException $e ) { |
91 | 91 | $this->addError( wfMsgForContent( 'smw_baduri', $this->m_wikitext ) ); |
92 | 92 | $this->m_dataitem = new SMWDIUri( 'http', '//example.com', '', '', $this->m_typeid ); // define data item to have some value |
— | — | @@ -108,7 +108,7 @@ |
109 | 109 | * @return boolean |
110 | 110 | */ |
111 | 111 | protected function loadDataItem( SMWDataItem $dataItem ) { |
112 | | - echo "loadItem"; |
| 112 | + SWBSpecialBrowseWiki:: debug( "loadItem" ); |
113 | 113 | if ( $dataItem->getDIType() == SMWDataItem::TYPE_URI ) { |
114 | 114 | $this->m_dataitem = $dataItem; |
115 | 115 | if ( $this->m_mode == SMW_URI_MODE_EMAIL ) { |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | } |
128 | 128 | |
129 | 129 | public function getShortWikiText( $linked = null ) { |
130 | | - echo "shortWiki"; |
| 130 | + SWBSpecialBrowseWiki:: debug( "shortWiki" ); |
131 | 131 | $url = $this->getURL(); |
132 | 132 | if ( ( $linked === null ) || ( $linked === false ) || ( $this->m_outformat == '-' ) || ( $url == '' ) || ( $this->m_caption == '' ) ) { |
133 | 133 | return $this->m_caption; |
— | — | @@ -136,7 +136,7 @@ |
137 | 137 | } |
138 | 138 | |
139 | 139 | public function getShortHTMLText( $linker = null ) { |
140 | | - echo "shortHTML"; |
| 140 | + SWBSpecialBrowseWiki:: debug( "shortHTML" ); |
141 | 141 | $url = $this->getURL(); |
142 | 142 | if ( ( $linker === null ) || ( !$this->isValid() ) || ( $this->m_outformat == '-' ) || ( $url == '' ) || ( $this->m_caption == '' ) ) { |
143 | 143 | return $this->m_caption; |
— | — | @@ -146,7 +146,7 @@ |
147 | 147 | } |
148 | 148 | |
149 | 149 | public function getLongWikiText( $linked = null ) { |
150 | | - echo "longWiki"; |
| 150 | + SWBSpecialBrowseWiki:: debug( "longWiki" ); |
151 | 151 | if ( !$this->isValid() ) { |
152 | 152 | return $this->getErrorText(); |
153 | 153 | } |
— | — | @@ -159,7 +159,7 @@ |
160 | 160 | } |
161 | 161 | |
162 | 162 | public function getLongHTMLText( $linker = null ) { |
163 | | - echo "longHTML"; |
| 163 | + SWBSpecialBrowseWiki:: debug( "longHTML" ); |
164 | 164 | if ( !$this->isValid() ) { |
165 | 165 | return $this->getErrorText(); |
166 | 166 | } |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | } |
178 | 178 | |
179 | 179 | public function getURI() { |
180 | | - echo "uri"; |
| 180 | + SWBSpecialBrowseWiki:: debug( "uri" ); |
181 | 181 | return $this->m_dataitem->getURI(); |
182 | 182 | } |
183 | 183 | |
— | — | @@ -193,7 +193,7 @@ |
194 | 194 | * @return string |
195 | 195 | */ |
196 | 196 | public function getURL() { |
197 | | - echo "getURL"; |
| 197 | + SWBSpecialBrowseWiki:: debug( "getURL" ); |
198 | 198 | global $wgUrlProtocols; |
199 | 199 | foreach ( $wgUrlProtocols as $prot ) { |
200 | 200 | if ( ( $prot == $this->m_dataitem->getScheme() . ':' ) || ( $prot == $this->m_dataitem->getScheme() . '://' ) ) { |
Index: trunk/extensions/SemanticWebBrowser/includes/SWB_Infolink.php |
— | — | @@ -1,30 +1,22 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * |
| 5 | + * |
6 | 6 | * @file SWB_Infolink |
7 | 7 | * @ingroup SWB |
8 | 8 | * @author Anna Kantorovitch and Benedikt Kämpgen |
9 | 9 | * |
10 | 10 | */ |
11 | 11 | class SWBInfolink extends SMWInfolink { |
12 | | - |
| 12 | + |
13 | 13 | public function __construct( $internal, $caption, $target, $style = false, array $params = array() ) { |
14 | | - parent::__construct($internal, $caption, $target, $style, $params); |
| 14 | + parent::__construct( $internal, $caption, $target, $style, $params ); |
15 | 15 | } |
16 | | - |
17 | | - /** |
18 | | - * Static function to construct links to the browsing special. |
19 | | - * |
20 | | - * @param string $caption The label for the link. |
21 | | - * @param string $titleText |
22 | | - * @param mixed $style CSS class of a span to embedd the link into, or false if no extra style is required. |
23 | | - * |
24 | | - * @return SMWInfolink |
25 | | - */ |
| 16 | + |
26 | 17 | public static function newBrowsingLink( $caption, $titleText, $style = 'smwbrowse' ) { |
27 | 18 | global $wgContLang; |
28 | | - return new SMWInfolink( |
| 19 | + |
| 20 | + return new SWBInfolink( |
29 | 21 | true, |
30 | 22 | $caption, |
31 | 23 | $wgContLang->getNsText( NS_SPECIAL ) . ':BrowseWiki', |
— | — | @@ -32,25 +24,8 @@ |
33 | 25 | array( $titleText ) |
34 | 26 | ); |
35 | 27 | } |
36 | | - |
37 | | - /** |
38 | | - * |
39 | | - * Link for toolbox |
40 | | - * @param unknown_type $caption |
41 | | - * @param unknown_type $titleText |
42 | | - * @param unknown_type $style |
43 | | - */ |
44 | | - public static function newBrowsingSemWeb( $caption, $titleText, $style = 'swbbrowse' ) { |
45 | | - global $wgContLang; |
46 | | - return new SMWInfolink( |
47 | | - true, |
48 | | - $caption, |
49 | | - $wgContLang->getNsText( NS_SPECIAL ) . ':BrowseWiki', |
50 | | - $style, |
51 | | - array( $titleText ) |
52 | | - ); |
53 | | - } |
54 | | -} |
55 | 28 | |
56 | 29 | |
| 30 | +} |
57 | 31 | |
| 32 | + |
Index: trunk/extensions/SemanticWebBrowser/lib/Graphite.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | # SimpleGraph - http://code.google.com/p/moriarty/wiki/SimpleGraph |
15 | 15 | # |
16 | 16 | # I've used function calls in common with EasyRDF, where it makes sense |
17 | | -# to do so. Easy RDF now uses our dump() style. We're one big happy linked |
| 17 | +# to do so. Easy RDF now uses our dump() style. We're one big happy linked |
18 | 18 | # data community! |
19 | 19 | |
20 | 20 | # todo: |
— | — | @@ -27,8 +27,8 @@ |
28 | 28 | { |
29 | 29 | public function __construct( $namespaces = array(), $uri = null ) |
30 | 30 | { |
31 | | - $this->t = array( "sp" => array(), "op"=>array() ); |
32 | | - foreach( $namespaces as $short=>$long ) |
| 31 | + $this->t = array( "sp" => array(), "op" => array() ); |
| 32 | + foreach ( $namespaces as $short => $long ) |
33 | 33 | { |
34 | 34 | $this->ns( $short, $long ); |
35 | 35 | } |
— | — | @@ -48,20 +48,20 @@ |
49 | 49 | $this->debug = false; |
50 | 50 | |
51 | 51 | $this->firstGraphURI = null; |
52 | | - if( $uri ) |
53 | | - { |
| 52 | + if ( $uri ) |
| 53 | + { |
54 | 54 | $this->forceString( $uri ); |
55 | | - $this->load( $uri ); |
| 55 | + $this->load( $uri ); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | | - public function cacheDir( $dir, $age = 86400 ) # default age is 24 hours |
| 59 | + public function cacheDir( $dir, $age = 86400 ) # default age is 24 hours |
60 | 60 | { |
61 | 61 | $error = ""; |
62 | | - if( !file_exists( $dir ) ) { $error = "No such directory: $dir"; } |
63 | | - elseif( !is_dir( $dir ) ) { $error = "Not a directory: $dir"; } |
64 | | - elseif( !is_writable( $dir ) ) { $error = "Not writable: $dir"; } |
65 | | - if( $error ) { |
| 62 | + if ( !file_exists( $dir ) ) { $error = "No such directory: $dir"; } |
| 63 | + elseif ( !is_dir( $dir ) ) { $error = "Not a directory: $dir"; } |
| 64 | + elseif ( !is_writable( $dir ) ) { $error = "Not writable: $dir"; } |
| 65 | + if ( $error ) { |
66 | 66 | print "<ul><li>Graphite cacheDir error: $error</li></ul>"; |
67 | 67 | } |
68 | 68 | else |
— | — | @@ -78,86 +78,86 @@ |
79 | 79 | $this->forceString( $uri ); |
80 | 80 | $uri = $this->expandURI( $uri ); |
81 | 81 | |
82 | | - if( substr( $uri,0,5 ) == "data:" ) |
| 82 | + if ( substr( $uri, 0, 5 ) == "data:" ) |
83 | 83 | { |
84 | | - $data = urldecode( preg_replace( "/^data:[^,]*,/","", $uri ) ); |
| 84 | + $data = urldecode( preg_replace( "/^data:[^,]*,/", "", $uri ) ); |
85 | 85 | $parser = ARC2::getTurtleParser(); |
86 | 86 | $parser->parse( $uri, $data ); |
87 | 87 | } |
88 | 88 | else |
89 | 89 | { |
90 | | - if( isset($this->loaded[$uri]) ) { return $this->loaded[$uri]; } |
91 | | - if( isset($this->cacheDir) ) |
| 90 | + if ( isset( $this->loaded[$uri] ) ) { return $this->loaded[$uri]; } |
| 91 | + if ( isset( $this->cacheDir ) ) |
92 | 92 | { |
93 | | - $filename = $this->cacheDir."/".md5($uri); |
| 93 | + $filename = $this->cacheDir . "/" . md5( $uri ); |
94 | 94 | |
95 | | - if( !file_exists( $filename ) || filemtime($filename)+$this->cacheAge < time() ) |
| 95 | + if ( !file_exists( $filename ) || filemtime( $filename ) + $this->cacheAge < time() ) |
96 | 96 | { |
97 | 97 | # decache if out of date, even if we fail to re cache. |
98 | | - if( file_exists( $filename ) ) { unlink( $filename ); } |
| 98 | + if ( file_exists( $filename ) ) { unlink( $filename ); } |
99 | 99 | $url = $uri; |
100 | 100 | $ttl = 16; |
101 | 101 | $mime = ""; |
102 | | - $old_user_agent = ini_get('user_agent'); |
103 | | - ini_set('user_agent', "PHP\r\nAccept: application/rdf+xml"); |
104 | | - while( $ttl > 0 ) |
| 102 | + $old_user_agent = ini_get( 'user_agent' ); |
| 103 | + ini_set( 'user_agent', "PHP\r\nAccept: application/rdf+xml" ); |
| 104 | + while ( $ttl > 0 ) |
105 | 105 | { |
106 | 106 | # dirty hack to set the accept header without using curl |
107 | | - if( !$rdf_fp = fopen($url, 'r') ) { break; } |
108 | | - $meta_data = stream_get_meta_data($rdf_fp); |
| 107 | + if ( !$rdf_fp = fopen( $url, 'r' ) ) { break; } |
| 108 | + $meta_data = stream_get_meta_data( $rdf_fp ); |
109 | 109 | $redir = 0; |
110 | | - foreach($meta_data['wrapper_data'] as $response) |
| 110 | + foreach ( $meta_data['wrapper_data'] as $response ) |
111 | 111 | { |
112 | | - if (substr(strtolower($response), 0, 10) == 'location: ') |
| 112 | + if ( substr( strtolower( $response ), 0, 10 ) == 'location: ' ) |
113 | 113 | { |
114 | | - $newurl = substr($response, 10); |
115 | | - if( substr( $newurl, 0, 1 ) == "/" ) |
116 | | - { |
117 | | - $parts = preg_split( "/\//",$url ); |
118 | | - $newurl = $parts[0]."//".$parts[2].$newurl; |
| 114 | + $newurl = substr( $response, 10 ); |
| 115 | + if ( substr( $newurl, 0, 1 ) == "/" ) |
| 116 | + { |
| 117 | + $parts = preg_split( "/\//", $url ); |
| 118 | + $newurl = $parts[0] . "//" . $parts[2] . $newurl; |
119 | 119 | } |
120 | 120 | $url = $newurl; |
121 | 121 | $redir = 1; |
122 | 122 | } |
123 | | - if (substr(strtolower($response), 0, 14) == 'content-type: ') |
| 123 | + if ( substr( strtolower( $response ), 0, 14 ) == 'content-type: ' ) |
124 | 124 | { |
125 | | - $mime = preg_replace( "/\s*;.*$/","", substr($response, 14)); |
| 125 | + $mime = preg_replace( "/\s*;.*$/", "", substr( $response, 14 ) ); |
126 | 126 | } |
127 | 127 | } |
128 | | - if( !$redir ) { break; } |
| 128 | + if ( !$redir ) { break; } |
129 | 129 | $ttl--; |
130 | | - fclose($rdf_fp); |
| 130 | + fclose( $rdf_fp ); |
131 | 131 | } |
132 | | - ini_set('user_agent', $old_user_agent); |
133 | | - if( $ttl > 0 && $mime == "application/rdf+xml" && $rdf_fp ) |
| 132 | + ini_set( 'user_agent', $old_user_agent ); |
| 133 | + if ( $ttl > 0 && $mime == "application/rdf+xml" && $rdf_fp ) |
134 | 134 | { |
135 | 135 | # candidate for caching! |
136 | | - if (!$cache_fp = fopen($filename, 'w')) |
| 136 | + if ( !$cache_fp = fopen( $filename, 'w' ) ) |
137 | 137 | { |
138 | 138 | echo "Cannot write file ($filename)"; |
139 | 139 | exit; |
140 | 140 | } |
141 | | - |
142 | | - while (!feof($rdf_fp)) { |
143 | | - fwrite( $cache_fp, fread($rdf_fp, 8192) ); |
| 141 | + |
| 142 | + while ( !feof( $rdf_fp ) ) { |
| 143 | + fwrite( $cache_fp, fread( $rdf_fp, 8192 ) ); |
144 | 144 | } |
145 | | - fclose($cache_fp); |
| 145 | + fclose( $cache_fp ); |
146 | 146 | } |
147 | | - fclose($rdf_fp); |
| 147 | + fclose( $rdf_fp ); |
148 | 148 | } |
149 | | - |
| 149 | + |
150 | 150 | } |
151 | | - if( isset( $filename ) && file_exists( $filename ) ) |
| 151 | + if ( isset( $filename ) && file_exists( $filename ) ) |
152 | 152 | { |
153 | 153 | $parser = ARC2::getRDFXMLParser(); |
154 | 154 | $parser->parse( $filename ); |
155 | 155 | } |
156 | 156 | else |
157 | | - { |
| 157 | + { |
158 | 158 | $parser = ARC2::getRDFParser(); |
159 | 159 | # Don't try to load the same URI twice! |
160 | | - |
161 | | - if( !isset( $this->firstGraphURI ) ) |
| 160 | + |
| 161 | + if ( !isset( $this->firstGraphURI ) ) |
162 | 162 | { |
163 | 163 | $this->firstGraphURI = $uri; |
164 | 164 | } |
— | — | @@ -167,12 +167,12 @@ |
168 | 168 | |
169 | 169 | $errors = $parser->getErrors(); |
170 | 170 | $parser->resetErrors(); |
171 | | - if( sizeof($errors) ) |
| 171 | + if ( sizeof( $errors ) ) |
172 | 172 | { |
173 | | - if( $this->debug ) |
| 173 | + if ( $this->debug ) |
174 | 174 | { |
175 | 175 | print "<h3>Error loading: $uri</h3>"; |
176 | | - print "<ul><li>".join( "</li><li>",$errors)."</li></ul>"; |
| 176 | + print "<ul><li>" . join( "</li><li>", $errors ) . "</li></ul>"; |
177 | 177 | } |
178 | 178 | return 0; |
179 | 179 | } |
— | — | @@ -186,12 +186,12 @@ |
187 | 187 | $parser->parse( $base, $data ); |
188 | 188 | $errors = $parser->getErrors(); |
189 | 189 | $parser->resetErrors(); |
190 | | - if( sizeof($errors) ) |
| 190 | + if ( sizeof( $errors ) ) |
191 | 191 | { |
192 | | - if( $this->debug ) |
| 192 | + if ( $this->debug ) |
193 | 193 | { |
194 | 194 | print "<h3>Error loading: $uri</h3>"; |
195 | | - print "<ul><li>".join( "</li><li>",$errors)."</li></ul>"; |
| 195 | + print "<ul><li>" . join( "</li><li>", $errors ) . "</li></ul>"; |
196 | 196 | } |
197 | 197 | return 0; |
198 | 198 | } |
— | — | @@ -203,12 +203,12 @@ |
204 | 204 | $parser->parse( $base, $data ); |
205 | 205 | $errors = $parser->getErrors(); |
206 | 206 | $parser->resetErrors(); |
207 | | - if( sizeof($errors) ) |
| 207 | + if ( sizeof( $errors ) ) |
208 | 208 | { |
209 | | - if( $this->debug ) |
| 209 | + if ( $this->debug ) |
210 | 210 | { |
211 | 211 | print "<h3>Error loading: $uri</h3>"; |
212 | | - print "<ul><li>".join( "</li><li>",$errors)."</li></ul>"; |
| 212 | + print "<ul><li>" . join( "</li><li>", $errors ) . "</li></ul>"; |
213 | 213 | } |
214 | 214 | return 0; |
215 | 215 | } |
— | — | @@ -217,36 +217,36 @@ |
218 | 218 | |
219 | 219 | function addTriples( $triples ) |
220 | 220 | { |
221 | | -if( @$_GET["X"] ) |
| 221 | +if ( @$_GET["X"] ) |
222 | 222 | { |
223 | 223 | print "<pre>"; |
224 | 224 | print_r( $triples ); |
225 | 225 | print "</pre>"; |
226 | 226 | } |
227 | | - foreach( $triples as $t ) |
| 227 | + foreach ( $triples as $t ) |
228 | 228 | { |
229 | | - $t["s"] = $this->cleanURI($t["s"]); |
230 | | - if( !isset($map[$t["s"]]) ) { continue; } |
231 | | - $t["p"] = $this->cleanURI($t["p"]); |
232 | | - if( $t["p"] != "http://www.w3.org/2002/07/owl#sameAs" ) { continue; } |
| 229 | + $t["s"] = $this->cleanURI( $t["s"] ); |
| 230 | + if ( !isset( $map[$t["s"]] ) ) { continue; } |
| 231 | + $t["p"] = $this->cleanURI( $t["p"] ); |
| 232 | + if ( $t["p"] != "http://www.w3.org/2002/07/owl#sameAs" ) { continue; } |
233 | 233 | $aliases[$t["o"]] = $t["s"]; |
234 | 234 | } |
235 | | - foreach( $triples as $t ) |
| 235 | + foreach ( $triples as $t ) |
236 | 236 | { |
237 | | - $t["s"] = $this->cleanURI($t["s"]); |
238 | | - $t["p"] = $this->cleanURI($t["p"]); |
| 237 | + $t["s"] = $this->cleanURI( $t["s"] ); |
| 238 | + $t["p"] = $this->cleanURI( $t["p"] ); |
239 | 239 | $mod = 0; |
240 | | - if( isset($aliases[$t["s"]]) ) { $t["s"]=$aliases[$t["s"]]; } |
241 | | - if( isset($aliases[$t["p"]]) ) { $t["p"]=$aliases[$t["p"]]; } |
242 | | - if( isset($aliases[$t["o"]]) ) { $t["o"]=$aliases[$t["o"]]; } |
| 240 | + if ( isset( $aliases[$t["s"]] ) ) { $t["s"] = $aliases[$t["s"]]; } |
| 241 | + if ( isset( $aliases[$t["p"]] ) ) { $t["p"] = $aliases[$t["p"]]; } |
| 242 | + if ( isset( $aliases[$t["o"]] ) ) { $t["o"] = $aliases[$t["o"]]; } |
243 | 243 | // if( $mod ) |
244 | 244 | // { |
245 | | - if( $t["o_type"]=="literal" ) |
| 245 | + if ( $t["o_type"] == "literal" ) |
246 | 246 | { |
247 | 247 | $this->t["sp"][$t["s"]][$t["p"]][] = array( |
248 | | - "v"=>$t["o"], |
249 | | - "d"=>$t["o_datatype"], |
250 | | - "l"=>$t["o_lang"] ); |
| 248 | + "v" => $t["o"], |
| 249 | + "d" => $t["o_datatype"], |
| 250 | + "l" => $t["o_lang"] ); |
251 | 251 | } |
252 | 252 | else |
253 | 253 | { |
— | — | @@ -261,16 +261,16 @@ |
262 | 262 | } |
263 | 263 | |
264 | 264 | |
265 | | - public function cleanURI( $uri ) |
| 265 | + public function cleanURI( $uri ) |
266 | 266 | { |
267 | | - if( !$uri ) { return; } |
268 | | - return preg_replace( '/^(https?:\/\/[^:\/]+):80\//','$1/', $uri ); |
| 267 | + if ( !$uri ) { return; } |
| 268 | + return preg_replace( '/^(https?:\/\/[^:\/]+):80\//', '$1/', $uri ); |
269 | 269 | } |
270 | 270 | |
271 | 271 | public function primaryTopic( $uri = null ) |
272 | 272 | { |
273 | | - if( !$uri ) { $uri = $this->firstGraphURI; } |
274 | | - if( !$uri ) { return new Graphite_Null($this->g); } |
| 273 | + if ( !$uri ) { $uri = $this->firstGraphURI; } |
| 274 | + if ( !$uri ) { return new Graphite_Null( $this->g ); } |
275 | 275 | $this->forceString( $uri ); |
276 | 276 | |
277 | 277 | return $this->resource( $uri )->get( "foaf:primaryTopic", "-foaf:isPrimaryTopicOf" ); |
— | — | @@ -278,7 +278,7 @@ |
279 | 279 | |
280 | 280 | public function ns( $short, $long ) |
281 | 281 | { |
282 | | - if( preg_match( '/^(urn|doi|http|https|ftp|mailto|xmlns|file|data)$/', $short ) ) |
| 282 | + if ( preg_match( '/^(urn|doi|http|https|ftp|mailto|xmlns|file|data)$/', $short ) ) |
283 | 283 | { |
284 | 284 | print "<ul><li>Setting a namespace called '$short' is just asking for trouble. Abort.</li></ul>"; |
285 | 285 | exit; |
— | — | @@ -295,18 +295,18 @@ |
296 | 296 | |
297 | 297 | public function allOfType( $uri ) |
298 | 298 | { |
299 | | - return $this->resource( $uri )->all("-rdf:type"); |
| 299 | + return $this->resource( $uri )->all( "-rdf:type" ); |
300 | 300 | } |
301 | 301 | |
302 | 302 | public function shrinkURI( $uri ) |
303 | 303 | { |
304 | 304 | $this->forceString( $uri ); |
305 | | - if( $uri == "" ) { return "* This Document *"; } |
306 | | - foreach( $this->ns as $short=>$long ) |
| 305 | + if ( $uri == "" ) { return "* This Document *"; } |
| 306 | + foreach ( $this->ns as $short => $long ) |
307 | 307 | { |
308 | | - if( substr( $uri, 0, strlen($long) ) == $long ) |
| 308 | + if ( substr( $uri, 0, strlen( $long ) ) == $long ) |
309 | 309 | { |
310 | | - return $short.":".substr( $uri, strlen($long )); |
| 310 | + return $short . ":" . substr( $uri, strlen( $long ) ); |
311 | 311 | } |
312 | 312 | } |
313 | 313 | return $uri; |
— | — | @@ -315,12 +315,12 @@ |
316 | 316 | public function expandURI( $uri ) |
317 | 317 | { |
318 | 318 | $this->forceString( $uri ); |
319 | | - if( preg_match( '/:/', $uri ) ) |
| 319 | + if ( preg_match( '/:/', $uri ) ) |
320 | 320 | { |
321 | 321 | list( $ns, $tag ) = preg_split( "/:/", $uri, 2 ); |
322 | | - if( isset($this->ns[$ns]) ) |
| 322 | + if ( isset( $this->ns[$ns] ) ) |
323 | 323 | { |
324 | | - return $this->ns[$ns].$tag; |
| 324 | + return $this->ns[$ns] . $tag; |
325 | 325 | } |
326 | 326 | } |
327 | 327 | return $uri; |
— | — | @@ -330,7 +330,7 @@ |
331 | 331 | public function allSubjects() |
332 | 332 | { |
333 | 333 | $r = new Graphite_ResourceList( $this ); |
334 | | - foreach( $this->t["sp"] as $subject_uri=>$foo ) |
| 334 | + foreach ( $this->t["sp"] as $subject_uri => $foo ) |
335 | 335 | { |
336 | 336 | $r[] = new Graphite_Resource( $this, $subject_uri ); |
337 | 337 | } |
— | — | @@ -340,27 +340,27 @@ |
341 | 341 | public function allObjects() |
342 | 342 | { |
343 | 343 | $r = new Graphite_ResourceList( $this ); |
344 | | - foreach( $this->t["op"] as $object_uri=>$foo ) |
| 344 | + foreach ( $this->t["op"] as $object_uri => $foo ) |
345 | 345 | { |
346 | 346 | $r[] = new Graphite_Resource( $this, $object_uri ); |
347 | 347 | } |
348 | 348 | return $r; |
349 | 349 | } |
350 | | - |
351 | | - public function dump($options=array()) |
| 350 | + |
| 351 | + public function dump( $options = array() ) |
352 | 352 | { |
353 | 353 | $r = array(); |
354 | | - foreach( $this->t["sp"] as $subject_uri=>$foo ) |
| 354 | + foreach ( $this->t["sp"] as $subject_uri => $foo ) |
355 | 355 | { |
356 | 356 | $subject = new Graphite_Resource( $this, $subject_uri ); |
357 | | - $r []= $subject->dump($options); |
| 357 | + $r [] = $subject->dump( $options ); |
358 | 358 | } |
359 | | - return join("",$r ); |
| 359 | + return join( "", $r ); |
360 | 360 | } |
361 | 361 | |
362 | 362 | public function forceString( &$uri ) |
363 | 363 | { |
364 | | - if( is_object( $uri ) ) { $uri = $uri->toString(); } |
| 364 | + if ( is_object( $uri ) ) { $uri = $uri->toString(); } |
365 | 365 | return $uri; |
366 | 366 | } |
367 | 367 | } |
— | — | @@ -372,18 +372,18 @@ |
373 | 373 | $this->g = $g; |
374 | 374 | } |
375 | 375 | function has() { return false; } |
376 | | - function get() { return new Graphite_Null($this->g); } |
377 | | - function type() { return new Graphite_Null($this->g); } |
| 376 | + function get() { return new Graphite_Null( $this->g ); } |
| 377 | + function type() { return new Graphite_Null( $this->g ); } |
378 | 378 | function label() { return "[UNKNOWN]"; } |
379 | 379 | function hasLabel() { return false; } |
380 | | - function all() { return new Graphite_ResourceList($this->g, array()); } |
| 380 | + function all() { return new Graphite_ResourceList( $this->g, array() ); } |
381 | 381 | function types() { return $this->all(); } |
382 | 382 | function relations() { return $this->all(); } |
383 | 383 | function load() { return 0; } |
384 | 384 | function loadSameAs() { return 0; } |
385 | | - function loadSameAsOrg($prefix) { return 0; } |
| 385 | + function loadSameAsOrg( $prefix ) { return 0; } |
386 | 386 | function loadDataGovUKBackLinks() { return 0; } |
387 | | - |
| 387 | + |
388 | 388 | function dumpText() { return "Non existant Node"; } |
389 | 389 | function dump() { return "<div style='padding:0.5em; background-color:lightgrey;border:dashed 1px grey;'>Non-existant Node</div>"; } |
390 | 390 | function nodeType() { return "#node"; } |
— | — | @@ -392,9 +392,9 @@ |
393 | 393 | |
394 | 394 | protected function parsePropertyArg( $arg ) |
395 | 395 | { |
396 | | - if( is_a( $arg, "Graphite_Resource" ) ) |
| 396 | + if ( is_a( $arg, "Graphite_Resource" ) ) |
397 | 397 | { |
398 | | - if( is_a( $arg, "Graphite_InverseRelation" ) ) |
| 398 | + if ( is_a( $arg, "Graphite_InverseRelation" ) ) |
399 | 399 | { |
400 | 400 | $this->g->forceString( $arg ); |
401 | 401 | return array( "op", "$arg" ); |
— | — | @@ -404,10 +404,10 @@ |
405 | 405 | } |
406 | 406 | |
407 | 407 | $set = "sp"; |
408 | | - if( substr( $arg,0,1) == "-" ) |
| 408 | + if ( substr( $arg, 0, 1 ) == "-" ) |
409 | 409 | { |
410 | 410 | $set = "op"; |
411 | | - $arg = substr($arg,1); |
| 411 | + $arg = substr( $arg, 1 ); |
412 | 412 | } |
413 | 413 | return array( $set, $this->g->expandURI( "$arg" ) ); |
414 | 414 | } |
— | — | @@ -427,53 +427,53 @@ |
428 | 428 | |
429 | 429 | function __toString() { return $this->triple["v"]; } |
430 | 430 | |
431 | | - function dumpValueText() |
| 431 | + function dumpValueText() |
432 | 432 | { |
433 | | - $r = '"'.$v.'"'; |
434 | | - if( isset($this->triple["l"]) && $this->triple["l"]) |
435 | | - { |
436 | | - $r.="@".$this->triple["l"]; |
| 433 | + $r = '"' . $v . '"'; |
| 434 | + if ( isset( $this->triple["l"] ) && $this->triple["l"] ) |
| 435 | + { |
| 436 | + $r .= "@" . $this->triple["l"]; |
437 | 437 | } |
438 | | - if( isset($this->triple["t"]) ) |
439 | | - { |
440 | | - $r.="^^".$this->g->shrinkURI($this->triple["t"]); |
| 438 | + if ( isset( $this->triple["t"] ) ) |
| 439 | + { |
| 440 | + $r .= "^^" . $this->g->shrinkURI( $this->triple["t"] ); |
441 | 441 | } |
442 | 442 | return $r; |
443 | 443 | } |
444 | 444 | |
445 | | - function dumpValueHTML() |
| 445 | + function dumpValueHTML() |
446 | 446 | { |
447 | | - $v = htmlspecialchars( $this->triple["v"],ENT_COMPAT,"UTF-8" ); |
448 | | - |
| 447 | + $v = htmlspecialchars( $this->triple["v"], ENT_COMPAT, "UTF-8" ); |
| 448 | + |
449 | 449 | $v = preg_replace( "/\t/", "<span class='special_char' style='font-size:70%'>[tab]</span>", $v ); |
450 | 450 | $v = preg_replace( "/\n/", "<span class='special_char' style='font-size:70%'>[nl]</span><br />", $v ); |
451 | 451 | $v = preg_replace( "/\r/", "<span class='special_char' style='font-size:70%'>[cr]</span>", $v ); |
452 | 452 | $v = preg_replace( "/ +/e", "\"<span class='special_char' style='font-size:70%'>\".str_repeat(\"␣\",strlen(\"$0\")).\"</span>\"", $v ); |
453 | | - $r = '"'.$v.'"'; |
454 | | - |
455 | | - if( isset($this->triple["l"]) && $this->triple["l"]) |
456 | | - { |
457 | | - $r.="@".$this->triple["l"]; |
| 453 | + $r = '"' . $v . '"'; |
| 454 | + |
| 455 | + if ( isset( $this->triple["l"] ) && $this->triple["l"] ) |
| 456 | + { |
| 457 | + $r .= "@" . $this->triple["l"]; |
458 | 458 | } |
459 | | - if( isset($this->triple["t"]) ) |
460 | | - { |
461 | | - $r.="^^".$this->g->shrinkURI($this->triple["t"]); |
| 459 | + if ( isset( $this->triple["t"] ) ) |
| 460 | + { |
| 461 | + $r .= "^^" . $this->g->shrinkURI( $this->triple["t"] ); |
462 | 462 | } |
463 | 463 | return $r; |
464 | 464 | } |
465 | 465 | |
466 | | - function nodeType() |
467 | | - { |
468 | | - if( isset($this->triple["d"]) ) |
469 | | - { |
| 466 | + function nodeType() |
| 467 | + { |
| 468 | + if ( isset( $this->triple["d"] ) ) |
| 469 | + { |
470 | 470 | return $this->triple["d"]; |
471 | | - } |
| 471 | + } |
472 | 472 | return "#literal"; |
473 | 473 | } |
474 | 474 | |
475 | | - function dumpValue() |
| 475 | + function dumpValue() |
476 | 476 | { |
477 | | - return "<span style='color:blue'>".$this->dumpValueHTML()."</span>"; |
| 477 | + return "<span style='color:blue'>" . $this->dumpValueHTML() . "</span>"; |
478 | 478 | } |
479 | 479 | } |
480 | 480 | |
— | — | @@ -489,36 +489,36 @@ |
490 | 490 | public function get( /* List */ ) |
491 | 491 | { |
492 | 492 | $args = func_get_args(); |
493 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
494 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 493 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 494 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
495 | 495 | |
496 | 496 | $l = $this->all( $args ); |
497 | | - if( sizeof( $l ) == 0 ) { return new Graphite_Null($this->g); } |
| 497 | + if ( sizeof( $l ) == 0 ) { return new Graphite_Null( $this->g ); } |
498 | 498 | return $l[0]; |
499 | 499 | } |
500 | 500 | |
501 | 501 | public function getString( /* List */ ) |
502 | 502 | { |
503 | 503 | $args = func_get_args(); |
504 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
505 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 504 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 505 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
506 | 506 | |
507 | 507 | $l = $this->all( $args ); |
508 | | - if( sizeof( $l ) == 0 ) { return; } |
| 508 | + if ( sizeof( $l ) == 0 ) { return; } |
509 | 509 | return $l[0]->toString(); |
510 | 510 | } |
511 | 511 | |
512 | 512 | public function has( /* List */ ) |
513 | 513 | { |
514 | 514 | $args = func_get_args(); |
515 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
516 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 515 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 516 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
517 | 517 | |
518 | | - foreach( $args as $arg ) |
| 518 | + foreach ( $args as $arg ) |
519 | 519 | { |
520 | 520 | list( $set, $relation_uri ) = $this->parsePropertyArg( $arg ); |
521 | | - if( isset($this->g->t[$set][$this->uri]) |
522 | | - && isset($this->g->t[$set][$this->uri][$relation_uri]) ) |
| 521 | + if ( isset( $this->g->t[$set][$this->uri] ) |
| 522 | + && isset( $this->g->t[$set][$this->uri][$relation_uri] ) ) |
523 | 523 | { |
524 | 524 | return true; |
525 | 525 | } |
— | — | @@ -529,54 +529,54 @@ |
530 | 530 | public function all( /* List */ ) |
531 | 531 | { |
532 | 532 | $args = func_get_args(); |
533 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
534 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 533 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 534 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
535 | 535 | $l = array(); |
536 | 536 | $done = array(); |
537 | | - foreach( $args as $arg ) |
| 537 | + foreach ( $args as $arg ) |
538 | 538 | { |
539 | 539 | list( $set, $relation_uri ) = $this->parsePropertyArg( $arg ); |
540 | | - if( !isset($this->g->t[$set][$this->uri]) |
541 | | - || !isset($this->g->t[$set][$this->uri][$relation_uri]) ) |
| 540 | + if ( !isset( $this->g->t[$set][$this->uri] ) |
| 541 | + || !isset( $this->g->t[$set][$this->uri][$relation_uri] ) ) |
542 | 542 | { |
543 | 543 | continue; |
544 | 544 | } |
545 | 545 | |
546 | | - foreach( $this->g->t[$set][$this->uri][$relation_uri] as $v ) |
| 546 | + foreach ( $this->g->t[$set][$this->uri][$relation_uri] as $v ) |
547 | 547 | { |
548 | | - if( is_array( $v ) ) |
| 548 | + if ( is_array( $v ) ) |
549 | 549 | { |
550 | | - $l []= new Graphite_Literal( $this->g, $v ); |
551 | | - } |
552 | | - else if( !isset($done[$v]) ) |
| 550 | + $l [] = new Graphite_Literal( $this->g, $v ); |
| 551 | + } |
| 552 | + else if ( !isset( $done[$v] ) ) |
553 | 553 | { |
554 | | - $l []= new Graphite_Resource( $this->g, $v ); |
| 554 | + $l [] = new Graphite_Resource( $this->g, $v ); |
555 | 555 | $done[$v] = 1; |
556 | 556 | } |
557 | 557 | } |
558 | 558 | } |
559 | | - return new Graphite_ResourceList($this->g,$l); |
| 559 | + return new Graphite_ResourceList( $this->g, $l ); |
560 | 560 | } |
561 | 561 | |
562 | 562 | public function relations() |
563 | 563 | { |
564 | 564 | $r = array(); |
565 | | - if( isset( $this->g->t["sp"][$this->uri] ) ) |
| 565 | + if ( isset( $this->g->t["sp"][$this->uri] ) ) |
566 | 566 | { |
567 | | - foreach( array_keys( $this->g->t["sp"][$this->uri] ) as $pred ) |
| 567 | + foreach ( array_keys( $this->g->t["sp"][$this->uri] ) as $pred ) |
568 | 568 | { |
569 | | - $r []= new Graphite_Relation( $this->g, $pred ); |
| 569 | + $r [] = new Graphite_Relation( $this->g, $pred ); |
570 | 570 | } |
571 | 571 | } |
572 | | - if( isset( $this->g->t["op"][$this->uri] ) ) |
| 572 | + if ( isset( $this->g->t["op"][$this->uri] ) ) |
573 | 573 | { |
574 | | - foreach( array_keys( $this->g->t["op"][$this->uri] ) as $pred ) |
| 574 | + foreach ( array_keys( $this->g->t["op"][$this->uri] ) as $pred ) |
575 | 575 | { |
576 | | - $r []= new Graphite_InverseRelation( $this->g, $pred ); |
| 576 | + $r [] = new Graphite_InverseRelation( $this->g, $pred ); |
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
580 | | - return new Graphite_ResourceList($this->g,$r); |
| 580 | + return new Graphite_ResourceList( $this->g, $r ); |
581 | 581 | } |
582 | 582 | |
583 | 583 | public function load() |
— | — | @@ -586,30 +586,30 @@ |
587 | 587 | |
588 | 588 | public function loadSameAsOrg( $prefix ) |
589 | 589 | { |
590 | | - $sameasorg_uri = "http://sameas.org/rdf?uri=".urlencode( $this->uri ); |
| 590 | + $sameasorg_uri = "http://sameas.org/rdf?uri=" . urlencode( $this->uri ); |
591 | 591 | $n = $this->g->load( $sameasorg_uri ); |
592 | | - $n+= $this->loadSameAs( $prefix ); |
| 592 | + $n += $this->loadSameAs( $prefix ); |
593 | 593 | return $n; |
594 | 594 | } |
595 | 595 | |
596 | | - function loadDataGovUKBackLinks() |
| 596 | + function loadDataGovUKBackLinks() |
597 | 597 | { |
598 | | - $backurl = "http://backlinks.psi.enakting.org/resource/rdf/".$this->uri; |
599 | | - return $this->g->load( $backurl, array(), array( $this->uri=>1 ) ); |
| 598 | + $backurl = "http://backlinks.psi.enakting.org/resource/rdf/" . $this->uri; |
| 599 | + return $this->g->load( $backurl, array(), array( $this->uri => 1 ) ); |
600 | 600 | } |
601 | | - |
602 | | - public function loadSameAs( $prefix=null ) |
| 601 | + |
| 602 | + public function loadSameAs( $prefix = null ) |
603 | 603 | { |
604 | 604 | $cnt = 0; |
605 | | - foreach( $this->all( "owl:sameAs" ) as $sameas ) |
| 605 | + foreach ( $this->all( "owl:sameAs" ) as $sameas ) |
606 | 606 | { |
607 | 607 | $this->g->forceString( $sameas ); |
608 | | - if( $prefix && substr( $sameas, 0, strlen($prefix )) != $prefix ) |
| 608 | + if ( $prefix && substr( $sameas, 0, strlen( $prefix ) ) != $prefix ) |
609 | 609 | { |
610 | 610 | continue; |
611 | 611 | } |
612 | | - |
613 | | - $cnt += $this->g->load( $sameas, array( $sameas=>$this->uri ) ); |
| 612 | + |
| 613 | + $cnt += $this->g->load( $sameas, array( $sameas => $this->uri ) ); |
614 | 614 | } |
615 | 615 | return $cnt; |
616 | 616 | } |
— | — | @@ -635,38 +635,38 @@ |
636 | 636 | |
637 | 637 | public function link() |
638 | 638 | { |
639 | | - return "<a title='".$this->uri."' href='".$this->uri."'>".$this->uri."</a>"; |
| 639 | + return "<a title='" . $this->uri . "' href='" . $this->uri . "'>" . $this->uri . "</a>"; |
640 | 640 | } |
641 | 641 | |
642 | 642 | public function dumpText() |
643 | 643 | { |
644 | 644 | $r = ""; |
645 | 645 | $plist = array(); |
646 | | - foreach( $this->relations() as $prop ) |
| 646 | + foreach ( $this->relations() as $prop ) |
647 | 647 | { |
648 | 648 | $olist = array(); |
649 | | - foreach( $this->all( $prop ) as $obj ) |
| 649 | + foreach ( $this->all( $prop ) as $obj ) |
650 | 650 | { |
651 | | - $olist []= $obj->dumpValueText(); |
| 651 | + $olist [] = $obj->dumpValueText(); |
652 | 652 | } |
653 | | - $plist []= $this->g->shrinkURI($prop)." ".join( ", ",$olist ); |
| 653 | + $plist [] = $this->g->shrinkURI( $prop ) . " " . join( ", ", $olist ); |
654 | 654 | } |
655 | | - return $this->g->shrinkURI($this->uri)."\n ".join( ";\n ", $plist )." .\n"; |
| 655 | + return $this->g->shrinkURI( $this->uri ) . "\n " . join( ";\n ", $plist ) . " .\n"; |
656 | 656 | } |
657 | 657 | |
658 | 658 | public function dump( $options = array() ) |
659 | 659 | { |
660 | 660 | $r = ""; |
661 | 661 | $plist = array(); |
662 | | - foreach( $this->relations() as $prop ) |
| 662 | + foreach ( $this->relations() as $prop ) |
663 | 663 | { |
664 | 664 | $olist = array(); |
665 | 665 | $all = $this->all( $prop ); |
666 | | - foreach( $all as $obj ) |
| 666 | + foreach ( $all as $obj ) |
667 | 667 | { |
668 | | - $olist []= $obj->dumpValue($options); |
| 668 | + $olist [] = $obj->dumpValue( $options ); |
669 | 669 | } |
670 | | - if( is_a( $prop, "Graphite_InverseRelation" ) ) |
| 670 | + if ( is_a( $prop, "Graphite_InverseRelation" ) ) |
671 | 671 | { |
672 | 672 | $pattern = "<span style='font-size:130%%'>←</span> is <a title='%s' href='%s' style='text-decoration:none;color: green'>%s</a> of <span style='font-size:130%%'>←</span> %s"; |
673 | 673 | } |
— | — | @@ -675,43 +675,43 @@ |
676 | 676 | $pattern = "<span style='font-size:130%%'>→</span> <a title='%s' href='%s' style='text-decoration:none;color: green'>%s</a> <span style='font-size:130%%'>→</span> %s"; |
677 | 677 | } |
678 | 678 | $this->g->forceString( $prop ); |
679 | | - $plist []= sprintf( $pattern, $prop, $prop, $this->g->shrinkURI($prop), join( ", ",$olist )); |
| 679 | + $plist [] = sprintf( $pattern, $prop, $prop, $this->g->shrinkURI( $prop ), join( ", ", $olist ) ); |
680 | 680 | } |
681 | | - $r.= "\n<a name='".htmlentities($this->uri)."'></a><div style='font-family: arial;padding:0.5em; background-color:lightgrey;border:dashed 1px grey;margin-bottom:2px;'>\n"; |
682 | | - if( isset($options["label"] ) ) |
| 681 | + $r .= "\n<a name='" . htmlentities( $this->uri ) . "'></a><div style='font-family: arial;padding:0.5em; background-color:lightgrey;border:dashed 1px grey;margin-bottom:2px;'>\n"; |
| 682 | + if ( isset( $options["label"] ) ) |
683 | 683 | { |
684 | 684 | $label = $this->label(); |
685 | | - if( $label == "[NULL]" ) { $label = ""; } else { $label = "<strong>$label</strong>"; } |
686 | | - if( $this->has( "rdf:type" ) ) |
| 685 | + if ( $label == "[NULL]" ) { $label = ""; } else { $label = "<strong>$label</strong>"; } |
| 686 | + if ( $this->has( "rdf:type" ) ) |
687 | 687 | { |
688 | | - if( $this->get( "rdf:type" )->hasLabel() ) |
| 688 | + if ( $this->get( "rdf:type" )->hasLabel() ) |
689 | 689 | { |
690 | 690 | $typename = $this->get( "rdf:type" )->label(); |
691 | 691 | } |
692 | | - else |
| 692 | + else |
693 | 693 | { |
694 | 694 | $bits = preg_split( "/[\/#]/", $this->get( "rdf:type" )->uri ); |
695 | 695 | $typename = array_pop( $bits ); |
696 | | - $typename = preg_replace( "/([a-z])([A-Z])/","$1 $2",$typename ); |
| 696 | + $typename = preg_replace( "/([a-z])([A-Z])/", "$1 $2", $typename ); |
697 | 697 | } |
698 | 698 | $r .= preg_replace( "/>a ([AEIOU])/i", ">an $1", "<div style='float:right'>a $typename</div>" ); |
699 | 699 | } |
700 | | - if( $label != "" ) { $r.="<div>$label</div>"; } |
| 700 | + if ( $label != "" ) { $r .= "<div>$label</div>"; } |
701 | 701 | } |
702 | | - $r.= " <!-- DUMP:".$this->uri." -->\n <div><a title='".$this->uri."' href='".$this->uri."' style='text-decoration:none'>".$this->g->shrinkURI($this->uri)."</a></div>\n"; |
703 | | - $r.=" <div style='padding-left: 3em'>\n <div>".join( "</div>\n <div>", $plist )."</div></div><div style='clear:both;height:1px; overflow:hidden'> </div></div>"; |
| 702 | + $r .= " <!-- DUMP:" . $this->uri . " -->\n <div><a title='" . $this->uri . "' href='" . $this->uri . "' style='text-decoration:none'>" . $this->g->shrinkURI( $this->uri ) . "</a></div>\n"; |
| 703 | + $r .= " <div style='padding-left: 3em'>\n <div>" . join( "</div>\n <div>", $plist ) . "</div></div><div style='clear:both;height:1px; overflow:hidden'> </div></div>"; |
704 | 704 | return $r; |
705 | 705 | } |
706 | 706 | |
707 | 707 | function __toString() { return $this->uri; } |
708 | | - function dumpValue($options=array()) |
709 | | - { |
| 708 | + function dumpValue( $options = array() ) |
| 709 | + { |
710 | 710 | $label = $this->dumpValueText(); |
711 | | - if( $this->hasLabel() && @$options["labeluris"] ) |
| 711 | + if ( $this->hasLabel() && @$options["labeluris"] ) |
712 | 712 | { |
713 | 713 | $label = $this->label(); |
714 | 714 | } |
715 | | - return "<a href='".$this->uri."' title='".$this->uri."' style='text-decoration:none;color:red'>".$label."</a>"; |
| 715 | + return "<a href='" . $this->uri . "' title='" . $this->uri . "' style='text-decoration:none;color:red'>" . $label . "</a>"; |
716 | 716 | } |
717 | 717 | function dumpValueText() { return $this->g->shrinkURI( $this->uri ); } |
718 | 718 | function nodeType() { return "#resource"; } |
— | — | @@ -728,10 +728,10 @@ |
729 | 729 | } |
730 | 730 | class Graphite_ResourceList extends ArrayIterator |
731 | 731 | { |
732 | | - function __construct( $g, $a=array() ) |
| 732 | + function __construct( $g, $a = array() ) |
733 | 733 | { |
734 | 734 | $this->g = $g; |
735 | | - if( $a instanceof Graphite_ResourceList ) |
| 735 | + if ( $a instanceof Graphite_ResourceList ) |
736 | 736 | { |
737 | 737 | print "<li>Graphite warning: passing a Graphite_ResourceList as the array passed to new Graphite_ResourceList will make weird stuff happen.</li>"; |
738 | 738 | } |
— | — | @@ -742,11 +742,11 @@ |
743 | 743 | { |
744 | 744 | $first = 1; |
745 | 745 | $l = array(); |
746 | | - foreach( $this as $resource ) |
| 746 | + foreach ( $this as $resource ) |
747 | 747 | { |
748 | | - if( !$first ) { $l []= $str; } |
| 748 | + if ( !$first ) { $l [] = $str; } |
749 | 749 | $this->g->forceString( $resource ); |
750 | | - $l []= $resource; |
| 750 | + $l [] = $resource; |
751 | 751 | $first = 0; |
752 | 752 | } |
753 | 753 | return join( "", $l ); |
— | — | @@ -755,108 +755,108 @@ |
756 | 756 | function dump() |
757 | 757 | { |
758 | 758 | $l = array(); |
759 | | - foreach( $this as $resource ) |
| 759 | + foreach ( $this as $resource ) |
760 | 760 | { |
761 | | - $l [] = $resource->dump(); |
| 761 | + $l [] = $resource->dump(); |
762 | 762 | } |
763 | 763 | return join( "", $l ); |
764 | 764 | } |
765 | | - |
| 765 | + |
766 | 766 | public function duplicate() |
767 | 767 | { |
768 | 768 | $l = array(); |
769 | | - foreach( $this as $resource ) { $l []= $resource; } |
770 | | - return new Graphite_ResourceList($this->g,$l); |
| 769 | + foreach ( $this as $resource ) { $l [] = $resource; } |
| 770 | + return new Graphite_ResourceList( $this->g, $l ); |
771 | 771 | } |
772 | 772 | |
773 | 773 | public function sort( /* List */ ) |
774 | 774 | { |
775 | 775 | $args = func_get_args(); |
776 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
777 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 776 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 777 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
778 | 778 | |
779 | 779 | global $graphite_sort_args; |
780 | 780 | $graphite_sort_args = array(); |
781 | | - foreach( $args as $arg ) |
| 781 | + foreach ( $args as $arg ) |
782 | 782 | { |
783 | | - if( $arg instanceof Graphite_Resource ) { $arg = $arg->toString(); } |
| 783 | + if ( $arg instanceof Graphite_Resource ) { $arg = $arg->toString(); } |
784 | 784 | $graphite_sort_args [] = $arg; |
785 | 785 | } |
786 | 786 | |
787 | 787 | $new_list = $this->duplicate(); |
788 | | - usort($new_list, "graphite_sort_list_cmp" ); |
| 788 | + usort( $new_list, "graphite_sort_list_cmp" ); |
789 | 789 | |
790 | 790 | return $new_list; |
791 | 791 | } |
792 | 792 | |
793 | 793 | public function uasort( $cmp ) |
794 | 794 | { |
795 | | - usort($this, $cmp ); |
| 795 | + usort( $this, $cmp ); |
796 | 796 | } |
797 | 797 | |
798 | 798 | public function get( /* List */ ) |
799 | 799 | { |
800 | 800 | $args = func_get_args(); |
801 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
802 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 801 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 802 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
803 | 803 | $l = array(); |
804 | | - foreach( $this as $resource ) |
| 804 | + foreach ( $this as $resource ) |
805 | 805 | { |
806 | 806 | $l [] = $resource->get( $args ); |
807 | 807 | } |
808 | | - return new Graphite_ResourceList($this->g,$l); |
| 808 | + return new Graphite_ResourceList( $this->g, $l ); |
809 | 809 | } |
810 | 810 | |
811 | | - public function label() |
| 811 | + public function label() |
812 | 812 | { |
813 | 813 | $l = array(); |
814 | | - foreach( $this as $resource ) |
| 814 | + foreach ( $this as $resource ) |
815 | 815 | { |
816 | 816 | $l [] = $resource->label(); |
817 | 817 | } |
818 | | - return new Graphite_ResourceList($this->g,$l); |
| 818 | + return new Graphite_ResourceList( $this->g, $l ); |
819 | 819 | } |
820 | | - |
821 | | - public function load() |
| 820 | + |
| 821 | + public function load() |
822 | 822 | { |
823 | 823 | $n = 0; |
824 | | - foreach( $this as $resource ) |
| 824 | + foreach ( $this as $resource ) |
825 | 825 | { |
826 | 826 | $n += $resource->load(); |
827 | 827 | } |
828 | 828 | return $n; |
829 | 829 | } |
830 | | - |
| 830 | + |
831 | 831 | public function all( /* List */ ) |
832 | 832 | { |
833 | 833 | $args = func_get_args(); |
834 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
835 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 834 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 835 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
836 | 836 | $l = array(); |
837 | 837 | $done = array(); |
838 | | - foreach( $this as $resource ) |
| 838 | + foreach ( $this as $resource ) |
839 | 839 | { |
840 | 840 | $all = $resource->all( $args ); |
841 | | - foreach( $all as $to_add ) |
| 841 | + foreach ( $all as $to_add ) |
842 | 842 | { |
843 | | - if( isset($done[$to_add->toString()]) ) { continue; } |
844 | | - $l []= $to_add; |
| 843 | + if ( isset( $done[$to_add->toString()] ) ) { continue; } |
| 844 | + $l [] = $to_add; |
845 | 845 | $done[$to_add->toString()] = 1; |
846 | 846 | } |
847 | 847 | } |
848 | | - return new Graphite_ResourceList($this->g,$l); |
| 848 | + return new Graphite_ResourceList( $this->g, $l ); |
849 | 849 | } |
850 | 850 | |
851 | 851 | function append( $x /* List */ ) |
852 | 852 | { |
853 | 853 | $args = func_get_args(); |
854 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
855 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 854 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 855 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
856 | 856 | |
857 | 857 | $list = $this->duplicate(); |
858 | | - foreach( $args as $arg ) |
| 858 | + foreach ( $args as $arg ) |
859 | 859 | { |
860 | | - if( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
| 860 | + if ( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
861 | 861 | $list [] = $arg; |
862 | 862 | } |
863 | 863 | return $list; |
— | — | @@ -864,37 +864,37 @@ |
865 | 865 | |
866 | 866 | function distinct() |
867 | 867 | { |
868 | | - $l= array(); |
| 868 | + $l = array(); |
869 | 869 | $done = array(); |
870 | | - foreach( $this as $resource ) |
| 870 | + foreach ( $this as $resource ) |
871 | 871 | { |
872 | | - if( isset( $done[$resource->toString()] ) ) { continue; } |
| 872 | + if ( isset( $done[$resource->toString()] ) ) { continue; } |
873 | 873 | $l [] = $resource; |
874 | | - $done[$resource->toString()]=1; |
| 874 | + $done[$resource->toString()] = 1; |
875 | 875 | } |
876 | | - return new Graphite_ResourceList($this->g,$l); |
| 876 | + return new Graphite_ResourceList( $this->g, $l ); |
877 | 877 | } |
878 | 878 | |
879 | 879 | function union( /* List */ ) |
880 | 880 | { |
881 | 881 | $args = func_get_args(); |
882 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
883 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 882 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 883 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
884 | 884 | |
885 | | - $list = new Graphite_ResourceList($this->g); |
| 885 | + $list = new Graphite_ResourceList( $this->g ); |
886 | 886 | $done = array(); |
887 | | - foreach( $this as $resource ) |
| 887 | + foreach ( $this as $resource ) |
888 | 888 | { |
889 | | - if( isset( $done[$resource->toString()] ) ) { continue; } |
| 889 | + if ( isset( $done[$resource->toString()] ) ) { continue; } |
890 | 890 | $list [] = $resource; |
891 | | - $done[$resource->toString()]=1; |
| 891 | + $done[$resource->toString()] = 1; |
892 | 892 | } |
893 | | - foreach( $args as $arg ) |
| 893 | + foreach ( $args as $arg ) |
894 | 894 | { |
895 | | - if( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
896 | | - if( isset( $done[$arg->toString()] ) ) { continue; } |
| 895 | + if ( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
| 896 | + if ( isset( $done[$arg->toString()] ) ) { continue; } |
897 | 897 | $list [] = $arg; |
898 | | - $done[$arg->toString()]=1; |
| 898 | + $done[$arg->toString()] = 1; |
899 | 899 | } |
900 | 900 | return $list; |
901 | 901 | } |
— | — | @@ -902,20 +902,20 @@ |
903 | 903 | function intersection( /* List */ ) |
904 | 904 | { |
905 | 905 | $args = func_get_args(); |
906 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
907 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 906 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 907 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
908 | 908 | |
909 | | - $list = new Graphite_ResourceList($this->g,array()); |
| 909 | + $list = new Graphite_ResourceList( $this->g, array() ); |
910 | 910 | $seen = array(); |
911 | | - foreach( $this as $arg ) |
| 911 | + foreach ( $this as $arg ) |
912 | 912 | { |
913 | | - if( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
914 | | - $seen[$arg->toString()]=1; |
| 913 | + if ( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
| 914 | + $seen[$arg->toString()] = 1; |
915 | 915 | } |
916 | | - foreach( $args as $arg ) |
| 916 | + foreach ( $args as $arg ) |
917 | 917 | { |
918 | | - if( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
919 | | - if( ! isset($seen[$arg->toString()]) ) { continue; } |
| 918 | + if ( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
| 919 | + if ( ! isset( $seen[$arg->toString()] ) ) { continue; } |
920 | 920 | $list [] = $arg; |
921 | 921 | } |
922 | 922 | return $list; |
— | — | @@ -924,20 +924,20 @@ |
925 | 925 | function except( /* List */ ) |
926 | 926 | { |
927 | 927 | $args = func_get_args(); |
928 | | - if( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
929 | | - if( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
| 928 | + if ( $args[0] instanceof Graphite_ResourceList ) { $args = $args[0]; } |
| 929 | + if ( is_array( $args[0] ) ) { $args = func_get_arg( 0 ); } |
930 | 930 | |
931 | | - $list = new Graphite_ResourceList($this->g,array()); |
| 931 | + $list = new Graphite_ResourceList( $this->g, array() ); |
932 | 932 | $exclude = array(); |
933 | | - foreach( $args as $arg ) |
| 933 | + foreach ( $args as $arg ) |
934 | 934 | { |
935 | | - if( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
936 | | - $exclude[$arg->toString()]=1; |
| 935 | + if ( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
| 936 | + $exclude[$arg->toString()] = 1; |
937 | 937 | } |
938 | | - foreach( $this as $arg ) |
| 938 | + foreach ( $this as $arg ) |
939 | 939 | { |
940 | | - if( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
941 | | - if( isset($exclude[$arg->toString()]) ) { continue; } |
| 940 | + if ( ! $arg instanceof Graphite_Resource ) { $arg = $this->g->resource( $arg ); } |
| 941 | + if ( isset( $exclude[$arg->toString()] ) ) { continue; } |
942 | 942 | $list [] = $arg; |
943 | 943 | } |
944 | 944 | return $list; |
— | — | @@ -947,13 +947,13 @@ |
948 | 948 | function graphite_sort_list_cmp( $a, $b ) |
949 | 949 | { |
950 | 950 | global $graphite_sort_args; |
951 | | - |
952 | | - foreach( $graphite_sort_args as $arg ) |
| 951 | + |
| 952 | + foreach ( $graphite_sort_args as $arg ) |
953 | 953 | { |
954 | 954 | $va = $a->get( $arg ); |
955 | 955 | $vb = $b->get( $arg ); |
956 | | - if($va < $vb) return -1; |
957 | | - if($va > $vb) return 1; |
| 956 | + if ( $va < $vb ) return -1; |
| 957 | + if ( $va > $vb ) return 1; |
958 | 958 | } |
959 | 959 | return 0; |
960 | 960 | } |
Index: trunk/extensions/SemanticWebBrowser/CHANGELOG |
— | — | @@ -3,4 +3,8 @@ |
4 | 4 | * Release-notes added |
5 | 5 | |
6 | 6 | == SWB - commit before 2011-09-19 == |
7 | | -* Basis functionality of browsing implemented |
\ No newline at end of file |
| 7 | +* Basis functionality of browsing implemented based on browse wiki |
| 8 | +*property of wikipage for search SWB is shown |
| 9 | + |
| 10 | +== SWB - 2011-11-27 == |
| 11 | +* Incoming links work now |
Index: trunk/extensions/SemanticWebBrowser/SemanticWebBrowser.i18n.php |
— | — | @@ -0,0 +1,28 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalization file for Semantic WebBrowser |
| 5 | + *@author Anna Kantorovitch and Benedikt K�mpgen |
| 6 | + * @ingroup Language |
| 7 | + * @ingroup SWBLanguage |
| 8 | + */ |
| 9 | + |
| 10 | + |
| 11 | +/** English |
| 12 | + * |
| 13 | + */ |
| 14 | +$messages['en'] = array( |
| 15 | + |
| 16 | + // Messages for the browsing semantic Web special |
| 17 | + |
| 18 | + 'browsewiki' => 'Browse Wiki & Semantic Web', #title of the SWB page |
| 19 | + 'swb_browse_semantic_web' => 'Browse Wiki & Semantic Web', #title for browsing |
| 20 | + 'swb_browse_article' => 'Enter the name of the page to start semantic browsing from.',#text above "go"window |
| 21 | + 'swb_browse_go' => 'Go', #title of button "go" |
| 22 | + 'swb_browse_show_incoming' => 'show incoming properties that link here', #title of properties |
| 23 | + 'swb_browse_hide_incoming' => 'hide incoming properties that link here', #title of properties |
| 24 | + 'swb_browse_no_outgoing' => 'This page has no properties.', #text: page has no properties |
| 25 | + 'swb_browse_no_incoming' => 'No properties link to this page.', #text:page has no incoming properties |
| 26 | + 'swb_inverse_label_property' => 'Inverse property label', # this is the name of a special property |
| 27 | + 'swb_inverse_label_default' => '$1 of', #text : inverse label dafault,$1 is place marker, have not to be translated |
| 28 | + 'swb_browse_more' => '…', #text: browse more details |
| 29 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticWebBrowser/SemanticWebBrowser.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 30 | + native |
Added: svn:keywords |
2 | 31 | + LastChangedDate LastChangedRevision LastChangedBy Id |