SemanticMediaWiki /
SemanticCite
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace SCI; |
||||||
| 4 | |||||||
| 5 | use SMW\Store; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 6 | use SMW\SemanticData; |
||||||
|
0 ignored issues
–
show
The type
SMW\SemanticData was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 7 | use SMW\DIProperty; |
||||||
|
0 ignored issues
–
show
The type
SMW\DIProperty was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 8 | use SMW\DIWikiPage; |
||||||
|
0 ignored issues
–
show
The type
SMW\DIWikiPage was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 9 | use SMW\Query\Language\SomeProperty; |
||||||
|
0 ignored issues
–
show
The type
SMW\Query\Language\SomeProperty was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 10 | use SMW\Query\Language\ThingDescription; |
||||||
|
0 ignored issues
–
show
The type
SMW\Query\Language\ThingDescription was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 11 | use SMW\Query\Language\ValueDescription; |
||||||
|
0 ignored issues
–
show
The type
SMW\Query\Language\ValueDescription was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 12 | use SMWQuery as Query; |
||||||
|
0 ignored issues
–
show
The type
SMWQuery was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 13 | |||||||
| 14 | /** |
||||||
| 15 | * @license GNU GPL v2+ |
||||||
| 16 | * @since 1.0 |
||||||
| 17 | * |
||||||
| 18 | * @author mwjames |
||||||
| 19 | */ |
||||||
| 20 | class ReferenceBacklinksLookup { |
||||||
| 21 | |||||||
| 22 | /** |
||||||
| 23 | * @var Store |
||||||
| 24 | */ |
||||||
| 25 | private $store; |
||||||
| 26 | |||||||
| 27 | /** |
||||||
| 28 | * @var integer |
||||||
| 29 | */ |
||||||
| 30 | private $limit = 20; |
||||||
| 31 | |||||||
| 32 | /** |
||||||
| 33 | * @var integer |
||||||
| 34 | */ |
||||||
| 35 | private $offset = 0; |
||||||
| 36 | |||||||
| 37 | /** |
||||||
| 38 | * @since 1.0 |
||||||
| 39 | * |
||||||
| 40 | * @param Store $store |
||||||
| 41 | */ |
||||||
| 42 | 19 | public function __construct( Store $store ) { |
|||||
| 43 | 19 | $this->store = $store; |
|||||
| 44 | 19 | } |
|||||
| 45 | |||||||
| 46 | /** |
||||||
| 47 | * @since 1.0 |
||||||
| 48 | * |
||||||
| 49 | * @param Store $store |
||||||
| 50 | */ |
||||||
| 51 | 15 | public function setStore( Store $store ) { |
|||||
| 52 | 15 | $this->store = $store; |
|||||
| 53 | 15 | } |
|||||
| 54 | |||||||
| 55 | /** |
||||||
| 56 | * @since 1.0 |
||||||
| 57 | * |
||||||
| 58 | * @param mixed|null $requestOptions |
||||||
| 59 | */ |
||||||
| 60 | 1 | public function setRequestOptions( $requestOptions = null ) { |
|||||
| 61 | |||||||
| 62 | 1 | if ( $requestOptions === null ) { |
|||||
| 63 | return; |
||||||
| 64 | } |
||||||
| 65 | |||||||
| 66 | 1 | $this->limit = $requestOptions->limit; |
|||||
| 67 | 1 | $this->offset = $requestOptions->offset; |
|||||
| 68 | 1 | } |
|||||
| 69 | |||||||
| 70 | /** |
||||||
| 71 | * @since 1.0 |
||||||
| 72 | * |
||||||
| 73 | * @param DIProperty $property |
||||||
| 74 | * @param DIWikiPage $subject |
||||||
| 75 | * @param string &$html |
||||||
| 76 | */ |
||||||
| 77 | 1 | public function getSpecialPropertySearchFurtherLink( DIProperty $property, DIWikiPage $subject, &$html ) { |
|||||
| 78 | |||||||
| 79 | 1 | if ( $property->getKey() !== PropertyRegistry::SCI_CITE_REFERENCE || ( $citationKey = $this->tryToFindCitationKeyFor( $subject ) ) === null ) { |
|||||
| 80 | return true; |
||||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | 1 | $html .= \Html::element( |
|||||
|
0 ignored issues
–
show
The type
Html was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 84 | 1 | 'a', |
|||||
| 85 | [ |
||||||
| 86 | 1 | 'href' => \SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL( [ |
|||||
|
0 ignored issues
–
show
The type
SpecialPage was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 87 | 1 | 'property' => $property->getLabel(), |
|||||
| 88 | 1 | 'value' => $citationKey->getString() |
|||||
| 89 | ] ) |
||||||
| 90 | ], |
||||||
| 91 | 1 | wfMessage( 'smw_browse_more' )->text() |
|||||
|
0 ignored issues
–
show
The function
wfMessage was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 92 | ); |
||||||
| 93 | |||||||
| 94 | 1 | return false; |
|||||
| 95 | } |
||||||
| 96 | |||||||
| 97 | /** |
||||||
| 98 | * Adds backlinks information to the SemanticData which is targeted towards |
||||||
| 99 | * the Special:Browse inproperties |
||||||
| 100 | * |
||||||
| 101 | * @since 1.0 |
||||||
| 102 | * |
||||||
| 103 | * @param SemanticData $semanticData |
||||||
| 104 | */ |
||||||
| 105 | 2 | public function addReferenceBacklinksTo( SemanticData $semanticData ) { |
|||||
| 106 | |||||||
| 107 | 2 | $key = $this->tryToFindCitationKeyFor( $semanticData->getSubject() ); |
|||||
| 108 | |||||||
| 109 | 2 | $property = new DIProperty( |
|||||
| 110 | 2 | PropertyRegistry::SCI_CITE_REFERENCE |
|||||
| 111 | ); |
||||||
| 112 | |||||||
| 113 | 2 | foreach ( $this->findReferenceBacklinksFor( $key ) as $subject ) { |
|||||
| 114 | 1 | $semanticData->addPropertyObjectValue( $property, $subject ); |
|||||
| 115 | } |
||||||
| 116 | 2 | } |
|||||
| 117 | |||||||
| 118 | /** |
||||||
| 119 | * @since 1.0 |
||||||
| 120 | * |
||||||
| 121 | * @param DIWikiPage $subject |
||||||
| 122 | * |
||||||
| 123 | * @return DIBlob|null |
||||||
|
0 ignored issues
–
show
The type
SCI\DIBlob was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 124 | */ |
||||||
| 125 | 4 | public function tryToFindCitationKeyFor( DIWikiPage $subject ) { |
|||||
| 126 | |||||||
| 127 | 4 | $keys = $this->store->getSemanticData( $subject )->getPropertyValues( |
|||||
| 128 | 4 | new DIProperty( PropertyRegistry::SCI_CITE_KEY ) |
|||||
| 129 | ); |
||||||
| 130 | |||||||
| 131 | // Not a resource that contains a citation key |
||||||
| 132 | 4 | if ( $keys === null || $keys === [] ) { |
|||||
| 133 | 1 | return null; |
|||||
| 134 | } |
||||||
| 135 | |||||||
| 136 | 3 | return end( $keys ); |
|||||
| 137 | } |
||||||
| 138 | |||||||
| 139 | /** |
||||||
| 140 | * @since 1.0 |
||||||
| 141 | * |
||||||
| 142 | * @param DIBlob|null |
||||||
| 143 | * |
||||||
| 144 | * @return DIWikiPage[] |
||||||
| 145 | */ |
||||||
| 146 | 2 | public function findReferenceBacklinksFor( $key = null ) { |
|||||
| 147 | |||||||
| 148 | 2 | if ( $key === null ) { |
|||||
| 149 | 1 | return []; |
|||||
| 150 | } |
||||||
| 151 | |||||||
| 152 | 1 | $property = new DIProperty( PropertyRegistry::SCI_CITE_REFERENCE ); |
|||||
| 153 | |||||||
| 154 | 1 | $description = new ValueDescription( |
|||||
| 155 | 1 | $key, |
|||||
| 156 | 1 | $property |
|||||
| 157 | ); |
||||||
| 158 | |||||||
| 159 | 1 | $someProperty = new SomeProperty( |
|||||
| 160 | 1 | $property, |
|||||
| 161 | 1 | $description |
|||||
| 162 | ); |
||||||
| 163 | |||||||
| 164 | 1 | $query = new Query( $someProperty ); |
|||||
| 165 | 1 | $query->setLimit( $this->limit ); |
|||||
| 166 | 1 | $query->setOffset( $this->offset ); |
|||||
| 167 | |||||||
| 168 | 1 | if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) { |
|||||
| 169 | 1 | $query->setOption( Query::PROC_CONTEXT, 'SCI.ReferenceBacklinksLookup' ); |
|||||
| 170 | } |
||||||
| 171 | |||||||
| 172 | 1 | return $this->store->getQueryResult( $query )->getResults(); |
|||||
| 173 | } |
||||||
| 174 | |||||||
| 175 | } |
||||||
| 176 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths