Index: trunk/extensions/SemanticGlossary/SpecialSemanticGlossaryBrowser.php |
— | — | @@ -251,15 +251,18 @@ |
252 | 252 | ) { |
253 | 253 | |
254 | 254 | $this -> updateData( $page, array( |
255 | | - '___glt' => $newTerm, |
256 | | - '___gld' => $newDefinition, |
257 | | - '___gll' => $newLink, |
| 255 | + '___glt' => ($newTerm ? new SMWDIString( $newTerm ) : null), |
| 256 | + '___gld' => ($newDefinition ? new SMWDIBlob( $newDefinition ) : null), |
| 257 | + '___gll' => ($newLink ? new SMWDIString( $newLink ) : null) |
258 | 258 | ) ); |
259 | 259 | |
260 | 260 | // issue a warning if the original definition is on a real page |
261 | | - if ( $page -> getArticleID() != 0 ) { |
262 | | - $this -> mMessages -> addMessage( wfMsg( 'semanticglossary-storedtermdefinedinarticle', array( $oldTerm, $page -> getPrefixedText() ) ) |
263 | | - , SemanticGlossaryMessageLog::SG_WARNING |
| 261 | + |
| 262 | + $title = $page -> getTitle(); |
| 263 | + if ( $title -> isKnown() ) { |
| 264 | + $this -> mMessages -> addMessage( |
| 265 | + wfMsg( 'semanticglossary-storedtermdefinedinarticle', array( $oldTerm, $title -> getPrefixedText() ) ), |
| 266 | + SemanticGlossaryMessageLog::SG_WARNING |
264 | 267 | ); |
265 | 268 | } else { |
266 | 269 | $this -> mMessages -> addMessage( wfMsg( 'semanticglossary-termchanged', array( $oldTerm ) ), SemanticGlossaryMessageLog::SG_NOTICE ); |
— | — | @@ -283,22 +286,13 @@ |
284 | 287 | $newDefinition = $wgRequest -> getText( 'newdefinition' ); |
285 | 288 | $newLink = $wgRequest -> getText( 'newlink' ); |
286 | 289 | |
287 | | - $termNumber = 1; |
| 290 | + $page = $this -> findNextPageName(); |
288 | 291 | |
289 | | - // find unused SMW page |
290 | | - do { |
291 | | - $page = SMWWikiPageValue::makePage( "GlossaryTerm#$termNumber", 0 ); |
292 | | - $termNumber++; |
293 | | - } while ( count( smwfGetStore() -> getProperties( $page ) ) > 0 ); |
294 | | - |
295 | 292 | // store data |
296 | 293 | $this -> updateData( $page, array( |
297 | | - '___glt' => $newTerm, |
298 | | - '___gld' => $newDefinition, |
299 | | - '___gll' => $newLink, |
300 | | -// wfMsg( 'semanticglossary-prop-glt' ) => $newTerm, |
301 | | -// wfMsg( 'semanticglossary-prop-gld' ) => $newDefinition, |
302 | | -// wfMsg( 'semanticglossary-prop-gll' ) => $newLink, |
| 294 | + '___glt' => ($newTerm ? new SMWDIString( $newTerm ) : null), |
| 295 | + '___gld' => ($newDefinition ? new SMWDIBlob( $newDefinition ) : null), |
| 296 | + '___gll' => ($newLink ? new SMWDIString( $newLink ) : null) |
303 | 297 | ) ); |
304 | 298 | |
305 | 299 | $this -> mMessages -> addMessage( wfMsg( 'semanticglossary-termadded', array( $newTerm ) ), SemanticGlossaryMessageLog::SG_NOTICE ); |
— | — | @@ -327,14 +321,14 @@ |
328 | 322 | '___gll' => null, |
329 | 323 | ) ); |
330 | 324 | |
331 | | - $title = $page -> getTitle(); |
332 | | - |
333 | 325 | $oldTerm = $wgRequest -> getVal( $pageString . ':term' ); |
334 | 326 | |
335 | | - if ( $title && $title -> exists() ) { |
| 327 | + $title = $page -> getTitle(); |
| 328 | + if ( $title && $title -> isKnown() ) { |
336 | 329 | |
337 | | - $this -> mMessages -> addMessage( wfMsg( 'semanticglossary-deletedtermdefinedinarticle', array( $oldTerm, $page -> getPrefixedText() ) ) |
338 | | - , SemanticGlossaryMessageLog::SG_WARNING |
| 330 | + $this -> mMessages -> addMessage( |
| 331 | + wfMsg( 'semanticglossary-deletedtermdefinedinarticle', array( $oldTerm, $title -> getPrefixedText() ) ), |
| 332 | + SemanticGlossaryMessageLog::SG_WARNING |
339 | 333 | ); |
340 | 334 | } else { |
341 | 335 | $this -> mMessages -> addMessage( wfMsg( 'semanticglossary-termdeleted', array( $oldTerm ) ), SemanticGlossaryMessageLog::SG_NOTICE ); |
— | — | @@ -345,12 +339,12 @@ |
346 | 340 | |
347 | 341 | protected function getPropertyFromData ( SMWSemanticData &$pageData, $propertyName ) { |
348 | 342 | |
349 | | - $property = SMWPropertyValue::makeProperty( $propertyName ); |
| 343 | + $property = new SMWDIProperty( $propertyName ); |
350 | 344 | $propertyValues = $pageData -> getPropertyValues( $property ); |
351 | 345 | |
352 | 346 | if ( count( $propertyValues ) == 1 ) { |
353 | 347 | |
354 | | - return $propertyValues[ 0 ] -> getShortWikiText(); |
| 348 | + return $propertyValues[ 0 ] -> getString(); |
355 | 349 | } else if ( count( $propertyValues ) > 1 ) { |
356 | 350 | |
357 | 351 | if ( count( $propertyValues ) > 1 ) { |
— | — | @@ -371,11 +365,44 @@ |
372 | 366 | preg_match( '/^(.*):(.*):(.*)$/', $pageString, $matches ); |
373 | 367 | |
374 | 368 | // create SMWWikiPageValue (SMW's wiki page representation) |
375 | | - return SMWWikiPageValue::makePage( $matches[ 3 ], $matches[ 2 ], '', $matches[ 1 ] ); |
| 369 | + return new SMWDIWikiPage( $matches[ 3 ], $matches[ 2 ], $matches[ 1 ] ); |
376 | 370 | } |
377 | 371 | |
378 | | - protected function updateData ( SMWWikiPageValue &$page, array $data ) { |
| 372 | + // find unused SMW page |
| 373 | + protected function findNextPageName () { |
379 | 374 | |
| 375 | + $termPages = smwfGetStore() -> getAllPropertySubjects( new SMWDIProperty( '___glt' ) ); |
| 376 | + $defPages = smwfGetStore() -> getAllPropertySubjects( new SMWDIProperty( '___gld' ) ); |
| 377 | + $linkPages = smwfGetStore() -> getAllPropertySubjects( new SMWDIProperty( '___gll' ) ); |
| 378 | + |
| 379 | + $pages = array( ); |
| 380 | + |
| 381 | + foreach ( $termPages as $page ) { |
| 382 | + $pages[ $page -> getDBkey() ] = $page -> getDBkey(); |
| 383 | + } |
| 384 | + |
| 385 | + foreach ( $defPages as $page ) { |
| 386 | + $pages[ $page -> getDBkey() ] = $page -> getDBkey(); |
| 387 | + } |
| 388 | + |
| 389 | + foreach ( $linkPages as $page ) { |
| 390 | + $pages[ $page -> getDBkey() ] = $page -> getDBkey(); |
| 391 | + } |
| 392 | + |
| 393 | + $termNumber = count( $pages ); |
| 394 | + |
| 395 | + |
| 396 | + while ( array_key_exists( "GlossaryTerm#$termNumber", $pages ) ) { |
| 397 | + $termNumber++; |
| 398 | + } |
| 399 | + |
| 400 | + return new SMWDIWikiPage( "GlossaryTerm#$termNumber", NS_MAIN, '' ); |
| 401 | + |
| 402 | + exit (); |
| 403 | + } |
| 404 | + |
| 405 | + protected function updateData ( SMWDIWikiPage &$page, array $data ) { |
| 406 | + |
380 | 407 | $newData = new SMWSemanticData( $page, false ); |
381 | 408 | |
382 | 409 | $oldData = smwfGetStore() -> getSemanticData( $page ); |
— | — | @@ -384,16 +411,15 @@ |
385 | 412 | // get properties, replace as requested, retain other properties |
386 | 413 | foreach ( $oldProps as $property ) { |
387 | 414 | |
388 | | - $propertyID = $property -> getPropertyID(); |
| 415 | + $propertyID = $property -> getKey(); |
389 | 416 | |
390 | 417 | if ( array_key_exists( $propertyID, $data ) ) { |
391 | 418 | |
392 | | - |
393 | 419 | // set new data if defined, else ignore property (i.e. delete property from page) |
394 | 420 | if ( $data[ $propertyID ] != null ) { |
395 | 421 | |
396 | | - $value = SMWDataValueFactory::newPropertyObjectValue( $property, $data[ $propertyID ] ); |
397 | | - $newData -> addPropertyObjectValue( $property, $value ); |
| 422 | +// $value = SMWDataValueFactory::newPropertyObjectValue( $property, $data[ $propertyID ] ); |
| 423 | + $newData -> addPropertyObjectValue( $property, $data[ $propertyID ] ); |
398 | 424 | } |
399 | 425 | |
400 | 426 | unset( $data[ $propertyID ] ); |
— | — | @@ -413,9 +439,9 @@ |
414 | 440 | // set new data if defined, else ignore property (i.e. do not set property on this page) |
415 | 441 | if ( $data[ $propertyID ] != null ) { |
416 | 442 | |
417 | | - $property = SMWPropertyValue::makeProperty( $propertyID ); |
418 | | - $value = SMWDataValueFactory::newPropertyObjectValue( $property, $data[ $propertyID ] ); |
419 | | - $newData -> addPropertyObjectValue( $property, $value ); |
| 443 | + $property = new SMWDIProperty( $propertyID ); |
| 444 | +// $value = SMWDataValueFactory::newPropertyObjectValue( $property, $data[ $propertyID ] ); |
| 445 | + $newData -> addPropertyObjectValue( $property, $data[ $propertyID ] ); |
420 | 446 | } |
421 | 447 | |
422 | 448 | unset( $data[ $propertyID ] ); |
Index: trunk/extensions/SemanticGlossary/SemanticGlossaryParser.php |
— | — | @@ -30,10 +30,15 @@ |
31 | 31 | */ |
32 | 32 | static function parse( &$parser, &$text ) { |
33 | 33 | |
| 34 | + wfProfileIn( __METHOD__ ); |
| 35 | + |
34 | 36 | $sl = new SemanticGlossaryParser(); |
35 | 37 | $sl -> realParse( $parser, $text ); |
36 | 38 | |
| 39 | + wfProfileOut( __METHOD__ ); |
| 40 | + |
37 | 41 | return true; |
| 42 | + |
38 | 43 | } |
39 | 44 | |
40 | 45 | /** |
— | — | @@ -45,10 +50,12 @@ |
46 | 51 | |
47 | 52 | global $smwgQDefaultNamespaces; |
48 | 53 | |
| 54 | + wfProfileIn( __METHOD__ ); |
| 55 | + |
49 | 56 | $store = smwfGetStore(); // default store |
50 | 57 | |
51 | 58 | // Create query |
52 | | - $desc = new SMWSomeProperty(SMWPropertyValue::makeProperty( '___glt' ), new SMWThingDescription()); |
| 59 | + $desc = new SMWSomeProperty(new SMWDIProperty( '___glt' ), new SMWThingDescription()); |
53 | 60 | $desc -> addPrintRequest(new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___glt' ) )); |
54 | 61 | $desc -> addPrintRequest(new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___gld' ) )); |
55 | 62 | $desc -> addPrintRequest(new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___gll' ) )); |
— | — | @@ -93,7 +100,7 @@ |
94 | 101 | continue; |
95 | 102 | } |
96 | 103 | |
97 | | - $source = $subject -> getDBkeys(); |
| 104 | + $source = array( $subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $subject->getDBkey() ); |
98 | 105 | |
99 | 106 | if ( array_key_exists( $term, $result ) ) { |
100 | 107 | $result[ $term ] -> addDefinition( $definition, $link, $source ); |
— | — | @@ -102,6 +109,8 @@ |
103 | 110 | } |
104 | 111 | } |
105 | 112 | |
| 113 | + wfProfileOut( __METHOD__ ); |
| 114 | + |
106 | 115 | return $result; |
107 | 116 | } |
108 | 117 | |
— | — | @@ -118,6 +127,8 @@ |
119 | 128 | |
120 | 129 | global $wgRequest, $sggSettings; |
121 | 130 | |
| 131 | + wfProfileIn( __METHOD__ ); |
| 132 | + |
122 | 133 | $action = $wgRequest -> getVal( 'action', 'view' ); |
123 | 134 | if ( $text == null || $text == '' || $action == "edit" || $action == "ajax" || isset( $_POST[ 'wpPreview' ] ) ) |
124 | 135 | return true; |
— | — | @@ -149,7 +160,7 @@ |
150 | 161 | |
151 | 162 | for ( $pos = 0; $pos < $nb; $pos++ ) { |
152 | 163 | |
153 | | - $el = &$elements -> item( $pos ); |
| 164 | + $el = $elements -> item( $pos ); |
154 | 165 | |
155 | 166 | if ( strlen( $el -> nodeValue ) < $min ) |
156 | 167 | continue; |
— | — | @@ -202,6 +213,8 @@ |
203 | 214 | $this -> loadModules( $parser ); |
204 | 215 | } |
205 | 216 | |
| 217 | + wfProfileOut( __METHOD__ ); |
| 218 | + |
206 | 219 | return true; |
207 | 220 | } |
208 | 221 | |
Index: trunk/extensions/SemanticGlossary/SemanticGlossary.php |
— | — | @@ -116,20 +116,15 @@ |
117 | 117 | |
118 | 118 | |
119 | 119 | function SemanticGlossaryRegisterProperties () { |
120 | | -// SMWPropertyValue::registerProperty( '___glt', '_str', false , true ); |
121 | | -// SMWPropertyValue::registerProperty( '___gld', '_txt', false , true ); |
122 | | -// SMWPropertyValue::registerProperty( '___gll', '_str', false , true ); |
123 | | - |
124 | | - SMWPropertyValue::registerProperty( '___glt', '_str', SG_PROP_GLT, true ); |
125 | | - SMWPropertyValue::registerProperty( '___gld', '_txt', SG_PROP_GLD, true ); |
126 | | - SMWPropertyValue::registerProperty( '___gll', '_str', SG_PROP_GLL, true ); |
127 | | - |
| 120 | + SMWDIProperty::registerProperty( '___glt', '_str', SG_PROP_GLT, true ); |
| 121 | + SMWDIProperty::registerProperty( '___gld', '_txt', SG_PROP_GLD, true ); |
| 122 | + SMWDIProperty::registerProperty( '___gll', '_str', SG_PROP_GLL, true ); |
128 | 123 | return true; |
129 | 124 | } |
130 | 125 | |
131 | 126 | function SemanticGlossaryRegisterPropertyAliases () { |
132 | | - SMWPropertyValue::registerPropertyAlias( '___glt', wfMsg( 'semanticglossary-prop-glt' ) ); |
133 | | - SMWPropertyValue::registerPropertyAlias( '___gld', wfMsg( 'semanticglossary-prop-gld' ) ); |
134 | | - SMWPropertyValue::registerPropertyAlias( '___gll', wfMsg( 'semanticglossary-prop-gll' ) ); |
| 127 | + SMWDIProperty::registerPropertyAlias( '___glt', wfMsg( 'semanticglossary-prop-glt' ) ); |
| 128 | + SMWDIProperty::registerPropertyAlias( '___gld', wfMsg( 'semanticglossary-prop-gld' ) ); |
| 129 | + SMWDIProperty::registerPropertyAlias( '___gll', wfMsg( 'semanticglossary-prop-gll' ) ); |
135 | 130 | return true; |
136 | 131 | } |