@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | /** |
| 42 | 42 | * @param string $typeid |
| 43 | 43 | */ |
| 44 | - public function __construct( $typeid = '' ) { |
|
| 45 | - parent::__construct( '_sci_ref' ); |
|
| 44 | + public function __construct($typeid = '') { |
|
| 45 | + parent::__construct('_sci_ref'); |
|
| 46 | 46 | |
| 47 | 47 | // Currently there is no good way to inject the setting |
| 48 | 48 | $this->captionFormat = $GLOBALS['scigCitationReferenceCaptionFormat']; |
@@ -53,42 +53,42 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @param integer $captionFormat |
| 55 | 55 | */ |
| 56 | - public function setCaptionFormat( $captionFormat ) { |
|
| 56 | + public function setCaptionFormat($captionFormat) { |
|
| 57 | 57 | $this->captionFormat = $captionFormat; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @see StringValue::parseUserValue |
| 62 | 62 | */ |
| 63 | - protected function parseUserValue( $value ) { |
|
| 63 | + protected function parseUserValue($value) { |
|
| 64 | 64 | |
| 65 | - if ( method_exists( $this, 'getCallable' ) ) { |
|
| 66 | - $citationReferencePositionJournal = $this->getCallable( 'sci.citationreferencepositionjournal' ); |
|
| 65 | + if (method_exists($this, 'getCallable')) { |
|
| 66 | + $citationReferencePositionJournal = $this->getCallable('sci.citationreferencepositionjournal'); |
|
| 67 | 67 | $this->citationReferencePositionJournal = $citationReferencePositionJournal(); |
| 68 | 68 | } else { |
| 69 | - $this->citationReferencePositionJournal = $this->getExtraneousFunctionFor( '\SCI\CitationReferencePositionJournal' ); |
|
| 69 | + $this->citationReferencePositionJournal = $this->getExtraneousFunctionFor('\SCI\CitationReferencePositionJournal'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $value = trim( $value ); |
|
| 72 | + $value = trim($value); |
|
| 73 | 73 | |
| 74 | - if ( $value === '' ) { |
|
| 75 | - $this->addError( wfMessage( 'sci-datavalue-empty-reference' )->inContentLanguage()->text() ); |
|
| 76 | - $this->m_dataitem = new DIBlob( 'ERROR' ); |
|
| 74 | + if ($value === '') { |
|
| 75 | + $this->addError(wfMessage('sci-datavalue-empty-reference')->inContentLanguage()->text()); |
|
| 76 | + $this->m_dataitem = new DIBlob('ERROR'); |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if ( $this->m_contextPage === null ) { |
|
| 81 | - parent::parseUserValue( $value ); |
|
| 80 | + if ($this->m_contextPage === null) { |
|
| 81 | + parent::parseUserValue($value); |
|
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $this->reference = $value; |
| 86 | 86 | |
| 87 | - if ( $this->m_caption && $this->captionFormat === SCI_CITEREF_NUM ) { |
|
| 87 | + if ($this->m_caption && $this->captionFormat === SCI_CITEREF_NUM) { |
|
| 88 | 88 | $this->usesShortFormCaption = true; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if ( !$this->m_caption ) { |
|
| 91 | + if (!$this->m_caption) { |
|
| 92 | 92 | $this->m_caption = $this->reference; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -99,20 +99,20 @@ discard block |
||
| 99 | 99 | $this->reference |
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - parent::parseUserValue( $this->reference ); |
|
| 102 | + parent::parseUserValue($this->reference); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * @see StringValue::parseUserValue |
| 107 | 107 | */ |
| 108 | - public function getShortWikiText( $linked = null ) { |
|
| 108 | + public function getShortWikiText($linked = null) { |
|
| 109 | 109 | |
| 110 | - if ( $this->citationReferencePositionJournal === null ) { |
|
| 111 | - if ( method_exists( $this, 'getCallable' ) ) { |
|
| 112 | - $citationReferencePositionJournal = $this->getCallable( 'sci.citationreferencepositionjournal' ); |
|
| 110 | + if ($this->citationReferencePositionJournal === null) { |
|
| 111 | + if (method_exists($this, 'getCallable')) { |
|
| 112 | + $citationReferencePositionJournal = $this->getCallable('sci.citationreferencepositionjournal'); |
|
| 113 | 113 | $this->citationReferencePositionJournal = $citationReferencePositionJournal(); |
| 114 | 114 | } else { |
| 115 | - $this->citationReferencePositionJournal = $this->getExtraneousFunctionFor( '\SCI\CitationReferencePositionJournal' ); |
|
| 115 | + $this->citationReferencePositionJournal = $this->getExtraneousFunctionFor('\SCI\CitationReferencePositionJournal'); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | $this->reference |
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - if ( $referencePosition === null || $this->m_caption === false ) { |
|
| 126 | + if ($referencePosition === null || $this->m_caption === false) { |
|
| 127 | 127 | return ''; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $referenceHash = md5( $this->reference ); |
|
| 130 | + $referenceHash = md5($this->reference); |
|
| 131 | 131 | |
| 132 | - if ( $this->captionFormat === SCI_CITEREF_NUM ) { |
|
| 133 | - list( $major, $minor ) = explode( '-', $referencePosition ); |
|
| 132 | + if ($this->captionFormat === SCI_CITEREF_NUM) { |
|
| 133 | + list($major, $minor) = explode('-', $referencePosition); |
|
| 134 | 134 | $caption = $major; |
| 135 | 135 | $captionClass = 'number'; |
| 136 | 136 | |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | $shortFormCaption = ''; // Never has a short form |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if ( $shortFormCaption !== '' ) { |
|
| 145 | + if ($shortFormCaption !== '') { |
|
| 146 | 146 | $shortFormCaption = Html::rawElement( |
| 147 | 147 | 'span', |
| 148 | - [ 'class' => 'scite-citeref-shortcaption' ], |
|
| 148 | + ['class' => 'scite-citeref-shortcaption'], |
|
| 149 | 149 | $shortFormCaption |
| 150 | 150 | ); |
| 151 | 151 | } |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | $html = Html::rawElement( |
| 155 | 155 | 'span', |
| 156 | 156 | [ |
| 157 | - 'id' => 'scite-ref-'. $referenceHash . '-' . $referencePosition, |
|
| 157 | + 'id' => 'scite-ref-' . $referenceHash . '-' . $referencePosition, |
|
| 158 | 158 | 'class' => 'scite-citeref-' . $captionClass, |
| 159 | 159 | 'data-reference' => $this->reference |
| 160 | 160 | ], |
| 161 | - '[[' .'#scite-' . $referenceHash . '|' . $caption . ']]' |
|
| 161 | + '[[' . '#scite-' . $referenceHash . '|' . $caption . ']]' |
|
| 162 | 162 | ) . $shortFormCaption; |
| 163 | 163 | |
| 164 | 164 | return $html; |
@@ -22,46 +22,46 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @param string $typeid |
| 24 | 24 | */ |
| 25 | - public function __construct( $typeid = '' ) { |
|
| 26 | - parent::__construct( $typeid ); |
|
| 27 | - $this->resourceIdentifierStringValueParser = new ResourceIdentifierStringValueParser( $typeid ); |
|
| 25 | + public function __construct($typeid = '') { |
|
| 26 | + parent::__construct($typeid); |
|
| 27 | + $this->resourceIdentifierStringValueParser = new ResourceIdentifierStringValueParser($typeid); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @see StringValue::parseUserValue |
| 32 | 32 | */ |
| 33 | - protected function parseUserValue( $value ) { |
|
| 33 | + protected function parseUserValue($value) { |
|
| 34 | 34 | |
| 35 | 35 | $inputValue = $value; |
| 36 | 36 | // $this->m_caption = $value; |
| 37 | 37 | |
| 38 | - if ( !$this->resourceIdentifierStringValueParser->parse( $value ) ) { |
|
| 39 | - $this->addError( wfMessage( 'sci-datavalue-invalid-id-value', $inputValue, $this->resourceIdentifierStringValueParser->getCanonicalName() )->inContentLanguage()->escaped() ); |
|
| 40 | - $this->m_dataitem = new DIBlob( 'ERROR' ); |
|
| 38 | + if (!$this->resourceIdentifierStringValueParser->parse($value)) { |
|
| 39 | + $this->addError(wfMessage('sci-datavalue-invalid-id-value', $inputValue, $this->resourceIdentifierStringValueParser->getCanonicalName())->inContentLanguage()->escaped()); |
|
| 40 | + $this->m_dataitem = new DIBlob('ERROR'); |
|
| 41 | 41 | return; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - parent::parseUserValue( $value ); |
|
| 44 | + parent::parseUserValue($value); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @see StringValue::getShortWikiText |
| 49 | 49 | */ |
| 50 | - public function getShortWikiText( $linker = null ) { |
|
| 50 | + public function getShortWikiText($linker = null) { |
|
| 51 | 51 | |
| 52 | - if ( !$this->isValid() ) { |
|
| 52 | + if (!$this->isValid()) { |
|
| 53 | 53 | return ''; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( !$this->m_caption ) { |
|
| 56 | + if (!$this->m_caption) { |
|
| 57 | 57 | $this->m_caption = $this->m_dataitem->getString(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ( $preferredCaption = $this->getPreferredCaption() ) { |
|
| 60 | + if ($preferredCaption = $this->getPreferredCaption()) { |
|
| 61 | 61 | return $preferredCaption; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if ( $linker === null ) { |
|
| 64 | + if ($linker === null) { |
|
| 65 | 65 | return $this->m_caption; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -70,35 +70,35 @@ discard block |
||
| 70 | 70 | [ |
| 71 | 71 | 'class' => 'plainlinks' |
| 72 | 72 | ], |
| 73 | - '[' . $this->getTargetLink( urlencode( $this->m_caption ) ) . ' ' . $this->m_caption .']' |
|
| 73 | + '[' . $this->getTargetLink(urlencode($this->m_caption)) . ' ' . $this->m_caption . ']' |
|
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * @see StringValue::getShortHTMLText |
| 79 | 79 | */ |
| 80 | - public function getShortHTMLText( $linker = null ) { |
|
| 80 | + public function getShortHTMLText($linker = null) { |
|
| 81 | 81 | |
| 82 | - if ( !$this->isValid() ) { |
|
| 82 | + if (!$this->isValid()) { |
|
| 83 | 83 | return ''; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( !$this->m_caption ) { |
|
| 86 | + if (!$this->m_caption) { |
|
| 87 | 87 | $this->m_caption = $this->m_dataitem->getString(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( $preferredCaption = $this->getPreferredCaption() ) { |
|
| 90 | + if ($preferredCaption = $this->getPreferredCaption()) { |
|
| 91 | 91 | return $preferredCaption; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( $linker === null ) { |
|
| 94 | + if ($linker === null) { |
|
| 95 | 95 | return $this->m_caption; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return Html::rawElement( |
| 99 | 99 | 'a', |
| 100 | 100 | [ |
| 101 | - 'href' => $this->getTargetLink( $this->m_caption ), |
|
| 101 | + 'href' => $this->getTargetLink($this->m_caption), |
|
| 102 | 102 | 'target' => '_blank' |
| 103 | 103 | ], |
| 104 | 104 | $this->m_caption |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | /** |
| 109 | 109 | * @see StringValue::getLongWikiText |
| 110 | 110 | */ |
| 111 | - public function getLongWikiText( $linked = null ) { |
|
| 112 | - return $this->getShortWikiText( $linked ); |
|
| 111 | + public function getLongWikiText($linked = null) { |
|
| 112 | + return $this->getShortWikiText($linked); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @see StringValue::getLongHTMLText |
| 117 | 117 | */ |
| 118 | - public function getLongHTMLText( $linker = null ) { |
|
| 119 | - return $this->getShortHTMLText( $linker ); |
|
| 118 | + public function getLongHTMLText($linker = null) { |
|
| 119 | + return $this->getShortHTMLText($linker); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -124,14 +124,14 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function getPreferredCaption() { |
| 126 | 126 | |
| 127 | - if ( $this->m_outformat == '-' ) { |
|
| 127 | + if ($this->m_outformat == '-') { |
|
| 128 | 128 | return $this->m_caption; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return false; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - private function getTargetLink( $target ) { |
|
| 134 | + private function getTargetLink($target) { |
|
| 135 | 135 | return $this->resourceIdentifierStringValueParser->getResourceTargetUri() . $target; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -23,36 +23,36 @@ |
||
| 23 | 23 | * @return ResourceIdentifierStringValue |
| 24 | 24 | * @throws RuntimeException |
| 25 | 25 | */ |
| 26 | - public function newResourceIdentifierStringValueForType( $type ) { |
|
| 26 | + public function newResourceIdentifierStringValueForType($type) { |
|
| 27 | 27 | |
| 28 | 28 | $propertyRegistry = PropertyRegistry::getInstance(); |
| 29 | 29 | $property = null; |
| 30 | 30 | |
| 31 | - switch ( strtoupper( $type ) ) { |
|
| 31 | + switch (strtoupper($type)) { |
|
| 32 | 32 | case 'OCLC': |
| 33 | 33 | case 'VIAF': |
| 34 | 34 | case 'DOI': |
| 35 | 35 | case 'OLID': |
| 36 | - $property = $propertyRegistry->findPropertyIdByLabel( $type ); |
|
| 36 | + $property = $propertyRegistry->findPropertyIdByLabel($type); |
|
| 37 | 37 | break; |
| 38 | 38 | case 'PUBMED': |
| 39 | 39 | case 'PMID': |
| 40 | - $property = $propertyRegistry->findPropertyIdByLabel( 'PMID' ); |
|
| 40 | + $property = $propertyRegistry->findPropertyIdByLabel('PMID'); |
|
| 41 | 41 | break; |
| 42 | 42 | case 'PMC': |
| 43 | 43 | case 'PMCID': |
| 44 | - $property = $propertyRegistry->findPropertyIdByLabel( 'PMCID' ); |
|
| 44 | + $property = $propertyRegistry->findPropertyIdByLabel('PMCID'); |
|
| 45 | 45 | break; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $typeId = $propertyRegistry->getPropertyTypeId( $property ); |
|
| 48 | + $typeId = $propertyRegistry->getPropertyTypeId($property); |
|
| 49 | 49 | |
| 50 | - if ( $typeId === null || $typeId === '' ) { |
|
| 51 | - throw new RuntimeException( "{$type} is an unmatched type for ResourceIdentifierStringValue" ); |
|
| 50 | + if ($typeId === null || $typeId === '') { |
|
| 51 | + throw new RuntimeException("{$type} is an unmatched type for ResourceIdentifierStringValue"); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $resourceIdentifierStringValue = DataValueFactory::getInstance()->newDataValueByType( $typeId ); |
|
| 55 | - $resourceIdentifierStringValue->setProperty( new DIProperty( $property ) ); |
|
| 54 | + $resourceIdentifierStringValue = DataValueFactory::getInstance()->newDataValueByType($typeId); |
|
| 55 | + $resourceIdentifierStringValue->setProperty(new DIProperty($property)); |
|
| 56 | 56 | |
| 57 | 57 | return $resourceIdentifierStringValue; |
| 58 | 58 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @param string $typeid |
| 20 | 20 | */ |
| 21 | - public function __construct( $typeid ) { |
|
| 21 | + public function __construct($typeid) { |
|
| 22 | 22 | $this->typeid = $typeid; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -27,16 +27,16 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return true |
| 29 | 29 | */ |
| 30 | - public function parse( &$value ) { |
|
| 30 | + public function parse(&$value) { |
|
| 31 | 31 | |
| 32 | 32 | // Remove a possible url-prefix |
| 33 | 33 | |
| 34 | - if ( $this->typeid === '_sci_doi' ) { |
|
| 34 | + if ($this->typeid === '_sci_doi') { |
|
| 35 | 35 | // Remove anything before 10 as in http://dx.doi.org/10.1000/123 |
| 36 | - $value = substr( $value, strcspn( $value, '10' ) ); |
|
| 37 | - } elseif ( strrpos( $value, '://' ) !== false ) { |
|
| 36 | + $value = substr($value, strcspn($value, '10')); |
|
| 37 | + } elseif (strrpos($value, '://') !== false) { |
|
| 38 | 38 | // Remove anything before the last / as in http://foo/bar123 |
| 39 | - $value = substr( $value, strrpos( $value, '/' ) + 1 ); |
|
| 39 | + $value = substr($value, strrpos($value, '/') + 1); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Remove other possible prefixes |
@@ -45,13 +45,13 @@ discard block |
||
| 45 | 45 | // All DOI names are converted to upper case upon registration |
| 46 | 46 | // but since it system is case insensitive, we store it as lower |
| 47 | 47 | // case as it "looks" better |
| 48 | - if ( $this->typeid === '_sci_doi' ) { |
|
| 49 | - $value = strtolower( $value ); |
|
| 48 | + if ($this->typeid === '_sci_doi') { |
|
| 49 | + $value = strtolower($value); |
|
| 50 | 50 | } else { |
| 51 | - $value = str_replace( [ 'VIAF', 'OCLC', 'PMID' ], '', strtoupper( $value ) ); |
|
| 51 | + $value = str_replace(['VIAF', 'OCLC', 'PMID'], '', strtoupper($value)); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - return $this->canMatchValueToPattern( $value ); |
|
| 54 | + return $this->canMatchValueToPattern($value); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function getCanonicalName() { |
| 61 | 61 | |
| 62 | - switch ( $this->typeid ) { |
|
| 62 | + switch ($this->typeid) { |
|
| 63 | 63 | case '_sci_viaf': |
| 64 | 64 | return 'VIAF'; |
| 65 | 65 | case '_sci_oclc': |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function getResourceTargetUri() { |
| 84 | 84 | |
| 85 | - switch ( $this->typeid ) { |
|
| 85 | + switch ($this->typeid) { |
|
| 86 | 86 | case '_sci_viaf': |
| 87 | 87 | // http://www.oclc.org/research/activities/viaf.html |
| 88 | 88 | // http://id.loc.gov/vocabulary/identifiers/viaf.html |
@@ -103,20 +103,20 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - private function canMatchValueToPattern( &$value ) { |
|
| 106 | + private function canMatchValueToPattern(&$value) { |
|
| 107 | 107 | |
| 108 | - switch ( $this->typeid ) { |
|
| 108 | + switch ($this->typeid) { |
|
| 109 | 109 | case '_sci_viaf': |
| 110 | 110 | case '_sci_oclc': |
| 111 | 111 | case '_sci_pmid': |
| 112 | - return preg_match( "/^[0-9]*$/", $value ); |
|
| 112 | + return preg_match("/^[0-9]*$/", $value); |
|
| 113 | 113 | case '_sci_pmcid': |
| 114 | - return preg_match( "/PMC[\d]+/", $value ); |
|
| 114 | + return preg_match("/PMC[\d]+/", $value); |
|
| 115 | 115 | case '_sci_olid': |
| 116 | - return preg_match( "/OL[A-Z0-9]+/", $value ); |
|
| 116 | + return preg_match("/OL[A-Z0-9]+/", $value); |
|
| 117 | 117 | case '_sci_doi': |
| 118 | 118 | // http://stackoverflow.com/questions/27910/finding-a-doi-in-a-document-or-page# |
| 119 | - return preg_match( "/\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?![\"&\'])\S)+)\b/", $value ); |
|
| 119 | + return preg_match("/\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?![\"&\'])\S)+)\b/", $value); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | return false; |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return string |
| 20 | 20 | */ |
| 21 | - public function getFormattedSciteFuncFrom( array $parameters ) { |
|
| 22 | - return "<pre>{{#scite:\n" . implode( "\n", $this->format( $parameters ) ) ."\n}}</pre>"; |
|
| 21 | + public function getFormattedSciteFuncFrom(array $parameters) { |
|
| 22 | + return "<pre>{{#scite:\n" . implode("\n", $this->format($parameters)) . "\n}}</pre>"; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -27,18 +27,18 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return array |
| 29 | 29 | */ |
| 30 | - public function format( array $parameters ) { |
|
| 30 | + public function format(array $parameters) { |
|
| 31 | 31 | |
| 32 | 32 | $formatted = []; |
| 33 | 33 | |
| 34 | - foreach ( $parameters as $key => $value ) { |
|
| 34 | + foreach ($parameters as $key => $value) { |
|
| 35 | 35 | |
| 36 | - if ( $value === '' || $value[0] === '@' ) { |
|
| 36 | + if ($value === '' || $value[0] === '@') { |
|
| 37 | 37 | continue; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if ( $value[0] === '+' ) { |
|
| 41 | - $formatted[$key-1] = $formatted[$key-1] . '|' . $value; |
|
| 40 | + if ($value[0] === '+') { |
|
| 41 | + $formatted[$key - 1] = $formatted[$key - 1] . '|' . $value; |
|
| 42 | 42 | continue; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param Cache $cache |
| 37 | 37 | * @param CacheKeyProvider $cacheKeyProvider |
| 38 | 38 | */ |
| 39 | - public function __construct( Cache $cache, CacheKeyProvider $cacheKeyProvider ) { |
|
| 39 | + public function __construct(Cache $cache, CacheKeyProvider $cacheKeyProvider) { |
|
| 40 | 40 | $this->cache = $cache; |
| 41 | 41 | $this->cacheKeyProvider = $cacheKeyProvider; |
| 42 | 42 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return boolean |
| 50 | 50 | */ |
| 51 | - public function hasCitationReference( SemanticData $semanticData ) { |
|
| 52 | - return $semanticData->getPropertyValues( new DIProperty( PropertyRegistry::SCI_CITE_REFERENCE ) ) !== []; |
|
| 51 | + public function hasCitationReference(SemanticData $semanticData) { |
|
| 52 | + return $semanticData->getPropertyValues(new DIProperty(PropertyRegistry::SCI_CITE_REFERENCE)) !== []; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return array|null |
| 61 | 61 | */ |
| 62 | - public function getJournalBySubject( DIWikiPage $subject ) { |
|
| 63 | - return $this->hasJournalForHash( $subject->getHash() ) ? self::$citationReferenceJournal[$subject->getHash()] : null; |
|
| 62 | + public function getJournalBySubject(DIWikiPage $subject) { |
|
| 63 | + return $this->hasJournalForHash($subject->getHash()) ? self::$citationReferenceJournal[$subject->getHash()] : null; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return array|null |
| 76 | 76 | */ |
| 77 | - public function buildJournalForUnboundReferenceList( array $referenceList ) { |
|
| 77 | + public function buildJournalForUnboundReferenceList(array $referenceList) { |
|
| 78 | 78 | |
| 79 | - if ( $referenceList === [] ) { |
|
| 79 | + if ($referenceList === []) { |
|
| 80 | 80 | return null; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | 'reference-pos' => [] |
| 87 | 87 | ]; |
| 88 | 88 | |
| 89 | - $journal['total'] = count( $referenceList ); |
|
| 89 | + $journal['total'] = count($referenceList); |
|
| 90 | 90 | |
| 91 | - foreach ( $referenceList as $reference ) { |
|
| 91 | + foreach ($referenceList as $reference) { |
|
| 92 | 92 | $journal['reference-pos'][$reference] = []; |
| 93 | 93 | $journal['reference-list'][$reference] = $reference; |
| 94 | 94 | } |
@@ -104,22 +104,22 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return string|null |
| 106 | 106 | */ |
| 107 | - public function findLastReferencePositionEntryFor( DIWikiPage $subject = null, $reference ) { |
|
| 107 | + public function findLastReferencePositionEntryFor(DIWikiPage $subject = null, $reference) { |
|
| 108 | 108 | |
| 109 | - if ( $subject === null ) { |
|
| 109 | + if ($subject === null) { |
|
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $referenceHash = md5( $reference ); |
|
| 113 | + $referenceHash = md5($reference); |
|
| 114 | 114 | $hash = $subject->getHash(); |
| 115 | 115 | |
| 116 | 116 | // Tracks the current parser run invoked by the InTextAnnotationParser |
| 117 | 117 | $uniqid = $subject->getContextReference(); |
| 118 | 118 | |
| 119 | - if ( $this->hasJournalForHash( $hash ) && |
|
| 119 | + if ($this->hasJournalForHash($hash) && |
|
| 120 | 120 | self::$citationReferenceJournal[$hash]['uniqid'] === $uniqid && |
| 121 | - isset( self::$citationReferenceJournal[$hash]['reference-pos'][$referenceHash] ) ) { |
|
| 122 | - return end( self::$citationReferenceJournal[$hash]['reference-pos'][$referenceHash] ); |
|
| 121 | + isset(self::$citationReferenceJournal[$hash]['reference-pos'][$referenceHash])) { |
|
| 122 | + return end(self::$citationReferenceJournal[$hash]['reference-pos'][$referenceHash]); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return null; |
@@ -131,19 +131,19 @@ discard block |
||
| 131 | 131 | * @param DIWikiPage|null $subject |
| 132 | 132 | * @param string $reference |
| 133 | 133 | */ |
| 134 | - public function addJournalEntryFor( DIWikiPage $subject = null, $reference ) { |
|
| 134 | + public function addJournalEntryFor(DIWikiPage $subject = null, $reference) { |
|
| 135 | 135 | |
| 136 | - if ( $subject === null ) { |
|
| 136 | + if ($subject === null) { |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $referenceHash = md5( $reference ); |
|
| 140 | + $referenceHash = md5($reference); |
|
| 141 | 141 | $hash = $subject->getHash(); |
| 142 | 142 | |
| 143 | 143 | // Tracks the current parser run invoked by the InTextAnnotationParser |
| 144 | 144 | $uniqid = $subject->getContextReference(); |
| 145 | 145 | |
| 146 | - if ( !$this->hasJournalForHash( $hash ) || self::$citationReferenceJournal[$hash]['uniqid'] !== $uniqid ) { |
|
| 146 | + if (!$this->hasJournalForHash($hash) || self::$citationReferenceJournal[$hash]['uniqid'] !== $uniqid) { |
|
| 147 | 147 | $journal = [ |
| 148 | 148 | 'uniqid' => $uniqid, |
| 149 | 149 | 'total' => 0, |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | // New reference, increase the total of existing citations for this |
| 162 | 162 | // subject and set the position level to 'a' |
| 163 | - if ( !isset( $journal['reference-pos'][$referenceHash] ) || $journal['reference-pos'][$referenceHash] === [] ) { |
|
| 163 | + if (!isset($journal['reference-pos'][$referenceHash]) || $journal['reference-pos'][$referenceHash] === []) { |
|
| 164 | 164 | $journal['total']++; |
| 165 | 165 | $journal['reference-pos'][$referenceHash][] = $journal['total'] . '-' . 'a'; |
| 166 | 166 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | // The exact position is specified by something like |
| 174 | 174 | // like 57d0dc056f9e5d5c6cfc77fc27091f60-1-a and to be used within |
| 175 | 175 | // html as link anchor |
| 176 | - list( $major, $minor ) = explode( '-', end( $journal['reference-pos'][$referenceHash] ) ); |
|
| 176 | + list($major, $minor) = explode('-', end($journal['reference-pos'][$referenceHash])); |
|
| 177 | 177 | $journal['reference-pos'][$referenceHash][] = $major . '-' . ++$minor; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -182,20 +182,20 @@ discard block |
||
| 182 | 182 | // Safeguard against a repeated call to the hashlist for when the static |
| 183 | 183 | // cache is empty |
| 184 | 184 | $this->cache->save( |
| 185 | - $this->cacheKeyProvider->getCacheKeyForCitationReference( $hash ), |
|
| 185 | + $this->cacheKeyProvider->getCacheKeyForCitationReference($hash), |
|
| 186 | 186 | self::$citationReferenceJournal |
| 187 | 187 | ); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - private function hasJournalForHash( $hash ) { |
|
| 190 | + private function hasJournalForHash($hash) { |
|
| 191 | 191 | |
| 192 | - if ( self::$citationReferenceJournal === [] ) { |
|
| 192 | + if (self::$citationReferenceJournal === []) { |
|
| 193 | 193 | self::$citationReferenceJournal = $this->cache->fetch( |
| 194 | - $this->cacheKeyProvider->getCacheKeyForCitationReference( $hash ) |
|
| 194 | + $this->cacheKeyProvider->getCacheKeyForCitationReference($hash) |
|
| 195 | 195 | ); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - return isset( self::$citationReferenceJournal[$hash] ); |
|
| 198 | + return isset(self::$citationReferenceJournal[$hash]); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * @since 1.0 |
| 22 | 22 | */ |
| 23 | - public function __construct( array $options = [] ) { |
|
| 23 | + public function __construct(array $options = []) { |
|
| 24 | 24 | $this->options = $options; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string $key |
| 31 | 31 | * @param mixed $value |
| 32 | 32 | */ |
| 33 | - public function set( $key, $value ) { |
|
| 33 | + public function set($key, $value) { |
|
| 34 | 34 | $this->options[$key] = $value; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return boolean |
| 43 | 43 | */ |
| 44 | - public function has( $key ) { |
|
| 45 | - return isset( $this->options[$key] ) || array_key_exists( $key, $this->options ); |
|
| 44 | + public function has($key) { |
|
| 45 | + return isset($this->options[$key]) || array_key_exists($key, $this->options); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -53,13 +53,13 @@ discard block |
||
| 53 | 53 | * @return string |
| 54 | 54 | * @throws InvalidArgumentException |
| 55 | 55 | */ |
| 56 | - public function get( $key ) { |
|
| 56 | + public function get($key) { |
|
| 57 | 57 | |
| 58 | - if ( $this->has( $key ) ) { |
|
| 58 | + if ($this->has($key)) { |
|
| 59 | 59 | return $this->options[$key]; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - throw new InvalidArgumentException( "{$key} is an unregistered option" ); |
|
| 62 | + throw new InvalidArgumentException("{$key} is an unregistered option"); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param OLFilteredHttpResponseParser $olFilteredHttpResponseParser |
| 26 | 26 | */ |
| 27 | - public function __construct( OLFilteredHttpResponseParser $olFilteredHttpResponseParser ) { |
|
| 27 | + public function __construct(OLFilteredHttpResponseParser $olFilteredHttpResponseParser) { |
|
| 28 | 28 | $this->olFilteredHttpResponseParser = $olFilteredHttpResponseParser; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * {@inheritDoc} |
| 62 | 62 | */ |
| 63 | - public function getRawResponse( $id ) { |
|
| 64 | - return $this->olFilteredHttpResponseParser->getRawResponse( $id ); |
|
| 63 | + public function getRawResponse($id) { |
|
| 64 | + return $this->olFilteredHttpResponseParser->getRawResponse($id); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -69,39 +69,39 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * {@inheritDoc} |
| 71 | 71 | */ |
| 72 | - public function doFilterResponseFor( $olID ) { |
|
| 72 | + public function doFilterResponseFor($olID) { |
|
| 73 | 73 | |
| 74 | - $this->olFilteredHttpResponseParser->doFilterResponseFor( $olID ); |
|
| 74 | + $this->olFilteredHttpResponseParser->doFilterResponseFor($olID); |
|
| 75 | 75 | $filteredRecord = $this->olFilteredHttpResponseParser->getFilteredRecord(); |
| 76 | 76 | |
| 77 | 77 | // Fetch the OLID has one could search for an ISBN as well |
| 78 | - if ( $filteredRecord->has( 'olid' ) ) { |
|
| 79 | - $olID = $filteredRecord->get( 'olid' ); |
|
| 78 | + if ($filteredRecord->has('olid')) { |
|
| 79 | + $olID = $filteredRecord->get('olid'); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( is_array( $olID ) ) { |
|
| 83 | - $olID = end( $olID ); |
|
| 82 | + if (is_array($olID)) { |
|
| 83 | + $olID = end($olID); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $filteredRecord->setTitleForPageCreation( |
| 87 | - 'OL:' . str_replace( 'OL', '', $olID ) |
|
| 87 | + 'OL:' . str_replace('OL', '', $olID) |
|
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | $filteredRecord->setSciteTransclusionHead( |
| 91 | 91 | $olID |
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | - $filteredRecord->addSearchMatchSet( 'olid', $olID ); |
|
| 94 | + $filteredRecord->addSearchMatchSet('olid', $olID); |
|
| 95 | 95 | |
| 96 | - if ( $filteredRecord->has( 'lccn' ) ) { |
|
| 96 | + if ($filteredRecord->has('lccn')) { |
|
| 97 | 97 | $filteredRecord->addSearchMatchSet( |
| 98 | 98 | 'lccn', |
| 99 | - $filteredRecord->get( 'lccn' ) |
|
| 99 | + $filteredRecord->get('lccn') |
|
| 100 | 100 | ); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
| 104 | - $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); |
|
| 103 | + $dateTimeUtc = new \DateTime('now', new \DateTimeZone('UTC')); |
|
| 104 | + $filteredRecord->set('retrieved-on', $dateTimeUtc->format('Y-m-d')); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param OclcFilteredHttpResponseParser $oclcFilteredHttpResponseParser |
| 26 | 26 | */ |
| 27 | - public function __construct( OclcFilteredHttpResponseParser $oclcFilteredHttpResponseParser ) { |
|
| 27 | + public function __construct(OclcFilteredHttpResponseParser $oclcFilteredHttpResponseParser) { |
|
| 28 | 28 | $this->oclcFilteredHttpResponseParser = $oclcFilteredHttpResponseParser; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * {@inheritDoc} |
| 62 | 62 | */ |
| 63 | - public function getRawResponse( $oclcID ) { |
|
| 64 | - return $this->oclcFilteredHttpResponseParser->getRawResponse( $oclcID ); |
|
| 63 | + public function getRawResponse($oclcID) { |
|
| 64 | + return $this->oclcFilteredHttpResponseParser->getRawResponse($oclcID); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -69,32 +69,32 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * {@inheritDoc} |
| 71 | 71 | */ |
| 72 | - public function doFilterResponseFor( $oclcID ) { |
|
| 72 | + public function doFilterResponseFor($oclcID) { |
|
| 73 | 73 | |
| 74 | 74 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); |
| 75 | 75 | |
| 76 | - $oclcValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( 'oclc' ); |
|
| 77 | - $oclcValue->setUserValue( $oclcID ); |
|
| 76 | + $oclcValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType('oclc'); |
|
| 77 | + $oclcValue->setUserValue($oclcID); |
|
| 78 | 78 | |
| 79 | - if ( !$oclcValue->isValid() ) { |
|
| 80 | - return $this->oclcFilteredHttpResponseParser->addMessage( $oclcValue->getErrors() ); |
|
| 79 | + if (!$oclcValue->isValid()) { |
|
| 80 | + return $this->oclcFilteredHttpResponseParser->addMessage($oclcValue->getErrors()); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $oclcID = $oclcValue->getWikiValue(); |
| 84 | 84 | |
| 85 | - $this->oclcFilteredHttpResponseParser->doFilterResponseFor( $oclcID ); |
|
| 85 | + $this->oclcFilteredHttpResponseParser->doFilterResponseFor($oclcID); |
|
| 86 | 86 | $filteredRecord = $this->oclcFilteredHttpResponseParser->getFilteredRecord(); |
| 87 | 87 | |
| 88 | - $filteredRecord->setTitleForPageCreation( 'OCLC:' . $oclcID ); |
|
| 88 | + $filteredRecord->setTitleForPageCreation('OCLC:' . $oclcID); |
|
| 89 | 89 | $filteredRecord->setSciteTransclusionHead( |
| 90 | 90 | 'OCLC' . $oclcID |
| 91 | 91 | ); |
| 92 | 92 | |
| 93 | - $filteredRecord->addSearchMatchSet( 'oclc', $oclcID ); |
|
| 94 | - $filteredRecord->set( 'oclc', $oclcID ); |
|
| 93 | + $filteredRecord->addSearchMatchSet('oclc', $oclcID); |
|
| 94 | + $filteredRecord->set('oclc', $oclcID); |
|
| 95 | 95 | |
| 96 | - $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); |
|
| 97 | - $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); |
|
| 96 | + $dateTimeUtc = new \DateTime('now', new \DateTimeZone('UTC')); |
|
| 97 | + $filteredRecord->set('retrieved-on', $dateTimeUtc->format('Y-m-d')); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | } |