@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | EntityIdLookup $entityIdLookup, |
40 | 40 | RdfVocabulary $rdfVocabulary |
41 | 41 | ) { |
42 | - parent::__construct( $page, $context ); |
|
42 | + parent::__construct($page, $context); |
|
43 | 43 | $this->resultsSource = $resultsSource; |
44 | 44 | $this->entityIdLookup = $entityIdLookup; |
45 | 45 | $this->rdfVocabulary = $rdfVocabulary; |
46 | 46 | } |
47 | 47 | |
48 | - public static function newFromGlobalState( Page $page, IContextSource $context ) { |
|
48 | + public static function newFromGlobalState(Page $page, IContextSource $context) { |
|
49 | 49 | $repo = WikibaseRepo::getDefaultInstance(); |
50 | 50 | |
51 | 51 | return new static( |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * @param string $guid |
93 | 93 | * @return string |
94 | 94 | */ |
95 | - private function cleanupGuid( $guid ) { |
|
96 | - return preg_replace( '/[^\w-]/', '-', $guid ); |
|
95 | + private function cleanupGuid($guid) { |
|
96 | + return preg_replace('/[^\w-]/', '-', $guid); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -105,60 +105,60 @@ discard block |
||
105 | 105 | $response = $this->getRequest()->response(); |
106 | 106 | $this->getOutput()->disable(); |
107 | 107 | |
108 | - if ( !$this->resultsSource instanceof CachingResultsSource ) { |
|
108 | + if (!$this->resultsSource instanceof CachingResultsSource) { |
|
109 | 109 | // TODO: make configurable whether only cached results are returned |
110 | - $response->statusHeader( 501 ); // Not Implemented |
|
110 | + $response->statusHeader(501); // Not Implemented |
|
111 | 111 | return null; |
112 | 112 | } |
113 | 113 | |
114 | - $entityId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() ); |
|
115 | - if ( $entityId === null ) { |
|
116 | - $response->statusHeader( 404 ); // Not Found |
|
114 | + $entityId = $this->entityIdLookup->getEntityIdForTitle($this->getTitle()); |
|
115 | + if ($entityId === null) { |
|
116 | + $response->statusHeader(404); // Not Found |
|
117 | 117 | return null; |
118 | 118 | } |
119 | - $revId = $this->getRequest()->getInt( 'revision' ); |
|
119 | + $revId = $this->getRequest()->getInt('revision'); |
|
120 | 120 | |
121 | - $results = $this->resultsSource->getStoredResults( $entityId, $revId ); |
|
122 | - if ( $results === null ) { |
|
123 | - $response->statusHeader( 204 ); // No Content |
|
121 | + $results = $this->resultsSource->getStoredResults($entityId, $revId); |
|
122 | + if ($results === null) { |
|
123 | + $response->statusHeader(204); // No Content |
|
124 | 124 | return null; |
125 | 125 | } |
126 | 126 | |
127 | 127 | $format = 'ttl'; // TODO: make format an option |
128 | 128 | |
129 | 129 | $writerFactory = new RdfWriterFactory(); |
130 | - $formatName = $writerFactory->getFormatName( $format ); |
|
131 | - $contentType = $writerFactory->getMimeTypes( $formatName )[0]; |
|
130 | + $formatName = $writerFactory->getFormatName($format); |
|
131 | + $contentType = $writerFactory->getMimeTypes($formatName)[0]; |
|
132 | 132 | |
133 | - $writer = $writerFactory->getWriter( $formatName ); |
|
134 | - foreach ( [ RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY ] as $ns ) { |
|
135 | - $writer->prefix( $ns, $this->rdfVocabulary->getNamespaceURI( $ns ) ); |
|
133 | + $writer = $writerFactory->getWriter($formatName); |
|
134 | + foreach ([RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY] as $ns) { |
|
135 | + $writer->prefix($ns, $this->rdfVocabulary->getNamespaceURI($ns)); |
|
136 | 136 | } |
137 | 137 | $writer->start(); |
138 | 138 | $writtenAny = false; |
139 | 139 | |
140 | - foreach ( $results->getArray() as $checkResult ) { |
|
141 | - if ( $checkResult instanceof NullResult ) { |
|
140 | + foreach ($results->getArray() as $checkResult) { |
|
141 | + if ($checkResult instanceof NullResult) { |
|
142 | 142 | continue; |
143 | 143 | } |
144 | - if ( $checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS ) { |
|
144 | + if ($checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS) { |
|
145 | 145 | continue; |
146 | 146 | } |
147 | 147 | $writtenAny = true; |
148 | - $writer->about( RdfVocabulary::NS_STATEMENT, |
|
149 | - $this->cleanupGuid( $checkResult->getContextCursor()->getStatementGuid() ) ) |
|
150 | - ->say( RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint' ) |
|
151 | - ->is( RdfVocabulary::NS_STATEMENT, |
|
152 | - $this->cleanupGuid( $checkResult->getConstraint()->getConstraintId() ) ); |
|
148 | + $writer->about(RdfVocabulary::NS_STATEMENT, |
|
149 | + $this->cleanupGuid($checkResult->getContextCursor()->getStatementGuid())) |
|
150 | + ->say(RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint') |
|
151 | + ->is(RdfVocabulary::NS_STATEMENT, |
|
152 | + $this->cleanupGuid($checkResult->getConstraint()->getConstraintId())); |
|
153 | 153 | } |
154 | 154 | $writer->finish(); |
155 | - if ( $writtenAny ) { |
|
156 | - $response->header( "Content-Type: $contentType; charset=UTF-8" ); |
|
155 | + if ($writtenAny) { |
|
156 | + $response->header("Content-Type: $contentType; charset=UTF-8"); |
|
157 | 157 | echo $writer->drain(); |
158 | 158 | } else { |
159 | 159 | // Do not output RDF if we haven't written any actual statements. Output 204 instead |
160 | 160 | $writer->drain(); |
161 | - $response->statusHeader( 204 ); // No Content |
|
161 | + $response->statusHeader(204); // No Content |
|
162 | 162 | } |
163 | 163 | return null; |
164 | 164 | } |