Skip to content

Commit

Permalink
SMW 2.5 compatibility (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames authored Mar 25, 2017
1 parent f1633af commit 05872d8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ terms and abbreviations can be defined using semantic properties.

- PHP 5.3.3 or later
- MediaWiki 1.26 or later
- [Semantic MediaWiki][smw] 2.3 or later
- [Semantic MediaWiki][smw] 2.4 or later

## Installation

Expand All @@ -25,7 +25,7 @@ Just add the following to the MediaWiki `composer.local.json` file and run the
```json
{
"require": {
"mediawiki/semantic-glossary": "~2.0"
"mediawiki/semantic-glossary": "~2.1"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"require": {
"php": ">=5.3.3",
"composer/installers":"^1.0.12",
"mediawiki/semantic-media-wiki": "~2.3|~3.0",
"mediawiki/semantic-media-wiki": "~2.4",
"mediawiki/lingo": "~2.0"
},
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Semantic Glossary",
"version": "2.0.1",
"version": "2.1.0-alpha",
"author": [
"[https://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]",
"[https://www.semantic-mediawiki.org/wiki/User:MWJames James Hong Kong]",
Expand Down
27 changes: 16 additions & 11 deletions src/Cache/ElementsCacheBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
namespace SG\Cache;

use SG\PropertyRegistry;

use SMW\DataValueFactory;
use SMW\Store;
use SMW\DIProperty;

use SMWStringValue as StringValue;
use SMWPrintRequest as PrintRequest;
use SMWPropertyValue as PropertyValue;
use SMWThingDescription as ThingDescription;
use SMWSomeProperty as SomeProperty;
use SMWQuery as Query;

use Lingo\Element;

/**
Expand Down Expand Up @@ -127,39 +125,42 @@ private function buildElements( $terms, $definition, $link, $style, $page ) {
}

private function buildQuery() {

$dataValueFactory = DataValueFactory::getInstance();

// build term data item and data value for later use
$this->mDiTerm = new DIProperty( PropertyRegistry::SG_TERM );
$this->mDvTerm = new StringValue( '_str' );
$this->mDvTerm = $dataValueFactory->newDataValueByType( '_txt' );
$this->mDvTerm->setProperty( $this->mDiTerm );

$pvTerm = new PropertyValue( '__pro' );
$pvTerm = $dataValueFactory->newDataValueByType( '__pro' );
$pvTerm->setDataItem( $this->mDiTerm );
$prTerm = new PrintRequest( PrintRequest::PRINT_PROP, null, $pvTerm );

// build definition data item and data value for later use
$this->mDiDefinition = new DIProperty( PropertyRegistry::SG_DEFINITION );
$this->mDvDefinition = new StringValue( '_txt' );
$this->mDvDefinition = $dataValueFactory->newDataValueByType( '_txt' );
$this->mDvDefinition->setProperty( $this->mDiDefinition );

$pvDefinition = new PropertyValue( '__pro' );
$pvDefinition = $dataValueFactory->newDataValueByType( '__pro' );
$pvDefinition->setDataItem( $this->mDiDefinition );
$prDefinition = new PrintRequest( PrintRequest::PRINT_PROP, null, $pvDefinition );

// build link data item and data value for later use
$this->mDiLink = new DIProperty( PropertyRegistry::SG_LINK );
$this->mDvLink = new StringValue( '_str' );
$this->mDvLink = $dataValueFactory->newDataValueByType( '_txt' );
$this->mDvLink->setProperty( $this->mDiLink );

$pvLink = new PropertyValue( '__pro' );
$pvLink = $dataValueFactory->newDataValueByType( '__pro' );
$pvLink->setDataItem( $this->mDiLink );
$prLink = new PrintRequest( PrintRequest::PRINT_PROP, null, $pvLink );

// build style data item and data value for later use
$this->mDiStyle = new DIProperty( PropertyRegistry::SG_STYLE );
$this->mDvStyle = new StringValue( '_txt' );
$this->mDvStyle = $dataValueFactory->newDataValueByType( '_txt' );
$this->mDvStyle->setProperty( $this->mDiStyle );

$pvStyle = new PropertyValue( '__pro' );
$pvStyle = $dataValueFactory->newDataValueByType( '__pro' );
$pvStyle->setDataItem( $this->mDiStyle );
$prStyle = new PrintRequest( PrintRequest::PRINT_PROP, null, $pvStyle );

Expand All @@ -174,6 +175,10 @@ private function buildQuery() {
$query->sort = true;
$query->sortkeys['___glt'] = 'ASC';

if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) {
$query->setOption( Query::PROC_CONTEXT, 'SG.ElementsCacheBuilder' );
}

return $query;
}

Expand Down

0 comments on commit 05872d8

Please sign in to comment.