@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param Store $store |
| 40 | 40 | */ |
| 41 | - public function __construct( Store $store ) { |
|
| 41 | + public function __construct(Store $store) { |
|
| 42 | 42 | $this->store = $store; |
| 43 | 43 | $this->dataValueFactory = DataValueFactory::getInstance(); |
| 44 | 44 | } |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return array |
| 53 | 53 | */ |
| 54 | - public function findCitationResourceLinks( array $subjects, $linkClass = '', $caption = '' ) { |
|
| 54 | + public function findCitationResourceLinks(array $subjects, $linkClass = '', $caption = '') { |
|
| 55 | 55 | |
| 56 | 56 | $citationResourceLinks = []; |
| 57 | 57 | |
| 58 | - foreach ( $subjects as $subject ) { |
|
| 58 | + foreach ($subjects as $subject) { |
|
| 59 | 59 | |
| 60 | 60 | $dataValue = $this->dataValueFactory->newDataItemValue( |
| 61 | 61 | $subject, |
@@ -84,21 +84,21 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return array |
| 86 | 86 | */ |
| 87 | - public function findMatchForResourceIdentifierTypeToValue( $type, $id = null ) { |
|
| 87 | + public function findMatchForResourceIdentifierTypeToValue($type, $id = null) { |
|
| 88 | 88 | |
| 89 | - if ( $id === null || $id === '' ) { |
|
| 89 | + if ($id === null || $id === '') { |
|
| 90 | 90 | return []; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); |
| 94 | 94 | |
| 95 | - $resourceIdentifierStringValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( $type ); |
|
| 96 | - $resourceIdentifierStringValue->setUserValue( $id ); |
|
| 95 | + $resourceIdentifierStringValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType($type); |
|
| 96 | + $resourceIdentifierStringValue->setUserValue($id); |
|
| 97 | 97 | $id = $resourceIdentifierStringValue->getWikiValue(); |
| 98 | 98 | |
| 99 | 99 | $description = new SomeProperty( |
| 100 | 100 | $resourceIdentifierStringValue->getProperty(), |
| 101 | - new ValueDescription( new DIBlob( $id ) ) |
|
| 101 | + new ValueDescription(new DIBlob($id)) |
|
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | $query = new Query( |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | 110 | $query->querymode = Query::MODE_INSTANCES; |
| 111 | - $query->setLimit( 10 ); |
|
| 111 | + $query->setLimit(10); |
|
| 112 | 112 | |
| 113 | - if ( defined( 'SMWQuery::NO_CACHE' ) ) { |
|
| 114 | - $query->setOption( Query::NO_CACHE, true ); |
|
| 113 | + if (defined('SMWQuery::NO_CACHE')) { |
|
| 114 | + $query->setOption(Query::NO_CACHE, true); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) { |
|
| 118 | - $query->setOption( Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder' ); |
|
| 117 | + if (defined('SMWQuery::PROC_CONTEXT')) { |
|
| 118 | + $query->setOption(Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - return $this->store->getQueryResult( $query )->getResults(); |
|
| 121 | + return $this->store->getQueryResult($query)->getResults(); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * |
| 129 | 129 | * @return array |
| 130 | 130 | */ |
| 131 | - public function findCitationTextFor( $citationReference ) { |
|
| 131 | + public function findCitationTextFor($citationReference) { |
|
| 132 | 132 | |
| 133 | 133 | $text = ''; |
| 134 | 134 | $subjects = []; |
@@ -137,12 +137,12 @@ discard block |
||
| 137 | 137 | $citationReference |
| 138 | 138 | ); |
| 139 | 139 | |
| 140 | - if ( !$queryResult instanceof QueryResult ) { |
|
| 141 | - return [ $subjects, $text ]; |
|
| 140 | + if (!$queryResult instanceof QueryResult) { |
|
| 141 | + return [$subjects, $text]; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - while ( $resultArray = $queryResult->getNext() ) { |
|
| 145 | - foreach ( $resultArray as $result ) { |
|
| 144 | + while ($resultArray = $queryResult->getNext()) { |
|
| 145 | + foreach ($resultArray as $result) { |
|
| 146 | 146 | |
| 147 | 147 | // Collect all subjects for the same reference because it can happen |
| 148 | 148 | // that the same reference key is used for different citation |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | // text but return all subjects to make it easier to find them later |
| 151 | 151 | $subjects[] = $result->getResultSubject(); |
| 152 | 152 | |
| 153 | - while ( ( $dataValue = $result->getNextDataValue() ) !== false ) { |
|
| 153 | + while (($dataValue = $result->getNextDataValue()) !== false) { |
|
| 154 | 154 | $text = $dataValue->getShortWikiText(); |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - return [ $subjects, $text ]; |
|
| 159 | + return [$subjects, $text]; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return QueryResult |
| 170 | 170 | */ |
| 171 | - public function findMatchForCitationReference( $citationReference ) { |
|
| 171 | + public function findMatchForCitationReference($citationReference) { |
|
| 172 | 172 | |
| 173 | 173 | $description = new SomeProperty( |
| 174 | - new DIProperty( PropertyRegistry::SCI_CITE_KEY ), |
|
| 175 | - new ValueDescription( new DIBlob( $citationReference ) ) |
|
| 174 | + new DIProperty(PropertyRegistry::SCI_CITE_KEY), |
|
| 175 | + new ValueDescription(new DIBlob($citationReference)) |
|
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | - $propertyValue = $this->dataValueFactory->newDataValueByType( '__pro' ); |
|
| 178 | + $propertyValue = $this->dataValueFactory->newDataValueByType('__pro'); |
|
| 179 | 179 | $propertyValue->setDataItem( |
| 180 | - new DIProperty( PropertyRegistry::SCI_CITE_TEXT ) |
|
| 180 | + new DIProperty(PropertyRegistry::SCI_CITE_TEXT) |
|
| 181 | 181 | ); |
| 182 | 182 | |
| 183 | 183 | $description->addPrintRequest( |
| 184 | - new PrintRequest( PrintRequest::PRINT_PROP, null, $propertyValue ) |
|
| 184 | + new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue) |
|
| 185 | 185 | ); |
| 186 | 186 | |
| 187 | 187 | $query = new Query( |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | 193 | $query->querymode = Query::MODE_INSTANCES; |
| 194 | - $query->setLimit( 10 ); |
|
| 194 | + $query->setLimit(10); |
|
| 195 | 195 | |
| 196 | - if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) { |
|
| 197 | - $query->setOption( Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder' ); |
|
| 196 | + if (defined('SMWQuery::PROC_CONTEXT')) { |
|
| 197 | + $query->setOption(Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - return $this->store->getQueryResult( $query ); |
|
| 200 | + return $this->store->getQueryResult($query); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param Store $store |
| 42 | 42 | * @param ReferenceBacklinksLookup $referenceBacklinksLookup |
| 43 | 43 | */ |
| 44 | - public function __construct( Store $store, ReferenceBacklinksLookup $referenceBacklinksLookup ) { |
|
| 44 | + public function __construct(Store $store, ReferenceBacklinksLookup $referenceBacklinksLookup) { |
|
| 45 | 45 | $this->store = $store; |
| 46 | 46 | $this->referenceBacklinksLookup = $referenceBacklinksLookup; |
| 47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param boolean $enabledUpdateJobState |
| 53 | 53 | */ |
| 54 | - public function setEnabledUpdateJobState( $enabledUpdateJobState ) { |
|
| 54 | + public function setEnabledUpdateJobState($enabledUpdateJobState) { |
|
| 55 | 55 | $this->enabledUpdateJobState = $enabledUpdateJobState; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -63,21 +63,21 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return boolean |
| 65 | 65 | */ |
| 66 | - public function dispatchUpdateJobFor( DIWikiPage $subject, ChangeOp $changeOp ) { |
|
| 66 | + public function dispatchUpdateJobFor(DIWikiPage $subject, ChangeOp $changeOp) { |
|
| 67 | 67 | |
| 68 | - if ( !$this->enabledUpdateJobState ) { |
|
| 68 | + if (!$this->enabledUpdateJobState) { |
|
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $tableName = $this->store->getPropertyTableInfoFetcher()->findTableIdForProperty( |
| 73 | - new DIProperty( PropertyRegistry::SCI_CITE_TEXT ) |
|
| 73 | + new DIProperty(PropertyRegistry::SCI_CITE_TEXT) |
|
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | 76 | $subjectIdList = $this->getSubjectListFrom( |
| 77 | - $changeOp->getOrderedDiffByTable( $tableName ) |
|
| 77 | + $changeOp->getOrderedDiffByTable($tableName) |
|
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - if ( ( $jobList = $this->getDispatchableTargetList( $subjectIdList ) ) === [] ) { |
|
| 80 | + if (($jobList = $this->getDispatchableTargetList($subjectIdList)) === []) { |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -93,30 +93,30 @@ discard block |
||
| 93 | 93 | return true; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - private function getSubjectListFrom( array $orderedDiff ) { |
|
| 96 | + private function getSubjectListFrom(array $orderedDiff) { |
|
| 97 | 97 | |
| 98 | 98 | $subjectIdList = []; |
| 99 | 99 | |
| 100 | 100 | // Find out whether a cite text object was altered |
| 101 | - foreach ( $orderedDiff as $key => $value ) { |
|
| 101 | + foreach ($orderedDiff as $key => $value) { |
|
| 102 | 102 | |
| 103 | - if ( strpos( $key, 'sci_cite_text' ) === false ) { |
|
| 103 | + if (strpos($key, 'sci_cite_text') === false) { |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( !isset( $value['delete'] ) ) { |
|
| 107 | + if (!isset($value['delete'])) { |
|
| 108 | 108 | $value['delete'] = []; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - foreach ( $value['delete'] as $delete ) { |
|
| 111 | + foreach ($value['delete'] as $delete) { |
|
| 112 | 112 | $subjectIdList[] = $delete['s_id']; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( !isset( $value['insert'] ) ) { |
|
| 115 | + if (!isset($value['insert'])) { |
|
| 116 | 116 | $value['insert'] = []; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - foreach ( $value['insert'] as $insert ) { |
|
| 119 | + foreach ($value['insert'] as $insert) { |
|
| 120 | 120 | $subjectIdList[] = $insert['s_id']; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -124,25 +124,25 @@ discard block |
||
| 124 | 124 | return $subjectIdList; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - private function getDispatchableTargetList( array $subjectIdList ) { |
|
| 127 | + private function getDispatchableTargetList(array $subjectIdList) { |
|
| 128 | 128 | |
| 129 | - if ( $subjectIdList === [] ) { |
|
| 129 | + if ($subjectIdList === []) { |
|
| 130 | 130 | return []; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $hashList = $this->store->getObjectIds()->getDataItemPoolHashListFor( $subjectIdList ); |
|
| 133 | + $hashList = $this->store->getObjectIds()->getDataItemPoolHashListFor($subjectIdList); |
|
| 134 | 134 | $referenceBacklinks = []; |
| 135 | 135 | |
| 136 | - foreach ( $hashList as $hash ) { |
|
| 136 | + foreach ($hashList as $hash) { |
|
| 137 | 137 | $referenceBacklinks += $this->referenceBacklinksLookup->findReferenceBacklinksFor( |
| 138 | - $this->referenceBacklinksLookup->tryToFindCitationKeyFor( DIWikiPage::doUnserialize( $hash ) ) |
|
| 138 | + $this->referenceBacklinksLookup->tryToFindCitationKeyFor(DIWikiPage::doUnserialize($hash)) |
|
| 139 | 139 | ); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $targetBatch = []; |
| 143 | 143 | |
| 144 | - foreach ( $referenceBacklinks as $referenceBacklink ) { |
|
| 145 | - $targetBatch[HashBuilder::getHashIdForDiWikiPage( $referenceBacklink )] = true; |
|
| 144 | + foreach ($referenceBacklinks as $referenceBacklink) { |
|
| 145 | + $targetBatch[HashBuilder::getHashIdForDiWikiPage($referenceBacklink)] = true; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | return $targetBatch; |