@@ -8,13 +8,13 @@ |
||
| 8 | 8 | * |
| 9 | 9 | * @codeCoverageIgnore |
| 10 | 10 | */ |
| 11 | -if ( !defined( 'MEDIAWIKI' ) ) { |
|
| 12 | - die( 'This file is part of the SemanticCite extension, it is not a valid entry point.' ); |
|
| 11 | +if (!defined('MEDIAWIKI')) { |
|
| 12 | + die('This file is part of the SemanticCite extension, it is not a valid entry point.'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // In-text citation reference format options |
| 16 | -define( 'SCI_CITEREF_NUM', 1 ); |
|
| 17 | -define( 'SCI_CITEREF_KEY', 2 ); |
|
| 16 | +define('SCI_CITEREF_NUM', 1); |
|
| 17 | +define('SCI_CITEREF_KEY', 2); |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Specifies the caption format of the citation reference, either as a number |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public static function load() { |
| 27 | 27 | |
| 28 | - if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 28 | + if (is_readable(__DIR__ . '/vendor/autoload.php')) { |
|
| 29 | 29 | include_once __DIR__ . '/vendor/autoload.php'; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * @since 1.1 |
| 38 | 38 | */ |
| 39 | - public static function initExtension( $credits = [] ) { |
|
| 39 | + public static function initExtension($credits = []) { |
|
| 40 | 40 | |
| 41 | 41 | // See https://phabricator.wikimedia.org/T151136 |
| 42 | - define( 'SCI_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'UNKNOWN' ); |
|
| 42 | + define('SCI_VERSION', isset($credits['version']) ? $credits['version'] : 'UNKNOWN'); |
|
| 43 | 43 | |
| 44 | 44 | // Extend the upgrade key provided by SMW to ensure that an DB |
| 45 | 45 | // schema is updated accordingly before using the extension |
| 46 | - if ( isset( $GLOBALS['smwgUpgradeKey'] ) ) { |
|
| 46 | + if (isset($GLOBALS['smwgUpgradeKey'])) { |
|
| 47 | 47 | // $GLOBALS['smwgUpgradeKey'] .= ':scite:2018-09'; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | // Register resource files |
| 62 | 62 | $GLOBALS['wgResourceModules']['ext.scite.styles'] = [ |
| 63 | 63 | 'styles' => 'res/scite.styles.css', |
| 64 | - 'localBasePath' => __DIR__ , |
|
| 64 | + 'localBasePath' => __DIR__, |
|
| 65 | 65 | 'remoteExtPath' => 'SemanticCite', |
| 66 | 66 | 'position' => 'top', |
| 67 | 67 | 'group' => 'ext.smw', |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | 'res/scite.text.selector.js', |
| 77 | 77 | 'res/scite.page.creator.js' |
| 78 | 78 | ], |
| 79 | - 'localBasePath' => __DIR__ , |
|
| 79 | + 'localBasePath' => __DIR__, |
|
| 80 | 80 | 'remoteExtPath' => 'SemanticCite', |
| 81 | 81 | 'position' => 'top', |
| 82 | 82 | 'group' => 'ext.smw', |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | ]; |
| 92 | 92 | |
| 93 | 93 | // #71 |
| 94 | - if ( version_compare( $GLOBALS['wgVersion'], '1.32', '<' ) ) { |
|
| 94 | + if (version_compare($GLOBALS['wgVersion'], '1.32', '<')) { |
|
| 95 | 95 | $dependencies = [ |
| 96 | 96 | 'onoi.qtip', |
| 97 | 97 | 'onoi.blobstore', |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | 'scripts' => [ |
| 112 | 112 | 'res/scite.tooltip.js' |
| 113 | 113 | ], |
| 114 | - 'localBasePath' => __DIR__ , |
|
| 114 | + 'localBasePath' => __DIR__, |
|
| 115 | 115 | 'remoteExtPath' => 'SemanticCite', |
| 116 | 116 | 'dependencies' => $dependencies, |
| 117 | 117 | 'messages' => [ |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public static function onExtensionFunction() { |
| 136 | 136 | |
| 137 | - if ( !defined( 'SMW_VERSION' ) ) { |
|
| 138 | - if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { |
|
| 139 | - die( "\nThe 'Semantic Cite' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" ); |
|
| 137 | + if (!defined('SMW_VERSION')) { |
|
| 138 | + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
|
| 139 | + die("\nThe 'Semantic Cite' extension requires 'Semantic MediaWiki' to be installed and enabled.\n"); |
|
| 140 | 140 | } else { |
| 141 | - die( '<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticCite/">Semantic Cite</a> extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> to be installed and enabled.<br />' ); |
|
| 141 | + die('<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticCite/">Semantic Cite</a> extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> to be installed and enabled.<br />'); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $hookRegistry = new HookRegistry( |
| 165 | 165 | $applicationFactory->getStore(), |
| 166 | - $applicationFactory->newCacheFactory()->newMediaWikiCompositeCache( $GLOBALS['scigReferenceListCacheType'] ), |
|
| 167 | - new Options( $configuration ) |
|
| 166 | + $applicationFactory->newCacheFactory()->newMediaWikiCompositeCache($GLOBALS['scigReferenceListCacheType']), |
|
| 167 | + new Options($configuration) |
|
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | 170 | $hookRegistry->register(); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param BibtexParser $bibtexParser |
| 27 | 27 | * @param BibtexAuthorListParser $bibtexAuthorListParser |
| 28 | 28 | */ |
| 29 | - public function __construct( BibtexParser $bibtexParser, BibtexAuthorListParser $bibtexAuthorListParser ) { |
|
| 29 | + public function __construct(BibtexParser $bibtexParser, BibtexAuthorListParser $bibtexAuthorListParser) { |
|
| 30 | 30 | $this->bibtexParser = $bibtexParser; |
| 31 | 31 | $this->bibtexAuthorListParser = $bibtexAuthorListParser; |
| 32 | 32 | } |
@@ -36,30 +36,30 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param ParserParameterProcessor $parserParameterProcessor |
| 38 | 38 | */ |
| 39 | - public function doProcess( ParserParameterProcessor $parserParameterProcessor ) { |
|
| 39 | + public function doProcess(ParserParameterProcessor $parserParameterProcessor) { |
|
| 40 | 40 | |
| 41 | 41 | $bibtex = $this->doPreprocess( |
| 42 | - $parserParameterProcessor->getParameterValuesFor( 'bibtex' ) |
|
| 42 | + $parserParameterProcessor->getParameterValuesFor('bibtex') |
|
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - $parameters = $this->bibtexParser->parse( $bibtex ); |
|
| 45 | + $parameters = $this->bibtexParser->parse($bibtex); |
|
| 46 | 46 | |
| 47 | - foreach ( $parameters as $key => $value ) { |
|
| 47 | + foreach ($parameters as $key => $value) { |
|
| 48 | 48 | |
| 49 | 49 | // The explicit parameters precedes the one found in bibtex |
| 50 | - if ( $key === 'reference' && ( $parserParameterProcessor->hasParameter( 'reference' ) || $parserParameterProcessor->getFirstParameter() !== '' ) ) { |
|
| 50 | + if ($key === 'reference' && ($parserParameterProcessor->hasParameter('reference') || $parserParameterProcessor->getFirstParameter() !== '')) { |
|
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if ( $key === 'type' && $parserParameterProcessor->hasParameter( 'type' ) ) { |
|
| 54 | + if ($key === 'type' && $parserParameterProcessor->hasParameter('type')) { |
|
| 55 | 55 | continue; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ( $key === 'author' ) { |
|
| 58 | + if ($key === 'author') { |
|
| 59 | 59 | |
| 60 | 60 | $parserParameterProcessor->setParameter( |
| 61 | 61 | $key, |
| 62 | - $this->bibtexAuthorListParser->parse( $value ) |
|
| 62 | + $this->bibtexAuthorListParser->parse($value) |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | // Add the original value for easier post-processing in a template |
@@ -74,23 +74,23 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - private function doPreprocess( array $bibtex ) { |
|
| 77 | + private function doPreprocess(array $bibtex) { |
|
| 78 | 78 | |
| 79 | - $bibtex = end( $bibtex ); |
|
| 79 | + $bibtex = end($bibtex); |
|
| 80 | 80 | |
| 81 | 81 | // Avoid things like {{Stable theories}}" which are not supported in MW |
| 82 | 82 | // since the parser replaces it with [[:Template:Stable theories]] |
| 83 | - $this->replace( '{{', "{", $bibtex ); |
|
| 84 | - $this->replace( '}}', "}", $bibtex ); |
|
| 83 | + $this->replace('{{', "{", $bibtex); |
|
| 84 | + $this->replace('}}', "}", $bibtex); |
|
| 85 | 85 | |
| 86 | - $this->replace( '{\textquotesingle}', "'", $bibtex ); |
|
| 87 | - $this->replace( '$\upgamma$', "γ", $bibtex ); |
|
| 86 | + $this->replace('{\textquotesingle}', "'", $bibtex); |
|
| 87 | + $this->replace('$\upgamma$', "γ", $bibtex); |
|
| 88 | 88 | |
| 89 | 89 | return $bibtex; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - private function replace( $search, $with, &$on ) { |
|
| 93 | - $on = strpos( $on, $search ) !== false ? str_replace( $search, $with, $on ) : $on; |
|
| 92 | + private function replace($search, $with, &$on) { |
|
| 93 | + $on = strpos($on, $search) !== false ? str_replace($search, $with, $on) : $on; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | } |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return array |
| 36 | 36 | */ |
| 37 | - public function parse( $input ) { |
|
| 37 | + public function parse($input) { |
|
| 38 | 38 | |
| 39 | 39 | $authorList = []; |
| 40 | 40 | |
| 41 | 41 | // split on ' and ' |
| 42 | - $authorArray = preg_split("/\s(and|&)\s/i", trim( $input ) ); |
|
| 42 | + $authorArray = preg_split("/\s(and|&)\s/i", trim($input)); |
|
| 43 | 43 | |
| 44 | - foreach( $authorArray as $value ) { |
|
| 44 | + foreach ($authorArray as $value) { |
|
| 45 | 45 | $appellation = ''; |
| 46 | 46 | $prefix = ''; |
| 47 | 47 | |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $this->prefix = []; |
| 52 | 52 | |
| 53 | - $author = explode( ",", preg_replace("/\s{2,}/", ' ', trim( $value ) ) ); |
|
| 54 | - $size = count( $author ); |
|
| 53 | + $author = explode(",", preg_replace("/\s{2,}/", ' ', trim($value))); |
|
| 54 | + $size = count($author); |
|
| 55 | 55 | |
| 56 | 56 | // No commas therefore something like Mark Grimshaw, Mark Nicholas Grimshaw, M N Grimshaw, Mark N. Grimshaw |
| 57 | - if( $size == 1 ) { |
|
| 57 | + if ($size == 1) { |
|
| 58 | 58 | // Is complete surname enclosed in {...}, unless the string starts with a backslash (\) because then it is |
| 59 | 59 | // probably a special latex-sign.. |
| 60 | 60 | // 2006.02.11 DR: in the last case, any NESTED curly braces should also be taken into account! so second |
| 61 | 61 | // clause rules out things such as author="a{\"{o}}" |
| 62 | 62 | // |
| 63 | - if( preg_match("/(.*){([^\\\].*)}/", $value, $matches) && |
|
| 64 | - !(preg_match("/(.*){\\\.{.*}.*}/", $value, $matches2 ) ) ) { |
|
| 63 | + if (preg_match("/(.*){([^\\\].*)}/", $value, $matches) && |
|
| 64 | + !(preg_match("/(.*){\\\.{.*}.*}/", $value, $matches2))) { |
|
| 65 | 65 | $author = explode(" ", $matches[1]); |
| 66 | 66 | $surname = $matches[2]; |
| 67 | 67 | } else { |
@@ -69,50 +69,50 @@ discard block |
||
| 69 | 69 | // last of array is surname (no prefix if entered correctly) |
| 70 | 70 | $surname = array_pop($author); |
| 71 | 71 | } |
| 72 | - } elseif( $size == 2 ) { // Something like Grimshaw, Mark or Grimshaw, Mark Nicholas or Grimshaw, M N or Grimshaw, Mark N. |
|
| 72 | + } elseif ($size == 2) { // Something like Grimshaw, Mark or Grimshaw, Mark Nicholas or Grimshaw, M N or Grimshaw, Mark N. |
|
| 73 | 73 | // first of array is surname (perhaps with prefix) |
| 74 | - list( $surname, $prefix ) = $this->grabSurname( array_shift( $author ) ); |
|
| 74 | + list($surname, $prefix) = $this->grabSurname(array_shift($author)); |
|
| 75 | 75 | } else { // If $size is 3, we're looking at something like Bush, Jr. III, George W |
| 76 | 76 | // middle of array is 'Jr.', 'IV' etc. |
| 77 | - $appellation = implode(' ', array_splice( $author, 1, 1 ) ); |
|
| 77 | + $appellation = implode(' ', array_splice($author, 1, 1)); |
|
| 78 | 78 | // first of array is surname (perhaps with prefix) |
| 79 | - list( $surname, $prefix ) = $this->grabSurname( array_shift( $author ) ); |
|
| 79 | + list($surname, $prefix) = $this->grabSurname(array_shift($author)); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $remainder = implode( " ", $author ); |
|
| 82 | + $remainder = implode(" ", $author); |
|
| 83 | 83 | |
| 84 | - list( $firstname, $initials ) = $this->grabFirstnameInitials( $remainder ); |
|
| 84 | + list($firstname, $initials) = $this->grabFirstnameInitials($remainder); |
|
| 85 | 85 | |
| 86 | - if( $this->prefix !== [] ) { |
|
| 87 | - $prefix = implode(' ', $this->prefix ); |
|
| 86 | + if ($this->prefix !== []) { |
|
| 87 | + $prefix = implode(' ', $this->prefix); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $surname = $surname . ' ' . trim( $appellation ); |
|
| 90 | + $surname = $surname . ' ' . trim($appellation); |
|
| 91 | 91 | |
| 92 | - $authorList[] = $this->concatenate( $firstname, $initials, $surname, $prefix ); |
|
| 92 | + $authorList[] = $this->concatenate($firstname, $initials, $surname, $prefix); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return $authorList; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - private function concatenate( $firstname, $initials, $surname, $prefix ) { |
|
| 98 | + private function concatenate($firstname, $initials, $surname, $prefix) { |
|
| 99 | 99 | |
| 100 | 100 | $author = [ |
| 101 | - trim( $firstname ), |
|
| 102 | - trim( $initials ), |
|
| 103 | - trim( $prefix ), |
|
| 104 | - trim( $surname ) |
|
| 101 | + trim($firstname), |
|
| 102 | + trim($initials), |
|
| 103 | + trim($prefix), |
|
| 104 | + trim($surname) |
|
| 105 | 105 | ]; |
| 106 | 106 | |
| 107 | - return implode( ' ', array_filter( $author ) ); |
|
| 107 | + return implode(' ', array_filter($author)); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * @note firstname and initials which may be of form "A.B.C." or "A. B. C. " or " A B C " etc. |
| 112 | 112 | */ |
| 113 | - private function grabFirstnameInitials( $remainder ) { |
|
| 113 | + private function grabFirstnameInitials($remainder) { |
|
| 114 | 114 | |
| 115 | - $array = explode( " ", $remainder ); |
|
| 115 | + $array = explode(" ", $remainder); |
|
| 116 | 116 | |
| 117 | 117 | $firstname = ''; |
| 118 | 118 | $initials = ''; |
@@ -120,25 +120,25 @@ discard block |
||
| 120 | 120 | $initialsArray = []; |
| 121 | 121 | $firstnameArray = []; |
| 122 | 122 | |
| 123 | - foreach( $array as $value ) { |
|
| 123 | + foreach ($array as $value) { |
|
| 124 | 124 | $firstChar = substr($value, 0, 1); |
| 125 | 125 | |
| 126 | - if( ( ord( $firstChar ) >= 97 ) && ( ord( $firstChar ) <= 122) ) { |
|
| 126 | + if ((ord($firstChar) >= 97) && (ord($firstChar) <= 122)) { |
|
| 127 | 127 | $this->prefix[] = $value; |
| 128 | - } elseif( preg_match("/[a-zA-Z]{2,}/", trim( $value ) ) ) { |
|
| 128 | + } elseif (preg_match("/[a-zA-Z]{2,}/", trim($value))) { |
|
| 129 | 129 | $firstnameArray[] = trim($value); |
| 130 | 130 | } else { |
| 131 | - $initialsArray[] = str_replace(".", " ", trim( $value ) ); |
|
| 131 | + $initialsArray[] = str_replace(".", " ", trim($value)); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - foreach( $initialsArray as $initial) { |
|
| 136 | - $initials .= ' ' . trim ( $initial ); |
|
| 135 | + foreach ($initialsArray as $initial) { |
|
| 136 | + $initials .= ' ' . trim($initial); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $firstname = implode(" ", $firstnameArray); |
| 140 | 140 | |
| 141 | - return [ $firstname, $initials ]; |
|
| 141 | + return [$firstname, $initials]; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -146,17 +146,17 @@ discard block |
||
| 146 | 146 | * characterised by first character lowercased. Any uppercased part means |
| 147 | 147 | * lowercased parts following are part of the surname (e.g. Van den Bussche) |
| 148 | 148 | */ |
| 149 | - private function grabSurname( $input ) { |
|
| 150 | - $surnameArray = explode(" ", $input ); |
|
| 149 | + private function grabSurname($input) { |
|
| 150 | + $surnameArray = explode(" ", $input); |
|
| 151 | 151 | |
| 152 | 152 | $noPrefix = false; |
| 153 | 153 | $surname = []; |
| 154 | 154 | $prefix = []; |
| 155 | 155 | |
| 156 | - foreach( $surnameArray as $value ) { |
|
| 156 | + foreach ($surnameArray as $value) { |
|
| 157 | 157 | $firstChar = substr($value, 0, 1); |
| 158 | 158 | |
| 159 | - if( !$noPrefix && ( ord( $firstChar ) >= 97 ) && ( ord( $firstChar ) <= 122 ) ) { |
|
| 159 | + if (!$noPrefix && (ord($firstChar) >= 97) && (ord($firstChar) <= 122)) { |
|
| 160 | 160 | $prefix[] = $value; |
| 161 | 161 | } else { |
| 162 | 162 | $surname[] = $value; |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $surname = implode(" ", $surname); |
| 168 | 168 | |
| 169 | - if( $prefix !== [] ) { |
|
| 170 | - return [ $surname, implode(" ", $prefix ) ]; |
|
| 169 | + if ($prefix !== []) { |
|
| 170 | + return [$surname, implode(" ", $prefix)]; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - return [ $surname, false ]; |
|
| 173 | + return [$surname, false]; |
|
| 174 | 174 | } |
| 175 | 175 | } |
@@ -41,107 +41,107 @@ |
||
| 41 | 41 | * |
| 42 | 42 | * @return array |
| 43 | 43 | */ |
| 44 | - public function parse( $bibtex ) { |
|
| 44 | + public function parse($bibtex) { |
|
| 45 | 45 | |
| 46 | - if ( ( $matches = $this->findBibtexFormatMatches( $bibtex ) ) === [] ) { |
|
| 46 | + if (($matches = $this->findBibtexFormatMatches($bibtex)) === []) { |
|
| 47 | 47 | return []; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $head = [ |
| 51 | - 'type' => strtolower( trim( $matches[1] ) ), |
|
| 51 | + 'type' => strtolower(trim($matches[1])), |
|
| 52 | 52 | 'reference' => $matches[2] |
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | - return $head + $this->parseFields( $matches[3] ); |
|
| 55 | + return $head + $this->parseFields($matches[3]); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - private function findBibtexFormatMatches( $bibtex ) { |
|
| 58 | + private function findBibtexFormatMatches($bibtex) { |
|
| 59 | 59 | |
| 60 | - $matches = preg_split("/@(.*)[{(](.*),/U", $bibtex, 2, PREG_SPLIT_DELIM_CAPTURE ); |
|
| 60 | + $matches = preg_split("/@(.*)[{(](.*),/U", $bibtex, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 61 | 61 | |
| 62 | 62 | // Silently retreat from processing |
| 63 | - if ( !isset( $matches[2] ) ) { |
|
| 63 | + if (!isset($matches[2])) { |
|
| 64 | 64 | return []; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if( preg_match("/=/", $matches[2] ) ) { |
|
| 68 | - $matches = preg_split("/@(.*)\s*[{(](.*)/U", $bibtex, 2, PREG_SPLIT_DELIM_CAPTURE ); |
|
| 67 | + if (preg_match("/=/", $matches[2])) { |
|
| 68 | + $matches = preg_split("/@(.*)\s*[{(](.*)/U", $bibtex, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $matches; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - private function parseFields( $content ) { |
|
| 74 | + private function parseFields($content) { |
|
| 75 | 75 | $elements = []; |
| 76 | 76 | $values = []; |
| 77 | 77 | |
| 78 | - $length = strlen( $content ); |
|
| 78 | + $length = strlen($content); |
|
| 79 | 79 | |
| 80 | - if( $content[$length - 1] == "}" || $content[$length - 1] == ")" || $content[$length - 1] == ",") { |
|
| 81 | - $content = substr( $content, 0, $length - 1 ); |
|
| 80 | + if ($content[$length - 1] == "}" || $content[$length - 1] == ")" || $content[$length - 1] == ",") { |
|
| 81 | + $content = substr($content, 0, $length - 1); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $split = preg_split("/=/", $content, 2 ); |
|
| 84 | + $split = preg_split("/=/", $content, 2); |
|
| 85 | 85 | $string = $split[1]; |
| 86 | 86 | |
| 87 | - while( $string ) { |
|
| 88 | - list( $entry, $string ) = $this->splitField( $string ); |
|
| 87 | + while ($string) { |
|
| 88 | + list($entry, $string) = $this->splitField($string); |
|
| 89 | 89 | $values[] = $entry; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - foreach( $values as $value ) { |
|
| 93 | - $pos = strpos( $content, $value); |
|
| 94 | - $content = substr_replace( $content, '', $pos, strlen( $value ) ); |
|
| 92 | + foreach ($values as $value) { |
|
| 93 | + $pos = strpos($content, $value); |
|
| 94 | + $content = substr_replace($content, '', $pos, strlen($value)); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $rev = strrev( trim( $content ) ); |
|
| 97 | + $rev = strrev(trim($content)); |
|
| 98 | 98 | |
| 99 | - if( $rev[0] != ',') { |
|
| 99 | + if ($rev[0] != ',') { |
|
| 100 | 100 | $content .= ','; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $keys = preg_split("/=,/", $content ); |
|
| 103 | + $keys = preg_split("/=,/", $content); |
|
| 104 | 104 | array_pop($keys); |
| 105 | 105 | |
| 106 | - foreach( $keys as $key ) { |
|
| 107 | - $value = trim( array_shift( $values ) ); |
|
| 108 | - $rev = strrev( $value ); |
|
| 106 | + foreach ($keys as $key) { |
|
| 107 | + $value = trim(array_shift($values)); |
|
| 108 | + $rev = strrev($value); |
|
| 109 | 109 | |
| 110 | 110 | // remove any dangling ',' left on final field of entry |
| 111 | - if( $rev[0] == ',') { |
|
| 111 | + if ($rev[0] == ',') { |
|
| 112 | 112 | $value = rtrim($value, ","); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if(!$value) { |
|
| 115 | + if (!$value) { |
|
| 116 | 116 | continue; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $key = strtolower(trim($key)); |
| 120 | 120 | $value = trim($value); |
| 121 | - $elements[$key] = $this->removeDelimiters( $value ); |
|
| 121 | + $elements[$key] = $this->removeDelimiters($value); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return $elements; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - private function splitField( $seg ) { |
|
| 127 | + private function splitField($seg) { |
|
| 128 | 128 | |
| 129 | - $array = preg_split("/,\s*([-_.:,a-zA-Z0-9]+)\s*={1}\s*/U", $seg, PREG_SPLIT_DELIM_CAPTURE ); |
|
| 129 | + $array = preg_split("/,\s*([-_.:,a-zA-Z0-9]+)\s*={1}\s*/U", $seg, PREG_SPLIT_DELIM_CAPTURE); |
|
| 130 | 130 | |
| 131 | 131 | // if(!array_key_exists( 1, $array ) ) { |
| 132 | 132 | // return array( $array[0], FALSE); |
| 133 | 133 | // } |
| 134 | 134 | |
| 135 | - return isset( $array[1] ) ? [ $array[0], $array[1] ] : [ $array[0], false ]; |
|
| 135 | + return isset($array[1]) ? [$array[0], $array[1]] : [$array[0], false]; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - private function removeDelimiters( $string ) { |
|
| 138 | + private function removeDelimiters($string) { |
|
| 139 | 139 | |
| 140 | - if( $string && ( $string[0] == "\"") ) { |
|
| 140 | + if ($string && ($string[0] == "\"")) { |
|
| 141 | 141 | $string = substr($string, 1); |
| 142 | 142 | $string = substr($string, 0, -1); |
| 143 | - } else if ( $string && ( $string[0] == "{") ) { |
|
| 144 | - if( strlen( $string ) > 0 && $string[strlen($string)-1] == "}" ) { |
|
| 143 | + } else if ($string && ($string[0] == "{")) { |
|
| 144 | + if (strlen($string) > 0 && $string[strlen($string) - 1] == "}") { |
|
| 145 | 145 | $string = substr($string, 1); |
| 146 | 146 | $string = substr($string, 0, -1); |
| 147 | 147 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param NamespaceExaminer $namespaceExaminer |
| 39 | 39 | * @param CitationReferencePositionJournal $citationReferencePositionJournal |
| 40 | 40 | */ |
| 41 | - public function __construct( Store $store, NamespaceExaminer $namespaceExaminer, CitationReferencePositionJournal $citationReferencePositionJournal ) { |
|
| 41 | + public function __construct(Store $store, NamespaceExaminer $namespaceExaminer, CitationReferencePositionJournal $citationReferencePositionJournal) { |
|
| 42 | 42 | $this->store = $store; |
| 43 | 43 | $this->namespaceExaminer = $namespaceExaminer; |
| 44 | 44 | $this->citationReferencePositionJournal = $citationReferencePositionJournal; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $htmlColumnListRenderer = $mwCollaboratorFactory->newHtmlColumnListRenderer(); |
| 56 | 56 | |
| 57 | 57 | $referenceListOutputRenderer = new ReferenceListOutputRenderer( |
| 58 | - new CitationResourceMatchFinder( $this->store ), |
|
| 58 | + new CitationResourceMatchFinder($this->store), |
|
| 59 | 59 | $this->citationReferencePositionJournal, |
| 60 | 60 | $htmlColumnListRenderer |
| 61 | 61 | ); |
@@ -73,28 +73,28 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return CachedReferenceListOutputRenderer |
| 75 | 75 | */ |
| 76 | - public function newCachedReferenceListOutputRenderer( MediaWikiContextInteractor $contextInteractor, Cache $cache, CacheKeyProvider $cacheKeyProvider, Options $options ) { |
|
| 76 | + public function newCachedReferenceListOutputRenderer(MediaWikiContextInteractor $contextInteractor, Cache $cache, CacheKeyProvider $cacheKeyProvider, Options $options) { |
|
| 77 | 77 | |
| 78 | 78 | $referenceListOutputRenderer = $this->newReferenceListOutputRenderer(); |
| 79 | 79 | |
| 80 | 80 | $referenceListOutputRenderer->setNumberOfReferenceListColumns( |
| 81 | - $options->get( 'numberOfReferenceListColumns' ) |
|
| 81 | + $options->get('numberOfReferenceListColumns') |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | $referenceListOutputRenderer->setResponsiveMonoColumnCharacterBoundLength( |
| 85 | - $options->get( 'responsiveMonoColumnCharacterBoundLength' ) |
|
| 85 | + $options->get('responsiveMonoColumnCharacterBoundLength') |
|
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | $referenceListOutputRenderer->setReferenceListType( |
| 89 | - $options->get( 'referenceListType' ) |
|
| 89 | + $options->get('referenceListType') |
|
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | 92 | $referenceListOutputRenderer->setBrowseLinkToCitationResourceVisibility( |
| 93 | - $options->get( 'browseLinkToCitationResource' ) |
|
| 93 | + $options->get('browseLinkToCitationResource') |
|
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | 96 | $referenceListOutputRenderer->setCitationReferenceCaptionFormat( |
| 97 | - $options->get( 'citationReferenceCaptionFormat' ) |
|
| 97 | + $options->get('citationReferenceCaptionFormat') |
|
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | 100 | $cachedReferenceListOutputRenderer = new CachedReferenceListOutputRenderer( |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param IContextSource $context |
| 34 | 34 | */ |
| 35 | - public function __construct( IContextSource $context ) { |
|
| 35 | + public function __construct(IContextSource $context) { |
|
| 36 | 36 | $this->context = $context; |
| 37 | 37 | $this->revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup(); |
| 38 | 38 | } |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | * @return int |
| 46 | 46 | */ |
| 47 | 47 | public function getOldId() { |
| 48 | - $oldid = $this->context->getRequest()->getInt( 'oldid' ); |
|
| 48 | + $oldid = $this->context->getRequest()->getInt('oldid'); |
|
| 49 | 49 | $title = $this->context->getTitle(); |
| 50 | 50 | |
| 51 | - switch ( $this->context->getRequest()->getText( 'direction' ) ) { |
|
| 51 | + switch ($this->context->getRequest()->getText('direction')) { |
|
| 52 | 52 | case 'next': |
| 53 | 53 | # output next revision, or nothing if there isn't one |
| 54 | 54 | $nextid = 0; |
| 55 | - if ( $oldid ) { |
|
| 56 | - $revision = $this->revisionLookup->getRevisionById( $oldid ); |
|
| 57 | - $nextRevision = $this->revisionLookup->getNextRevision( $revision ); |
|
| 58 | - if ( $nextRevision ) { |
|
| 55 | + if ($oldid) { |
|
| 56 | + $revision = $this->revisionLookup->getRevisionById($oldid); |
|
| 57 | + $nextRevision = $this->revisionLookup->getNextRevision($revision); |
|
| 58 | + if ($nextRevision) { |
|
| 59 | 59 | $nextid = $nextRevision->getId(); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | case 'prev': |
| 65 | 65 | # output previous revision, or nothing if there isn't one |
| 66 | 66 | $previd = 0; |
| 67 | - if ( !$oldid ) { |
|
| 67 | + if (!$oldid) { |
|
| 68 | 68 | # get the current revision so we can get the penultimate one |
| 69 | 69 | $oldid = $title->getLatestRevID(); |
| 70 | 70 | } |
| 71 | - if ( $oldid ) { |
|
| 72 | - $revision = $this->revisionLookup->getRevisionById( $oldid ); |
|
| 73 | - $previousRevision = $this->revisionLookup->getPreviousRevision( $revision ); |
|
| 74 | - if ( $previousRevision ) { |
|
| 71 | + if ($oldid) { |
|
| 72 | + $revision = $this->revisionLookup->getRevisionById($oldid); |
|
| 73 | + $previousRevision = $this->revisionLookup->getPreviousRevision($revision); |
|
| 74 | + if ($previousRevision) { |
|
| 75 | 75 | $previd = $previousRevision->getId(); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return boolean |
| 94 | 94 | */ |
| 95 | - public function hasMagicWord( $magicword ) { |
|
| 95 | + public function hasMagicWord($magicword) { |
|
| 96 | 96 | |
| 97 | 97 | $outputPage = $this->context->getOutput(); |
| 98 | 98 | |
| 99 | - if ( isset( $outputPage->smwmagicwords ) && in_array( $magicword, $outputPage->smwmagicwords ) ) { |
|
| 99 | + if (isset($outputPage->smwmagicwords) && in_array($magicword, $outputPage->smwmagicwords)) { |
|
| 100 | 100 | return true; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return boolean |
| 112 | 112 | */ |
| 113 | - public function hasAction( $action ) { |
|
| 114 | - return \Action::getActionName( $this->context ) === $action; |
|
| 113 | + public function hasAction($action) { |
|
| 114 | + return \Action::getActionName($this->context) === $action; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @param Store $store |
| 41 | 41 | */ |
| 42 | - public function __construct( Store $store ) { |
|
| 42 | + public function __construct(Store $store) { |
|
| 43 | 43 | $this->store = $store; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @param Store $store |
| 50 | 50 | */ |
| 51 | - public function setStore( Store $store ) { |
|
| 51 | + public function setStore(Store $store) { |
|
| 52 | 52 | $this->store = $store; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @param mixed|null $requestOptions |
| 59 | 59 | */ |
| 60 | - public function setRequestOptions( $requestOptions = null ) { |
|
| 60 | + public function setRequestOptions($requestOptions = null) { |
|
| 61 | 61 | |
| 62 | - if ( $requestOptions === null ) { |
|
| 62 | + if ($requestOptions === null) { |
|
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -74,21 +74,21 @@ discard block |
||
| 74 | 74 | * @param DIWikiPage $subject |
| 75 | 75 | * @param string &$html |
| 76 | 76 | */ |
| 77 | - public function getSpecialPropertySearchFurtherLink( DIProperty $property, DIWikiPage $subject, &$html ) { |
|
| 77 | + public function getSpecialPropertySearchFurtherLink(DIProperty $property, DIWikiPage $subject, &$html) { |
|
| 78 | 78 | |
| 79 | - if ( $property->getKey() !== PropertyRegistry::SCI_CITE_REFERENCE || ( $citationKey = $this->tryToFindCitationKeyFor( $subject ) ) === null ) { |
|
| 79 | + if ($property->getKey() !== PropertyRegistry::SCI_CITE_REFERENCE || ($citationKey = $this->tryToFindCitationKeyFor($subject)) === null) { |
|
| 80 | 80 | return true; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $html .= \Html::element( |
| 84 | 84 | 'a', |
| 85 | 85 | [ |
| 86 | - 'href' => \SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL( [ |
|
| 86 | + 'href' => \SpecialPage::getSafeTitleFor('SearchByProperty')->getLocalURL([ |
|
| 87 | 87 | 'property' => $property->getLabel(), |
| 88 | 88 | 'value' => $citationKey->getString() |
| 89 | - ] ) |
|
| 89 | + ]) |
|
| 90 | 90 | ], |
| 91 | - wfMessage( 'smw_browse_more' )->text() |
|
| 91 | + wfMessage('smw_browse_more')->text() |
|
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | return false; |
@@ -102,16 +102,16 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @param SemanticData $semanticData |
| 104 | 104 | */ |
| 105 | - public function addReferenceBacklinksTo( SemanticData $semanticData ) { |
|
| 105 | + public function addReferenceBacklinksTo(SemanticData $semanticData) { |
|
| 106 | 106 | |
| 107 | - $key = $this->tryToFindCitationKeyFor( $semanticData->getSubject() ); |
|
| 107 | + $key = $this->tryToFindCitationKeyFor($semanticData->getSubject()); |
|
| 108 | 108 | |
| 109 | 109 | $property = new DIProperty( |
| 110 | 110 | PropertyRegistry::SCI_CITE_REFERENCE |
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | - foreach ( $this->findReferenceBacklinksFor( $key ) as $subject ) { |
|
| 114 | - $semanticData->addPropertyObjectValue( $property, $subject ); |
|
| 113 | + foreach ($this->findReferenceBacklinksFor($key) as $subject) { |
|
| 114 | + $semanticData->addPropertyObjectValue($property, $subject); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return DIBlob|null |
| 124 | 124 | */ |
| 125 | - public function tryToFindCitationKeyFor( DIWikiPage $subject ) { |
|
| 125 | + public function tryToFindCitationKeyFor(DIWikiPage $subject) { |
|
| 126 | 126 | |
| 127 | - $keys = $this->store->getSemanticData( $subject )->getPropertyValues( |
|
| 128 | - new DIProperty( PropertyRegistry::SCI_CITE_KEY ) |
|
| 127 | + $keys = $this->store->getSemanticData($subject)->getPropertyValues( |
|
| 128 | + new DIProperty(PropertyRegistry::SCI_CITE_KEY) |
|
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | 131 | // Not a resource that contains a citation key |
| 132 | - if ( $keys === null || $keys === [] ) { |
|
| 132 | + if ($keys === null || $keys === []) { |
|
| 133 | 133 | return null; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - return end( $keys ); |
|
| 136 | + return end($keys); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -143,13 +143,13 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return DIWikiPage[] |
| 145 | 145 | */ |
| 146 | - public function findReferenceBacklinksFor( $key = null ) { |
|
| 146 | + public function findReferenceBacklinksFor($key = null) { |
|
| 147 | 147 | |
| 148 | - if ( $key === null ) { |
|
| 148 | + if ($key === null) { |
|
| 149 | 149 | return []; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $property = new DIProperty( PropertyRegistry::SCI_CITE_REFERENCE ); |
|
| 152 | + $property = new DIProperty(PropertyRegistry::SCI_CITE_REFERENCE); |
|
| 153 | 153 | |
| 154 | 154 | $description = new ValueDescription( |
| 155 | 155 | $key, |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | $description |
| 162 | 162 | ); |
| 163 | 163 | |
| 164 | - $query = new Query( $someProperty ); |
|
| 165 | - $query->setLimit( $this->limit ); |
|
| 166 | - $query->setOffset( $this->offset ); |
|
| 164 | + $query = new Query($someProperty); |
|
| 165 | + $query->setLimit($this->limit); |
|
| 166 | + $query->setOffset($this->offset); |
|
| 167 | 167 | |
| 168 | - if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) { |
|
| 169 | - $query->setOption( Query::PROC_CONTEXT, 'SCI.ReferenceBacklinksLookup' ); |
|
| 168 | + if (defined('SMWQuery::PROC_CONTEXT')) { |
|
| 169 | + $query->setOption(Query::PROC_CONTEXT, 'SCI.ReferenceBacklinksLookup'); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - return $this->store->getQueryResult( $query )->getResults(); |
|
| 172 | + return $this->store->getQueryResult($query)->getResults(); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param Store $store |
| 38 | 38 | */ |
| 39 | - public function __construct( Store $store ) { |
|
| 39 | + public function __construct(Store $store) { |
|
| 40 | 40 | $this->store = $store; |
| 41 | 41 | $this->dataValueFactory = DataValueFactory::getInstance(); |
| 42 | 42 | } |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return array |
| 51 | 51 | */ |
| 52 | - public function findCitationResourceLinks( array $subjects, $linkClass = '', $caption = '' ) { |
|
| 52 | + public function findCitationResourceLinks(array $subjects, $linkClass = '', $caption = '') { |
|
| 53 | 53 | |
| 54 | 54 | $citationResourceLinks = []; |
| 55 | 55 | |
| 56 | - foreach ( $subjects as $subject ) { |
|
| 56 | + foreach ($subjects as $subject) { |
|
| 57 | 57 | |
| 58 | 58 | $dataValue = $this->dataValueFactory->newDataItemValue( |
| 59 | 59 | $subject, |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return array |
| 84 | 84 | */ |
| 85 | - public function findMatchForResourceIdentifierTypeToValue( $type, $id = null ) { |
|
| 85 | + public function findMatchForResourceIdentifierTypeToValue($type, $id = null) { |
|
| 86 | 86 | |
| 87 | - if ( $id === null || $id === '' ) { |
|
| 87 | + if ($id === null || $id === '') { |
|
| 88 | 88 | return []; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); |
| 92 | 92 | |
| 93 | - $resourceIdentifierStringValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( $type ); |
|
| 94 | - $resourceIdentifierStringValue->setUserValue( $id ); |
|
| 93 | + $resourceIdentifierStringValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType($type); |
|
| 94 | + $resourceIdentifierStringValue->setUserValue($id); |
|
| 95 | 95 | $id = $resourceIdentifierStringValue->getWikiValue(); |
| 96 | 96 | |
| 97 | 97 | $description = new SomeProperty( |
| 98 | 98 | $resourceIdentifierStringValue->getProperty(), |
| 99 | - new ValueDescription( new DIBlob( $id ) ) |
|
| 99 | + new ValueDescription(new DIBlob($id)) |
|
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | 102 | $query = new Query( |
@@ -106,17 +106,17 @@ discard block |
||
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | $query->querymode = Query::MODE_INSTANCES; |
| 109 | - $query->setLimit( 10 ); |
|
| 109 | + $query->setLimit(10); |
|
| 110 | 110 | |
| 111 | - if ( defined( 'SMWQuery::NO_CACHE' ) ) { |
|
| 112 | - $query->setOption( Query::NO_CACHE, true ); |
|
| 111 | + if (defined('SMWQuery::NO_CACHE')) { |
|
| 112 | + $query->setOption(Query::NO_CACHE, true); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) { |
|
| 116 | - $query->setOption( Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder' ); |
|
| 115 | + if (defined('SMWQuery::PROC_CONTEXT')) { |
|
| 116 | + $query->setOption(Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder'); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - return $this->store->getQueryResult( $query )->getResults(); |
|
| 119 | + return $this->store->getQueryResult($query)->getResults(); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return array |
| 128 | 128 | */ |
| 129 | - public function findCitationTextFor( $citationReference ) { |
|
| 129 | + public function findCitationTextFor($citationReference) { |
|
| 130 | 130 | |
| 131 | 131 | $text = ''; |
| 132 | 132 | $subjects = []; |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | $citationReference |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | - if ( !$queryResult instanceof \SMWQueryResult ) { |
|
| 139 | - return [ $subjects, $text ]; |
|
| 138 | + if (!$queryResult instanceof \SMWQueryResult) { |
|
| 139 | + return [$subjects, $text]; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - while ( $resultArray = $queryResult->getNext() ) { |
|
| 143 | - foreach ( $resultArray as $result ) { |
|
| 142 | + while ($resultArray = $queryResult->getNext()) { |
|
| 143 | + foreach ($resultArray as $result) { |
|
| 144 | 144 | |
| 145 | 145 | // Collect all subjects for the same reference because it can happen |
| 146 | 146 | // that the same reference key is used for different citation |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | // text but return all subjects to make it easier to find them later |
| 149 | 149 | $subjects[] = $result->getResultSubject(); |
| 150 | 150 | |
| 151 | - while ( ( $dataValue = $result->getNextDataValue() ) !== false ) { |
|
| 151 | + while (($dataValue = $result->getNextDataValue()) !== false) { |
|
| 152 | 152 | $text = $dataValue->getShortWikiText(); |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - return [ $subjects, $text ]; |
|
| 157 | + return [$subjects, $text]; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -166,20 +166,20 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return QueryResult |
| 168 | 168 | */ |
| 169 | - public function findMatchForCitationReference( $citationReference ) { |
|
| 169 | + public function findMatchForCitationReference($citationReference) { |
|
| 170 | 170 | |
| 171 | 171 | $description = new SomeProperty( |
| 172 | - new DIProperty( PropertyRegistry::SCI_CITE_KEY ), |
|
| 173 | - new ValueDescription( new DIBlob( $citationReference ) ) |
|
| 172 | + new DIProperty(PropertyRegistry::SCI_CITE_KEY), |
|
| 173 | + new ValueDescription(new DIBlob($citationReference)) |
|
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | - $propertyValue = $this->dataValueFactory->newDataValueByType( '__pro' ); |
|
| 176 | + $propertyValue = $this->dataValueFactory->newDataValueByType('__pro'); |
|
| 177 | 177 | $propertyValue->setDataItem( |
| 178 | - new DIProperty( PropertyRegistry::SCI_CITE_TEXT ) |
|
| 178 | + new DIProperty(PropertyRegistry::SCI_CITE_TEXT) |
|
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | 181 | $description->addPrintRequest( |
| 182 | - new PrintRequest( PrintRequest::PRINT_PROP, null, $propertyValue ) |
|
| 182 | + new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue) |
|
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | $query = new Query( |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | ); |
| 190 | 190 | |
| 191 | 191 | $query->querymode = Query::MODE_INSTANCES; |
| 192 | - $query->setLimit( 10 ); |
|
| 192 | + $query->setLimit(10); |
|
| 193 | 193 | |
| 194 | - if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) { |
|
| 195 | - $query->setOption( Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder' ); |
|
| 194 | + if (defined('SMWQuery::PROC_CONTEXT')) { |
|
| 195 | + $query->setOption(Query::PROC_CONTEXT, 'SCI.CitationResourceMatchFinder'); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - return $this->store->getQueryResult( $query ); |
|
| 198 | + return $this->store->getQueryResult($query); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | } |