From 6193033ae85643ee2a5ea0656fb82c2ddf56b22e Mon Sep 17 00:00:00 2001 From: mwjames Date: Thu, 5 Nov 2015 13:31:50 +0100 Subject: [PATCH 1/3] Tidy --- CONFIGURATION.md | 2 +- README.md | 3 ++ SemanticCite.php | 4 +-- docs/04-scite.md | 30 +++++++++---------- src/CitationTextChangeUpdateJobDispatcher.php | 11 ++----- src/DataValues/CitationReferenceValue.php | 4 ++- src/ParserFunctionFactory.php | 2 +- .../Parser/ByJsonParserTestCaseRunnerTest.php | 2 +- tests/phpunit/Unit/HookRegistryTest.php | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 0d7692b..5c69a22 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -11,7 +11,7 @@ - `$GLOBALS['scigReferenceListCacheType']` to disable caching for the reference list, use setting [`CACHE_NONE`][mw-cachetype] otherwise the cache is being renewed an each new revision or when the page is purged -- `$GLOBALS['scigStrictParserValidationEnabled']` whether a strict validation of input data for +- `$GLOBALS['scigEnabledStrictParserValidation']` whether a strict validation of input data for the `{{#scite:}}` parser should be carried out or not - `$GLOBALS['scigEnabledCitationTextChangeUpdateJob']` whether an update job should be dispatched for changed citation text entities or not diff --git a/README.md b/README.md index ae5441d..0d907b5 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,9 @@ but can also be executed using `composer phpunit` from the extension base direct [GNU General Public License, version 2 or later][gpl-licence]. +Part of the bibtex related parsing code has been reused from the http://bibliophile.sourceforge.net project +which is released under the GPL license. + [smw]: https://github.com/SemanticMediaWiki/SemanticMediaWiki [contributors]: https://github.com/SemanticMediaWiki/SemanticCite/graphs/contributors [travis]: https://travis-ci.org/SemanticMediaWiki/SemanticCite diff --git a/SemanticCite.php b/SemanticCite.php index 36adbce..29b1a55 100644 --- a/SemanticCite.php +++ b/SemanticCite.php @@ -166,7 +166,7 @@ * Whether a strict validation on behalf of the #scite parser should be * enabled or not */ - $GLOBALS['scigStrictParserValidationEnabled'] = true; + $GLOBALS['scigEnabledStrictParserValidation'] = true; /** * Whether an update job should be dispatched for changed citation text @@ -188,7 +188,7 @@ 'tooltipRequestCacheTTL' => $GLOBALS['scigTooltipRequestCacheTTLInSeconds'], 'citationReferenceCaptionFormat' => $GLOBALS['scigCitationReferenceCaptionFormat'], 'referenceListType' => $GLOBALS['scigReferenceListType'], - 'strictParserValidationEnabled' => $GLOBALS['scigStrictParserValidationEnabled'], + 'enabledstrictParserValidation' => $GLOBALS['scigEnabledStrictParserValidation'], 'cachePrefix' => $GLOBALS['scigCachePrefix'], 'enabledCitationTextChangeUpdateJob' => $GLOBALS['scigEnabledCitationTextChangeUpdateJob'] ); diff --git a/docs/04-scite.md b/docs/04-scite.md index 48feb07..e815332 100644 --- a/docs/04-scite.md +++ b/docs/04-scite.md @@ -55,14 +55,14 @@ a `Byrne 2008` resource the short or the explicit reference parameter form can b If it becomes necessary to rename a citation key (because a resource with key `Foo 2007` no longer represents a unique resource due to adding another resource with the same key) -then the existing usage of that resource needs to be queried and changed before applying +then it is recommended that the existing usage is queried and changed before applying the new citation key (e.g. `Foo 2007a`). ## Citation text The property `Citation text` contains the formatted output of a citation resource and is -used when the [referencelist](05-referencelist.md) is generated. The text is formatted using -assinged template or can be added directly (without further processing) in its final form +used when the [referencelist](05-referencelist.md) is generated. The text is formatted either by +an assigned template or can be added directly (without further processing) in its final form to the `|citation text=` parameter. ``` @@ -73,8 +73,8 @@ to the `|citation text=` parameter. ``` In case the parameter `|citation text=` is not declared then `#scite` is going to try to determine -an a template by first looking at the `|template=` parameter and if such parameter is not assigned -then the [template](03-template-mapping.md) assigned to the type of the resource +a template by first looking at the `|template=` parameter and if such parameter is not assigned +then the [template](03-template-mapping.md) mapped to the type of the resource is used for processing to return a formatted text value. ``` @@ -88,23 +88,23 @@ is used for processing to return a formatted text value. }} ``` -If `$GLOBALS['scigEnabledCitationTextChangeUpdateJob']` is set true then a change to +If `$GLOBALS['scigEnabledCitationTextChangeUpdateJob']` is set true then an alteration to a citation text will initiate an update job for those pages that make reference to the -related citation resource. +changed citation resource. ## Type assignment -A type assignment is expected for each citation resource unless `$GLOBALS['scigStrictParserValidationEnabled']` +A type assignment is required for each citation resource unless `$GLOBALS['scigEnabledStrictParserValidation']` is set `false`. If multiple types are assigned (e.g.`|type=bgn:Thesis;schema:Book|+sep=;`) then -the last entry (e.g. `schema:Book`) will be selected as valid type descriptor. +the last entry (e.g. `schema:Book`) will be used as type descriptor. ## Bibtex record import To ease the reuse of bibtex records, `#scite` provides the `|bibtex=` parameter to -import a bibtex formatted text to create annotatable record following -the assignments declared in the `MediaWiki:` [property](02-property-mapping.md) and +import a bibtex formatted text to create an annotatable record that corresponds to +the mapping found in the [property](02-property-mapping.md) and [template](03-template-mapping.md) page. ``` @@ -121,7 +121,7 @@ YEAR=2000 }} ``` -### Author list +### Bibtex author list Authors (e.g. `Einstein, Albert and Podolsky, Boris and Rosen, Nathan`) will be split into an author list of natural representations (`Albert Einstein` etc.) while the original @@ -142,12 +142,12 @@ annotation string is still available using the hidden `bibtex-author` parameter. }} ``` -### Content formatting +### Bibtex content formatting `@article` is parsed as type `article` that can be assigned to a specific [template](03-template-mapping.md) containing the rules of how text elements are to be formatted. Please be aware -that no automatic clean-up is done on elements like containing `{`/`}` or new lines as in -`in \n SUSY`. Furthermore, complex expressions (those involve macros etc.) are +that no automatic clean-up is done on elements like containing `{`/`}` or `in \n SUSY`, and +complex expressions (those involve macros etc.) are not parsed or resolved. ``` diff --git a/src/CitationTextChangeUpdateJobDispatcher.php b/src/CitationTextChangeUpdateJobDispatcher.php index eee71fa..ba8fe81 100644 --- a/src/CitationTextChangeUpdateJobDispatcher.php +++ b/src/CitationTextChangeUpdateJobDispatcher.php @@ -73,7 +73,7 @@ public function dispatchUpdateJobFor( DIWikiPage $subject, CompositePropertyTabl new DIProperty( PropertyRegistry::SCI_CITE_TEXT ) ); - $subjectIdList = $this->getSubjectListFrom( + $subjectIdList = $this->getSubjectIdListFromOrderedTableDiff( $compositePropertyTableDiffIterator->getOrderedDiffByTable( $tableName ) ); @@ -93,16 +93,11 @@ public function dispatchUpdateJobFor( DIWikiPage $subject, CompositePropertyTabl return true; } - private function getSubjectListFrom( array $orderedDiff ) { + private function getSubjectIdListFromOrderedTableDiff( array $orderedTableDiff ) { $subjectIdList = array(); - // Find out whether a cite text object was altered - foreach ( $orderedDiff as $key => $value ) { - - if ( strpos( $key, 'sci_cite_text' ) === false ) { - continue; - } + foreach ( $orderedTableDiff as $key => $value ) { if ( !isset( $value['delete'] ) ) { $value['delete'] = array(); diff --git a/src/DataValues/CitationReferenceValue.php b/src/DataValues/CitationReferenceValue.php index ec6b0d5..5eeab6f 100644 --- a/src/DataValues/CitationReferenceValue.php +++ b/src/DataValues/CitationReferenceValue.php @@ -102,6 +102,8 @@ protected function parseUserValue( $value ) { */ public function getShortWikiText( $linked = null ) { + $this->citationReferencePositionJournal = $this->getExtraneousFunctionFor( '\SCI\CitationReferencePositionJournal' ); + // We want the last entry here to get the major/minor // number that was internally recorded $referencePosition = $this->citationReferencePositionJournal->findLastReferencePositionEntryFor( @@ -110,7 +112,7 @@ public function getShortWikiText( $linked = null ) { ); if ( $referencePosition === null || $this->m_caption === false ) { - return ''; + return $this->m_dataitem->getString(); } $referenceHash = md5( $this->reference ); diff --git a/src/ParserFunctionFactory.php b/src/ParserFunctionFactory.php index d299da2..e243fd5 100644 --- a/src/ParserFunctionFactory.php +++ b/src/ParserFunctionFactory.php @@ -56,7 +56,7 @@ public function newSciteParserFunctionDefinition( NamespaceExaminer $namespaceEx ); $sciteParserFunction->setStrictParserValidationState( - $options->get( 'strictParserValidationEnabled' ) + $options->get( 'enabledstrictParserValidation' ) ); return $sciteParserFunction->doProcess( diff --git a/tests/phpunit/Integration/Parser/ByJsonParserTestCaseRunnerTest.php b/tests/phpunit/Integration/Parser/ByJsonParserTestCaseRunnerTest.php index 0212dab..8f4f476 100644 --- a/tests/phpunit/Integration/Parser/ByJsonParserTestCaseRunnerTest.php +++ b/tests/phpunit/Integration/Parser/ByJsonParserTestCaseRunnerTest.php @@ -39,7 +39,7 @@ protected function setUp() { 'tooltipRequestCacheTTL' => false, 'citationReferenceCaptionFormat' => 1, 'referenceListType' => 'ol', - 'strictParserValidationEnabled' => true, + 'enabledstrictParserValidation' => true, 'cachePrefix' => 'foo', 'enabledCitationTextChangeUpdateJob' => false ); diff --git a/tests/phpunit/Unit/HookRegistryTest.php b/tests/phpunit/Unit/HookRegistryTest.php index cb60552..c349bbb 100644 --- a/tests/phpunit/Unit/HookRegistryTest.php +++ b/tests/phpunit/Unit/HookRegistryTest.php @@ -56,7 +56,7 @@ public function testRegister() { 'tooltipRequestCacheTTL' => false, 'citationReferenceCaptionFormat' => 1, 'referenceListType' => 'ul', - 'strictParserValidationEnabled' => true, + 'enabledstrictParserValidation' => true, 'cachePrefix' => 'foo', 'enabledCitationTextChangeUpdateJob' => false ); From c9847eac1a735bd5abca4214975fc6289cab624d Mon Sep 17 00:00:00 2001 From: mwjames Date: Sun, 6 Dec 2015 16:22:12 +0100 Subject: [PATCH 2/3] Support search-index --- src/PropertyRegistry.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/PropertyRegistry.php b/src/PropertyRegistry.php index bf1df04..0404f88 100644 --- a/src/PropertyRegistry.php +++ b/src/PropertyRegistry.php @@ -51,7 +51,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_sci_olid', 'alias' => array( wfMessage( 'sci-property-alias-olid' )->text(), 'olid', 'Olid' ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => false ), self::SCI_VIAF => array( @@ -59,7 +60,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_sci_viaf', 'alias' => array( wfMessage( 'sci-property-alias-viaf' )->text(), 'viaf', 'Viaf' ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => false ), self::SCI_OCLC => array( @@ -67,7 +69,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_sci_oclc', 'alias' => array( wfMessage( 'sci-property-alias-oclc' )->text(), 'oclc', 'Oclc' ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => false ), self::SCI_DOI => array( @@ -75,7 +78,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_sci_doi', 'alias' => array( wfMessage( 'sci-property-alias-doi' )->text(), 'Doi', 'doi' ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => false ), self::SCI_PMCID => array( @@ -83,7 +87,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_sci_pmcid', 'alias' => array( wfMessage( 'sci-property-alias-pmcid' )->text(), 'Pmcid', 'pmcid' ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => false ), self::SCI_PMID => array( @@ -91,7 +96,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_sci_pmid', 'alias' => array( wfMessage( 'sci-property-alias-pmid' )->text(), 'Pmid', 'pmid' ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => false ), self::SCI_CITE_KEY => array( @@ -99,7 +105,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_txt', 'alias' => array( wfMessage( 'sci-property-alias-citation-key' )->text() ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => true ), // Allow CiteRef to be an alias as it saves typing @@ -109,7 +116,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_sci_ref', 'alias' => array( wfMessage( 'sci-property-alias-citation-reference' )->text(), 'CiteRef' ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => true ), self::SCI_CITE_TEXT => array( @@ -117,7 +125,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '_txt', 'alias' => array( wfMessage( 'sci-property-alias-citation-text' )->text() ), 'visibility' => true, - 'annotableByUser' => true + 'annotableByUser' => true, + 'isSearchableByIndex' => true ), self::SCI_CITE => array( @@ -125,7 +134,8 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'type' => '__sob', 'alias' => array( wfMessage( 'sci-property-alias-citation-resource' )->text() ), 'visibility' => true, - 'annotableByUser' => false + 'annotableByUser' => true, + 'isSearchableByIndex' => false ) ); @@ -143,7 +153,8 @@ private function addPropertyDefinitionFor( $corePropertyRegistry, $propertyId, $ $definition['type'], $definition['label'], $definition['visibility'], - $definition['annotableByUser'] + $definition['annotableByUser'], + $definition['isSearchableByIndex'] ); foreach ( $definition['alias'] as $alias ) { From acd5d212dc4ab21e1262b1eba240150af3d4946b Mon Sep 17 00:00:00 2001 From: mwjames Date: Wed, 9 Dec 2015 20:15:43 +0100 Subject: [PATCH 3/3] [WIP] Add Citation meta to include Citation frequency/count `$GLOBALS['scigEnabledCitationMetaRecord']` can be enabled to help support content analysis in connection wih questions like "How often is a reference cited within an article?" or "How often is a reference cited within a wiki?". Prerequisites - https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/1302 - https://github.com/SemanticMediaWiki/SemanticMediaWiki/commit/8e4351fced28aec442e18fc75f0365e7adac069b --- SemanticCite.php | 11 +- docs/04-scite.md | 7 +- src/CitationMeta.php | 124 ++++++++++++++++++ src/CitationResourceMatchFinder.php | 10 ++ src/DataValues/CitationFrequencyValue.php | 31 +++++ src/HookRegistry.php | 14 +- src/PropertyRegistry.php | 55 ++++++-- .../Parser/ByJsonParserTestCaseRunnerTest.php | 3 +- tests/phpunit/Unit/HookRegistryTest.php | 3 +- 9 files changed, 241 insertions(+), 17 deletions(-) create mode 100644 src/CitationMeta.php create mode 100644 src/DataValues/CitationFrequencyValue.php diff --git a/SemanticCite.php b/SemanticCite.php index 29b1a55..f91033b 100644 --- a/SemanticCite.php +++ b/SemanticCite.php @@ -22,7 +22,7 @@ return 1; } -define( 'SCI_VERSION', '1.0.0' ); +define( 'SCI_VERSION', '1.1.0-alpha' ); /** * @codeCoverageIgnore @@ -174,6 +174,12 @@ */ $GLOBALS['scigEnabledCitationTextChangeUpdateJob'] = true; + /** + * Whether an article should collect meta information about citation + * resources (i.e citation frequency etc.) + */ + $GLOBALS['scigEnabledCitationMetaRecord'] = false; + // Finalize registration process $GLOBALS['wgExtensionFunctions'][] = function() { @@ -190,7 +196,8 @@ 'referenceListType' => $GLOBALS['scigReferenceListType'], 'enabledstrictParserValidation' => $GLOBALS['scigEnabledStrictParserValidation'], 'cachePrefix' => $GLOBALS['scigCachePrefix'], - 'enabledCitationTextChangeUpdateJob' => $GLOBALS['scigEnabledCitationTextChangeUpdateJob'] + 'enabledCitationTextChangeUpdateJob' => $GLOBALS['scigEnabledCitationTextChangeUpdateJob'], + 'enabledCitationMetaRecord' => $GLOBALS['scigEnabledCitationMetaRecord'] ); $applicationFactory = ApplicationFactory::getInstance(); diff --git a/docs/04-scite.md b/docs/04-scite.md index e815332..06bd039 100644 --- a/docs/04-scite.md +++ b/docs/04-scite.md @@ -103,7 +103,7 @@ the last entry (e.g. `schema:Book`) will be used as type descriptor. ## Bibtex record import To ease the reuse of bibtex records, `#scite` provides the `|bibtex=` parameter to -import a bibtex formatted text to create an annotatable record that corresponds to +import a bibtex formatted text to create an annotatable record that corresponds to the mapping found in the [property](02-property-mapping.md) and [template](03-template-mapping.md) page. @@ -170,5 +170,10 @@ not parsed or resolved. } }} ``` +## Citation meta record + +`$GLOBALS['scigEnabledCitationMetaRecord']` can be enabled to generate additional record data about the +references used (e.g citation frequency) to help answer questions like "How often is a reference cited +within an article?" or "How often is a reference cited within a wiki?. [smw-ns]: https://semantic-mediawiki.org/wiki/Help:$smwgNamespacesWithSemanticLinks diff --git a/src/CitationMeta.php b/src/CitationMeta.php new file mode 100644 index 0000000..bbdf07b --- /dev/null +++ b/src/CitationMeta.php @@ -0,0 +1,124 @@ +citationReferencePositionJournal = $citationReferencePositionJournal; + } + + /** + * @since 1.1 + * + * @param $isEnabled boolean + */ + public function setEnabledState( $isEnabled ) { + $this->isEnabled = (bool)$isEnabled; + } + + /** + * @since 1.1 + * + * @param SemanticData $semanticData + * + * @return boolean + */ + public function addMetaRecordToSemanticData( SemanticData $semanticData ) { + + if ( !$this->isEnabled ) { + return false; + } + + $containerSemanticData = $this->tryToCollectCitationFrequency( + $semanticData->getSubject() + ); + + if ( $containerSemanticData === null || $containerSemanticData->isEmpty() ) { + return false; + } + + $semanticData->addPropertyObjectValue( + new DIProperty( PropertyRegistry::SCI_CITE_META ), + new DIContainer( $containerSemanticData ) + ); + + return true; + } + + private function tryToCollectCitationFrequency( DIWikiPage $subject ) { + + $journal = $this->citationReferencePositionJournal->getJournalBySubject( $subject ); + + if ( $journal === array() || !isset( $journal['reference-list'] ) ) { + return null; + } + + $subWikiPage = new DIWikiPage( + $subject->getDBkey(), + $subject->getNamespace(), + $subject->getInterwiki(), + 'sci.meta' + ); + + $containerSemanticData = new ContainerSemanticData( $subWikiPage ); + + foreach ( $journal['reference-list'] as $hash => $citationKey ) { + + if ( !isset( $journal['reference-pos'][$hash] ) ) { + continue; + } + + $this->addFrequencyRecord( + $containerSemanticData, + $subject, + $citationKey, + count( $journal['reference-pos'][$hash] ) + ); + } + + return $containerSemanticData; + } + + private function addFrequencyRecord( $containerSemanticData, $subject, $citationKey, $count ) { + + $dataValue = DataValueFactory::getInstance()->newPropertyObjectValue( + new DIProperty( PropertyRegistry::SCI_CITE_FREQUENCY ), + $citationKey . ';' . $count, + false, + $subject + ); + + $containerSemanticData->addDataValue( $dataValue ); + } + +} diff --git a/src/CitationResourceMatchFinder.php b/src/CitationResourceMatchFinder.php index 1103459..1c318a5 100644 --- a/src/CitationResourceMatchFinder.php +++ b/src/CitationResourceMatchFinder.php @@ -4,6 +4,8 @@ use SMW\Query\Language\SomeProperty; use SMW\Query\Language\ValueDescription; +use SMW\Query\Language\Conjunction; +use SMW\Query\Language\ThingDescription; use SMW\Query\PrintRequest; use SMW\Store; use SMW\DIProperty; @@ -165,6 +167,14 @@ public function findMatchForCitationReference( $citationReference ) { new ValueDescription( new DIBlob( $citationReference ) ) ); + $description = new Conjunction( array( $description ) ); + $description->addDescription( + new SomeProperty( + new DIProperty( PropertyRegistry::SCI_CITE_TEXT ), + new ThingDescription() + ) + ); + $propertyValue = new PropertyValue( '__pro' ); $propertyValue->setDataItem( new DIProperty( PropertyRegistry::SCI_CITE_TEXT ) diff --git a/src/DataValues/CitationFrequencyValue.php b/src/DataValues/CitationFrequencyValue.php new file mode 100644 index 0000000..8129003 --- /dev/null +++ b/src/DataValues/CitationFrequencyValue.php @@ -0,0 +1,31 @@ +registerDatatype( + '_sci_rec', + '\SCI\DataValues\CitationFrequencyValue', + DataItem::TYPE_WIKIPAGE, + false, + true + ); + $types = array( '_sci_doi', '_sci_pmcid', @@ -264,7 +272,11 @@ function() use( $citationReferencePositionJournal ) { return $citationReferenceP /** * @see https://www.semantic-mediawiki.org/wiki/Hooks#SMWStore::updateDataBefore */ - $this->handlers['SMWStore::updateDataBefore'] = function ( $store, $semanticData ) use ( $cache, $cacheKeyProvider, $citationReferencePositionJournal ) { + $this->handlers['SMWStore::updateDataBefore'] = function ( $store, $semanticData ) use ( $cache, $cacheKeyProvider, $options, $citationReferencePositionJournal ) { + + $citationMeta = new CitationMeta( $citationReferencePositionJournal ); + $citationMeta->setEnabledState( $options->get( 'enabledCitationMetaRecord' ) ); + $citationMeta->addMetaRecordToSemanticData( $semanticData ); $hash = $semanticData->getSubject()->getHash(); diff --git a/src/PropertyRegistry.php b/src/PropertyRegistry.php index 0404f88..6a30c12 100644 --- a/src/PropertyRegistry.php +++ b/src/PropertyRegistry.php @@ -8,6 +8,9 @@ define( 'SCI_PROP_CITE_KEY', 'Citation key' ); define( 'SCI_PROP_CITE_REFERENCE', 'Citation reference' ); define( 'SCI_PROP_CITE_TEXT', 'Citation text' ); +define( 'SCI_PROP_CITE_META', 'Citation meta' ); +define( 'SCI_PROP_CITE_FREQUENCY', 'Citation frequency' ); +define( 'SCI_PROP_CITE_COUNT', 'Citation count' ); define( 'SCI_PROP_CITE', 'Citation resource' ); define( 'SCI_PROP_DOI', 'DOI' ); define( 'SCI_PROP_PMCID', 'PMCID' ); @@ -27,6 +30,9 @@ class PropertyRegistry { const SCI_CITE_KEY = '__sci_cite_key'; const SCI_CITE_REFERENCE = '__sci_cite_reference'; const SCI_CITE_TEXT = '__sci_cite_text'; + const SCI_CITE_META = '__sci_cite_meta'; + const SCI_CITE_FREQUENCY = '__sci_cite_frequency'; + const SCI_CITE_COUNT = '__sci_cite_count'; const SCI_CITE = '__sci_cite'; const SCI_DOI = '__sci_doi'; const SCI_PMCID = '__sci_pmcid'; @@ -52,7 +58,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-olid' )->text(), 'olid', 'Olid' ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => false + 'canUseEnhancedSearchField' => false ), self::SCI_VIAF => array( @@ -61,7 +67,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-viaf' )->text(), 'viaf', 'Viaf' ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => false + 'canUseEnhancedSearchField' => false ), self::SCI_OCLC => array( @@ -70,7 +76,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-oclc' )->text(), 'oclc', 'Oclc' ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => false + 'canUseEnhancedSearchField' => false ), self::SCI_DOI => array( @@ -79,7 +85,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-doi' )->text(), 'Doi', 'doi' ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => false + 'canUseEnhancedSearchField' => false ), self::SCI_PMCID => array( @@ -88,7 +94,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-pmcid' )->text(), 'Pmcid', 'pmcid' ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => false + 'canUseEnhancedSearchField' => false ), self::SCI_PMID => array( @@ -97,7 +103,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-pmid' )->text(), 'Pmid', 'pmid' ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => false + 'canUseEnhancedSearchField' => false ), self::SCI_CITE_KEY => array( @@ -106,7 +112,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-citation-key' )->text() ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => true + 'canUseEnhancedSearchField' => true ), // Allow CiteRef to be an alias as it saves typing @@ -117,7 +123,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-citation-reference' )->text(), 'CiteRef' ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => true + 'canUseEnhancedSearchField' => true ), self::SCI_CITE_TEXT => array( @@ -126,7 +132,34 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-citation-text' )->text() ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => true + 'canUseEnhancedSearchField' => true + ), + + self::SCI_CITE_META => array( + 'label' => SCI_PROP_CITE_META, + 'type' => '__sob', + 'alias' => array( wfMessage( 'sci-property-alias-citation-meta' )->text() ), + 'visibility' => false, + 'annotableByUser' => false, + 'canUseEnhancedSearchField' => false + ), + + self::SCI_CITE_FREQUENCY => array( + 'label' => SCI_PROP_CITE_FREQUENCY, + 'type' => '_sci_rec', + 'alias' => array( wfMessage( 'sci-property-alias-citation-frequency' )->text() ), + 'visibility' => false, + 'annotableByUser' => false, + 'canUseEnhancedSearchField' => false + ), + + self::SCI_CITE_COUNT => array( + 'label' => SCI_PROP_CITE_COUNT, + 'type' => '_num', + 'alias' => array( wfMessage( 'sci-property-alias-citation-count' )->text() ), + 'visibility' => false, + 'annotableByUser' => false, + 'canUseEnhancedSearchField' => false ), self::SCI_CITE => array( @@ -135,7 +168,7 @@ public function registerTo( CorePropertyRegistry $corePropertyRegistry ) { 'alias' => array( wfMessage( 'sci-property-alias-citation-resource' )->text() ), 'visibility' => true, 'annotableByUser' => true, - 'isSearchableByIndex' => false + 'canUseEnhancedSearchField' => false ) ); @@ -154,7 +187,7 @@ private function addPropertyDefinitionFor( $corePropertyRegistry, $propertyId, $ $definition['label'], $definition['visibility'], $definition['annotableByUser'], - $definition['isSearchableByIndex'] + $definition['canUseEnhancedSearchField'] ); foreach ( $definition['alias'] as $alias ) { diff --git a/tests/phpunit/Integration/Parser/ByJsonParserTestCaseRunnerTest.php b/tests/phpunit/Integration/Parser/ByJsonParserTestCaseRunnerTest.php index 8f4f476..60b7405 100644 --- a/tests/phpunit/Integration/Parser/ByJsonParserTestCaseRunnerTest.php +++ b/tests/phpunit/Integration/Parser/ByJsonParserTestCaseRunnerTest.php @@ -41,7 +41,8 @@ protected function setUp() { 'referenceListType' => 'ol', 'enabledstrictParserValidation' => true, 'cachePrefix' => 'foo', - 'enabledCitationTextChangeUpdateJob' => false + 'enabledCitationTextChangeUpdateJob' => false, + 'enabledCitationMetaRecord' => false ); // This is to ensure we read from the DB when a test case diff --git a/tests/phpunit/Unit/HookRegistryTest.php b/tests/phpunit/Unit/HookRegistryTest.php index c349bbb..2aa1366 100644 --- a/tests/phpunit/Unit/HookRegistryTest.php +++ b/tests/phpunit/Unit/HookRegistryTest.php @@ -58,7 +58,8 @@ public function testRegister() { 'referenceListType' => 'ul', 'enabledstrictParserValidation' => true, 'cachePrefix' => 'foo', - 'enabledCitationTextChangeUpdateJob' => false + 'enabledCitationTextChangeUpdateJob' => false, + 'enabledCitationMetaRecord' => false ); $instance = new HookRegistry(