├── .github ├── FUNDING.yml └── workflows │ └── ci.yml ├── .gitignore ├── .gitmodules ├── COPYING ├── DefaultSettings.php ├── Makefile ├── README.md ├── RELEASE-NOTES.md ├── SemanticCite.php ├── codecov.yml ├── composer.json ├── docs ├── 00-configuration.md ├── 01-introduction.md ├── 02-property-mapping.md ├── 03-template-mapping.md ├── 04-scite.md ├── 05-referencelist.md ├── 06-references.md ├── 07-metadata-search.md ├── 08-faq.md ├── 09-notes.md ├── 10-template-examples.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── tmpl-sci-apa-citation-formatter-journal.mediawiki ├── tmpl-sci-apa-citation-formatter-web-publication.mediawiki ├── tmpl-sci-apa-citation-formatter.mediawiki ├── tmpl-sci-mla-citation-formatter-book.mediawiki ├── tmpl-sci-mla-citation-formatter-web-publication.mediawiki ├── tmpl-sci-mla-citation-formatter.mediawiki └── tmpl-sci-viaf-citation-formatter.mediawiki ├── extension.json ├── i18n ├── SemanticCite.alias.php ├── SemanticCite.magic.php ├── ar.json ├── ast.json ├── be-tarask.json ├── bn.json ├── br.json ├── ca.json ├── ce.json ├── cs.json ├── cy.json ├── da.json ├── de-formal.json ├── de.json ├── diq.json ├── el.json ├── en.json ├── es.json ├── eu.json ├── fa.json ├── fi.json ├── fr.json ├── gl.json ├── he.json ├── hi.json ├── hu.json ├── ia.json ├── id.json ├── ilo.json ├── io.json ├── it.json ├── ja.json ├── jv.json ├── ko.json ├── krc.json ├── ksh.json ├── lb.json ├── li.json ├── lt.json ├── mai.json ├── mg.json ├── mk.json ├── mr.json ├── nb.json ├── nl.json ├── oc.json ├── olo.json ├── pam.json ├── pl.json ├── ps.json ├── pt-br.json ├── pt.json ├── qqq.json ├── roa-tara.json ├── ru.json ├── sd.json ├── sl.json ├── sr-ec.json ├── sr-el.json ├── sv.json ├── tl.json ├── tr.json ├── uk.json ├── vi.json ├── zh-hans.json └── zh-hant.json ├── phpunit.xml.dist ├── res ├── scite.page.creator.js ├── scite.styles.css ├── scite.text.selector.js └── scite.tooltip.js ├── src ├── Bibtex │ ├── BibtexAuthorListParser.php │ ├── BibtexParser.php │ └── BibtexProcessor.php ├── CacheKeyProvider.php ├── CachedReferenceListOutputRenderer.php ├── CitationReferencePositionJournal.php ├── CitationResourceMatchFinder.php ├── CitationTextChangeUpdateJobDispatcher.php ├── CitationTextTemplateRenderer.php ├── DataValues │ ├── CitationReferenceValue.php │ ├── ResourceIdentifierFactory.php │ ├── ResourceIdentifierStringValue.php │ └── ResourceIdentifierStringValueParser.php ├── FilteredMetadata │ ├── BibliographicFilteredRecord.php │ ├── CrossRefResponseParser.php │ ├── HttpResponseParserFactory.php │ ├── NcbiPubMedResponseParser.php │ ├── OLResponseParser.php │ ├── OclcResponseParser.php │ └── ViafResponseParser.php ├── HookRegistry.php ├── MediaWikiContextInteractor.php ├── MediaWikiNsContentMapper.php ├── Options.php ├── ParserFunctionFactory.php ├── PreTextFormatter.php ├── PropertyRegistry.php ├── ReferenceBacklinksLookup.php ├── ReferenceListFactory.php ├── ReferenceListOutputRenderer.php ├── ReferenceListParserFunction.php ├── SciteParserFunction.php └── Specials │ ├── CitableMetadata │ ├── HtmlResponseParserRenderer.php │ └── PageBuilder.php │ └── SpecialFindCitableMetadata.php └── tests ├── bootstrap.php ├── phpunit ├── Integration │ ├── FilteredMetadata │ │ ├── Fixtures │ │ │ ├── 10.1007-2F978-0-387-76978-3.expected │ │ │ ├── 10.1007-2F978-0-387-76978-3.json │ │ │ ├── OCLC41266045.expected │ │ │ ├── OCLC41266045.json │ │ │ ├── OCLC74330434.expected │ │ │ ├── OCLC74330434.json │ │ │ ├── OL2206423M.expected │ │ │ ├── OL2206423M.json │ │ │ ├── PMC2776723.expected │ │ │ ├── PMC2776723.json │ │ │ ├── PMC2776723.xml │ │ │ ├── VIAF253484422.expected │ │ │ └── VIAF253484422.xml │ │ └── SciteTransclusionForCannedResponseParserTest.php │ └── JSONScript │ │ ├── SemanticCiteJsonTestCaseScriptRunnerTest.php │ │ └── TestCases │ │ ├── scite-01-simple-intext-reference.json │ │ ├── scite-02-multiple-intext-references.json │ │ ├── scite-03-use-property-definition.json │ │ ├── scite-04-use-template-definition.json │ │ ├── scite-05-different-referencelist-position.json │ │ ├── scite-06-different-caption-format.json │ │ ├── scite-07-referencelist-custom-options.json │ │ ├── scite-08-ul-referencelist-with-key.json │ │ ├── scite-09-nonbound-referencelist.json │ │ ├── scite-10-reference-with-sortkey.json │ │ ├── scite-11-noreferencelist-magic-word.json │ │ ├── scite-12-fixed-property-annotation.json │ │ ├── scite-13-bibtex-record-mapping.json │ │ └── scite-14-fixed-property-query.json ├── Structure │ └── I18nJsonFileIntegrityTest.php └── Unit │ ├── Bibtex │ ├── BibtexAuthorListParserTest.php │ ├── BibtexParserTest.php │ └── BibtexProcessorTest.php │ ├── CacheKeyProviderTest.php │ ├── CachedReferenceListOutputRendererTest.php │ ├── CitationReferencePositionJournalTest.php │ ├── CitationResourceMatchFinderTest.php │ ├── CitationTextChangeUpdateJobDispatcherTest.php │ ├── CitationTextTemplateRendererTest.php │ ├── DataValues │ ├── CitationReferenceValueTest.php │ ├── ResourceIdentifierFactoryTest.php │ ├── ResourceIdentifierStringValueParserTest.php │ └── ResourceIdentifierStringValueTest.php │ ├── FilteredMetadata │ ├── BibliographicFilteredRecordTest.php │ ├── CrossRefResponseParserTest.php │ ├── HttpResponseParserFactoryTest.php │ ├── NcbiPubMedResponseParserTest.php │ ├── OLResponseParserTest.php │ ├── OclcResponseParserTest.php │ └── ViafResponseParserTest.php │ ├── HookRegistryTest.php │ ├── MediaWikiContextInteractorTest.php │ ├── MediaWikiNsContentMapperTest.php │ ├── OptionsTest.php │ ├── ParserFunctionFactoryTest.php │ ├── PreTextFormatterTest.php │ ├── PropertyRegistryTest.php │ ├── ReferenceBacklinksLookupTest.php │ ├── ReferenceListFactoryTest.php │ ├── ReferenceListOutputRendererTest.php │ ├── ReferenceListParserFunctionTest.php │ ├── SciteParserFunctionTest.php │ └── Specials │ ├── CitableMetadata │ ├── HtmlResponseParserRendererTest.php │ └── PageBuilderTest.php │ └── SpecialFindCitableMetadataTest.php └── travis ├── install-mediawiki.sh ├── install-semantic-cite.sh ├── run-tests.sh └── upload-coverage-report.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | 12 | test: 13 | 14 | runs-on: ubuntu-20.04 15 | continue-on-error: ${{ matrix.experimental }} 16 | 17 | strategy: 18 | matrix: 19 | include: 20 | - mediawiki_version: '1.39' 21 | smw_version: dev-master 22 | php_version: 8.1 23 | database_type: mysql 24 | database_image: "mariadb:11.2" 25 | coverage: false 26 | experimental: false 27 | - mediawiki_version: '1.39' 28 | smw_version: dev-master 29 | php_version: 8.1 30 | database_type: mysql 31 | database_image: "mariadb:11.2" 32 | coverage: false 33 | experimental: false 34 | - mediawiki_version: '1.40' 35 | smw_version: dev-master 36 | php_version: 8.1 37 | database_type: mysql 38 | database_image: "mariadb:11.2" 39 | coverage: true 40 | experimental: false 41 | - mediawiki_version: '1.41' 42 | smw_version: dev-master 43 | php_version: 8.1 44 | database_type: mysql 45 | database_image: "mariadb:11.2" 46 | coverage: false 47 | experimental: false 48 | - mediawiki_version: '1.42' 49 | smw_version: dev-master 50 | php_version: 8.1 51 | database_type: mysql 52 | database_image: "mariadb:11.2" 53 | coverage: false 54 | experimental: false 55 | - mediawiki_version: '1.43' 56 | smw_version: dev-master 57 | php_version: 8.1 58 | database_type: mysql 59 | database_image: "mariadb:11.2" 60 | coverage: false 61 | experimental: false 62 | 63 | env: 64 | MW_VERSION: ${{ matrix.mediawiki_version }} 65 | SMW_VERSION: ${{ matrix.smw_version }} 66 | PHP_VERSION: ${{ matrix.php_version }} 67 | DB_TYPE: ${{ matrix.database_type }} 68 | DB_IMAGE: ${{ matrix.database_image }} 69 | 70 | 71 | steps: 72 | - name: Checkout 73 | uses: actions/checkout@v4 74 | with: 75 | submodules: recursive 76 | 77 | - name: Update submodules 78 | run: git submodule update --init --remote 79 | 80 | - name: Run tests 81 | run: make ci 82 | if: matrix.coverage == false 83 | 84 | - name: Run tests with coverage 85 | run: make ci-coverage 86 | if: matrix.coverage == true 87 | 88 | - name: Upload code coverage 89 | uses: codecov/codecov-action@v4 90 | with: 91 | token: ${{ secrets.CODECOV_TOKEN }} 92 | files: coverage/php/coverage.xml 93 | if: matrix.coverage == true 94 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.kate-swp 3 | 4 | vendor/ 5 | extensions/ 6 | 7 | composer.phar 8 | composer.lock 9 | 10 | !.* 11 | .idea/ 12 | .phpunit.result.cache 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "build"] 2 | path = build 3 | url = https://github.com/gesinn-it-pub/docker-compose-ci.git 4 | -------------------------------------------------------------------------------- /DefaultSettings.php: -------------------------------------------------------------------------------- 1 | =7.4", 30 | "composer/installers": ">=1.0.1", 31 | "onoi/cache": "~1.2", 32 | "mediawiki/http-request": "~2.0|~1.1", 33 | "onoi/remi":"~0.2" 34 | }, 35 | "autoload": { 36 | "files" : [ 37 | "SemanticCite.php" 38 | ], 39 | "psr-4": { 40 | "SCI\\": "src/" 41 | } 42 | }, 43 | "config": { 44 | "process-timeout": 0, 45 | "allow-plugins": { 46 | "composer/installers": true 47 | } 48 | }, 49 | "scripts":{ 50 | "test-coverage": [ 51 | "@phpunit-coverage" 52 | ], 53 | "phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist", 54 | "phpunit-coverage": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml", 55 | "post-test-coverage": [ 56 | "sed -i 's|/var/www/html/extensions/SemanticCite/||g' coverage/php/coverage.xml", 57 | "find coverage/php -type f -name '*.html' -exec sed -i 's|/var/www/html/extensions/||g' {} +" 58 | ], 59 | "test": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /docs/00-configuration.md: -------------------------------------------------------------------------------- 1 | ## General settings 2 | 3 | - `$GLOBALS['scigCitationReferenceCaptionFormat']` specifies the display format for a citation 4 | reference to be displayed either as a number (`SCI_CITEREF_NUM`) or by its key (`SCI_CITEREF_KEY`) 5 | - `$GLOBALS['scigShowTooltipForCitationReference']` maintains an array for which format the tooltip 6 | can be shown (`false` or an empty array will disable the tooltip) 7 | - `$GLOBALS['scigTooltipRequestCacheTTLInSeconds']` to allow to store tooltip query results from 8 | the backend to the local browser cache in order to avoid repeated requests for already queried 9 | references. Setting this parameter to false will disable the cache. Items that are cached will show 10 | a `[+]` as indicator. 11 | - `$GLOBALS['scigReferenceListCacheType']` to disable caching for the reference list, use setting 12 | [`CACHE_NONE`][mw-cachetype] otherwise the cache is being renewed an each new revision or when 13 | the page is purged 14 | - `$GLOBALS['scigEnabledStrictParserValidation']` whether a strict validation of input data for 15 | the `{{#scite:}}` parser should be carried out or not 16 | - `$GLOBALS['scigEnabledCitationTextChangeUpdateJob']` whether an update job should be dispatched 17 | for changed citation text entities or not 18 | 19 | ### Reference list 20 | 21 | - `$GLOBALS['scigNumberOfReferenceListColumns']` specifies the number of columns to be shown 22 | on the reference list 23 | - `$GLOBALS['scigReferenceListType']` either formatted using `ul` or `ol` 24 | - `$GLOBALS['scigBrowseLinkToCitationResource']` whether to show a browse link to the citation 25 | resource or not 26 | 27 | ### Metadata search 28 | 29 | - `$GLOBALS['scigMetadataResponseCacheType']` specifies the type of the cache expected to be used 30 | - `$GLOBALS['scigMetadataResponseCacheLifetime']` specifies the time duration responses are cached from a 31 | metadata service provider 32 | - `$GLOBALS['wgGroupPermissions']['user']['sci-metasearch'] = true;` to restricted access to users 33 | 34 | ## Configuration 35 | 36 | - [Property mapping](https://github.com/SemanticMediaWiki/SemanticCite/blob/master/docs/02-property-mapping.md) 37 | - [Template mapping](https://github.com/SemanticMediaWiki/SemanticCite/blob/master/docs/03-template-mapping.md) 38 | 39 | [mw-cachetype]: http://www.mediawiki.org/wiki/Manual:$wgMainCacheType 40 | -------------------------------------------------------------------------------- /docs/01-introduction.md: -------------------------------------------------------------------------------- 1 | # Getting started 2 | 3 | - Define property and text formatting rules 4 | - Create a resource with `#scite` 5 | - Create an in-text citation using `[[Citation reference::...]]` (= `[[CiteRef::...]]`) 6 | 7 | ## Create a citation resource 8 | 9 | A simple citation resource can be created using `#scite` and the 10 | `|citation text=...` parameter without the need for any extra customization (or 11 | property mapping). 12 | 13 | ``` 14 | {{#scite:Einstein 1956 15 | |type=book 16 | |citation text=Einstein, Albert. Investigations on the Theory of the Brownian Movement. Courier Corporation, 1956. 17 | }} 18 | ``` 19 | 20 | ## Create an in-text reference 21 | 22 | To create a in-text reference, a user only is required to add an annotation (e.g. `[[CiteRef::Einstein 1956]]`) 23 | to the selected text position and after the document is saved, a reference link 24 | together with a reference list will appear on the page that includes the 25 | `Citation reference` annotation. 26 | 27 | ## What about structured data? 28 | 29 | For more information about how to map local [properties](02-property-mapping.md) and 30 | how to use other features of the `#scite` parser, have a look at this [help](04-scite.md) 31 | document. 32 | 33 | ## What about citation styles? 34 | 35 | `#scite` allows to support different citation styles making use of the existing 36 | [template](03-template-mapping.md) infrastructure to generate a customized text output. 37 | -------------------------------------------------------------------------------- /docs/02-property-mapping.md: -------------------------------------------------------------------------------- 1 | ## Property mapping 2 | 3 | Not all resource identifiers in `{{#scite:}}` (e.g `|pages=...` etc. ) are relevant for semantic recognition 4 | therefore `MediaWiki:Sci-property-definition` describes the mapping between identifiers 5 | and properties specific to a wiki (no mapping, means no annotations). 6 | 7 |
 8 | type|Has reference type
 9 | author|Has author
10 | publisher|Has publisher
11 | 
12 | 13 | ``` 14 | {{#scite:Foo 15 | ... 16 | |type=Faz 17 | |author=Bar 18 | |publisher=Foobar 19 | |pages=123 20 | |volume=10 21 | ... 22 | }} 23 | ``` 24 | For example, with the mapping above the following annotations `[[Has reference type::Faz]]`, `[[Has author::Bar]]`, and 25 | `[[Has publisher::Foobar]]` will be made available. The `pages` and `volume` identifier are not mapped to a 26 | property therefore are not available as semantic annotation. 27 | 28 | ## Predefined properties 29 | 30 | Semantic Cite provides several predefined properties including: 31 | 32 | - `OLID` to identify OpenLibrary records 33 | - `VIAF` to describe a Virtual International Authority File 34 | - `OCLC` as an identifier for a WorldCat catalog entity 35 | - `PMID` and `PMCID` to represent a PubMed identifier 36 | - `DOI` as Digital Object Identifier 37 | - `Citation resource`, `Citation reference`, `Citation key`, and `Citation text` 38 | 39 | ### External vocabulary assignment 40 | 41 | If for some of the predefined properties an external RDF [vocabulary assignment][smw-import] is required then 42 | simple statements (e.g. `[[Imported from::bibo:doi]]`) can be added to a selected property. 43 | 44 | `MediaWiki:Smw_import_bibo` to specify: 45 | 46 | ``` 47 | http://purl.org/ontology/bibo/|[http://bibliontology.com/ Bibliographic Ontology] 48 | title|Type:Text 49 | doi|Type:Text 50 | pmid|Type:Text 51 | ``` 52 | 53 | [smw-import]: https://semantic-mediawiki.org/wiki/Help:Import_vocabulary -------------------------------------------------------------------------------- /docs/03-template-mapping.md: -------------------------------------------------------------------------------- 1 | ## Template mapping and citation text rendering 2 | 3 | The generation of a citation text is determined by rules and include: 4 | 5 | ### Type assignment 6 | 7 | `MediaWiki:Sci-template-definition` describes and maps citation resource types to specific 8 | templates with a template containing the rules of how identifiers are expected to be formatted 9 | and positioned to generate a citation text. 10 | 11 |
12 |  online|SciteOnlineResourceFormatter
13 |  journal|SciteAPAJournalResourceFormatter
14 |  book|SciteMPABookResourceFormatter
15 |  someothertype|SciteFormatterForAnotherType
16 | 
17 | 18 | ### Template parameter 19 | 20 | A citation resource can override the template type assignment by invoking 21 | the `|template=...` parameter directly. 22 | 23 | ``` 24 | {{#scite:Segon & Booth 2011 25 | |type=online 26 | ... 27 | |journal=Journal of Business Systems, Governance and Ethics 28 | |available=20 October 2014 29 | |template=SciteUseDifferentOnlineResourceFormatter 30 | }} 31 | ``` 32 | ### Citation text parameter 33 | 34 | Using the `|citation text=...` parameter allows to circumvent 35 | any template rendering by storing the input text "as-is". 36 | 37 | ``` 38 | {{#scite: 39 | |type=book 40 | |reference=Barone and Gianfranco, 1982 41 | |citation text=Barone, Antonio, and Gianfranco Paterno. Physics and applications of the Josephson effect. Vol. 1. New York: Wiley, 1982. 42 | }} 43 | ``` 44 | 45 | The mapping is made flexible enough to support citation styles or types that 46 | do not fit the standard guidelines or use citations for more than just 47 | bibliographic references. 48 | -------------------------------------------------------------------------------- /docs/05-referencelist.md: -------------------------------------------------------------------------------- 1 | ## #referencelist parser 2 | 3 | In general a reference list is auto-maintained (except for the NS_FILE namespace) 4 | and added to the bottom of a page if a citation reference is being detected. In 5 | case a user whishes to place a list differently, `#referencelist` can be used to 6 | mark the position as to where the list is expected to appear. 7 | 8 | Citation resources that use the same key are displayed on the reference list and 9 | linked to each other if `$GLOBALS['scigBrowseLinkToCitationResource']` is enabled. 10 | For example, ` ↑ | ↑` is indicating that two resources use the same citation 11 | key with `↑` linking to each of the resources. 12 | 13 | ### Options 14 | 15 | The `#referencelist` parser does accept several options that allows to modify the output 16 | of an individual list. 17 | 18 | ``` 19 | {{#referencelist: 20 | |listtype=ul 21 | |browselinks=false // ("true", "1", "on" and "yes") or ( "false", "0", "off", and "no") 22 | |columns=3 23 | |header=Notes 24 | }} 25 | ``` 26 | ### Table of contents 27 | 28 | To display an entry in the table of contents section (which by default is hidden) 29 | the parameter `|toc=yes` is required. 30 | 31 | ``` 32 | {{#referencelist: 33 | |listtype=ol 34 | |browselinks=no 35 | |columns=1 36 | |toc=yes 37 | }} 38 | ``` 39 | ### Unbound reference list 40 | 41 | To generate an unbound reference list (for notes or additional literature references) 42 | using the `|references=` parameter is required because such list uses the information 43 | provided by this parameter and is not bound to any of the `Citation reference` annotations 44 | made on the source page. 45 | 46 | ``` 47 | {{#referencelist: 48 | |listtype=ul 49 | |browselinks=yes 50 | |columns=1 51 | |header=Notes 52 | |references=PMC2483364;Einstein et al. 1935|+sep=; 53 | }} 54 | ``` 55 | 56 | If an unbound list is added an additional `#referencelist` is required to position the 57 | standard list in context of the unbound list. 58 | 59 | ## Hide the reference list 60 | 61 | The magic word `__NOREFERENCELIST__` can be used to suppress a reference list from showing 62 | on an individual page. 63 | -------------------------------------------------------------------------------- /docs/06-references.md: -------------------------------------------------------------------------------- 1 | ## In-text citation 2 | 3 | A resource can easily be cited using the `Citation reference` (or its alias `CiteRef`) 4 | property. For example, a simple in-text annotation is created by `Lorem ipsum [[CiteRef::Byrne 2008]] ...` to appear as 5 | `Lorem ipsum``[1]`` ...`. 6 | 7 | ### References and citation keys 8 | 9 | - The parentheses style of a citation reference can be modified using the `scite.styles.css` 10 | style sheet. 11 | - If a page number reference is required then one can use the longform syntax 12 | `[[CiteRef::Foo and Bar, 1970|Foo and Bar, 1970:42]]` for `SCI_CITEREF_KEY` to highlight 13 | the page 42 while the shortform `[[CiteRef::Foo and Bar, 1970|:42]]` is suggested for 14 | `SCI_CITEREF_NUM` in order to appear as `...``[1]:42` 15 | - To avoid cluttering a source text with citation resources it is suggested to divide 16 | text and resource definitions by storing `{{#scite:}}` resources on a related a subpage 17 | and use the `[[CiteRef:: ...]]` annotation on the source page for inclusion. 18 | 19 | ## Backlinks (Where is the resource used?) 20 | 21 | A citation resource displayed by `Special:Browse` will not only list all available 22 | structured data but also indicate subjects that have a reference to the key annotated 23 | by the `Citation reference` property. -------------------------------------------------------------------------------- /docs/07-metadata-search.md: -------------------------------------------------------------------------------- 1 | # Metadata search 2 | 3 | ![image](https://cloud.githubusercontent.com/assets/1245473/10266229/1c8b9bca-6a55-11e5-9ccb-cb44bfb400f0.png) 4 | 5 | `Special:FindCitableMetadata` provides access to selected metadata provider to map 6 | external data to the internal `#scite` format. Supported providers are: 7 | 8 | - PubMed (PMID, PMCID) 9 | - CrossRef (DOI) 10 | - OpenLibrary 11 | - OCLC (WorldCat) 12 | - VIAF 13 | 14 | This [video](https://www.youtube.com/watch?v=d2dNFTUUUjs) shows the usage variety 15 | of the metadata search. 16 | 17 | ## Direct search 18 | 19 | A link `Special:FindCitableMetadata` + `/doi/10.1126/science.1152662` or `/pubmed/18487186` 20 | with a type and ID parameter allows to execute a search immediately. 21 | 22 | ## Search 23 | 24 | After a successful search, a generated `#scite` form is provided which can either 25 | be copied manually (see the `Search text` button) or with the help of the auto creation 26 | feature (use the `Create` button) can add an individual article directly from the 27 | special page. 28 | 29 | The data received from a service provider are compacted to fit the `#scite` format but the 30 | parameter `&format=raw` can be used to display the unprocessed data retrieved from a provider. 31 | 32 | If a citation resource already exists for one of the selected identifiers then a link 33 | to this resource is provided. 34 | 35 | ### Citation resource auto creation 36 | 37 | `Special:FindCitableMetadata` allows to create a dedicated article containing the mapped 38 | `#scite` with content from the search and a page title that is generated from: 39 | 40 | - `CR:` (is the fixed identifier indicating a citation resource article) 41 | - UID prefix ( `PMC`, `PMID`, `OCLC` etc.) and 42 | - UID itself 43 | 44 | For example, a search for `18487186` on the PubMed database is expected to create the article 45 | `CR:PMID:18487186` containing the filtered `#scite` content matched during the 46 | search if the user was to engage in a `Create` action. 47 | 48 | ### CR: namespace 49 | 50 | It is possible to customize `CR:` and be recognized as [separate namespace][mw-cns] so 51 | that it is distinguishable from other content. 52 | 53 | ```php 54 | // Define custom CR namespace 55 | define( "NS_CR", 3000 ); 56 | define( "NS_CR_TALK", 3001 ); 57 | $GLOBALS['wgExtraNamespaces'][NS_CR] = "CR"; 58 | $GLOBALS['wgExtraNamespaces'][NS_CR_TALK] = "CR_talk"; 59 | 60 | // Enable annotation for the CR namespace when used as custom NS 61 | $GLOBALS['smwgNamespacesWithSemanticLinks'][NS_CR] = true; 62 | ``` 63 | 64 | If this step is done after resources have already been created `rebuildData.php` needs to be 65 | executed to ensure that annotations are reconnected to the newly assigned namespace number. 66 | 67 | ## Related settings 68 | 69 | To avoid repeated data downloads from a service provider, requests are cached that contain the 70 | same signature with an expiry specified by `$GLOBALS['scigMetadataResponseCacheLifetime']`. 71 | 72 | By default, the access to the search is restricted to users with the `sci-metasearch` right. 73 | 74 | [mw-cns]: https://www.mediawiki.org/wiki/Manual:Using_custom_namespaces 75 | -------------------------------------------------------------------------------- /docs/08-faq.md: -------------------------------------------------------------------------------- 1 | ## Questions 2 | 3 | > Can I store a `Citation resource` on a page different from where the actual reference is made? 4 | 5 | Yes. A `Citation resource` can be stored on any page and is accessible from any page 6 | through the `Citation key` declared by the resource. 7 | 8 | > Can I add the same reference multiple times to a (or different) text source? 9 | 10 | Yes. Using the same `[[CiteRef:: ...]]` reference at the position that needs citing 11 | is all that is required. 12 | 13 | > Is it possible to use a resource defined by `` (Cite) with #scite? 14 | 15 | No. Due to a different technical approach resources declared by `` can not be used 16 | by (or in) Semantic Cite. 17 | 18 | ## FAQ 19 | 20 | ### How to handle different authors 21 | 22 | There are various ways of making different authors available to the semantic search 23 | and as ordered output. 24 | 25 | For example using a parameter `authors` that is matched to a property `Has author` 26 | (to contain all authors in clear form) while an `author` parameter (not matched to any 27 | property) is used as identifier so that the template formatter can generate the expected 28 | ordered output from `{{{author|}}}` without having to apply a complex parsing process. 29 | 30 | ``` 31 | {{#scite:Watson and Crick, 1953 32 | ... 33 | |author=James D. Watson;Francis HC Crick|+sep=; 34 | |authors=Watson, James D., and Francis HC Crick 35 | ... 36 | }} 37 | ``` -------------------------------------------------------------------------------- /docs/09-notes.md: -------------------------------------------------------------------------------- 1 | # Technical notes 2 | 3 | ![image](https://cloud.githubusercontent.com/assets/1245473/10267125/8bfb2688-6a87-11e5-919f-944baea4fd4e.png) 4 | 5 | ## Properties 6 | 7 | - Property `Citation key` is a string value that identifies a citation resource 8 | - Property `Citation reference` (or its alias `CiteRef`) is representing the citation key when used as in-text 9 | annotation and contains special rules for display and text placement 10 | - Property `Citation resource` describes an individual entity that is uniquely identified 11 | by a key. It represents the sum of all information collectively stored as subobject. 12 | - Property `Citation text` contains the citation output generated from a template or free text assignment 13 | - Pre-deployed properties are scheduled to create separate property tables that can be found under `smw_ftp_sci*` 14 | - Properties for external representation include `DOI`, `PMCID`, `PMID`, `VIAF`, 15 | `OCLC`, and `OLID` as a `ResourceIdentifierStringValue` (a string value that is transformed into an 16 | appropriate output URL representation when displayed) 17 | 18 | ## Citation reference 19 | 20 | The `CitationReferenceValue` object together with the `CitationReferencePositionJournal` are building 21 | the basis in counting and identifying the position of each `[[CiteRef::]]` annotation in a text source. 22 | 23 | ## #scite parser 24 | 25 | `#scite` parser is self-sustained and does not make use of any of the `Cite` provided functionality. 26 | 27 | ## #referencelist parser 28 | 29 | The `CachedReferenceListOutputRenderer` is responsible for caching the generated list that 30 | is retrieved from `ReferenceListOutputRenderer` together with an appropriate text position (which 31 | if the `{{#referencelist:}}` parser is used can be different from the default bottom position). 32 | 33 | `ReferenceListOutputRenderer` uses the position information from `CitationReferencePositionJournal` 34 | that was collected from each `Citation reference` annotation within a page and generatesa list of 35 | references matched with information from the `CitationResourceMatchFinder` (citation text etc.). 36 | 37 | `{{#referencelist:}}` adds a simple placeholder (this is required as all parser functions run before 38 | the `OutputPage` hooks) to mark the position of the list where it is expected to appear. This 39 | placeholder is later replaced by `CachedReferenceListOutputRenderer::addReferenceListToCorrectTextPosition`. 40 | 41 | ## Metadata search / provider 42 | 43 | Metadata selection and REST response parsing are provided by the `onoi/remi` library. -------------------------------------------------------------------------------- /docs/10-template-examples.md: -------------------------------------------------------------------------------- 1 | The listed examples are provided as starting point which may or may not be appropriate 2 | or complete in one or the other use case. Examples can contain conditionals therefore 3 | it is expected that a user has installed the [ParserFunctions][ext:pf] extension. 4 | 5 | - The naming of a template is of no real importance with the only restriction that 6 | type-template assignments and names should correlate with each other 7 | - Template parameter names correspond to the names used in the `#scite` parser 8 | function which are independent of property assignments (`MediaWiki:Sci-property-definition`) 9 | 10 | ## MediaWiki:Sci-template-definition 11 | 12 | `MediaWiki:Sci-template-definition` page may contain the following type-template 13 | assignments ([see also](03-template-mapping.md)). 14 | 15 | ``` 16 | article|Sci-mla-citation-formatter 17 | journal|Sci-mla-citation-formatter 18 | journal article|Sci-mla-citation-formatter 19 | inproceedings|Sci-mla-citation-formatter 20 | book|Sci-mla-citation-formatter 21 | personal|Sci-viaf-citation-formatter 22 | internet|Sci-mla-citation-formatter-web-publication 23 | research-article|Sci-mla-citation-formatter-web-publication 24 | ``` 25 | 26 | ### Examples 27 | 28 | - [Template:Sci-mla-citation-formatter](tmpl-sci-mla-citation-formatter.mediawiki) 29 | - [Template:Sci-mla-citation-formatter-book (incomplete)](tmpl-sci-mla-citation-formatter.mediawiki) 30 | - [Template:Sci-mla-citation-formatter-web-publication](tmpl-sci-mla-citation-formatter-web-publication.mediawiki) 31 | - [Template:Sci-apa-citation-formatter (incomplete)](tmpl-sci-apa-citation-formatter.mediawiki) 32 | - [Template:Sci-apa-citation-formatter-journal (incomplete)](tmpl-sci-apa-citation-formatter-journal.mediawiki) 33 | - [Template:Sci-apa-citation-formatter-web-publication (incomplete)](tmpl-sci-apa-citation-formatter-web-publication.mediawiki) 34 | - [Template:Sci-viaf-citation-formatter](tmpl-sci-viaf-citation-formatter.mediawiki) 35 | 36 | 37 | [ext:pf]: https://www.mediawiki.org/wiki/Extension:ParserFunctions 38 | -------------------------------------------------------------------------------- /docs/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Setup and configuration 2 | 3 | - SMW version: 4 | - SCI version: 5 | - MW version: 6 | - DB (MySQL etc. and version): 7 | 8 | ### Issue 9 | 10 | Produces a [stack trace](https://www.semantic-mediawiki.org/wiki/Help:Identifying_bugs) and outputs: 11 | 12 | ``` 13 | ``` 14 | 15 | Steps to reproduce the observation (recommendation is to use the [sandbox](https://sandbox.semantic-mediawiki.org)): 16 | -------------------------------------------------------------------------------- /docs/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | This PR is made in reference to: # 2 | 3 | This PR addresses or contains: 4 | - ... 5 | - ... 6 | - ... 7 | 8 | This PR includes: 9 | - [ ] Tests (unit/integration) 10 | - [ ] CI build passed 11 | 12 | Fixes # 13 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## Configuration 2 | 3 | - [00 configuration](00-configuration.md) 4 | 5 | ## Manual 6 | 7 | - [01 introduction](01-introduction.md) 8 | - [02 property mapping](02-property-mapping.md) 9 | - [03 template mapping](03-template-mapping.md) 10 | - [04 #scite parser](04-scite.md) 11 | - [05 #referencelist parser](05-referencelist.md) 12 | - [06 references and in-text citation](06-references.md) 13 | - [07 metadata search](07-metadata-search.md) 14 | - [08 faq](08-faq.md) 15 | - [09 technical notes](09-notes.md) 16 | 17 | ## Examples 18 | 19 | - [10 template examples](10-template-examples.md) 20 | -------------------------------------------------------------------------------- /docs/tmpl-sci-apa-citation-formatter-journal.mediawiki: -------------------------------------------------------------------------------- 1 | [[Category:Semantic Cite]] [[Category:Citation formatter]]{{{authors}}}. ({{{year}}}) "{{{title}}}". ''{{{journal}}}'' {{#if: {{{volume|}}} | {{{volume}}}({{{number|}}}) | }} {{#if: {{{pages|}}} |: {{{pages}}}. |. }} {{#if: {{{doi|}}} |doi: [http://dx.doi.org/{{{doi}}} {{{doi}}}] | }} -------------------------------------------------------------------------------- /docs/tmpl-sci-apa-citation-formatter-web-publication.mediawiki: -------------------------------------------------------------------------------- 1 | [[Category:Semantic Cite]] [[Category:Citation formatter]]{{{authors}}}. ({{{year}}}) "{{{title}}}". ''{{{journal}}}'' {{#if: {{{volume|}}} | {{{volume}}}({{{number|}}}) | }} {{#if: {{{pages|}}} |: {{{pages}}}. |. }} {{#if: {{{url|}}} |Retrieved from {{{url}}}. |. }} -------------------------------------------------------------------------------- /docs/tmpl-sci-apa-citation-formatter.mediawiki: -------------------------------------------------------------------------------- 1 | [[Category:Semantic Cite]] [[Category:Citation formatter]]{{{authors}}} ({{{year}}}). {{{title}}}. {{{publisher}}}{{#if: {{{volume|}}} |, {{{volume}}} | }}{{#if: {{{pages|}}} |, {{{pages}}}. |. }} -------------------------------------------------------------------------------- /docs/tmpl-sci-mla-citation-formatter-book.mediawiki: -------------------------------------------------------------------------------- 1 | MLA (Modern Language Association) style is most commonly used to cite sources within the liberal arts and humanities. 2 | * [https://owl.english.purdue.edu/owl/resource/747/01/ MLA Formatting and Style Guide] 3 | * [http://www.citationmachine.net/mla/cite-a-book Citation Machine: MLA format citation generator for book] [[Category:Semantic Cite]] [[Category:Citation formatter]]{{#if: {{{authors|}}} |{{{authors}}}. | {{{author}}}. }} "{{{title}}}". {{#if: {{{journal|}}} | {{{journal}}} | {{{publisher}}} }} {{#if: {{{volume|}}} | {{{volume}}}.{{{number|}}} | }} ({{{year}}}){{#if: {{{pages|}}} |: {{{pages}}}. |. }} {{#if: {{{doi|}}} |doi: [http://dx.doi.org/{{{doi}}} {{{doi}}}] | }} {{#if: {{{pmcid|}}} |PMCID: [https://www.ncbi.nlm.nih.gov/pmc/{{{pmcid}}} {{{pmcid}}}] | }} -------------------------------------------------------------------------------- /docs/tmpl-sci-mla-citation-formatter-web-publication.mediawiki: -------------------------------------------------------------------------------- 1 | [https://owl.english.purdue.edu/owl/resource/747/08/ MLA Works Cited: Electronic Sources] (Web Publications) states that: 2 | * Publisher information, including the publisher name and publishing date. 3 | * Take note of any page numbers (if available). 4 | * Medium of publication. 5 | * Date you accessed the material 6 | * URL (if required, or for your own personal reference; MLA does not require a URL). [[Category:Semantic Cite]] [[Category:Citation formatter]]{{#if: {{{authors|}}} |{{{authors}}}. | }} "{{{title}}}". {{#if: {{{publisher|}}} | {{{publisher}}} | }} {{#if: {{{volume|}}} | {{{volume}}}.{{{number|}}} | }} {{#if: {{{year|}}} | ({{{year}}}) | }} {{#if: {{{pages|}}} |: {{{pages}}}. | }} {{#if: {{{url|}}} |<[{{{url}}} {{{url}}}]> | }} Accessed: {{{accessed}}} -------------------------------------------------------------------------------- /docs/tmpl-sci-mla-citation-formatter.mediawiki: -------------------------------------------------------------------------------- 1 | [[Category:Semantic Cite]] [[Category:Citation formatter]]{{#if: {{{bibtex-author|}}} |{{{bibtex-author}}}. | {{{author}}}. }} ''{{{title}}}''. {{#if: {{{publisher|}}} |{{{publisher}}}. | }}{{#if: {{{edition|}}} |{{{edition}}} ed. | }}, {{{year|pubdate}}}. -------------------------------------------------------------------------------- /docs/tmpl-sci-viaf-citation-formatter.mediawiki: -------------------------------------------------------------------------------- 1 | Virtual International Authority File (VIAF)[[Category:Semantic Cite]] [[Category:Citation formatter]]{{{name}}} ({{{viaf}}}) -------------------------------------------------------------------------------- /extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SemanticCite", 3 | "version": "3.0.0", 4 | "author": [ 5 | "James Hong Kong" 6 | ], 7 | "url": "https://github.com/SemanticMediaWiki/SemanticCite/", 8 | "descriptionmsg": "sci-desc", 9 | "namemsg": "sci-name", 10 | "license-name": "GPL-2.0-or-later", 11 | "type": "semantic", 12 | "requires": { 13 | "MediaWiki": ">= 1.39", 14 | "extensions": { 15 | "SemanticMediaWiki": ">= 4.0" 16 | } 17 | }, 18 | "AutoloadNamespaces": { 19 | "SCI\\": "src/" 20 | }, 21 | "AutoloadClasses": { 22 | "SemanticCite": "SemanticCite.php" 23 | }, 24 | "TestAutoloadNamespaces": { 25 | "SCI\\Tests\\": "tests/phpunit/Unit/", 26 | "SCI\\Tests\\Integration\\": "tests/phpunit/Integration/" 27 | }, 28 | "MessagesDirs": { 29 | "SemanticCite": [ 30 | "i18n" 31 | ] 32 | }, 33 | "callback": "SemanticCite::initExtension", 34 | "ExtensionFunctions": [ 35 | "SemanticCite::onExtensionFunction" 36 | ], 37 | "load_composer_autoloader": true, 38 | "manifest_version": 2 39 | } 40 | -------------------------------------------------------------------------------- /i18n/SemanticCite.alias.php: -------------------------------------------------------------------------------- 1 | [ 'FindCitableMetadata', 'FindMetadataById' ] 15 | ]; 16 | 17 | /** German (Deutsch) */ 18 | $specialPageAliases['de'] = [ 19 | 'FindCitableMetadata' => [ 'Metadatensuche_nach_Identifizierungskennung' ] 20 | ]; 21 | -------------------------------------------------------------------------------- /i18n/SemanticCite.magic.php: -------------------------------------------------------------------------------- 1 | [ 0, 'scite' ], 13 | 'referencelist' => [ 0, 'referencelist' ], 14 | 'SCI_NOREFERENCELIST' => [ 0, '__NOREFERENCELIST__' ] 15 | ]; 16 | 17 | /** 18 | * German (Deutsch) 19 | */ 20 | $magicWords['de'] = [ 21 | 'referencelist' => [ 0, 'referenzierungen' ], 22 | 'SCI_NOREFERENCELIST' => [ 0, '__KEINE_REFERENZIERUNGEN__', '__KEINEREFERENZIERUNGEN__' ] 23 | ]; 24 | -------------------------------------------------------------------------------- /i18n/bn.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Aftabuzzaman", 5 | "Aishik Rehman", 6 | "আফতাবুজ্জামান" 7 | ] 8 | }, 9 | "sci-referencelist-header": "তথ্যসূত্র", 10 | "sci-specials-header-results": "ফলাফলের তালিকা", 11 | "sci-specials-select-options": "বিকল্প নির্বাচন করুন", 12 | "sci-specials-no-results": "কোনো ফলাফল উপলব্ধ নয়।", 13 | "sci-metadata-search-action-highlight": "লেখা নির্বাচন করুন", 14 | "sci-metadata-search-action-create": "তৈরি করুন", 15 | "sci-metadata-search-header-log": "লগ", 16 | "sci-metadata-search-header-result": "ফলাফল", 17 | "sci-metadata-search-form-submit": "অনুসন্ধান", 18 | "sci-metadata-search-select-label": "ধরন:" 19 | } 20 | -------------------------------------------------------------------------------- /i18n/br.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Dishual", 5 | "Fulup", 6 | "Y-M D" 7 | ] 8 | }, 9 | "sci-referencelist-header": "Daveennoù", 10 | "sci-specials-header-results": "Roll an disoc'hoù", 11 | "sci-specials-no-results": "Disoc'h ebet", 12 | "sci-metadata-search-form": "Dre god anaout", 13 | "sci-metadata-search-action-highlight": "Diuzañ an destenn", 14 | "sci-metadata-search-action-create": "Krouiñ", 15 | "sci-metadata-search-header-log": "Marilh", 16 | "sci-metadata-search-header-result": "Disoc'h", 17 | "sci-metadata-search-form-submit": "Klask", 18 | "sci-metadata-search-select-label": "Seurt :" 19 | } 20 | -------------------------------------------------------------------------------- /i18n/ca.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Fitoschido", 5 | "Macofe", 6 | "Toniher" 7 | ] 8 | }, 9 | "sci-referencelist-header": "Referències", 10 | "sci-datavalue-invalid-id-value": "El valor «$1» no és vàlid per al tipus $2.", 11 | "findmetadatabyid": "Cerca metadades", 12 | "findcitablemetadata": "Cerca metadades citables", 13 | "sci-specials-header-results": "Llista de resultats", 14 | "sci-specials-select-options": "Selecciona opcions", 15 | "sci-specials-no-results": "No hi ha cap resultat disponible.", 16 | "sci-metadata-search-form": "Per identificador", 17 | "sci-metadata-search-action-highlight": "Selecciona text", 18 | "sci-metadata-search-action-create": "Crea", 19 | "sci-metadata-search-header-log": "Registre", 20 | "sci-metadata-search-header-result": "Resultat", 21 | "sci-metadata-search-form-submit": "Cerca", 22 | "sci-metadata-search-select-label": "Tipus:", 23 | "sci-metadata-search-cached": "S’ha recuperat la resposta de la cerca des de la memòria cau." 24 | } 25 | -------------------------------------------------------------------------------- /i18n/ce.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Умар" 5 | ] 6 | }, 7 | "sci-referencelist-header": "Билгалдахарш", 8 | "sci-property-alias-citation-key": "Цитатин догӀа", 9 | "sci-property-alias-citation-reference": "Цитатин тӀе хьажорг", 10 | "sci-property-alias-citation-text": "Цитатин текст", 11 | "sci-property-alias-citation-resource": "Цитатин ресурс", 12 | "findmetadatabyid": "Метахаамаш лаха", 13 | "sci-specials-select-options": "Харжа опцеш", 14 | "sci-specials-no-results": "Цхьа а жамӀ дац.", 15 | "sci-metadata-search-form": "ID-ца", 16 | "sci-metadata-search-action-highlight": "Текст схьахаржа", 17 | "sci-metadata-search-action-create": "Кхолла", 18 | "sci-metadata-search-header-log": "Журнал", 19 | "sci-metadata-search-header-result": "Хилам", 20 | "sci-metadata-search-form-submit": "Лахар", 21 | "sci-metadata-search-select-label": "Тайпа:" 22 | } 23 | -------------------------------------------------------------------------------- /i18n/cy.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Robin Owain" 5 | ] 6 | }, 7 | "sci-referencelist-header": "Cyfeiriadau", 8 | "sci-property-alias-citation-key": "Allwedd y cyfeiriad", 9 | "sci-property-alias-citation-reference": "Cyfeiriad", 10 | "sci-property-alias-citation-text": "Testun y cyfeiriad", 11 | "sci-property-alias-citation-resource": "Adnoddau ar gyfer y gyfeiriadaeth", 12 | "findmetadatabyid": "Canfod metadata", 13 | "findcitablemetadata": "Canfod metadata yn gyfeiriadaeth", 14 | "sci-specials-header-results": "Rhestr ganlyniadau", 15 | "sci-specials-select-options": "Dewis opsiynau", 16 | "sci-specials-no-results": "Dim canlyniad.", 17 | "sci-metadata-search-form": "Fesul ID", 18 | "sci-metadata-search-action-highlight": "Dewisiwch y testun", 19 | "sci-metadata-search-action-create": "Creu", 20 | "sci-metadata-search-header-log": "Log", 21 | "sci-metadata-search-header-result": "Canlyniad", 22 | "sci-metadata-search-form-submit": "Chwilio", 23 | "sci-metadata-search-select-label": "Math:" 24 | } 25 | -------------------------------------------------------------------------------- /i18n/da.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Joedalton", 5 | "Saederup92" 6 | ] 7 | }, 8 | "sci-referencelist-header": "Henvisninger", 9 | "sci-datavalue-invalid-id-value": "\"$1\" er en ugyldig værdi for $2 typen.", 10 | "sci-property-alias-citation-text": "Citeringstekst", 11 | "findmetadatabyid": "Find metadata", 12 | "sci-specials-header-results": "Liste over resultater", 13 | "sci-specials-select-options": "Vælg indstillinger", 14 | "sci-specials-no-results": "Ingen resultater tilgængelige.", 15 | "sci-metadata-search-form": "Efter id", 16 | "sci-metadata-search-action-highlight": "Vælg tekst", 17 | "sci-metadata-search-action-create": "Opret", 18 | "sci-metadata-search-header-log": "Log", 19 | "sci-metadata-search-header-result": "Resultat", 20 | "sci-metadata-search-form-submit": "Søg", 21 | "sci-metadata-search-select-label": "Tast:" 22 | } 23 | -------------------------------------------------------------------------------- /i18n/de-formal.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Kghbln" 5 | ] 6 | }, 7 | "sci-metadata-search-intro": "Bitte geben Sie ein Identifizierungsmerkmal an und wählen Sie einen Dienstanbieter aus (erfordert eine aktive Internetverbindung), um abrufbare Metadaten im für die Parserfunktion #scite erforderlichen Format zuzuordnen." 8 | } 9 | -------------------------------------------------------------------------------- /i18n/diq.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Kumkumuk", 5 | "Mirzali" 6 | ] 7 | }, 8 | "sci-referencelist-header": "Çımeyi", 9 | "sci-property-alias-citation-key": "Kılitê istasyoni", 10 | "sci-property-alias-citation-reference": "Referansê istasyoni", 11 | "sci-property-alias-citation-text": "Metnê istasyoni", 12 | "sci-property-alias-citation-resource": "Çımey istasyoni", 13 | "findmetadatabyid": "Metadata bıvin", 14 | "sci-specials-header-results": "Listey neticeyan", 15 | "sci-specials-select-options": "Hereketan weçine", 16 | "sci-specials-no-results": "Qet neticey nêvineyay", 17 | "sci-metadata-search-form": "ID", 18 | "sci-metadata-search-action-highlight": "Metın weçine", 19 | "sci-metadata-search-action-create": "Vıraze", 20 | "sci-metadata-search-header-log": "Qeyd", 21 | "sci-metadata-search-header-result": "Netice", 22 | "sci-metadata-search-form-submit": "Cı geyre", 23 | "sci-metadata-search-select-label": "Babet:" 24 | } 25 | -------------------------------------------------------------------------------- /i18n/el.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "NikosLikomitros", 5 | "Nikosgranturismogt", 6 | "Veronikialexopulos" 7 | ] 8 | }, 9 | "sci-referencelist-header": "Παραπομπές", 10 | "sci-property-alias-citation-key": "Κλειδί παραπομπής", 11 | "sci-property-alias-citation-reference": "Αναφορά παραπομπής", 12 | "sci-specials-header-results": "Λίστα αποτελεσμάτων", 13 | "sci-specials-select-options": "Επιλογή επιλογών", 14 | "sci-specials-no-results": "Δεν υπάρχουν διαθέσιμα αποτελέσματα.", 15 | "sci-metadata-search-form": "Ανά αναγνωριστικό", 16 | "sci-metadata-search-action-highlight": "Επιλογή κειμένου", 17 | "sci-metadata-search-action-create": "Δημιουργία", 18 | "sci-metadata-search-header-log": "Μητρώο", 19 | "sci-metadata-search-header-result": "Αποτέλεσμα", 20 | "sci-metadata-search-form-submit": "Αναζήτηση", 21 | "sci-metadata-search-select-label": "Τύπος:", 22 | "smw-pa-property-predefined__sci_cite": "Η «$1» είναι προκαθορισμένη ιδιοκτησία παρωχημένη από την επέκταση [https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Cite Semantic Cite], η οποία περιγράφει όλα τα στοιχεία μίας παραπομπής και είναι αποθηκευμένη ως υποαντικείμενο.", 23 | "smw-pa-property-predefined__sci_olid": "Η «$1» είναι προκαθορισμένη ιδιοκτησία παρωχημένη από την προέκταση [https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Cite Semantic Cite], η οποία εξακριβώνει την ταυτότητα των αρχείων OpenLibrary." 24 | } 25 | -------------------------------------------------------------------------------- /i18n/fa.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Alifakoor", 5 | "Alirezaaa", 6 | "Beginneruser", 7 | "Ebrahim", 8 | "Ebraminio", 9 | "Mahdy Saffar", 10 | "Ommmmid", 11 | "Reza1615" 12 | ] 13 | }, 14 | "sci-referencelist-header": "صفحه‌ها", 15 | "sci-scite-parser-no-reference": "#scite منبعی را مشخص نکرد.", 16 | "sci-scite-parser-no-type": "#scite نتوانست منبعی از نوع \"$1\" بیابد.", 17 | "sci-scite-parser-no-citation-text": "#scite نتوانست یک متن یادکرد برای منبع \"$1\" بسازد، چرا که به نوع \"$2\" [[MediaWiki:Sci-template-definition|الگویی]] اختصاص داده نشده است.", 18 | "sci-datavalue-empty-reference": "منبع ذکر شده نمی‌تواند خالی باشد.", 19 | "sci-datavalue-invalid-id-value": "\"$1\" برای نوع $2 مقداری نامعتبر است.", 20 | "sci-property-alias-citation-key": "کلید مدرک", 21 | "sci-property-alias-citation-reference": "منبع ارجاع", 22 | "sci-property-alias-citation-text": "متن ارجاع", 23 | "sci-property-alias-citation-resource": "منبع مدرک", 24 | "findmetadatabyid": "جستجوی فراداده", 25 | "findcitablemetadata": "جستجوی فرادادهٔ قابل ارجاع", 26 | "right-sci-metadatasearch": "دسترسی جستجوی فراداده", 27 | "action-sci-metadatasearch": "جستجوی فراداده‌ای یادکرد معناشناختی", 28 | "sci-specials-header-results": "فهرست نتایج", 29 | "sci-specials-select-options": "انتخاب گزینه‌ها", 30 | "sci-specials-no-results": "هیچ نتیجه‌ای یافت نشد.", 31 | "listcitationreferencebacklinks": "فهرست پیونددهنده‌های منبع مدرک", 32 | "sci-metadata-search-form": "با شناسه", 33 | "sci-metadata-search-action-highlight": "انتخاب متن", 34 | "sci-metadata-search-action-create": "ایجاد", 35 | "sci-metadata-search-header-log": "سیاهه", 36 | "sci-metadata-search-header-result": "نتیجه", 37 | "sci-metadata-search-form-submit": "جستجو کن", 38 | "sci-metadata-search-select-label": "نوع:", 39 | "sci-metadata-search-read-only": "پایگاه‌داده فقط در حالت خواندن در دسترس است و مانع از ساخت خودکار صفحه می‌شود.", 40 | "sci-metadata-search-has-match": "شناسه با منابعی که دارای همان شناسه و شامل $1 هستند مطابقت پیدا کرده است.", 41 | "sci-metadata-search-cached": "پاسخ جستجو از حافظۀ نهان واکشی شد.", 42 | "sci-metadata-search-intro-ol": "[[Property:OLID|OLID]] شابک جهت تطابق با یک رکورد OpenLibrary", 43 | "onoi-remi-request-error": "درخواست اچ‌تی‌تی‌پی/رست، \"$1\" را برای \"$2\" بازگرداند.", 44 | "onoi-remi-response-empty": "پاسخی خالی برای \"$1\" بازگشت.", 45 | "onoi-remi-parser-no-id-match": "پارسر نتوانست $1 را مطابقت دهد" 46 | } 47 | -------------------------------------------------------------------------------- /i18n/fi.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "01miki10", 5 | "Pyscowicz", 6 | "Samoasambia" 7 | ] 8 | }, 9 | "sci-referencelist-header": "Viitteet", 10 | "sci-datavalue-invalid-id-value": "\"$1\" on virheellinen arvo tyypille $2.", 11 | "sci-property-alias-citation-text": "Lainausteksti", 12 | "findmetadatabyid": "Etsi metatiedot", 13 | "sci-specials-header-results": "Luettelo tuloksista", 14 | "sci-specials-select-options": "Valitse vaihtoehto", 15 | "sci-specials-no-results": "Ei tuloksia saatavilla.", 16 | "sci-metadata-search-action-highlight": "Valitse teksti", 17 | "sci-metadata-search-action-create": "Luo", 18 | "sci-metadata-search-header-log": "Loki", 19 | "sci-metadata-search-header-result": "Tulos", 20 | "sci-metadata-search-form-submit": "Hae", 21 | "sci-metadata-search-select-label": "Tyyppi:", 22 | "sci-metadata-search-read-only": "Tietokanta on vain luku -tilassa ja voi estää automaattisen sivujen luonnin." 23 | } 24 | -------------------------------------------------------------------------------- /i18n/hi.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Sfic", 5 | "चक्रपाणी", 6 | "संजीव कुमार" 7 | ] 8 | }, 9 | "sci-desc": "[https://www.semantic-mediawiki.org सेमांटिक मीडियाविकि] की सहायता से उद्धरण संसाधनों का प्रबन्धन", 10 | "sci-referencelist-header": "संदर्भ", 11 | "sci-scite-parser-no-reference": "#scite ने कोई सन्दर्भ घोषित नहीं किया।", 12 | "sci-scite-parser-no-type": "#scite, $1 के लिए सन्दर्भ प्रकार निर्धारित करने में अक्षम है।", 13 | "sci-datavalue-empty-reference": "उद्धरण सन्दर्भ का खाली रखना अपेक्षित नहीं है।", 14 | "sci-datavalue-invalid-id-value": "$2 प्रकार हेतु \"$1\" एक अमान्य मान है।", 15 | "sci-property-alias-citation-key": "उद्धरण चाबी", 16 | "sci-property-alias-citation-reference": "उद्धरण संदर्भ", 17 | "sci-property-alias-citation-text": "उद्धरण टेक्स्ट", 18 | "sci-property-alias-citation-resource": "उद्धरण स्रोत", 19 | "findmetadatabyid": "मेटाडाटा खोजें", 20 | "findcitablemetadata": "उद्धरण योग्य मेटाडेटा खोजें", 21 | "right-sci-metadatasearch": "मेटाडेटा खोज एक्सेस", 22 | "action-sci-metadatasearch": "सेमांटिक साइट मॅटा-डाटा खोज", 23 | "sci-specials-header-results": "परिणामों की सूची", 24 | "sci-specials-select-options": "विकल्प चुनें", 25 | "sci-specials-no-results": "कोई परिणाम उपलब्ध नहीं।", 26 | "listcitationreferencebacklinks": "उद्धरण संदर्भ बैकलिंक सूची", 27 | "sci-metadata-search-form": "आईडी अनुसार", 28 | "sci-metadata-search-action-highlight": "टेक्स्ट चुनें", 29 | "sci-metadata-search-action-create": "बनाएं", 30 | "sci-metadata-search-header-log": "लॉग", 31 | "sci-metadata-search-header-result": "परिणाम", 32 | "sci-metadata-search-form-submit": "खोजें", 33 | "sci-metadata-search-select-label": "प्रकार:", 34 | "sci-metadata-search-read-only": "डेटाबेस केवल पठन-योग्य विधा में है और स्वतः-पृष्ठ निर्माण को बाधित कर सकता है।", 35 | "sci-metadata-search-cached": "खोज उत्तर कैश में पाये गये।", 36 | "onoi-remi-parser-no-id-match": "पर्सर \"$1\" को मिलाने में सक्षम नहीं है।" 37 | } 38 | -------------------------------------------------------------------------------- /i18n/hu.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Bencemac", 5 | "Urbalazs", 6 | "Wolf Rex" 7 | ] 8 | }, 9 | "sci-referencelist-header": "Források", 10 | "sci-scite-parser-not-enabled-namespace": "A(z) #scite nem használható azon névterekben, melyek nincsenek engedélyezve a Sematic MediaWiki számára", 11 | "sci-datavalue-invalid-id-value": "A(z) „$1” érvénytelen érték a(z) $2 típushoz", 12 | "sci-property-alias-citation-reference": "Idézet forrása", 13 | "sci-property-alias-citation-text": "Idézet szövege", 14 | "findmetadatabyid": "Metaadat keresése", 15 | "sci-specials-header-results": "Találatok listája", 16 | "sci-metadata-search-form": "Azonosító szerint", 17 | "sci-metadata-search-action-create": "Létrehozás", 18 | "sci-metadata-search-header-log": "Napló", 19 | "sci-metadata-search-header-result": "Eredmény", 20 | "sci-metadata-search-form-submit": "Keresés", 21 | "sci-metadata-search-select-label": "Típus:" 22 | } 23 | -------------------------------------------------------------------------------- /i18n/id.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Bagas Chrisara", 5 | "Kenrick95" 6 | ] 7 | }, 8 | "sci-referencelist-header": "Referensi", 9 | "sci-property-alias-citation-key": "Kunci rujukan", 10 | "sci-property-alias-citation-reference": "Referensi rujukan", 11 | "sci-property-alias-citation-text": "Teks rujukan", 12 | "sci-property-alias-citation-resource": "Sumber rujukan", 13 | "findmetadatabyid": "Temukan metadata", 14 | "findcitablemetadata": "Temukan metadata yang dapat dirujuk", 15 | "right-sci-metadatasearch": "Pencarian akses metadata", 16 | "action-sci-metadatasearch": "pencarian metadata Semantic Cite", 17 | "sci-specials-header-results": "Daftar hasil", 18 | "sci-specials-select-options": "Pilih tindakan", 19 | "sci-specials-no-results": "Hasil tidak tersedia", 20 | "listcitationreferencebacklinks": "Daftar pranala balik referensi rujukan", 21 | "sci-metadata-search-form": "Melalui ID", 22 | "sci-metadata-search-action-highlight": "Pilih teks", 23 | "sci-metadata-search-action-create": "Buat", 24 | "sci-metadata-search-header-log": "Log", 25 | "sci-metadata-search-header-result": "Hasil", 26 | "sci-metadata-search-form-submit": "Cari", 27 | "sci-metadata-search-select-label": "Jenis:" 28 | } 29 | -------------------------------------------------------------------------------- /i18n/ilo.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Lam-ang" 5 | ] 6 | }, 7 | "sci-referencelist-header": "Dagiti nagibasaran", 8 | "sci-property-alias-citation-key": "Tekla ti dakamat", 9 | "sci-property-alias-citation-reference": "Nagibasaran ti dakamat", 10 | "sci-property-alias-citation-text": "Teksto ti dakamat", 11 | "sci-property-alias-citation-resource": "Rekurso ti dakamat", 12 | "findmetadatabyid": "Biruken ti metadata", 13 | "findcitablemetadata": "Biruken ti madakamat a metadata", 14 | "right-sci-metadatasearch": "Sumrekan ti panagbiruk iti metadata", 15 | "action-sci-metadatasearch": "ti panagbiruk iti metadata a Semantic Cite", 16 | "sci-specials-header-results": "Listaan dagiti resulta", 17 | "sci-specials-select-options": "Agpili kadagiti pagpilian", 18 | "sci-specials-no-results": "Awan dagiti magun-od a resulta.", 19 | "sci-metadata-search-form": "Babaen ti ID", 20 | "sci-metadata-search-action-highlight": "Pilien ti teksto", 21 | "sci-metadata-search-action-create": "Agpartuat", 22 | "sci-metadata-search-header-log": "Listaan", 23 | "sci-metadata-search-header-result": "Resulta", 24 | "sci-metadata-search-form-submit": "Agbiruk", 25 | "sci-metadata-search-select-label": "Kita:" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/io.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Joao Xavier" 5 | ] 6 | }, 7 | "sci-referencelist-header": "Referi", 8 | "sci-scite-parser-not-enabled-namespace": "#scite Ne povis uzesar che ''namespace'' qua ne esas permisata segun MediaWiki-semantiko", 9 | "sci-property-alias-citation-text": "Citajo", 10 | "sci-property-alias-citation-resource": "Fonto di la citajo", 11 | "findmetadatabyid": "Renkontrar 'metadata'", 12 | "sci-specials-header-results": "Listo di rezulti", 13 | "sci-metadata-search-form": "Segun ID", 14 | "sci-metadata-search-action-highlight": "Selektez texto", 15 | "sci-metadata-search-action-create": "Krear", 16 | "sci-metadata-search-header-log": "Log (sendar selektita texto al JavaScript-fenestro)", 17 | "sci-metadata-search-header-result": "Rezulto", 18 | "sci-metadata-search-form-submit": "Serchez", 19 | "sci-metadata-search-select-label": "Tipo:" 20 | } 21 | -------------------------------------------------------------------------------- /i18n/it.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Beta16", 5 | "Macofe", 6 | "Selven", 7 | "Urielejh" 8 | ] 9 | }, 10 | "sci-referencelist-header": "Riferimenti", 11 | "sci-property-alias-citation-text": "Testo della citazione", 12 | "sci-specials-header-results": "Elenco dei risultati", 13 | "sci-specials-select-options": "Seleziona le opzioni", 14 | "sci-specials-no-results": "Nessun risultato disponibile.", 15 | "sci-metadata-search-form": "Per ID", 16 | "sci-metadata-search-action-highlight": "Seleziona testo", 17 | "sci-metadata-search-action-create": "Crea", 18 | "sci-metadata-search-header-log": "Registro", 19 | "sci-metadata-search-header-result": "Risultato", 20 | "sci-metadata-search-form-submit": "Ricerca", 21 | "sci-metadata-search-select-label": "Tipo:" 22 | } 23 | -------------------------------------------------------------------------------- /i18n/ja.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Shirayuki", 5 | "Sujiniku", 6 | "Suyama", 7 | "Yusuke1109", 8 | "mwjames", 9 | "おはぐろ蜻蛉" 10 | ] 11 | }, 12 | "sci-referencelist-header": "情報源", 13 | "sci-scite-parser-not-enabled-namespace": "Semantic MediaWiki のために有効化されていない名前空間では、#scite は使用できません", 14 | "sci-scite-parser-no-reference": "#scite は参照を宣言していません。", 15 | "sci-datavalue-empty-reference": "引用の参照は、空白でないことが予想されます。", 16 | "sci-property-alias-citation-key": "引用キー", 17 | "sci-property-alias-citation-reference": "引用", 18 | "sci-property-alias-citation-text": "引用書目", 19 | "sci-property-alias-citation-resource": "引用リソース", 20 | "findmetadatabyid": "メタデータの発見", 21 | "action-sci-metadatasearch": "Semantic Cite メタデータ検索", 22 | "sci-specials-header-results": "結果の一覧", 23 | "sci-specials-select-options": "オプションを選択", 24 | "sci-specials-no-results": "該当結果はありません。", 25 | "sci-metadata-search-form": "IDで", 26 | "sci-metadata-search-action-highlight": "テキストを選択", 27 | "sci-metadata-search-action-create": "作成", 28 | "sci-metadata-search-header-log": "ログ", 29 | "sci-metadata-search-header-result": "結果", 30 | "sci-metadata-search-form-submit": "検索", 31 | "sci-metadata-search-select-label": "種類:", 32 | "sci-metadata-search-read-only": "データベースは読み取り専用モードであり、自動ページ作成を妨げることがあります。", 33 | "sci-metadata-search-cached": "この検索結果はキャッシュから読み込まれました。", 34 | "sci-metadata-search-intro-doi": "CrossRef レポジトリ検索のための [[Property:DOI|DOI]]", 35 | "sci-metadata-search-intro-ol": "OpenLibrary record に一致する、 [[Property:OLID|OLID]] または ISBN 番号", 36 | "sci-metadata-search-intro-viaf": "Virtual International Authority File ための検索のための [[Property:VIAF|VIAF]] 番号", 37 | "onoi-remi-request-error": "REST/HTTP リクエストは \"$2\" のため、\"$1\" エラーで終了しました。", 38 | "onoi-remi-response-empty": "応答が、「$1」のための空白の結果をかえしました。", 39 | "onoi-remi-parser-no-id-match": "パーサは「$1」と一致することができませんでした。", 40 | "sci-tooltip-citation-lookup-failure": "「$1」のためのバックエンドからの適切な引数の取得に失敗しました。", 41 | "sci-tooltip-citation-lookup-failure-multiple": "複数の一致を持っている「$1」のための引用テキストの取得に失敗しました。" 42 | } 43 | -------------------------------------------------------------------------------- /i18n/jv.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "NoiX180" 5 | ] 6 | }, 7 | "sci-property-alias-citation-key": "Kunci sitiran", 8 | "sci-property-alias-citation-reference": "Rujukan sitiran", 9 | "sci-property-alias-citation-text": "Tèks sitiran", 10 | "findmetadatabyid": "Golèk métadata", 11 | "findcitablemetadata": "Golèk métadata kang bisa kasitir", 12 | "sci-specials-header-results": "Pratélan kasil", 13 | "sci-specials-select-options": "Pilih wikalpa", 14 | "sci-specials-no-results": "Ora ana kasil.", 15 | "sci-metadata-search-form": "Miturut ID", 16 | "sci-metadata-search-action-highlight": "Pilih tèks", 17 | "sci-metadata-search-action-create": "Gawé", 18 | "sci-metadata-search-header-log": "Log", 19 | "sci-metadata-search-header-result": "Kasil", 20 | "sci-metadata-search-form-submit": "Golèk", 21 | "sci-metadata-search-select-label": "Jinis:" 22 | } 23 | -------------------------------------------------------------------------------- /i18n/ko.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Hwangjy9", 5 | "Nuevo Paso", 6 | "Ykhwong", 7 | "고솜" 8 | ] 9 | }, 10 | "sci-desc": "[https://www.semantic-mediawiki.org Semantic MediaWiki]를 사용하여 출처를 관리하세요", 11 | "sci-referencelist-header": "각주", 12 | "sci-scite-parser-not-enabled-namespace": "#scite는 시맨틱 미디어위키에서 사용 중이 아닌 이름공간에서 사용할 수 없습니다", 13 | "sci-scite-parser-no-reference": "#scite는 참조를 선언하지 않았습니다.", 14 | "sci-scite-parser-no-type": "#scite는 \"$1\"에 대한 참조 유형을 결정하지 못했습니다.", 15 | "sci-datavalue-empty-reference": "인용 참조는 비어있지 않는 것으로 예측됩니다.", 16 | "sci-datavalue-invalid-id-value": "\"$1\"은 $2 유형에 대한 유효하지 않은 값입니다.", 17 | "sci-property-alias-citation-key": "인용 키", 18 | "sci-property-alias-citation-reference": "인용 참조", 19 | "sci-property-alias-citation-text": "인용 텍스트", 20 | "sci-property-alias-citation-resource": "인용 리소스", 21 | "findmetadatabyid": "메타데이터 찾기", 22 | "findcitablemetadata": "인용 가능한 메타데이터 찾기", 23 | "right-sci-metadatasearch": "메타데이터 검색 접근", 24 | "action-sci-metadatasearch": "Semantic Cite 메타데이터 검색", 25 | "sci-specials-header-results": "결과 목록", 26 | "sci-specials-select-options": "검색 옵션", 27 | "sci-specials-no-results": "이용 가능한 결과가 없습니다.", 28 | "listcitationreferencebacklinks": "인용 참조 백링크 목록", 29 | "sci-metadata-search-form": "ID별", 30 | "sci-metadata-search-action-highlight": "텍스트 선택", 31 | "sci-metadata-search-action-create": "만들기", 32 | "sci-metadata-search-header-log": "로그", 33 | "sci-metadata-search-header-result": "결과", 34 | "sci-metadata-search-form-submit": "검색", 35 | "sci-metadata-search-select-label": "유형:", 36 | "sci-metadata-search-read-only": "데이터베이스가 읽기 전용 모드이므로 자동 문서 생성을 방해할 수 있습니다.", 37 | "sci-metadata-search-has-match": "ID가 동일 식별자를 포함하고 다음을 포함하는 인용 자원과 일치되었습니다: $1", 38 | "sci-metadata-search-cached": "검색 응답을 캐시에서 가져왔습니다.", 39 | "sci-metadata-search-intro": "검색 가능한 메타데이터를 #scite 형식에 매핑하려면 식별자를 입력하고 서비스 제공자를 선택해 주십시오. (인터넷 연결 필요)", 40 | "sci-metadata-search-intro-doi": "CrossRef 저장소를 검색하기 위한 [[Property:DOI|DOI]]", 41 | "sci-metadata-search-intro-pubmed": "PubMed Central용 [[Property:PMCID|PMCID]]과 PubMed 아카이브용 [[Property:PMID|PMID]]", 42 | "sci-metadata-search-intro-oclc": "월드캣 카탈로그의 [[Property:OCLC|OCLC]] 번호", 43 | "sci-metadata-search-intro-ol": "오픈라이브러리 레코드에 일치시키기 위한 [[Property:OLID|OLID]] 또는 ISBN 번호", 44 | "sci-metadata-search-intro-viaf": "가상 국제 전거 파일을 검색하기 위한 [[Property:VIAF|VIAF]] 번호", 45 | "onoi-remi-request-error": "\"$2\"에 대해 \"$1\"(으)로 REST/HTTP 요청을 반환했습니다.", 46 | "onoi-remi-response-empty": "\"$1\"에 대해 비어있는 결과로 응답을 반환했습니다.", 47 | "onoi-remi-parser-no-id-match": "파서가 \"$1\" 항목을 일치시키지 못했습니다.", 48 | "sci-tooltip-citation-lookup-failure": "\"$1\"의 백엔드로부터 적절한 인용을 검색하는데 실패했습니다.", 49 | "sci-tooltip-citation-lookup-failure-multiple": "여러 개의 일치가 있는 \"$1\"에 대한 인용 텍스트의 검색을 실패했습니다." 50 | } 51 | -------------------------------------------------------------------------------- /i18n/ksh.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Purodha" 5 | ] 6 | }, 7 | "findcitablemetadata": "Mettadate zom zom Zittehre fenge.", 8 | "sci-specials-header-results": "Leß met dämm, wdd erus kohm", 9 | "sci-specials-select-options": "Söhk jädd uß", 10 | "sci-specials-no-results": "Ed es nix doh, wadd eruß jekumme wöhr.", 11 | "sci-metadata-search-form": "Noh de Kännong" 12 | } 13 | -------------------------------------------------------------------------------- /i18n/lb.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Robby" 5 | ] 6 | }, 7 | "sci-referencelist-header": "Referenzen", 8 | "sci-property-alias-citation-reference": "Referenzéierung", 9 | "sci-property-alias-citation-text": "Text vum Zitat", 10 | "findmetadatabyid": "Metadate fannen", 11 | "sci-specials-header-results": "Lëscht vun de Resultater", 12 | "sci-specials-select-options": "Optiounen auswielen", 13 | "sci-specials-no-results": "Keng Resultater disponibel.", 14 | "sci-metadata-search-form": "No ID", 15 | "sci-metadata-search-action-highlight": "Text eraussichen", 16 | "sci-metadata-search-action-create": "Uleeën", 17 | "sci-metadata-search-header-log": "Logbuch", 18 | "sci-metadata-search-header-result": "Resultat", 19 | "sci-metadata-search-form-submit": "Sichen", 20 | "sci-metadata-search-select-label": "Typ:" 21 | } 22 | -------------------------------------------------------------------------------- /i18n/lt.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Eitvys200", 5 | "Nokeoo", 6 | "Zygimantus" 7 | ] 8 | }, 9 | "sci-referencelist-header": "Šaltiniai", 10 | "sci-scite-parser-no-reference": "#scite nepateikė nuorodos.", 11 | "sci-scite-parser-no-type": "#scite nepavyko nustatyti „$1“ nuorodos tipo.", 12 | "sci-datavalue-empty-reference": "Tikimasi, kad citatos nuoroda nebus tuščia.", 13 | "sci-datavalue-invalid-id-value": "„$1“ yra neteisinga $2 tipo vertė.", 14 | "sci-property-alias-citation-key": "Citatos id", 15 | "sci-property-alias-citation-reference": "Citatos išnaša", 16 | "sci-property-alias-citation-text": "Citatos tekstas", 17 | "sci-property-alias-citation-resource": "Citacijos išteklius", 18 | "findmetadatabyid": "Rasti metaduomenis", 19 | "findcitablemetadata": "Rasti cituotinus metaduomenis", 20 | "right-sci-metadatasearch": "Prieiga prie metaduomenų paieškos", 21 | "action-sci-metadatasearch": "Semantic Cite metaduomenų paieška", 22 | "sci-specials-header-results": "Rezultatų sąrašas", 23 | "sci-specials-select-options": "Pasirinkti nustatymus", 24 | "sci-specials-no-results": "Nėra prieinamų rezultatų.", 25 | "sci-metadata-search-form": "Pagal ID", 26 | "sci-metadata-search-action-highlight": "Pasirinkti tekstą", 27 | "sci-metadata-search-action-create": "Sukurti", 28 | "sci-metadata-search-header-log": "Žurnalas", 29 | "sci-metadata-search-header-result": "Rezultatas", 30 | "sci-metadata-search-form-submit": "Paieška", 31 | "sci-metadata-search-select-label": "Tipas:", 32 | "sci-metadata-search-read-only": "Duomenų bazė veikia tik skaitymo režimu ir gali trukdyti automatiškai sukurti puslapį." 33 | } 34 | -------------------------------------------------------------------------------- /i18n/mai.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Haribanshi", 5 | "Tulsi Bhagat" 6 | ] 7 | }, 8 | "sci-referencelist-header": "संदर्भ", 9 | "sci-property-alias-citation-key": "उद्धरण चाबी", 10 | "sci-property-alias-citation-reference": "उद्धरण संदर्भ", 11 | "sci-property-alias-citation-text": "उद्धरण टेक्स्ट", 12 | "sci-property-alias-citation-resource": "उद्धरण स्रोत", 13 | "findmetadatabyid": "मेटाडाटा खोजु", 14 | "findcitablemetadata": "उद्धरण योग्य मेटाडेटा खोजु", 15 | "right-sci-metadatasearch": "मेटाडेटा खोज एक्सेस", 16 | "action-sci-metadatasearch": "सेमांटिक साइट मॅटा-डाटा खोजु", 17 | "sci-specials-header-results": "परिणाम क सूची", 18 | "sci-specials-select-options": "क्रिया चयन करु", 19 | "sci-specials-no-results": "कोनाे परिणाम उपलब्ध नैअछि।", 20 | "sci-metadata-search-form": "आईडी अनुसार", 21 | "sci-metadata-search-action-highlight": "टेक्स्ट चुनु", 22 | "sci-metadata-search-action-create": "बनाबी", 23 | "sci-metadata-search-header-log": "लॉग", 24 | "sci-metadata-search-header-result": "परिणाम", 25 | "sci-metadata-search-form-submit": "ताकू", 26 | "sci-metadata-search-select-label": "प्रकार:" 27 | } 28 | -------------------------------------------------------------------------------- /i18n/mg.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Jagwar" 5 | ] 6 | }, 7 | "sci-referencelist-header": "Tsiahy", 8 | "sci-property-alias-citation-key": "Lakilenn'ny teny nindramina", 9 | "sci-property-alias-citation-reference": "Tsiahin'ny teny nindramina", 10 | "sci-property-alias-citation-text": "Votoatin'ny teny nindramina", 11 | "sci-property-alias-citation-resource": "Loharanon'ny teny nindramina", 12 | "findmetadatabyid": "Hikaroka metadata", 13 | "findcitablemetadata": "Hikaroka metadata azo indramina", 14 | "right-sci-metadatasearch": "Fijerena ny karoka anaty meta-angona", 15 | "sci-specials-header-results": "Lisitry ny valiny", 16 | "sci-specials-select-options": "Hisafidy", 17 | "sci-specials-no-results": "Tsy misy valiny.", 18 | "sci-metadata-search-form": "Araka ny mpamantatra", 19 | "sci-metadata-search-action-highlight": "Hisafidy teny", 20 | "sci-metadata-search-action-create": "Foronina", 21 | "sci-metadata-search-header-log": "Laogy", 22 | "sci-metadata-search-header-result": "Valiny", 23 | "sci-metadata-search-form-submit": "Hikaroka" 24 | } 25 | -------------------------------------------------------------------------------- /i18n/mr.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "V.narsikar" 5 | ] 6 | }, 7 | "sci-referencelist-header": "संदर्भ", 8 | "sci-specials-header-results": "निकालांची यादी", 9 | "sci-specials-select-options": "पर्याय निवडा", 10 | "sci-specials-no-results": "काहीच निकाल उपलब्ध नाहीत.", 11 | "sci-metadata-search-action-highlight": "मजकूर निवडा", 12 | "sci-metadata-search-action-create": "निर्मित करा", 13 | "sci-metadata-search-header-log": "नोंदी", 14 | "sci-metadata-search-header-result": "निकाल", 15 | "sci-metadata-search-form-submit": "शोधा" 16 | } 17 | -------------------------------------------------------------------------------- /i18n/oc.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Cedric31" 5 | ] 6 | }, 7 | "sci-referencelist-header": "Referéncias", 8 | "sci-property-alias-citation-key": "Clau de citacion", 9 | "sci-property-alias-citation-reference": "Referéncia de la citacion", 10 | "sci-property-alias-citation-text": "Tèxte de la citacion", 11 | "sci-property-alias-citation-resource": "Ressorsa de la citacion", 12 | "findmetadatabyid": "Trobar las metadonadas", 13 | "findcitablemetadata": "Trobar las metadonadas citablas", 14 | "right-sci-metadatasearch": "Accès a la recèrca de metadonadas", 15 | "action-sci-metadatasearch": "la recèrca de metadonadas de Cite Semantic", 16 | "sci-specials-header-results": "Lista de resultats", 17 | "sci-specials-select-options": "Seleccionar las opcions", 18 | "sci-specials-no-results": "Cap de resultat pas disponible.", 19 | "listcitationreferencebacklinks": "Lista dels ligams arrièr de referéncia de Citacion", 20 | "sci-metadata-search-form": "Per identificant", 21 | "sci-metadata-search-action-highlight": "Seleccionatz lo tèxte", 22 | "sci-metadata-search-action-create": "Crear", 23 | "sci-metadata-search-header-log": "Jornal", 24 | "sci-metadata-search-header-result": "Resultat", 25 | "sci-metadata-search-form-submit": "Cercar" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/olo.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Mashoi7" 5 | ] 6 | }, 7 | "sci-property-alias-citation-key": "Citaciiavain", 8 | "sci-property-alias-citation-reference": "Citaciiviiteh", 9 | "sci-property-alias-citation-text": "Citaciitekstu", 10 | "sci-metadata-search-action-highlight": "Valliče tekstu", 11 | "sci-metadata-search-action-create": "Luaji", 12 | "sci-metadata-search-header-result": "Tulos", 13 | "sci-metadata-search-form-submit": "Eči" 14 | } 15 | -------------------------------------------------------------------------------- /i18n/pam.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Leeheonjin" 5 | ] 6 | }, 7 | "sci-specials-header-results": "Tala da reng resulta" 8 | } 9 | -------------------------------------------------------------------------------- /i18n/pl.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Chrumps", 5 | "CiaPan", 6 | "InternerowyGołąb", 7 | "Rail", 8 | "Railfail536", 9 | "SemanticPioneer", 10 | "XnIcRaM" 11 | ] 12 | }, 13 | "sci-desc": "Zarządzanie zasobami cytowania z pomocą [https://www.semantic-mediawiki.org Semantic MediaWiki]", 14 | "sci-referencelist-header": "Przypisy", 15 | "sci-scite-parser-not-enabled-namespace": "#scite nie może być używany w przestrzeni nazw nie dostępnej dla Semantic MediaWiki", 16 | "sci-scite-parser-no-reference": "#scite nie zadeklarował odniesienia.", 17 | "sci-datavalue-empty-reference": "Odnośnik do cytatu nie powinien być pusty.", 18 | "sci-datavalue-invalid-id-value": "„$1” jest nieprawidłową wartością dla typu $2.", 19 | "sci-property-alias-citation-key": "Klucz cytowania", 20 | "sci-property-alias-citation-reference": "Odnośnik cytowania", 21 | "sci-property-alias-citation-text": "Tekst cytowania", 22 | "sci-property-alias-citation-resource": "Źródło cytowania", 23 | "findmetadatabyid": "Znajdź metadane", 24 | "findcitablemetadata": "Znajdź możliwe do cytowania metadane", 25 | "right-sci-metadatasearch": "Dostęp do wyszukiwania metadanych", 26 | "sci-specials-header-results": "Lista wyników", 27 | "sci-specials-select-options": "Wybierz opcje", 28 | "sci-specials-no-results": "Brak dostępnych wyników.", 29 | "sci-metadata-search-form": "Według ID", 30 | "sci-metadata-search-action-highlight": "Zaznacz tekst", 31 | "sci-metadata-search-action-create": "Utwórz", 32 | "sci-metadata-search-header-log": "Rejestr", 33 | "sci-metadata-search-header-result": "Wynik", 34 | "sci-metadata-search-form-submit": "Szukaj", 35 | "sci-metadata-search-select-label": "Typ:", 36 | "sci-metadata-search-read-only": "Baza danych jest w trybie tylko do odczytu i może sprawiać trudność przy automatycznym tworzeniu stron", 37 | "sci-metadata-search-has-match": "ID został przypisany do cytatu źródeł które zawierają tak sam identyfikator oraz posiadają: $1.", 38 | "sci-metadata-search-cached": "Wynik wyszukiwania został pobrany z pamięci podręcznej.", 39 | "sci-metadata-search-intro-doi": "[[Property:DOI|DOI]] do wyszukiwania w repozytorium CrossRef", 40 | "sci-metadata-search-intro-oclc": "Numer [[Property:OCLC|OCLC]] w katalogu WorldCat", 41 | "onoi-remi-request-error": "Żądanie REST/HTTP zwróciło \"$1\" dla \"$2\".", 42 | "onoi-remi-response-empty": "Odpowiedź została zwrócona z pustym wynikiem dla „$1”.", 43 | "onoi-remi-parser-no-id-match": "Parser nie mógł dopasować „$1”." 44 | } 45 | -------------------------------------------------------------------------------- /i18n/ps.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Af420", 5 | "Ahmed-Najib-Biabani-Ibrahimkhel", 6 | "Amjad Khan" 7 | ] 8 | }, 9 | "sci-specials-header-results": "د پايلو لړليک", 10 | "sci-specials-select-options": "خوښنې ټاکل", 11 | "sci-metadata-search-action-create": "جوړول" 12 | } 13 | -------------------------------------------------------------------------------- /i18n/roa-tara.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Joetaras" 5 | ] 6 | }, 7 | "sci-referencelist-header": "Rifereminde", 8 | "sci-scite-parser-no-reference": "#scite non ge dichiare 'nu referimende.", 9 | "sci-property-alias-citation-key": "Chiave d'a citazione", 10 | "sci-property-alias-citation-reference": "Referimende d'a citazione", 11 | "sci-property-alias-citation-text": "Teste d'a citazione", 12 | "sci-property-alias-citation-resource": "Resorse d'a citazione", 13 | "findmetadatabyid": "Iacchie 'u metadate", 14 | "findcitablemetadata": "Iacchie metadate citabbile", 15 | "action-sci-metadatasearch": "'A ricerche de metadate d'a Citazione Semandeche", 16 | "sci-specials-header-results": "Elenghe de le resultate", 17 | "sci-specials-select-options": "Scacchie le opziune", 18 | "sci-specials-no-results": "Nisciune resultate disponibbile.", 19 | "sci-metadata-search-form": "Pe ID", 20 | "sci-metadata-search-action-highlight": "Scacchie 'u teste", 21 | "sci-metadata-search-action-create": "Ccreje", 22 | "sci-metadata-search-header-log": "Archivije", 23 | "sci-metadata-search-header-result": "Resultate", 24 | "sci-metadata-search-form-submit": "Cirche", 25 | "sci-metadata-search-select-label": "Tipe:", 26 | "sci-metadata-search-intro-doi": "[[Property:DOI|DOI]] pe cercà l'archivije CrossRef" 27 | } 28 | -------------------------------------------------------------------------------- /i18n/sd.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Mehtab ahmed" 5 | ] 6 | }, 7 | "sci-referencelist-header": "حوالا", 8 | "sci-property-alias-citation-text": "حوالي جو متن", 9 | "sci-specials-header-results": "نتيجن جي فھرست", 10 | "sci-specials-select-options": "چارا چونڊيو", 11 | "sci-specials-no-results": "ڪي بہ نتيجا موجود ناھن.", 12 | "sci-metadata-search-action-highlight": "متن چونڊيو" 13 | } 14 | -------------------------------------------------------------------------------- /i18n/sr-ec.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Aca", 5 | "Acamicamacaraca", 6 | "BadDog", 7 | "Obsuser", 8 | "Prevodim" 9 | ] 10 | }, 11 | "sci-referencelist-header": "Референце", 12 | "sci-property-alias-citation-key": "Кључ референце", 13 | "sci-property-alias-citation-text": "Текст референце", 14 | "sci-property-alias-citation-resource": "Ресурс референце", 15 | "findmetadatabyid": "Пронађи метаподатке", 16 | "sci-specials-header-results": "Списак резултата", 17 | "sci-specials-select-options": "Одабери опцију", 18 | "sci-specials-no-results": "Нема доступних резултата.", 19 | "sci-metadata-search-form": "По ID", 20 | "sci-metadata-search-action-highlight": "Одабери текст", 21 | "sci-metadata-search-action-create": "Направи", 22 | "sci-metadata-search-header-log": "Дневник", 23 | "sci-metadata-search-header-result": "Резултат", 24 | "sci-metadata-search-form-submit": "Претражи", 25 | "sci-metadata-search-select-label": "Тип:" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/sr-el.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [] 4 | }, 5 | "sci-referencelist-header": "Reference", 6 | "sci-property-alias-citation-key": "Ključ reference", 7 | "sci-property-alias-citation-text": "Tekst reference", 8 | "sci-property-alias-citation-resource": "Resurs reference", 9 | "findmetadatabyid": "Pronađi metapodatke", 10 | "sci-specials-header-results": "Spisak rezultata", 11 | "sci-specials-select-options": "Odaberi opciju", 12 | "sci-specials-no-results": "Nema dostupnih rezultata.", 13 | "sci-metadata-search-form": "Po ID", 14 | "sci-metadata-search-action-highlight": "Odaberi tekst", 15 | "sci-metadata-search-action-create": "Napravi", 16 | "sci-metadata-search-header-log": "Dnevnik", 17 | "sci-metadata-search-header-result": "Rezultat", 18 | "sci-metadata-search-form-submit": "Pretraži", 19 | "sci-metadata-search-select-label": "Tip:" 20 | } 21 | -------------------------------------------------------------------------------- /i18n/tl.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Leeheonjin" 5 | ] 6 | }, 7 | "sci-specials-header-results": "Talaan ng mga resulta", 8 | "sci-specials-select-options": "Pumili ng mga pagpipilian" 9 | } 10 | -------------------------------------------------------------------------------- /i18n/vi.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Nguyên Lê" 5 | ] 6 | }, 7 | "sci-specials-no-results": "Không có kết quả nào." 8 | } 9 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | tests/phpunit/Unit 18 | 19 | 20 | tests/phpunit/Integration 21 | 22 | 23 | tests/phpunit/Structure 24 | 25 | 26 | 27 | 28 | src 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /res/scite.page.creator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * MW Api handler to create article content from data-content-selector 3 | */ 4 | 5 | /*global jQuery, mediaWiki */ 6 | /*global confirm */ 7 | 8 | ( function ( $, mw ) { 9 | 10 | 'use strict'; 11 | 12 | $( function ( $ ) { 13 | 14 | var page = { 15 | 16 | /** 17 | * @since 1.0 18 | * 19 | * MW Api handler 20 | */ 21 | api: new mw.Api(), 22 | 23 | /** 24 | * @since 1.0 25 | * 26 | * Create article 27 | */ 28 | create: function ( title, content ) { 29 | 30 | this.api.postWithToken( "csrf", { 31 | action: "edit", 32 | title: title, 33 | section: 0, // Existing content will be replaced 34 | // summary: section, // no need for a section heading 35 | text: content 36 | } ).done( function( result, jqXHR ) { 37 | location.reload(); 38 | // $( '#scite-status' ).append( 'Added: ' + title ); // not sure we need an update not 39 | } ).fail( function( xhr, status, error ) { 40 | 41 | var apiErrorText = ''; 42 | 43 | if ( xhr === "http" ) { 44 | apiErrorText = "HTTP error: " + status.textStatus; // status.xhr contains the jqXHR object 45 | } else if ( xhr === "ok-but-empty" ) { 46 | apiErrorText = "Got an empty response from the server"; 47 | } else { 48 | apiErrorText = "API error: " + xhr; 49 | } 50 | 51 | if ( status.hasOwnProperty( 'xhr' ) ) { 52 | apiErrorText = status.xhr.responseText.replace(/\
/g," "); 53 | var xhr = status.xhr; 54 | 55 | if ( xhr.hasOwnProperty( 'responseText' ) ) { 56 | apiErrorText = xhr.responseText.replace(/\
/g," " ); 57 | }; 58 | 59 | if ( xhr.hasOwnProperty( 'statusText' ) ) { 60 | apiErrorText = 'The API returned with: ' + xhr.statusText.replace(/\
/g," " ); 61 | }; 62 | } 63 | 64 | $( '#scite-status' ).append( apiErrorText ); 65 | } ); 66 | } 67 | } 68 | 69 | $( '.scite-create' ).on( 'click', function( event ) { 70 | 71 | // Dynamically select element that contains the content 72 | // to be copied 73 | page.create( 74 | $( this ).data( 'title' ), 75 | $( $( this ).data( 'content-selector' ) ).text() 76 | ); 77 | 78 | event.preventDefault(); 79 | } ); 80 | 81 | } ); 82 | }( jQuery, mediaWiki ) ); 83 | -------------------------------------------------------------------------------- /res/scite.text.selector.js: -------------------------------------------------------------------------------- 1 | /** 2 | * qTip Javascript handler for the scite extension 3 | */ 4 | 5 | /*global jQuery, mediaWiki */ 6 | /*global confirm */ 7 | 8 | ( function ( $, mw ) { 9 | 10 | 'use strict'; 11 | 12 | $( function ( $ ) { 13 | 14 | // http://jsfiddle.net/edelman/KcX6A/1506/ 15 | var highlighter = { 16 | doSelectFor: function( selector ){ 17 | 18 | var context = $( selector ); 19 | 20 | var doc = document, 21 | element = context[0], range, selection; 22 | 23 | if (doc.body.createTextRange) { 24 | range = document.body.createTextRange(); 25 | range.moveToElementText(element); 26 | range.select(); 27 | } else if ( window.getSelection ) { 28 | selection = window.getSelection(); 29 | range = document.createRange(); 30 | range.selectNodeContents(element); 31 | selection.removeAllRanges(); 32 | selection.addRange(range); 33 | } 34 | } 35 | }; 36 | 37 | $( '.scite-highlight' ).on( 'click', function( event ) { 38 | 39 | highlighter.doSelectFor( 40 | $( this ).data( 'content-selector' ) 41 | ); 42 | 43 | event.preventDefault(); 44 | } ); 45 | 46 | } ); 47 | }( jQuery, mediaWiki ) ); 48 | -------------------------------------------------------------------------------- /src/Bibtex/BibtexProcessor.php: -------------------------------------------------------------------------------- 1 | bibtexParser = $bibtexParser; 31 | $this->bibtexAuthorListParser = $bibtexAuthorListParser; 32 | } 33 | 34 | /** 35 | * @since 1.0 36 | * 37 | * @param ParserParameterProcessor $parserParameterProcessor 38 | */ 39 | public function doProcess( ParserParameterProcessor $parserParameterProcessor ) { 40 | 41 | $bibtex = $this->doPreprocess( 42 | $parserParameterProcessor->getParameterValuesFor( 'bibtex' ) 43 | ); 44 | 45 | $parameters = $this->bibtexParser->parse( $bibtex ); 46 | 47 | foreach ( $parameters as $key => $value ) { 48 | 49 | // The explicit parameters precedes the one found in bibtex 50 | if ( $key === 'reference' && ( $parserParameterProcessor->hasParameter( 'reference' ) || $parserParameterProcessor->getFirstParameter() !== '' ) ) { 51 | continue; 52 | } 53 | 54 | if ( $key === 'type' && $parserParameterProcessor->hasParameter( 'type' ) ) { 55 | continue; 56 | } 57 | 58 | if ( $key === 'author' ) { 59 | 60 | $parserParameterProcessor->setParameter( 61 | $key, 62 | $this->bibtexAuthorListParser->parse( $value ) 63 | ); 64 | 65 | // Add the original value for easier post-processing in a template 66 | // as hidden parameter 67 | $key = 'bibtex-author'; 68 | } 69 | 70 | $parserParameterProcessor->addParameter( 71 | $key, 72 | $value 73 | ); 74 | } 75 | } 76 | 77 | private function doPreprocess( array $bibtex ) { 78 | 79 | $bibtex = end( $bibtex ); 80 | 81 | // Avoid things like {{Stable theories}}" which are not supported in MW 82 | // since the parser replaces it with [[:Template:Stable theories]] 83 | $this->replace( '{{', "{", $bibtex ); 84 | $this->replace( '}}', "}", $bibtex ); 85 | 86 | $this->replace( '{\textquotesingle}', "'", $bibtex ); 87 | $this->replace( '$\upgamma$', "γ", $bibtex ); 88 | 89 | return $bibtex; 90 | } 91 | 92 | private function replace( $search, $with, &$on ) { 93 | $on = strpos( $on, $search ) !== false ? str_replace( $search, $with, $on ) : $on; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/CacheKeyProvider.php: -------------------------------------------------------------------------------- 1 | cachePrefix = $cachePrefix; 31 | } 32 | 33 | /** 34 | * @since 1.0 35 | * 36 | * @param string $hash 37 | * 38 | * @return string 39 | */ 40 | public function getCacheKeyForCitationReference( $hash ) { 41 | return $this->cachePrefix . ':sci:ref:' . md5( $hash . self::VERSION ); 42 | } 43 | 44 | /** 45 | * @since 1.0 46 | * 47 | * @param string $hash 48 | * 49 | * @return string 50 | */ 51 | public function getCacheKeyForReferenceList( $hash ) { 52 | return $this->cachePrefix . ':sci:reflist:' . md5( $hash . self::VERSION ); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/CitationTextTemplateRenderer.php: -------------------------------------------------------------------------------- 1 | wikitextTemplateRenderer = $wikitextTemplateRenderer; 39 | $this->parser = $parser; 40 | } 41 | 42 | /** 43 | * @since 1.0 44 | * 45 | * @param string $templateName 46 | */ 47 | public function packFieldsForTemplate( $templateName ) { 48 | $this->templateName = $templateName; 49 | } 50 | 51 | /** 52 | * @since 1.0 53 | * 54 | * @param array $parameters 55 | * 56 | * @return string 57 | */ 58 | public function renderFor( array $parameters ) { 59 | 60 | $wikiText = $this->doFormat( $parameters ); 61 | 62 | if ( $wikiText === '' ) { 63 | return ''; 64 | } 65 | 66 | return $this->parser->recursivePreprocess( $wikiText ); 67 | } 68 | 69 | private function doFormat( array $parameters ) { 70 | 71 | if ( $this->templateName === '' ) { 72 | return ''; 73 | } 74 | 75 | foreach ( $parameters as $key => $values ) { 76 | 77 | $key = strtolower( trim( $key ) ); 78 | $pieces = []; 79 | 80 | foreach ( $values as $value ) { 81 | $pieces[] = trim( $value ); 82 | } 83 | 84 | $this->wikitextTemplateRenderer->addField( $key, implode( ', ', $pieces ) ); 85 | } 86 | 87 | $this->wikitextTemplateRenderer->packFieldsForTemplate( $this->templateName ); 88 | 89 | return $this->wikitextTemplateRenderer->render(); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/DataValues/ResourceIdentifierFactory.php: -------------------------------------------------------------------------------- 1 | findPropertyIdByLabel( $type ); 37 | break; 38 | case 'PUBMED': 39 | case 'PMID': 40 | $property = $propertyRegistry->findPropertyIdByLabel( 'PMID' ); 41 | break; 42 | case 'PMC': 43 | case 'PMCID': 44 | $property = $propertyRegistry->findPropertyIdByLabel( 'PMCID' ); 45 | break; 46 | } 47 | 48 | $typeId = $propertyRegistry->getPropertyTypeId( $property ); 49 | 50 | if ( $typeId === null || $typeId === '' ) { 51 | throw new RuntimeException( "{$type} is an unmatched type for ResourceIdentifierStringValue" ); 52 | } 53 | 54 | $resourceIdentifierStringValue = DataValueFactory::getInstance()->newDataValueByType( $typeId ); 55 | $resourceIdentifierStringValue->setProperty( new DIProperty( $property ) ); 56 | 57 | return $resourceIdentifierStringValue; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/FilteredMetadata/BibliographicFilteredRecord.php: -------------------------------------------------------------------------------- 1 | [], 39 | 'type' => [], 40 | 'title' => '', 41 | 'subtitle' => '', 42 | 'author' => [], 43 | 'editor' => [], 44 | 'journal' => '', 45 | 'iso-abbreviation' => '', 46 | 'publisher' => '', 47 | 'pubdate' => '', 48 | 'year' => '', 49 | 'volume' => '', 50 | 'issue' => '', 51 | 'pages' => '', 52 | 'doi' => '', 53 | 'abstract' => '', 54 | 'subject' => [], 55 | 'genre' => [], 56 | 'isbn' => [], 57 | 'oclc' => '', 58 | 'viaf' => [] 59 | ]; 60 | 61 | /** 62 | * @since 1.0 63 | * 64 | * @param string $key 65 | * 66 | * @return string|null 67 | */ 68 | public function getSearchMatchSetValueFor( $key ) { 69 | 70 | if ( isset( $this->searchMatchSet[$key] ) ) { 71 | return $this->searchMatchSet[$key]; 72 | } 73 | 74 | return null; 75 | } 76 | 77 | /** 78 | * @since 1.0 79 | * 80 | * @param string $key 81 | * @param string $value 82 | */ 83 | public function addSearchMatchSet( $key, $value ) { 84 | $this->searchMatchSet[$key] = $value; 85 | } 86 | 87 | /** 88 | * @since 1.0 89 | * 90 | * @return string 91 | */ 92 | public function setTitleForPageCreation( $titleForPageCreation ) { 93 | $this->titleForPageCreation = 'CR:' . $titleForPageCreation; 94 | } 95 | 96 | /** 97 | * @since 1.0 98 | * 99 | * @return string 100 | */ 101 | public function getTitleForPageCreation() { 102 | return $this->titleForPageCreation; 103 | } 104 | 105 | /** 106 | * @since 1.0 107 | * 108 | * @return string 109 | */ 110 | public function setSciteTransclusionHead( $sciteTransclusionHead ) { 111 | $this->sciteTransclusionHead = $sciteTransclusionHead; 112 | } 113 | 114 | /** 115 | * @since 1.0 116 | * 117 | * @return string 118 | */ 119 | public function __toString() { 120 | 121 | $text = ''; 122 | 123 | foreach ( $this->recordFields as $key => $value ) { 124 | 125 | if ( is_array( $value ) ) { 126 | $value = implode( ';', $value ) . ( count( $value ) > 1 ? '|+sep=;' : '' ); 127 | } 128 | 129 | if ( $value === '' || $value === null ) { 130 | continue; 131 | } 132 | 133 | $text .= " |{$key}=" . $value . "\n"; 134 | } 135 | 136 | return $text; 137 | } 138 | 139 | /** 140 | * @since 1.0 141 | * 142 | * @return string 143 | */ 144 | public function asSciteTransclusion() { 145 | return '{{#scite:' . $this->sciteTransclusionHead ."\n" . $this . "}}";; 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /src/FilteredMetadata/CrossRefResponseParser.php: -------------------------------------------------------------------------------- 1 | crossRefFilteredHttpResponseParser = $crossRefFilteredHttpResponseParser; 29 | } 30 | 31 | /** 32 | * @since 1.0 33 | * 34 | * {@inheritDoc} 35 | */ 36 | public function usesCache() { 37 | return $this->crossRefFilteredHttpResponseParser->usesCache(); 38 | } 39 | 40 | /** 41 | * @since 1.0 42 | * 43 | * {@inheritDoc} 44 | */ 45 | public function getMessages() { 46 | return $this->crossRefFilteredHttpResponseParser->getMessages(); 47 | } 48 | 49 | /** 50 | * @since 1.0 51 | * 52 | * {@inheritDoc} 53 | */ 54 | public function getFilteredRecord() { 55 | return $this->crossRefFilteredHttpResponseParser->getFilteredRecord(); 56 | } 57 | 58 | /** 59 | * @since 1.0 60 | * 61 | * {@inheritDoc} 62 | */ 63 | public function getRawResponse( $doi ) { 64 | return $this->crossRefFilteredHttpResponseParser->getRawResponse( $doi ); 65 | } 66 | 67 | /** 68 | * @since 1.0 69 | * 70 | * {@inheritDoc} 71 | */ 72 | public function doFilterResponseFor( $doi ) { 73 | 74 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); 75 | 76 | $doiValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( 'doi' ); 77 | $doiValue->setUserValue( $doi ); 78 | 79 | if ( !$doiValue->isValid() ) { 80 | return $this->crossRefFilteredHttpResponseParser->addMessage( $doiValue->getErrors() ); 81 | } 82 | 83 | $doi = $doiValue->getWikiValue(); 84 | 85 | $this->crossRefFilteredHttpResponseParser->doFilterResponseFor( $doi ); 86 | $filteredRecord = $this->crossRefFilteredHttpResponseParser->getFilteredRecord(); 87 | 88 | $filteredRecord->setTitleForPageCreation( 'DOI:' . md5( $doi ) ); 89 | 90 | $filteredRecord->addSearchMatchSet( 91 | 'doi', 92 | $doi 93 | ); 94 | 95 | $filteredRecord->addSearchMatchSet( 96 | 'reference', 97 | $this->crossRefFilteredHttpResponseParser->getFilteredRecord()->get( 'reference' ) 98 | ); 99 | 100 | $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); 101 | $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/FilteredMetadata/HttpResponseParserFactory.php: -------------------------------------------------------------------------------- 1 | httpRequest = $httpRequest; 28 | } 29 | 30 | /** 31 | * @since 1.0 32 | * 33 | * @param string $type 34 | * 35 | * @return ResponseParser 36 | */ 37 | public function newResponseParserForType( $type ) { 38 | 39 | $bibliographicFilteredRecord = new BibliographicFilteredRecord(); 40 | 41 | $filteredHttpResponseParserFactory = new FilteredHttpResponseParserFactory( 42 | $this->httpRequest 43 | ); 44 | 45 | switch ( strtolower( $type ) ) { 46 | case 'doi': 47 | $responseParser = new CrossRefResponseParser( 48 | $filteredHttpResponseParserFactory->newCrossRefFilteredHttpResponseParser( 49 | $bibliographicFilteredRecord 50 | ) 51 | ); 52 | break; 53 | case 'viaf': 54 | $responseParser = new ViafResponseParser( 55 | $filteredHttpResponseParserFactory->newViafFilteredHttpResponseParser( 56 | $bibliographicFilteredRecord 57 | ) 58 | ); 59 | break; 60 | case 'pubmed': 61 | $responseParser = new NcbiPubMedResponseParser( 62 | $filteredHttpResponseParserFactory->newNcbiPubMedFilteredHttpResponseParser( 63 | $bibliographicFilteredRecord 64 | ) 65 | ); 66 | break; 67 | case 'pmc': 68 | $responseParser = new NcbiPubMedResponseParser( 69 | $filteredHttpResponseParserFactory->newNcbiPubMedCentralFilteredHttpResponseParser( 70 | $bibliographicFilteredRecord 71 | ) 72 | ); 73 | break; 74 | case 'oclc': 75 | $responseParser = new OclcResponseParser( 76 | $filteredHttpResponseParserFactory->newOclcFilteredHttpResponseParser( 77 | $bibliographicFilteredRecord 78 | ) 79 | ); 80 | break; 81 | case 'ol': 82 | $responseParser = new OLResponseParser( 83 | $filteredHttpResponseParserFactory->newOLFilteredHttpResponseParser( 84 | $bibliographicFilteredRecord 85 | ) 86 | ); 87 | break; 88 | default: 89 | $responseParser = $filteredHttpResponseParserFactory->newNullResponseParser( 90 | $bibliographicFilteredRecord 91 | ); 92 | break; 93 | } 94 | 95 | return $responseParser; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/FilteredMetadata/NcbiPubMedResponseParser.php: -------------------------------------------------------------------------------- 1 | ncbiPubMedFilteredHttpResponseParser = $ncbiPubMedFilteredHttpResponseParser; 29 | } 30 | 31 | /** 32 | * @since 1.0 33 | * 34 | * {@inheritDoc} 35 | */ 36 | public function usesCache() { 37 | return $this->ncbiPubMedFilteredHttpResponseParser->usesCache(); 38 | } 39 | 40 | /** 41 | * @since 1.0 42 | * 43 | * {@inheritDoc} 44 | */ 45 | public function getMessages() { 46 | return $this->ncbiPubMedFilteredHttpResponseParser->getMessages(); 47 | } 48 | 49 | /** 50 | * @since 1.0 51 | * 52 | * {@inheritDoc} 53 | */ 54 | public function getFilteredRecord() { 55 | return $this->ncbiPubMedFilteredHttpResponseParser->getFilteredRecord(); 56 | } 57 | 58 | /** 59 | * @since 1.0 60 | * 61 | * {@inheritDoc} 62 | */ 63 | public function getRawResponse( $id ) { 64 | return $this->ncbiPubMedFilteredHttpResponseParser->getRawResponse( $id ); 65 | } 66 | 67 | /** 68 | * @since 1.0 69 | * 70 | * {@inheritDoc} 71 | */ 72 | public function doFilterResponseFor( $id ) { 73 | 74 | $type = $this->ncbiPubMedFilteredHttpResponseParser->getFilteredRecord()->get( 75 | 'ncbi-dbtype' 76 | ); 77 | 78 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); 79 | 80 | $pubmedValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( $type ); 81 | $pubmedValue->setUserValue( $id ); 82 | 83 | if ( !$pubmedValue->isValid() ) { 84 | return $this->ncbiPubMedFilteredHttpResponseParser->addMessage( $pubmedValue->getErrors() ); 85 | } 86 | 87 | // NCBI requires to work without any prefix 88 | $id = str_replace( 'PMC', '', $pubmedValue->getWikiValue() ); 89 | 90 | // We expect this type of either being PMC or PMID as 91 | // invoked by NcbiResponseContentParser 92 | $prefix = $type === 'pmc' ? 'PMC' : 'PMID'; 93 | 94 | $this->ncbiPubMedFilteredHttpResponseParser->doFilterResponseFor( $id ); 95 | $filteredRecord = $this->ncbiPubMedFilteredHttpResponseParser->getFilteredRecord(); 96 | 97 | $filteredRecord->setTitleForPageCreation( $prefix . ':' . $id ); 98 | $filteredRecord->setSciteTransclusionHead( 99 | $prefix . $id 100 | ); 101 | 102 | $filteredRecord->addSearchMatchSet( 103 | 'doi', 104 | $this->ncbiPubMedFilteredHttpResponseParser->getFilteredRecord()->get( 'doi' ) 105 | ); 106 | 107 | $filteredRecord->addSearchMatchSet( 108 | $type, 109 | $prefix . $id 110 | ); 111 | 112 | $filteredRecord->delete( 'ncbi-dbtype' ); 113 | 114 | $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); 115 | $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/FilteredMetadata/OLResponseParser.php: -------------------------------------------------------------------------------- 1 | olFilteredHttpResponseParser = $olFilteredHttpResponseParser; 29 | } 30 | 31 | /** 32 | * @since 1.0 33 | * 34 | * {@inheritDoc} 35 | */ 36 | public function usesCache() { 37 | return $this->olFilteredHttpResponseParser->usesCache(); 38 | } 39 | 40 | /** 41 | * @since 1.0 42 | * 43 | * {@inheritDoc} 44 | */ 45 | public function getMessages() { 46 | return $this->olFilteredHttpResponseParser->getMessages(); 47 | } 48 | 49 | /** 50 | * @since 1.0 51 | * 52 | * {@inheritDoc} 53 | */ 54 | public function getFilteredRecord() { 55 | return $this->olFilteredHttpResponseParser->getFilteredRecord(); 56 | } 57 | 58 | /** 59 | * @since 1.0 60 | * 61 | * {@inheritDoc} 62 | */ 63 | public function getRawResponse( $id ) { 64 | return $this->olFilteredHttpResponseParser->getRawResponse( $id ); 65 | } 66 | 67 | /** 68 | * @since 1.0 69 | * 70 | * {@inheritDoc} 71 | */ 72 | public function doFilterResponseFor( $olID ) { 73 | 74 | $this->olFilteredHttpResponseParser->doFilterResponseFor( $olID ); 75 | $filteredRecord = $this->olFilteredHttpResponseParser->getFilteredRecord(); 76 | 77 | // Fetch the OLID has one could search for an ISBN as well 78 | if ( $filteredRecord->has( 'olid' ) ) { 79 | $olID = $filteredRecord->get( 'olid' ); 80 | } 81 | 82 | if ( is_array( $olID ) ) { 83 | $olID = end( $olID ); 84 | } 85 | 86 | $filteredRecord->setTitleForPageCreation( 87 | 'OL:' . str_replace( 'OL', '', $olID ) 88 | ); 89 | 90 | $filteredRecord->setSciteTransclusionHead( 91 | $olID 92 | ); 93 | 94 | $filteredRecord->addSearchMatchSet( 'olid', $olID ); 95 | 96 | if ( $filteredRecord->has( 'lccn' ) ) { 97 | $filteredRecord->addSearchMatchSet( 98 | 'lccn', 99 | $filteredRecord->get( 'lccn' ) 100 | ); 101 | } 102 | 103 | $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); 104 | $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/FilteredMetadata/OclcResponseParser.php: -------------------------------------------------------------------------------- 1 | oclcFilteredHttpResponseParser = $oclcFilteredHttpResponseParser; 29 | } 30 | 31 | /** 32 | * @since 1.0 33 | * 34 | * {@inheritDoc} 35 | */ 36 | public function usesCache() { 37 | return $this->oclcFilteredHttpResponseParser->usesCache(); 38 | } 39 | 40 | /** 41 | * @since 1.0 42 | * 43 | * {@inheritDoc} 44 | */ 45 | public function getMessages() { 46 | return $this->oclcFilteredHttpResponseParser->getMessages(); 47 | } 48 | 49 | /** 50 | * @since 1.0 51 | * 52 | * {@inheritDoc} 53 | */ 54 | public function getFilteredRecord() { 55 | return $this->oclcFilteredHttpResponseParser->getFilteredRecord(); 56 | } 57 | 58 | /** 59 | * @since 1.0 60 | * 61 | * {@inheritDoc} 62 | */ 63 | public function getRawResponse( $oclcID ) { 64 | return $this->oclcFilteredHttpResponseParser->getRawResponse( $oclcID ); 65 | } 66 | 67 | /** 68 | * @since 1.0 69 | * 70 | * {@inheritDoc} 71 | */ 72 | public function doFilterResponseFor( $oclcID ) { 73 | 74 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); 75 | 76 | $oclcValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( 'oclc' ); 77 | $oclcValue->setUserValue( $oclcID ); 78 | 79 | if ( !$oclcValue->isValid() ) { 80 | return $this->oclcFilteredHttpResponseParser->addMessage( $oclcValue->getErrors() ); 81 | } 82 | 83 | $oclcID = $oclcValue->getWikiValue(); 84 | 85 | $this->oclcFilteredHttpResponseParser->doFilterResponseFor( $oclcID ); 86 | $filteredRecord = $this->oclcFilteredHttpResponseParser->getFilteredRecord(); 87 | 88 | $filteredRecord->setTitleForPageCreation( 'OCLC:' . $oclcID ); 89 | $filteredRecord->setSciteTransclusionHead( 90 | 'OCLC' . $oclcID 91 | ); 92 | 93 | $filteredRecord->addSearchMatchSet( 'oclc', $oclcID ); 94 | $filteredRecord->set( 'oclc', $oclcID ); 95 | 96 | $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); 97 | $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/FilteredMetadata/ViafResponseParser.php: -------------------------------------------------------------------------------- 1 | viafFilteredHttpResponseParser = $viafFilteredHttpResponseParser; 29 | } 30 | 31 | /** 32 | * @since 1.0 33 | * 34 | * {@inheritDoc} 35 | */ 36 | public function usesCache() { 37 | return $this->viafFilteredHttpResponseParser->usesCache(); 38 | } 39 | 40 | /** 41 | * @since 1.0 42 | * 43 | * {@inheritDoc} 44 | */ 45 | public function getMessages() { 46 | return $this->viafFilteredHttpResponseParser->getMessages(); 47 | } 48 | 49 | /** 50 | * @since 1.0 51 | * 52 | * {@inheritDoc} 53 | */ 54 | public function getFilteredRecord() { 55 | return $this->viafFilteredHttpResponseParser->getFilteredRecord(); 56 | } 57 | 58 | /** 59 | * @since 1.0 60 | * 61 | * {@inheritDoc} 62 | */ 63 | public function getRawResponse( $viafID ) { 64 | return $this->viafFilteredHttpResponseParser->getRawResponse( $viafID ); 65 | } 66 | 67 | /** 68 | * @since 1.0 69 | * 70 | * {@inheritDoc} 71 | */ 72 | public function doFilterResponseFor( $viafID ) { 73 | 74 | $resourceIdentifierFactory = new ResourceIdentifierFactory(); 75 | 76 | $viafValue = $resourceIdentifierFactory->newResourceIdentifierStringValueForType( 'viaf' ); 77 | $viafValue->setUserValue( $viafID ); 78 | 79 | if ( !$viafValue->isValid() ) { 80 | return $this->viafFilteredHttpResponseParser->addMessage( $viafValue->getErrors() ); 81 | } 82 | 83 | $viafID = $viafValue->getWikiValue(); 84 | 85 | $this->viafFilteredHttpResponseParser->doFilterResponseFor( $viafID ); 86 | $filteredRecord = $this->viafFilteredHttpResponseParser->getFilteredRecord(); 87 | 88 | $filteredRecord->setTitleForPageCreation( 'VIAF:' . $viafID ); 89 | $filteredRecord->setSciteTransclusionHead( 90 | 'VIAF' . $viafID 91 | ); 92 | 93 | $filteredRecord->addSearchMatchSet( 'viaf', $viafID ); 94 | 95 | $dateTimeUtc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); 96 | $filteredRecord->set( 'retrieved-on', $dateTimeUtc->format( 'Y-m-d' ) ); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/MediaWikiContextInteractor.php: -------------------------------------------------------------------------------- 1 | context = $context; 37 | $this->revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup(); 38 | } 39 | 40 | /** 41 | * @see RawAction::getOldId 42 | * 43 | * @since 1.0 44 | * 45 | * @return int 46 | */ 47 | public function getOldId() { 48 | $oldid = $this->context->getRequest()->getInt( 'oldid' ); 49 | $title = $this->context->getTitle(); 50 | 51 | switch ( $this->context->getRequest()->getText( 'direction' ) ) { 52 | case 'next': 53 | # output next revision, or nothing if there isn't one 54 | $nextid = 0; 55 | if ( $oldid ) { 56 | $revision = $this->revisionLookup->getRevisionById( $oldid ); 57 | $nextRevision = $this->revisionLookup->getNextRevision( $revision ); 58 | if ( $nextRevision ) { 59 | $nextid = $nextRevision->getId(); 60 | } 61 | } 62 | $oldid = $nextid ?: -1; 63 | break; 64 | case 'prev': 65 | # output previous revision, or nothing if there isn't one 66 | $previd = 0; 67 | if ( !$oldid ) { 68 | # get the current revision so we can get the penultimate one 69 | $oldid = $title->getLatestRevID(); 70 | } 71 | if ( $oldid ) { 72 | $revision = $this->revisionLookup->getRevisionById( $oldid ); 73 | $previousRevision = $this->revisionLookup->getPreviousRevision( $revision ); 74 | if ( $previousRevision ) { 75 | $previd = $previousRevision->getId(); 76 | } 77 | } 78 | $oldid = $previd ?: -1; 79 | break; 80 | case 'cur': 81 | $oldid = 0; 82 | break; 83 | } 84 | 85 | return (int)$oldid; 86 | } 87 | 88 | /** 89 | * @since 1.0 90 | * 91 | * @param string $magicword 92 | * 93 | * @return boolean 94 | */ 95 | public function hasMagicWord( $magicword ) { 96 | 97 | $outputPage = $this->context->getOutput(); 98 | 99 | if ( isset( $outputPage->smwmagicwords ) && in_array( $magicword, $outputPage->smwmagicwords ) ) { 100 | return true; 101 | } 102 | 103 | return false; 104 | } 105 | 106 | /** 107 | * @since 1.0 108 | * 109 | * @param string $action 110 | * 111 | * @return boolean 112 | */ 113 | public function hasAction( $action ) { 114 | return \Action::getActionName( $this->context ) === $action; 115 | } 116 | 117 | /** 118 | * @since 1.0 119 | * 120 | * @return Title 121 | */ 122 | public function getTitle() { 123 | return $this->context->getTitle(); 124 | } 125 | 126 | /** 127 | * @since 1.0 128 | * 129 | * @return string 130 | */ 131 | public function getLanguageCode() { 132 | return $this->context->getLanguage()->getCode(); 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /src/Options.php: -------------------------------------------------------------------------------- 1 | options = $options; 25 | } 26 | 27 | /** 28 | * @since 1.0 29 | * 30 | * @param string $key 31 | * @param mixed $value 32 | */ 33 | public function set( $key, $value ) { 34 | $this->options[$key] = $value; 35 | } 36 | 37 | /** 38 | * @since 1.0 39 | * 40 | * @param string $key 41 | * 42 | * @return boolean 43 | */ 44 | public function has( $key ) { 45 | return isset( $this->options[$key] ) || array_key_exists( $key, $this->options ); 46 | } 47 | 48 | /** 49 | * @since 1.0 50 | * 51 | * @param string $key 52 | * 53 | * @return string 54 | * @throws InvalidArgumentException 55 | */ 56 | public function get( $key ) { 57 | 58 | if ( $this->has( $key ) ) { 59 | return $this->options[$key]; 60 | } 61 | 62 | throw new InvalidArgumentException( "{$key} is an unregistered option" ); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/ParserFunctionFactory.php: -------------------------------------------------------------------------------- 1 | newParserData( 35 | $parser->getTitle(), 36 | $parser->getOutput() 37 | ); 38 | 39 | $mwCollaboratorFactory = ApplicationFactory::getInstance()->newMwCollaboratorFactory(); 40 | 41 | $citationTextTemplateRenderer = new CitationTextTemplateRenderer( 42 | $mwCollaboratorFactory->newWikitextTemplateRenderer(), 43 | $parser 44 | ); 45 | 46 | $mediaWikiNsContentMapper = new MediaWikiNsContentMapper( 47 | $mwCollaboratorFactory->newMediaWikiNsContentReader() 48 | ); 49 | 50 | $sciteParserFunction = new SciteParserFunction( 51 | $parserData, 52 | $namespaceExaminer, 53 | $citationTextTemplateRenderer, 54 | $mediaWikiNsContentMapper, 55 | new BibtexProcessor( new BibtexParser(), new BibtexAuthorListParser() ) 56 | ); 57 | 58 | $sciteParserFunction->setStrictParserValidationState( 59 | $options->get( 'enabledStrictParserValidation' ) 60 | ); 61 | 62 | return $sciteParserFunction->doProcess( 63 | ParameterProcessorFactory::newFromArray( func_get_args() ), 64 | new PreTextFormatter() 65 | ); 66 | }; 67 | 68 | return [ 'scite', $sciteParserFunctionDefinition, 0 ]; 69 | } 70 | 71 | /** 72 | * {{#referencelist:}} 73 | * 74 | * @since 1.0 75 | * 76 | * @return array 77 | */ 78 | public function newReferenceListParserFunctionDefinition() { 79 | 80 | $referenceListParserFunctionDefinition = function( $parser ) { 81 | 82 | $parserData = ApplicationFactory::getInstance()->newParserData( 83 | $parser->getTitle(), 84 | $parser->getOutput() 85 | ); 86 | 87 | $referenceListParserFunction = new ReferenceListParserFunction( $parserData ); 88 | 89 | return $referenceListParserFunction->doProcess( 90 | ParameterProcessorFactory::newFromArray( func_get_args() ) 91 | ); 92 | }; 93 | 94 | return [ 'referencelist', $referenceListParserFunctionDefinition, 0 ]; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/PreTextFormatter.php: -------------------------------------------------------------------------------- 1 | {{#scite:\n" . implode( "\n", $this->format( $parameters ) ) ."\n}}"; 23 | } 24 | 25 | /** 26 | * @since 1.4 27 | * 28 | * @return array 29 | */ 30 | public function format( array $parameters ) { 31 | 32 | $formatted = []; 33 | 34 | foreach ( $parameters as $key => $value ) { 35 | 36 | if ( $value === '' || $value[0] === '@' ) { 37 | continue; 38 | } 39 | 40 | if ( $value[0] === '+' ) { 41 | $formatted[$key-1] = $formatted[$key-1] . '|' . $value; 42 | continue; 43 | } 44 | 45 | $formatted[$key] = ' |' . $value; 46 | } 47 | 48 | return $formatted; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/ReferenceListFactory.php: -------------------------------------------------------------------------------- 1 | store = $store; 43 | $this->namespaceExaminer = $namespaceExaminer; 44 | $this->citationReferencePositionJournal = $citationReferencePositionJournal; 45 | } 46 | 47 | /** 48 | * @since 1.0 49 | * 50 | * @return ReferenceListOutputRenderer 51 | */ 52 | public function newReferenceListOutputRenderer() { 53 | 54 | $mwCollaboratorFactory = ApplicationFactory::getInstance()->newMwCollaboratorFactory(); 55 | $htmlColumnListRenderer = $mwCollaboratorFactory->newHtmlColumnListRenderer(); 56 | 57 | $referenceListOutputRenderer = new ReferenceListOutputRenderer( 58 | new CitationResourceMatchFinder( $this->store ), 59 | $this->citationReferencePositionJournal, 60 | $htmlColumnListRenderer 61 | ); 62 | 63 | return $referenceListOutputRenderer; 64 | } 65 | 66 | /** 67 | * @since 1.0 68 | * 69 | * @param MediaWikiContextInteractor $contextInteractor 70 | * @param Cache $cache 71 | * @param CacheKeyProvider $cacheKeyProvider 72 | * @param Options $options 73 | * 74 | * @return CachedReferenceListOutputRenderer 75 | */ 76 | public function newCachedReferenceListOutputRenderer( MediaWikiContextInteractor $contextInteractor, Cache $cache, CacheKeyProvider $cacheKeyProvider, Options $options ) { 77 | 78 | $referenceListOutputRenderer = $this->newReferenceListOutputRenderer(); 79 | 80 | $referenceListOutputRenderer->setNumberOfReferenceListColumns( 81 | $options->get( 'numberOfReferenceListColumns' ) 82 | ); 83 | 84 | $referenceListOutputRenderer->setResponsiveMonoColumnCharacterBoundLength( 85 | $options->get( 'responsiveMonoColumnCharacterBoundLength' ) 86 | ); 87 | 88 | $referenceListOutputRenderer->setReferenceListType( 89 | $options->get( 'referenceListType' ) 90 | ); 91 | 92 | $referenceListOutputRenderer->setBrowseLinkToCitationResourceVisibility( 93 | $options->get( 'browseLinkToCitationResource' ) 94 | ); 95 | 96 | $referenceListOutputRenderer->setCitationReferenceCaptionFormat( 97 | $options->get( 'citationReferenceCaptionFormat' ) 98 | ); 99 | 100 | $cachedReferenceListOutputRenderer = new CachedReferenceListOutputRenderer( 101 | $referenceListOutputRenderer, 102 | $contextInteractor, 103 | $this->namespaceExaminer, 104 | $cache, 105 | $cacheKeyProvider 106 | ); 107 | 108 | return $cachedReferenceListOutputRenderer; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/Specials/CitableMetadata/HtmlResponseParserRenderer.php: -------------------------------------------------------------------------------- 1 | responseParser = $responseParser; 33 | } 34 | 35 | /** 36 | * @since 1.4 37 | * 38 | * @param boolean $isReadOnly 39 | */ 40 | public function isReadOnly( $isReadOnly ) { 41 | $this->isReadOnly = (bool)$isReadOnly; 42 | } 43 | 44 | /** 45 | * @since 1.0 46 | * 47 | * @return string 48 | */ 49 | public function getRawResponse( $id ) { 50 | 51 | if ( $id === '' ) { 52 | return ''; 53 | } 54 | 55 | return $this->responseParser->getRawResponse( $id ); 56 | } 57 | 58 | /** 59 | * @since 1.0 60 | * 61 | * @return string 62 | */ 63 | public function renderTextFor( $id ) { 64 | 65 | $html = ''; 66 | 67 | $this->responseParser->doFilterResponseFor( $id ); 68 | 69 | $html .= Html::rawElement( 70 | 'div', 71 | [ 72 | 'id' => 'scite-status', 73 | ], 74 | '' 75 | ); 76 | 77 | if ( $this->responseParser->getMessages() !== [] ) { 78 | return ''; 79 | } 80 | 81 | $create = ''; 82 | 83 | // Only display the create button for when the DB can be actually 84 | // accessed 85 | if ( $this->isReadOnly === false ) { 86 | $create = Html::element( 87 | 'a', 88 | [ 89 | 'href' => '#', 90 | 'class' => 'scite-create scite-action-button', 91 | 'data-content-selector' => '#scite-record-content', 92 | 'data-title' => $this->responseParser->getFilteredRecord()->getTitleForPageCreation() 93 | ], 94 | wfMessage( 'sci-metadata-search-action-create' )->text() 95 | ); 96 | } 97 | 98 | $html .= Html::rawElement( 99 | 'div', 100 | [ 101 | 'class' => 'scite-metadata-search-action' 102 | ], 103 | Html::element( 104 | 'a', 105 | [ 106 | 'href' => '#', 107 | 'class' => 'scite-highlight scite-action-button', 108 | 'data-content-selector' => '#scite-record-content' 109 | ], 110 | wfMessage( 'sci-metadata-search-action-highlight' )->text() 111 | ) . ' ' . $create 112 | ); 113 | 114 | // To display the #scite on the generated page 115 | $this->responseParser->getFilteredRecord()->set( '@show', 'true' ); 116 | 117 | $html .= Html::rawElement( 118 | 'div', 119 | [ 120 | 'id' => 'scite-record-content', 121 | 'class' => 'scite-pre' 122 | ], 123 | $this->responseParser->getFilteredRecord()->asSciteTransclusion() 124 | ); 125 | 126 | $html .= Html::rawElement( 127 | 'div', 128 | [ 129 | 'class' => 'visualClear' 130 | ], 131 | '' 132 | ); 133 | 134 | return $html; 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | addPsr4( 'SCI\\Tests\\', __DIR__ . '/phpunit/Unit' ); 31 | $autoloader->addPsr4( 'SCI\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration' ); 32 | 33 | unset( $autoloader ); 34 | -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/10.1007-2F978-0-387-76978-3.expected: -------------------------------------------------------------------------------- 1 | {{#scite: 2 | |reference=schoenberg2013th 3 | |type=book 4 | |title=The Little Black Book of Neuropsychology 5 | |editor=Mike R. Schoenberg;James G. Scott|+sep=; 6 | |publisher=Springer Science + Business Media 7 | |year=2013 8 | |doi=10.1007/978-0-387-76978-3 9 | |retrieved-from=https://dx.doi.org/ 10 | |retrieved-on=1970-01-01 11 | }} -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/10.1007-2F978-0-387-76978-3.json: -------------------------------------------------------------------------------- 1 | {"subtitle":[],"issued":{"date-parts":[[2011]]},"score":1.0,"prefix":"http:\/\/id.crossref.org\/prefix\/10.1007","container-title":null,"reference-count":0,"deposited":{"date-parts":[[2013,9,6]],"timestamp":1378425600000},"title":"The Little Black Book of Neuropsychology","editor":[{"affiliation":[],"family":"Schoenberg","given":"Mike R."},{"affiliation":[],"family":"Scott","given":"James G."}],"type":"book","DOI":"10.1007\/978-0-387-76978-3","ISBN":["http:\/\/id.crossref.org\/isbn\/978-0-387-70703-7","http:\/\/id.crossref.org\/isbn\/978-0-387-76978-3"],"URL":"http:\/\/dx.doi.org\/10.1007\/978-0-387-76978-3","source":"CrossRef","publisher":"Springer Science + Business Media","indexed":{"date-parts":[[2015,6,11]],"timestamp":1434026028914},"member":"http:\/\/id.crossref.org\/member\/297"} -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/OCLC41266045.expected: -------------------------------------------------------------------------------- 1 | {{#scite:OCLC41266045 2 | |type=schema:Book;schema:CreativeWork|+sep=; 3 | |title=Harry Potter and the prisoner of Azkaban 4 | |author=J. K. Rowling;(Fictitious character) Harry Potter|+sep=; 5 | |pubdate=1999 6 | |abstract=During his third year at Hogwarts School for Witchcraft and Wizardry, Harry Potter must confront the devious and dangerous wizard responsible for his parents' deaths. 7 | |subject=Fantasy fiction;Harry Potter (Fictitious character.);Magic;Schools;Wizards;Magic;Magic;Schools;Wizards;Hogwarts School of Witchcraft and Wizardry (Imaginary organization);Granger, Hermione (Fictitious character);Weasley, Ron (Fictitious character)|+sep=; 8 | |genre=Juvenile works;Fantasy fiction;Fiction|+sep=; 9 | |isbn=9780439136358;0439136350;9780439136365;0439136369;9781480614994;1480614998|+sep=; 10 | |oclc=41266045 11 | |viaf=116796842;308752753|+sep=; 12 | |url=http://www.worldcat.org/oclc/41266045 13 | |edition=1st American ed. 14 | |retrieved-from=http://www.worldcat.org/ 15 | |retrieved-on=1970-01-01 16 | }} -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/OCLC74330434.expected: -------------------------------------------------------------------------------- 1 | {{#scite:OCLC74330434 2 | |type=schema:CreativeWork;schema:Movie;bgn:DVD|+sep=; 3 | |title=Science. Disc 2, Life science 4 | |pubdate=2006 5 | |subject=Arthropoda--Study and teaching (Middle school);Biotic communities--Study and teaching (Middle school);Habitat (Ecology)--Study and teaching (Middle school);Life sciences--Study and teaching (Middle school);Plant life cycles--Study and teaching (Middle school);Plant propagation--Study and teaching (Middle school);Protozoa--Study and teaching (Middle school);Science--Study and teaching (Middle school);Vertebrates--Study and teaching (Middle school);Plant life cycles;Plant propagation;Protozoa;Vertebrates;Arthropoda;Biotic communities;Habitat (Ecology);Life sciences|+sep=; 6 | |genre=Films;Science films;Juvenile works;Educational films;Children's films;Nonfiction films|+sep=; 7 | |isbn=9781594642555;1594642559|+sep=; 8 | |oclc=74330434 9 | |url=http://www.worldcat.org/oclc/74330434 10 | |edition=[Full screen]. 11 | |retrieved-from=http://www.worldcat.org/ 12 | |retrieved-on=1970-01-01 13 | }} -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/OL2206423M.expected: -------------------------------------------------------------------------------- 1 | {{#scite:OL2206423M 2 | |title=Zen flesh, Zen bones 3 | |subtitle=a collection of Zen & pre-Zen writings 4 | |author=Paul Reps 5 | |publisher=Anchor Books 6 | |pubdate=1989 7 | |pages=174 8 | |subject=Zen literature;Protected DAISY;Accessible book;In library|+sep=; 9 | |isbn=0385081308 10 | |lccn=89028542 11 | |olid=OL2206423M 12 | |url=https://openlibrary.org/books/OL2206423M/Zen_flesh_Zen_bones 13 | |dewey decimal class=294.3/927 14 | |lc classifications=BQ9264 .R47 1989 15 | |cover=https://covers.openlibrary.org/b/id/4610625-M.jpg 16 | |retrieved-from=https://openlibrary.org/ 17 | |retrieved-on=1970-01-01 18 | }} -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/OL2206423M.json: -------------------------------------------------------------------------------- 1 | {"ISBN:0385081308": {"publishers": [{"name": "Anchor Books"}], "pagination": "174 p. :", "identifiers": {"lccn": ["89028542"], "openlibrary": ["OL2206423M"], "isbn_10": ["0385081308"], "librarything": ["16724"], "goodreads": ["1707125"]}, "subtitle": "a collection of Zen & pre-Zen writings", "title": "Zen flesh, Zen bones", "url": "https://openlibrary.org/books/OL2206423M/Zen_flesh_Zen_bones", "classifications": {"dewey_decimal_class": ["294.3/927"], "lc_classifications": ["BQ9264 .R47 1989"]}, "notes": "Reprint. Originally published: Tokyo ; Rutland, Vt. : C.E. Tuttle, 1957.", "number_of_pages": 174, "cover": {"small": "https://covers.openlibrary.org/b/id/4610625-S.jpg", "large": "https://covers.openlibrary.org/b/id/4610625-L.jpg", "medium": "https://covers.openlibrary.org/b/id/4610625-M.jpg"}, "subjects": [{"url": "https://openlibrary.org/subjects/zen_literature", "name": "Zen literature"}, {"url": "https://openlibrary.org/subjects/protected_daisy", "name": "Protected DAISY"}, {"url": "https://openlibrary.org/subjects/accessible_book", "name": "Accessible book"}, {"url": "https://openlibrary.org/subjects/in_library", "name": "In library"}], "publish_date": "1989", "key": "/books/OL2206423M", "authors": [{"url": "https://openlibrary.org/authors/OL418604A/Paul_Reps", "name": "Paul Reps"}], "by_statement": "compiled by Paul Reps.", "publish_places": [{"name": "New York"}], "ebooks": [{"formats": {"djvu": {"url": "https://archive.org/download/zenfleshzenbones00reps/zenfleshzenbones00reps.djvu", "permission": "restricted"}}, "checkedout": true, "borrow_url": "https://openlibrary.org/books/OL2206423M/Zen_flesh_Zen_bones/borrow", "preview_url": "https://archive.org/details/zenfleshzenbones00reps", "availability": "borrow"}]}} -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/PMC2776723.expected: -------------------------------------------------------------------------------- 1 | {{#scite:PMC2776723 2 | |type=research-article 3 | |title=Design Logic of a Cannabinoid Receptor Signaling Network That Triggers Neurite Outgrowth 4 | |author=Bromberg KD;Ma'ayan A;Neves SR;Iyengar R|+sep=; 5 | |journal=Science (New York, N.Y.) 6 | |pubdate=2008/05/16 00:00 7 | |year=2009 8 | |volume=320 9 | |issue=5878 10 | |pages=903-909 11 | |doi=10.1126/science.1152662 12 | |abstract=Cannabinoid receptor ... 13 | |pmid=18487186 14 | |pmcid=PMC2776723 15 | |retrieved-from=http://www.ncbi.nlm.nih.gov/ 16 | |retrieved-on=1970-01-01 17 | }} -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/PMC2776723.json: -------------------------------------------------------------------------------- 1 | { 2 | "header": { 3 | "type": "esummary", 4 | "version": "0.3" 5 | }, 6 | "result": { 7 | "uids": [ 8 | "2776723" 9 | ], 10 | "2776723": { 11 | "uid": "2776723", 12 | "pubdate": "2008/05/16 00:00", 13 | "epubdate": "", 14 | "printpubdate": "2008/05/16 00:00", 15 | "epubdate": "1/01/01 00:00", 16 | "source": "Science", 17 | "authors": [ 18 | { 19 | "name": "Bromberg KD", 20 | "authtype": "Author" 21 | }, 22 | { 23 | "name": "Ma'ayan A", 24 | "authtype": "Author" 25 | }, 26 | { 27 | "name": "Neves SR", 28 | "authtype": "Author" 29 | }, 30 | { 31 | "name": "Iyengar R", 32 | "authtype": "Author" 33 | } 34 | ], 35 | "title": "Design Logic of a Cannabinoid Receptor Signaling Network That Triggers Neurite Outgrowth", 36 | "volume": "320", 37 | "issue": "5878", 38 | "pages": "903-909", 39 | "articleids": [ 40 | { 41 | "idtype": "pmid", 42 | "value": "18487186" 43 | }, 44 | { 45 | "idtype": "doi", 46 | "value": "10.1126/science.1152662" 47 | }, 48 | { 49 | "idtype": "pmcid", 50 | "value": "PMC2776723" 51 | }, 52 | { 53 | "idtype": "MID", 54 | "value": "NIHMS142954" 55 | } 56 | ], 57 | "fulljournalname": "Science (New York, N.Y.)", 58 | "sortdate": "2008/05/16 00:00", 59 | "pmclivedate": "2009/11/12 00:00" 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/FilteredMetadata/Fixtures/VIAF253484422.expected: -------------------------------------------------------------------------------- 1 | {{#scite:VIAF253484422 2 | |type=Personal 3 | |viaf=253484422 4 | |ndl=00163864 5 | |lc=nr92005566 6 | |isni=0000000376206155 7 | |dnb=159934044 8 | |name=手束, 正昭, 1944- 9 | |retrieved-from=http://viaf.org/ 10 | |retrieved-on=1970-01-01 11 | }} -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-01-simple-intext-reference.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Test paser/in-text annotation", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Citation/Resource", 7 | "contents": "{{#scite:Foo:123|type=text|citation text=Citation for bar}}" 8 | }, 9 | { 10 | "name": "Example/01/1", 11 | "contents": "[[CiteRef::Foo:123]]" 12 | }, 13 | { 14 | "name": "Example/01/2", 15 | "contents": "[[CiteRef::Foo:123|:50-52]]" 16 | } 17 | ], 18 | "parser-testcases": [ 19 | { 20 | "about": "#0 verify citation resource definition", 21 | "subject": "Citation/Resource", 22 | "store": { 23 | "semantic-data": { 24 | "strict-mode-valuematch": false, 25 | "propertyCount": 3, 26 | "propertyKeys": [ "__sci_cite", "_MDAT", "_SKEY" ], 27 | "propertyValues": [ "Citation/Resource#_SCITE86f84b9b2cf2ae4405199e26f121b4e9" ] 28 | } 29 | } 30 | }, 31 | { 32 | "about": "#1 verify citation resource container", 33 | "subject": "Citation/Resource#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 34 | "store": { 35 | "semantic-data": { 36 | "strict-mode-valuematch": false, 37 | "propertyCount": 3, 38 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "_SKEY" ], 39 | "propertyValues": [ "Foo:123", "Citation for bar" ] 40 | } 41 | } 42 | }, 43 | { 44 | "about": "#2 verify reference", 45 | "subject": "Example/01/1", 46 | "store": { 47 | "semantic-data": { 48 | "strict-mode-valuematch": false, 49 | "propertyCount": 3, 50 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 51 | "propertyValues": [ "Foo:123" ] 52 | } 53 | }, 54 | "expected-output": { 55 | "to-contain": [ 56 | "1", 57 | "
  • ^" 58 | ] 59 | } 60 | }, 61 | { 62 | "about": "#3 verify short form", 63 | "subject": "Example/01/2", 64 | "store": { 65 | "semantic-data": { 66 | "strict-mode-valuematch": false, 67 | "propertyCount": 3, 68 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 69 | "propertyValues": [ "Foo:123" ] 70 | } 71 | }, 72 | "expected-output": { 73 | "to-contain": [ 74 | "1:50-52", 75 | "
  • ^" 76 | ] 77 | } 78 | } 79 | ], 80 | "settings": { 81 | "wgContLang": "en", 82 | "scigReferenceListType": "ol", 83 | "scigCitationReferenceCaptionFormat" : 1, 84 | "smwgPageSpecialProperties": [ "_MDAT" ] 85 | }, 86 | "meta": { 87 | "version": "0.1", 88 | "is-incomplete": false, 89 | "debug": false 90 | } 91 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-02-multiple-intext-references.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Test multiple in-text annotations", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Citation/Resource/1", 7 | "contents": "{{#scite:Foo:123|type=text|citation text=A citation text}}" 8 | }, 9 | { 10 | "name": "Citation/Resource/2", 11 | "contents": "{{#scite:Bar abc|type=text|citation text=Another citation text}}" 12 | }, 13 | { 14 | "name": "Citation/Reference", 15 | "contents": "[[CiteRef::Foo:123]][[Citation reference::Bar abc]][[CiteRef::Foo:123]]" 16 | } 17 | ], 18 | "parser-testcases": [ 19 | { 20 | "about": "#0", 21 | "subject": "Citation/Resource/1#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 22 | "store": { 23 | "semantic-data": { 24 | "strict-mode-valuematch": false, 25 | "propertyCount": 3, 26 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "_SKEY" ], 27 | "propertyValues": [ "Foo:123", "A citation text" ] 28 | } 29 | } 30 | }, 31 | { 32 | "about": "#1", 33 | "subject": "Citation/Resource/2#_SCITE93a83f3f4f27770cf5084f131206bb3b", 34 | "store": { 35 | "semantic-data": { 36 | "strict-mode-valuematch": false, 37 | "propertyCount": 3, 38 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "_SKEY" ], 39 | "propertyValues": [ "Bar abc", "Another citation text" ] 40 | } 41 | } 42 | }, 43 | { 44 | "about": "#2 verify reference", 45 | "subject": "Citation/Reference", 46 | "store": { 47 | "semantic-data": { 48 | "strict-mode-valuematch": false, 49 | "propertyCount": 3, 50 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 51 | "propertyValues": [ "Foo:123", "Bar abc" ] 52 | } 53 | }, 54 | "expected-output": { 55 | "to-contain": [ 56 | "scite-ref-86f84b9b2cf2ae4405199e26f121b4e9-1-a", 57 | "scite-ref-86f84b9b2cf2ae4405199e26f121b4e9-1-b", 58 | "scite-ref-93a83f3f4f27770cf5084f131206bb3b-2-a", 59 | "scite-citeref-number", 60 | "data-reference=\"Foo:123\"", 61 | "data-reference=\"Bar abc\"", 62 | "#scite-86f84b9b2cf2ae4405199e26f121b4e9", 63 | "#scite-93a83f3f4f27770cf5084f131206bb3b" 64 | ] 65 | } 66 | } 67 | ], 68 | "settings": { 69 | "wgContLang": "en", 70 | "scigReferenceListType": "ol", 71 | "scigCitationReferenceCaptionFormat" : 1, 72 | "smwgPageSpecialProperties": [ "_MDAT" ] 73 | }, 74 | "meta": { 75 | "version": "0.1", 76 | "is-incomplete": false, 77 | "debug": false 78 | } 79 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-03-use-property-definition.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Test user-defined property annotation", 3 | "properties": [ 4 | { 5 | "name": "Has reference type", 6 | "contents": "[[Has type::Text]]" 7 | }, 8 | { 9 | "name": "Has author", 10 | "contents": "[[Has type::Page]]" 11 | }, 12 | { 13 | "name": "Has abstract", 14 | "contents": "[[Has type::Text]]" 15 | } 16 | ], 17 | "subjects": [ 18 | { 19 | "name": "Sci-property-definition", 20 | "namespace": "NS_MEDIAWIKI", 21 | "contents": "Some assignments\n type|Has reference type \n reference|Has reference \n author|Has author \n abstract|Has abstract\n" 22 | }, 23 | { 24 | "name": "Citation/Resource/3", 25 | "contents": "{{#scite:Foo:123|type=journal|author=AuthorA,AuthorB|+sep=,|abstract=Foobar|citation text=123}}" 26 | } 27 | ], 28 | "parser-testcases": [ 29 | { 30 | "about": "#0 verify citation resource definition", 31 | "subject": "Citation/Resource/3", 32 | "store": { 33 | "semantic-data": { 34 | "strict-mode-valuematch": false, 35 | "propertyCount": 3, 36 | "propertyKeys": [ "__sci_cite", "_MDAT", "_SKEY" ], 37 | "propertyValues": [ "Citation/Resource/3#_SCITE86f84b9b2cf2ae4405199e26f121b4e9" ] 38 | } 39 | } 40 | }, 41 | { 42 | "about": "#1 verify citation resource container", 43 | "subject": "Citation/Resource/3#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 44 | "store": { 45 | "semantic-data": { 46 | "strict-mode-valuematch": false, 47 | "propertyCount": 6, 48 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "Has_reference_type", "Has_author", "Has_abstract", "_SKEY" ], 49 | "propertyValues": [ "Foo:123", "123", "journal", "AuthorA", "AuthorB" ] 50 | } 51 | } 52 | } 53 | ], 54 | "settings": { 55 | "wgContLang": "en", 56 | "scigReferenceListType": "ol", 57 | "scigCitationReferenceCaptionFormat" : 1, 58 | "smwgPageSpecialProperties": [ "_MDAT" ] 59 | }, 60 | "meta": { 61 | "version": "0.1", 62 | "is-incomplete": false, 63 | "debug": false 64 | } 65 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-04-use-template-definition.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Test user-defined template generated citation text", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Sci-template-definition", 7 | "namespace": "NS_MEDIAWIKI", 8 | "contents": "Some type-template assignments\n journal|SciteJournalAFormatter \n" 9 | }, 10 | { 11 | "name": "SciteJournalAFormatter", 12 | "namespace": "NS_TEMPLATE", 13 | "contents": "{{{author}}}, {{{title}}}. ({{{year}}})" 14 | }, 15 | { 16 | "name": "SciteJournalBFormatter", 17 | "namespace": "NS_TEMPLATE", 18 | "contents": "({{{year}}}), {{{title}}}, {{{author}}}" 19 | }, 20 | { 21 | "name": "Citation/Resource/1", 22 | "contents": "{{#scite:Foo:123|type=journal|author=AuthorA,AuthorB|+sep=,|title=Some title|year=1970}}" 23 | }, 24 | { 25 | "name": "Citation/Resource/2", 26 | "contents": "{{#scite:Foo:456|type=journal|author=AuthorA,AuthorB|+sep=,|title=Some title|year=1970|template=SciteJournalBFormatter}}" 27 | } 28 | ], 29 | "parser-testcases": [ 30 | { 31 | "about": "#0", 32 | "subject": "Citation/Resource/1", 33 | "store": { 34 | "semantic-data": { 35 | "strict-mode-valuematch": false, 36 | "propertyCount": 3, 37 | "propertyKeys": [ "__sci_cite", "_MDAT", "_SKEY" ], 38 | "propertyValues": [ "Citation/Resource/1#_SCITE86f84b9b2cf2ae4405199e26f121b4e9" ] 39 | } 40 | } 41 | }, 42 | { 43 | "about": "#1 citation text determined by type-template mapping", 44 | "subject": "Citation/Resource/1#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 45 | "store": { 46 | "semantic-data": { 47 | "strict-mode-valuematch": false, 48 | "propertyCount": 3, 49 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "_SKEY" ], 50 | "propertyValues": [ "Foo:123", "AuthorA, AuthorB, Some title. (1970)" ] 51 | } 52 | } 53 | }, 54 | { 55 | "about": "#2", 56 | "subject": "Citation/Resource/2", 57 | "store": { 58 | "semantic-data": { 59 | "strict-mode-valuematch": false, 60 | "propertyCount": 3, 61 | "propertyKeys": [ "__sci_cite", "_MDAT", "_SKEY" ], 62 | "propertyValues": [ "Citation/Resource/2#_SCITE0c2129948fae0ce94908235dd949ea00" ] 63 | } 64 | } 65 | }, 66 | { 67 | "about": "#3 citation text determined by direct template assignment", 68 | "subject": "Citation/Resource/2#_SCITE0c2129948fae0ce94908235dd949ea00", 69 | "store": { 70 | "semantic-data": { 71 | "strict-mode-valuematch": false, 72 | "propertyCount": 3, 73 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "_SKEY" ], 74 | "propertyValues": [ "Foo:456", "(1970), Some title, AuthorA, AuthorB" ] 75 | } 76 | } 77 | } 78 | ], 79 | "settings": { 80 | "wgContLang": "en", 81 | "scigReferenceListType": "ol", 82 | "scigCitationReferenceCaptionFormat" : 1, 83 | "smwgPageSpecialProperties": [ "_MDAT" ] 84 | }, 85 | "meta": { 86 | "version": "0.1", 87 | "is-incomplete": false, 88 | "debug": false 89 | } 90 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-05-different-referencelist-position.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Testing {{#referencelist:}} for a different referencelist position", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Citation/Resource/05", 7 | "contents": "{{#scite:Foo:abc|type=text|citation text=Citation for bar}}" 8 | }, 9 | { 10 | "name": "Citation/Reference/05/1", 11 | "contents": "[[CiteRef::Foo:abc]]

    " 12 | }, 13 | { 14 | "name": "Citation/Reference/05/2", 15 | "contents": "[[CiteRef::Foo:abc]][[CiteRef::Foo:abc]] {{#referencelist:}}" 16 | } 17 | ], 18 | "parser-testcases": [ 19 | { 20 | "about": "#0 single citeref", 21 | "subject": "Citation/Reference/05/1", 22 | "store": { 23 | "semantic-data": { 24 | "strict-mode-valuematch": false, 25 | "propertyCount": 3, 26 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 27 | "propertyValues": [ "Foo:abc" ] 28 | } 29 | }, 30 | "expected-output": { 31 | "to-contain": [ 32 | "1", 33 | "
    ", 34 | "
  • ^", 35 | "Citation for bar" 36 | ] 37 | } 38 | }, 39 | { 40 | "about": "#1 two citeref's to same citation", 41 | "subject": "Citation/Reference/05/2", 42 | "store": { 43 | "semantic-data": { 44 | "strict-mode-valuematch": false, 45 | "propertyCount": 3, 46 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 47 | "propertyValues": [ "Foo:abc" ] 48 | } 49 | }, 50 | "expected-output": { 51 | "to-contain": [ 52 | "1", 53 | "1", 54 | "
    ", 55 | "a", 56 | "b", 57 | "Citation for bar" 58 | ] 59 | } 60 | } 61 | ], 62 | "settings": { 63 | "wgContLang": "en", 64 | "scigReferenceListType": "ol", 65 | "scigCitationReferenceCaptionFormat" : 1, 66 | "smwgPageSpecialProperties": [ "_MDAT" ] 67 | }, 68 | "meta": { 69 | "version": "0.1", 70 | "is-incomplete": false, 71 | "debug": false 72 | } 73 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-06-different-caption-format.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Test different citation reference caption format/display", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Citation/Resource", 7 | "contents": "{{#scite:Foo:123|type=text|citation text=Citation for bar}}" 8 | }, 9 | { 10 | "name": "Citation/Reference", 11 | "contents": "[[CiteRef::Foo:123|abc, 1970]]" 12 | } 13 | ], 14 | "parser-testcases": [ 15 | { 16 | "about": "#0 verify caption display", 17 | "subject": "Citation/Reference", 18 | "store": { 19 | "semantic-data": { 20 | "strict-mode-valuematch": false, 21 | "propertyCount": 3, 22 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 23 | "propertyValues": [ "Foo:123" ] 24 | } 25 | }, 26 | "expected-output": { 27 | "to-contain": [ 28 | "scite-ref-86f84b9b2cf2ae4405199e26f121b4e9-1-a", 29 | "class=\"scite-citeref-key\" data-reference=\"Foo:123\"", 30 | "abc, 1970", 31 | "#scite-86f84b9b2cf2ae4405199e26f121b4e9" 32 | ] 33 | } 34 | } 35 | ], 36 | "settings": { 37 | "wgContLang": "en", 38 | "scigReferenceListType": "ol", 39 | "scigCitationReferenceCaptionFormat" : 2, 40 | "smwgPageSpecialProperties": [ "_MDAT" ] 41 | }, 42 | "meta": { 43 | "version": "0.1", 44 | "is-incomplete": false, 45 | "debug": false 46 | } 47 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-07-referencelist-custom-options.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Testing {{#referencelist:}} with different custom options", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Citation/Resource/05", 7 | "contents": "{{#scite:Foo:abc|type=text|citation text=Citation for bar}}" 8 | }, 9 | { 10 | "name": "Citation/Reference/07/1", 11 | "contents": "[[CiteRef::Foo:abc]][[CiteRef::Foo:abc]] {{#referencelist:|browselinks=no|columns=1|listtype=ol}}" 12 | }, 13 | { 14 | "name": "Citation/Reference/07/2", 15 | "contents": "[[CiteRef::Foo:abc]][[CiteRef::Foo:abc]] {{#referencelist:|browselinks=yes|columns=2|listtype=ul|header=SomeHeader}}" 16 | } 17 | ], 18 | "parser-testcases": [ 19 | { 20 | "about": "#0", 21 | "subject": "Citation/Reference/07/1", 22 | "store": { 23 | "semantic-data": { 24 | "strict-mode-valuematch": false, 25 | "propertyCount": 3, 26 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 27 | "propertyValues": [ "Foo:abc" ] 28 | } 29 | }, 30 | "expected-output": { 31 | "to-contain": [ 32 | "1", 33 | "1", 34 | "
    ", 35 | "a", 36 | "b", 37 | "Citation for bar" 38 | ] 39 | } 40 | }, 41 | { 42 | "about": "#1", 43 | "subject": "Citation/Reference/07/2", 44 | "store": { 45 | "semantic-data": { 46 | "strict-mode-valuematch": false, 47 | "propertyCount": 3, 48 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 49 | "propertyValues": [ "Foo:abc" ] 50 | } 51 | }, 52 | "expected-output": { 53 | "to-contain": [ 54 | "1", 55 | "1", 56 | "
    ", 57 | "1.a", 58 | "1.b", 59 | "Citation for bar", 60 | "

    SomeHeader

    " 61 | ] 62 | } 63 | } 64 | ], 65 | "settings": { 66 | "wgContLang": "en", 67 | "scigReferenceListType": "ol", 68 | "scigCitationReferenceCaptionFormat" : 1, 69 | "smwgPageSpecialProperties": [ "_MDAT" ] 70 | }, 71 | "meta": { 72 | "version": "0.1", 73 | "is-incomplete": false, 74 | "debug": false 75 | } 76 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-08-ul-referencelist-with-key.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Testing {{#referencelist:}} for a different referencelist position", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Citation/Resource/08", 7 | "contents": "{{#scite:Foo:abc|type=text|citation text=Citation for bar}}" 8 | }, 9 | { 10 | "name": "Citation/Reference/08/1", 11 | "contents": "[[CiteRef::Foo:abc]] {{#referencelist:listtype=ul}}" 12 | }, 13 | { 14 | "name": "Citation/Reference/08/2", 15 | "contents": "[[CiteRef::Foo:abc]][[CiteRef::Foo:abc]] {{#referencelist:listtype=ul}}" 16 | } 17 | ], 18 | "parser-testcases": [ 19 | { 20 | "about": "#0 single citeref", 21 | "subject": "Citation/Reference/08/1", 22 | "store": { 23 | "semantic-data": { 24 | "strict-mode-valuematch": false, 25 | "propertyCount": 3, 26 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 27 | "propertyValues": [ "Foo:abc" ] 28 | } 29 | }, 30 | "expected-output": { 31 | "to-contain": [ 32 | "Foo:abc", 33 | "
    ", 34 | "
    • ^", 35 | "Citation for bar" 36 | ] 37 | } 38 | }, 39 | { 40 | "about": "#1 two citeref's to same citation", 41 | "subject": "Citation/Reference/08/2", 42 | "store": { 43 | "semantic-data": { 44 | "strict-mode-valuematch": false, 45 | "propertyCount": 3, 46 | "propertyKeys": [ "__sci_cite_reference", "_MDAT", "_SKEY" ], 47 | "propertyValues": [ "Foo:abc" ] 48 | } 49 | }, 50 | "expected-output": { 51 | "to-contain": [ 52 | "Foo:abc", 53 | "Foo:abc", 54 | "
      ", 55 | "
      • ", 56 | "a", 57 | "b", 58 | "Citation for bar" 59 | ] 60 | } 61 | } 62 | ], 63 | "settings": { 64 | "wgContLang": "en", 65 | "scigReferenceListType": "ul", 66 | "smwgQueryResultCacheType": false, 67 | "scigCitationReferenceCaptionFormat" : 2, 68 | "smwgPageSpecialProperties": [ "_MDAT" ] 69 | }, 70 | "meta": { 71 | "version": "0.1", 72 | "is-incomplete": false, 73 | "debug": false 74 | } 75 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-10-reference-with-sortkey.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Verify sorkey annotation", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Citation/Resource", 7 | "contents": "{{#scite:Foo:123|type=text|citation text=Citation for bar|sortkey=ABC}}" 8 | } 9 | ], 10 | "parser-testcases": [ 11 | { 12 | "about": "#0", 13 | "subject": "Citation/Resource#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 14 | "store": { 15 | "semantic-data": { 16 | "strict-mode-valuematch": false, 17 | "propertyCount": 3, 18 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "_SKEY" ], 19 | "propertyValues": [ "Foo:123", "Citation for bar", "ABC" ] 20 | } 21 | } 22 | } 23 | ], 24 | "settings": { 25 | "wgContLang": "en", 26 | "scigReferenceListType": "ol", 27 | "scigCitationReferenceCaptionFormat" : 1, 28 | "smwgPageSpecialProperties": [ "_MDAT" ] 29 | }, 30 | "meta": { 31 | "version": "0.1", 32 | "is-incomplete": false, 33 | "debug": false 34 | } 35 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-11-noreferencelist-magic-word.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Testing the absense of content using __NOREFERENCELIST__", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Citation/Resource/11", 7 | "contents": "{{#scite:Foo:abc|type=text|citation text=Citation for bar}} {{#scite:Bar:abc|type=text|citation text=Citation for a loose reference}}" 8 | }, 9 | { 10 | "name": "Citation/Reference/11/1", 11 | "contents": "{{#referencelist:listtype=ul|references=Bar:abc,Foo:abc|+sep=,|header=Notes}}" 12 | }, 13 | { 14 | "name": "Citation/Reference/11/2", 15 | "contents": "{{#referencelist:listtype=ul|references=Bar:abc,Foo:abc|+sep=,|header=Notes}} __NOREFERENCELIST__" 16 | } 17 | ], 18 | "parser-testcases": [ 19 | { 20 | "about": "#0 test group to contain a list", 21 | "subject": "Citation/Reference/11/1", 22 | "expected-output": { 23 | "to-contain": [ 24 | "

        Notes

        ", 25 | "
      • Citation for a loose reference
      • ", 26 | "
      • Citation for bar
      • " 27 | ] 28 | } 29 | }, 30 | { 31 | "about": "#1 test for absence", 32 | "subject": "Citation/Reference/11/2", 33 | "expected-output": { 34 | "to-not-contain": [ 35 | "

        Notes

        ", 36 | "
      • Citation for a loose reference
      • ", 37 | "
      • Citation for bar
      • " 38 | ] 39 | } 40 | } 41 | ], 42 | "settings": { 43 | "wgContLang": "en", 44 | "scigReferenceListType": "ul", 45 | "smwgQueryResultCacheType": false, 46 | "scigCitationReferenceCaptionFormat" : 2, 47 | "smwgPageSpecialProperties": [ "_MDAT" ] 48 | }, 49 | "meta": { 50 | "version": "0.1", 51 | "is-incomplete": false, 52 | "debug": false 53 | } 54 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-12-fixed-property-annotation.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Test fixed property annotation", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Example/12/1", 7 | "contents": "{{#scite:Foo:123|type=text|doi=http://dx.doi.org/10.1074/jbc.M114.559054|citation text=DOI test}}" 8 | }, 9 | { 10 | "name": "Example/12/2", 11 | "contents": "{{#scite:Foo:123|type=text|doi=10.1074/jbc.M114.559054|citation text=DOI test}}" 12 | }, 13 | { 14 | "name": "Example/12/3", 15 | "contents": "{{#scite:Foo:123|type=text|oclc=42|viaf=VIAF123|citation text=OCLC/VIAF test}}" 16 | }, 17 | { 18 | "name": "Example/12/4", 19 | "contents": "{{#scite:Foo:123|type=text|pmid=102|pmcid=PMC123|citation text=PMID/PMCID test}}" 20 | }, 21 | { 22 | "name": "Example/12/5", 23 | "contents": "{{#scite:Foo:123|type=text|olid=OL102M|citation text=OLID test}}" 24 | } 25 | ], 26 | "parser-testcases": [ 27 | { 28 | "about": "#0 DOI url annotation", 29 | "subject": "Example/12/1#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 30 | "store": { 31 | "semantic-data": { 32 | "strict-mode-valuematch": false, 33 | "propertyCount": 4, 34 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "__sci_doi", "_SKEY" ], 35 | "propertyValues": [ "Foo:123", "DOI test", "10.1074/jbc.m114.559054" ] 36 | } 37 | } 38 | }, 39 | { 40 | "about": "#1 DOI short annotation", 41 | "subject": "Example/12/1#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 42 | "store": { 43 | "semantic-data": { 44 | "strict-mode-valuematch": false, 45 | "propertyCount": 4, 46 | "propertyKeys": [ "__sci_cite_key", "__sci_cite_text", "__sci_doi", "_SKEY" ], 47 | "propertyValues": [ "Foo:123", "DOI test", "10.1074/jbc.m114.559054" ] 48 | } 49 | } 50 | }, 51 | { 52 | "about": "#2 OCLC/VIAF annotation", 53 | "subject": "Example/12/3#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 54 | "store": { 55 | "semantic-data": { 56 | "strict-mode-valuematch": false, 57 | "propertyCount": 5, 58 | "propertyKeys": [ "__sci_cite_key", "__sci_oclc", "__sci_viaf", "__sci_cite_text", "_SKEY" ], 59 | "propertyValues": [ "Foo:123", "42", "123", "OCLC/VIAF test" ] 60 | } 61 | } 62 | }, 63 | { 64 | "about": "#3 PMID/PMCID annotation", 65 | "subject": "Example/12/4#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 66 | "store": { 67 | "semantic-data": { 68 | "strict-mode-valuematch": false, 69 | "propertyCount": 5, 70 | "propertyKeys": [ "__sci_cite_key", "__sci_pmid", "__sci_pmcid", "__sci_cite_text", "_SKEY" ], 71 | "propertyValues": [ "Foo:123", "102", "PMC123", "PMID/PMCID test" ] 72 | } 73 | } 74 | }, 75 | { 76 | "about": "#4 OLID annotation", 77 | "subject": "Example/12/5#_SCITE86f84b9b2cf2ae4405199e26f121b4e9", 78 | "store": { 79 | "semantic-data": { 80 | "strict-mode-valuematch": false, 81 | "propertyCount": 4, 82 | "propertyKeys": [ "__sci_cite_key", "__sci_olid", "__sci_cite_text", "_SKEY" ], 83 | "propertyValues": [ "Foo:123", "OL102M", "OLID test" ] 84 | } 85 | } 86 | } 87 | ], 88 | "settings": { 89 | "wgContLang": "en", 90 | "scigReferenceListType": "ol", 91 | "scigCitationReferenceCaptionFormat" : 1, 92 | "smwgPageSpecialProperties": [ "_MDAT" ] 93 | }, 94 | "meta": { 95 | "version": "0.1", 96 | "is-incomplete": false, 97 | "debug": false 98 | } 99 | } -------------------------------------------------------------------------------- /tests/phpunit/Integration/JSONScript/TestCases/scite-14-fixed-property-query.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Test queries in connection with predefined properties", 3 | "properties": [], 4 | "subjects": [ 5 | { 6 | "name": "Example/14/1", 7 | "contents": "{{#scite:Foo:123|type=text|doi=http://dx.doi.org/10.1074/jbc.M114.559054|citation text=DOI test}}" 8 | }, 9 | { 10 | "name": "Example/Query/1", 11 | "contents": "{{#ask:[[DOI::~*M114.559054]]|?DOI|format=table}}" 12 | }, 13 | { 14 | "name": "Example/Query/2", 15 | "contents": "{{#ask:[[DOI::~*M114.559054]]|?DOI#-|format=table}}" 16 | } 17 | ], 18 | "parser-testcases": [ 19 | { 20 | "about": "#0 non display formatted query output", 21 | "subject": "Example/Query/1", 22 | "skip-on": { 23 | "mediawiki": [ ">1.38.x", "Failing with 'is an invalid value for the DOI type' on MW 1.39 and above. Needs to be checked and fixed." ] 24 | }, 25 | "expected-output": { 26 | "to-contain": [ 27 | "10.1074/jbc.m114.559054" 28 | ] 29 | } 30 | }, 31 | { 32 | "about": "#1 display formatted query output", 33 | "subject": "Example/Query/2", 34 | "skip-on": { 35 | "mediawiki": [ ">1.38.x", "Failing with 'is an invalid value for the DOI type' on MW 1.39 and above. Needs to be checked and fixed." ] 36 | }, 37 | "expected-output": { 38 | "to-contain": [ 39 | "10.1074/jbc.m114.559054" 40 | ] 41 | } 42 | } 43 | ], 44 | "settings": { 45 | "wgContLang": "en", 46 | "scigReferenceListType": "ul", 47 | "scigCitationReferenceCaptionFormat" : 2, 48 | "smwgPageSpecialProperties": [ "_MDAT" ] 49 | }, 50 | "meta": { 51 | "version": "0.1", 52 | "is-incomplete": false, 53 | "debug": false 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tests/phpunit/Structure/I18nJsonFileIntegrityTest.php: -------------------------------------------------------------------------------- 1 | newJsonFileReader( $file ); 27 | 28 | $this->assertInternalType( 29 | 'integer', 30 | $jsonFileReader->getModificationTime() 31 | ); 32 | 33 | $this->assertInternalType( 34 | 'array', 35 | $jsonFileReader->read() 36 | ); 37 | } 38 | 39 | public function i18nFileProvider() { 40 | 41 | $provider = []; 42 | $location = $GLOBALS['wgMessagesDirs']['SemanticCite']; 43 | 44 | $bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider( $location ); 45 | $bulkFileProvider->searchByFileExtension( 'json' ); 46 | 47 | foreach ( $bulkFileProvider->getFiles() as $file ) { 48 | $provider[] = [ $file ]; 49 | } 50 | 51 | return $provider; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/CacheKeyProviderTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf( 24 | '\SCI\CacheKeyProvider', 25 | new CacheKeyProvider() 26 | ); 27 | } 28 | 29 | public function testGetKey() { 30 | 31 | $instance = new CacheKeyProvider(); 32 | $instance->setCachePrefix( 'foo' ); 33 | 34 | $this->assertContains( 35 | 'foo', 36 | $instance->getCacheKeyForCitationReference( 'abc' ) 37 | ); 38 | 39 | $this->assertContains( 40 | ':ref:', 41 | $instance->getCacheKeyForCitationReference( 123 ) 42 | ); 43 | 44 | $this->assertContains( 45 | 'foo', 46 | $instance->getCacheKeyForReferenceList( 'def' ) 47 | ); 48 | 49 | $this->assertContains( 50 | ':reflist:', 51 | $instance->getCacheKeyForReferenceList( 456 ) 52 | ); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/CitationReferencePositionJournalTest.php: -------------------------------------------------------------------------------- 1 | cache = $this->getMockBuilder( '\Onoi\Cache\Cache' ) 27 | ->disableOriginalConstructor() 28 | ->getMock(); 29 | 30 | $this->cacheKeyProvider = $this->getMockBuilder( '\SCI\CacheKeyProvider' ) 31 | ->disableOriginalConstructor() 32 | ->getMock(); 33 | } 34 | 35 | public function testCanConstruct() { 36 | 37 | $this->assertInstanceOf( 38 | '\SCI\CitationReferencePositionJournal', 39 | new CitationReferencePositionJournal( $this->cache, $this->cacheKeyProvider ) 40 | ); 41 | } 42 | 43 | public function testUnboundReferenceList() { 44 | 45 | $instance = new CitationReferencePositionJournal( 46 | $this->cache, 47 | $this->cacheKeyProvider 48 | ); 49 | 50 | $this->assertNull( 51 | $instance->buildJournalForUnboundReferenceList( [] ) 52 | ); 53 | 54 | $this->assertInternalType( 55 | 'array', 56 | $instance->buildJournalForUnboundReferenceList( [ 'foo' ] ) 57 | ); 58 | } 59 | 60 | public function testTryToAddJournalEntryForNullSubject() { 61 | 62 | $instance = new CitationReferencePositionJournal( 63 | $this->cache, 64 | $this->cacheKeyProvider 65 | ); 66 | 67 | $this->assertNull( 68 | $instance->addJournalEntryFor( null, 'foo' ) 69 | ); 70 | } 71 | 72 | public function testTryToGetJournalBySubject() { 73 | 74 | $subject = \SMW\DIWikiPage::newFromText( __METHOD__ ); 75 | 76 | $this->cacheKeyProvider->expects( $this->once() ) 77 | ->method( 'getCacheKeyForCitationReference' ) 78 | ->with( $this->equalTo( $subject->getHash() ) ); 79 | 80 | $instance = new CitationReferencePositionJournal( 81 | $this->cache, 82 | $this->cacheKeyProvider 83 | ); 84 | 85 | $instance->getJournalBySubject( $subject ); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/CitationResourceMatchFinderTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\SMW\Store' ) 21 | ->disableOriginalConstructor() 22 | ->getMockForAbstractClass(); 23 | 24 | $this->assertInstanceOf( 25 | '\SCI\CitationResourceMatchFinder', 26 | new CitationResourceMatchFinder( $store ) 27 | ); 28 | } 29 | 30 | /** 31 | * @dataProvider uidTypeProvider 32 | */ 33 | public function testFindMatchForUidTypeOf( $key, $id ) { 34 | 35 | $queryResult = $this->getMockBuilder( '\SMW\Query\QueryResult' ) 36 | ->disableOriginalConstructor() 37 | ->getMock(); 38 | 39 | $store = $this->getMockBuilder( '\SMW\Store' ) 40 | ->disableOriginalConstructor() 41 | ->getMockForAbstractClass(); 42 | 43 | $store->expects( $this->once() ) 44 | ->method( 'getQueryResult' ) 45 | ->will( $this->returnValue( $queryResult ) ); 46 | 47 | $instance = new CitationResourceMatchFinder( $store ); 48 | 49 | $instance->findMatchForResourceIdentifierTypeToValue( 50 | $key, 51 | $id 52 | ); 53 | } 54 | 55 | public function uidTypeProvider() { 56 | 57 | $provider[] = [ 58 | 'oclc', 59 | 42 60 | ]; 61 | 62 | $provider[] = [ 63 | 'viaf', 64 | 42 65 | ]; 66 | 67 | $provider[] = [ 68 | 'doi', 69 | 42 70 | ]; 71 | 72 | $provider[] = [ 73 | 'pmid', 74 | 42 75 | ]; 76 | 77 | $provider[] = [ 78 | 'pmcid', 79 | 42 80 | ]; 81 | 82 | $provider[] = [ 83 | 'olid', 84 | 42 85 | ]; 86 | 87 | return $provider; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/CitationTextTemplateRendererTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\SMW\MediaWiki\Renderer\WikitextTemplateRenderer' ) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | 24 | $parser = $this->getMockBuilder( '\Parser' ) 25 | ->disableOriginalConstructor() 26 | ->getMock(); 27 | 28 | $this->assertInstanceOf( 29 | '\SCI\CitationTextTemplateRenderer', 30 | new CitationTextTemplateRenderer( $wikitextTemplateRenderer, $parser ) 31 | ); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/DataValues/CitationReferenceValueTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\SMW\DataValues\ValueValidators\ConstraintValueValidator' ) 25 | ->disableOriginalConstructor() 26 | ->getMock(); 27 | 28 | $this->dataValueServiceFactory = $this->getMockBuilder( '\SMW\Services\DataValueServiceFactory' ) 29 | ->disableOriginalConstructor() 30 | ->getMock(); 31 | 32 | $this->dataValueServiceFactory->expects( $this->any() ) 33 | ->method( 'getConstraintValueValidator' ) 34 | ->will( $this->returnValue( $constraintValueValidator ) ); 35 | } 36 | 37 | public function testCanConstruct() { 38 | 39 | $this->assertInstanceOf( 40 | '\SCI\DataValues\CitationReferenceValue', 41 | new CitationReferenceValue() 42 | ); 43 | } 44 | 45 | public function testNoValueCreatesError() { 46 | 47 | $citationReferencePositionJournal = $this->getMockBuilder( '\SCI\CitationReferencePositionJournal' ) 48 | ->disableOriginalConstructor() 49 | ->getMock(); 50 | 51 | $callback = function() use ( $citationReferencePositionJournal ) { 52 | return $citationReferencePositionJournal; 53 | }; 54 | 55 | $instance = new CitationReferenceValue(); 56 | $instance->addCallable( 'sci.citationreferencepositionjournal', $callback ); 57 | 58 | $instance->setDataValueServiceFactory( 59 | $this->dataValueServiceFactory 60 | ); 61 | 62 | $instance->setUserValue( '' ); 63 | 64 | $this->assertNotEmpty( 65 | $instance->getErrors() 66 | ); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/DataValues/ResourceIdentifierFactoryTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf( 21 | '\SCI\DataValues\ResourceIdentifierFactory', 22 | new ResourceIdentifierFactory() 23 | ); 24 | } 25 | 26 | public function testUnknownTypeMatchThrowsException() { 27 | 28 | $instance = new ResourceIdentifierFactory(); 29 | 30 | $this->expectException( 'RuntimeException' ); 31 | $instance->newResourceIdentifierStringValueForType( 'foo' ); 32 | } 33 | 34 | /** 35 | * @dataProvider typeProvider 36 | */ 37 | public function testUidValueForType( $type ) { 38 | 39 | $instance = new ResourceIdentifierFactory(); 40 | 41 | $this->assertInstanceOf( 42 | '\SCI\DataValues\ResourceIdentifierStringValue', 43 | $instance->newResourceIdentifierStringValueForType( $type ) 44 | ); 45 | } 46 | 47 | public function typeProvider() { 48 | 49 | $provider[] = [ 50 | 'DOI' 51 | ]; 52 | 53 | $provider[] = [ 54 | 'VIAF' 55 | ]; 56 | 57 | $provider[] = [ 58 | 'OCLC' 59 | ]; 60 | 61 | $provider[] = [ 62 | 'OLID' 63 | ]; 64 | 65 | $provider[] = [ 66 | 'PMCID' 67 | ]; 68 | 69 | $provider[] = [ 70 | 'PMID' 71 | ]; 72 | 73 | $provider[] = [ 74 | 'pubmed' 75 | ]; 76 | 77 | $provider[] = [ 78 | 'pmc' 79 | ]; 80 | 81 | return $provider; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/FilteredMetadata/BibliographicFilteredRecordTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf( 21 | '\Onoi\Remi\FilteredRecord', 22 | new BibliographicFilteredRecord() 23 | ); 24 | } 25 | 26 | public function testSearchMatchSet() { 27 | 28 | $instance = new BibliographicFilteredRecord(); 29 | 30 | $instance->addSearchMatchSet( 'foo', 42 ); 31 | 32 | $this->assertEquals( 33 | 42, 34 | $instance->getSearchMatchSetValueFor( 'foo' ) 35 | ); 36 | } 37 | 38 | public function testTitleForPageCreation() { 39 | 40 | $instance = new BibliographicFilteredRecord(); 41 | 42 | $instance->setTitleForPageCreation( 'foo' ); 43 | 44 | $this->assertEquals( 45 | 'CR:foo', 46 | $instance->getTitleForPageCreation() 47 | ); 48 | } 49 | 50 | public function testSciteTransclusion() { 51 | 52 | $instance = new BibliographicFilteredRecord(); 53 | 54 | $instance->setSciteTransclusionHead( 'foo' ); 55 | 56 | $this->assertEquals( 57 | '{{#scite:foo' . "\n" . '}}', 58 | $instance->asSciteTransclusion() 59 | ); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/FilteredMetadata/CrossRefResponseParserTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\Onoi\Remi\CrossRef\CrossRefFilteredHttpResponseParser' ) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | 24 | $this->assertInstanceOf( 25 | '\Onoi\Remi\ResponseParser', 26 | new CrossRefResponseParser( $crossRefFilteredHttpResponseParser ) 27 | ); 28 | } 29 | 30 | public function testInterfaceMethods() { 31 | 32 | $crossRefFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\CrossRef\CrossRefFilteredHttpResponseParser' ) 33 | ->disableOriginalConstructor() 34 | ->getMock(); 35 | 36 | $instance = new CrossRefResponseParser( $crossRefFilteredHttpResponseParser ); 37 | 38 | $this->assertNull( 39 | $instance->usesCache() 40 | ); 41 | 42 | $this->assertNull( 43 | $instance->getMessages() 44 | ); 45 | 46 | $this->assertNull( 47 | $instance->getFilteredRecord() 48 | ); 49 | 50 | $this->assertNull( 51 | $instance->getRawResponse( 42 ) 52 | ); 53 | } 54 | 55 | /** 56 | * @dataProvider idProvider 57 | */ 58 | public function testDoParseForId( $id, $expects ) { 59 | 60 | $record = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) 61 | ->disableOriginalConstructor() 62 | ->getMock(); 63 | 64 | $crossRefFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\CrossRef\CrossRefFilteredHttpResponseParser' ) 65 | ->disableOriginalConstructor() 66 | ->getMock(); 67 | 68 | $crossRefFilteredHttpResponseParser->expects( $this->any() ) 69 | ->method( 'getFilteredRecord' ) 70 | ->will( $this->returnValue( $record ) ); 71 | 72 | $crossRefFilteredHttpResponseParser->expects( $expects ) 73 | ->method( 'doFilterResponseFor' ); 74 | 75 | $instance = new CrossRefResponseParser( $crossRefFilteredHttpResponseParser ); 76 | $instance->doFilterResponseFor( $id ); 77 | } 78 | 79 | public function idProvider() { 80 | 81 | $provider[] = [ 82 | 'abc', 83 | $this->never() 84 | ]; 85 | 86 | $provider[] = [ 87 | '10.1126/science.1152662', 88 | $this->once() 89 | ]; 90 | 91 | return $provider; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/FilteredMetadata/HttpResponseParserFactoryTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\Onoi\HttpRequest\HttpRequest' ) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | 24 | $this->assertInstanceOf( 25 | '\SCI\FilteredMetadata\HttpResponseParserFactory', 26 | new HttpResponseParserFactory( $httpRequest ) 27 | ); 28 | } 29 | 30 | /** 31 | * @dataProvider typeProvider 32 | */ 33 | public function testHttpResponseContentParserForType( $type ) { 34 | 35 | $httpRequest = $this->getMockBuilder( '\Onoi\HttpRequest\HttpRequest' ) 36 | ->disableOriginalConstructor() 37 | ->getMock(); 38 | 39 | $instance = new HttpResponseParserFactory( $httpRequest ); 40 | 41 | $this->assertInstanceOf( 42 | '\Onoi\Remi\ResponseParser', 43 | $instance->newResponseParserForType( $type ) 44 | ); 45 | } 46 | 47 | public function typeProvider() { 48 | 49 | $provider[] = [ 50 | 'pubmed' 51 | ]; 52 | 53 | $provider[] = [ 54 | 'pmc' 55 | ]; 56 | 57 | $provider[] = [ 58 | 'doi' 59 | ]; 60 | 61 | $provider[] = [ 62 | 'oclc' 63 | ]; 64 | 65 | $provider[] = [ 66 | 'viaf' 67 | ]; 68 | 69 | $provider[] = [ 70 | 'ol' 71 | ]; 72 | 73 | // Unknown = null 74 | $provider[] = [ 75 | 'foo' 76 | ]; 77 | 78 | return $provider; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/FilteredMetadata/NcbiPubMedResponseParserTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\Onoi\Remi\Ncbi\NcbiPubMedFilteredHttpResponseParser' ) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | 24 | $this->assertInstanceOf( 25 | '\Onoi\Remi\ResponseParser', 26 | new NcbiPubMedResponseParser( $ncbiPubMedFilteredHttpResponseParser ) 27 | ); 28 | } 29 | 30 | public function testInterfaceMethods() { 31 | 32 | $ncbiPubMedFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\Ncbi\NcbiPubMedFilteredHttpResponseParser' ) 33 | ->disableOriginalConstructor() 34 | ->getMock(); 35 | 36 | $instance = new NcbiPubMedResponseParser( $ncbiPubMedFilteredHttpResponseParser ); 37 | 38 | $this->assertNull( 39 | $instance->usesCache() 40 | ); 41 | 42 | $this->assertNull( 43 | $instance->getMessages() 44 | ); 45 | 46 | $this->assertNull( 47 | $instance->getFilteredRecord() 48 | ); 49 | 50 | $this->assertNull( 51 | $instance->getRawResponse( 42 ) 52 | ); 53 | } 54 | 55 | /** 56 | * @dataProvider idProvider 57 | */ 58 | public function testDoParseForId( $id, $type, $expects ) { 59 | 60 | $record = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) 61 | ->disableOriginalConstructor() 62 | ->getMock(); 63 | 64 | $record->expects( $this->at( 0 ) ) 65 | ->method( 'get' ) 66 | ->with( $this->stringContains( 'ncbi-dbtype' ) ) 67 | ->will( $this->returnValue( $type ) ); 68 | 69 | $ncbiPubMedFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\Ncbi\NcbiPubMedFilteredHttpResponseParser' ) 70 | ->disableOriginalConstructor() 71 | ->getMock(); 72 | 73 | $ncbiPubMedFilteredHttpResponseParser->expects( $this->any() ) 74 | ->method( 'getFilteredRecord' ) 75 | ->will( $this->returnValue( $record ) ); 76 | 77 | $ncbiPubMedFilteredHttpResponseParser->expects( $expects ) 78 | ->method( 'doFilterResponseFor' ); 79 | 80 | $instance = new NcbiPubMedResponseParser( $ncbiPubMedFilteredHttpResponseParser ); 81 | $instance->doFilterResponseFor( $id ); 82 | } 83 | 84 | public function idProvider() { 85 | 86 | $provider[] = [ 87 | 'abc', 88 | 'pmc', 89 | $this->never() 90 | ]; 91 | 92 | $provider[] = [ 93 | 'abc', 94 | 'pubmed', 95 | $this->never() 96 | ]; 97 | 98 | $provider[] = [ 99 | 'PMID54846467', 100 | 'pmc', 101 | $this->never() 102 | ]; 103 | 104 | $provider[] = [ 105 | 'PMC54846467', 106 | 'pmc', 107 | $this->once() 108 | ]; 109 | 110 | $provider[] = [ 111 | 'PMID54846467', 112 | 'pmid', 113 | $this->once() 114 | ]; 115 | 116 | $provider[] = [ 117 | 'PMID54846467', 118 | 'pubmed', 119 | $this->once() 120 | ]; 121 | 122 | return $provider; 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/FilteredMetadata/OLResponseParserTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\Onoi\Remi\OpenLibrary\OLFilteredHttpResponseParser' ) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | 24 | $this->assertInstanceOf( 25 | '\Onoi\Remi\ResponseParser', 26 | new OLResponseParser( $olFilteredHttpResponseParser ) 27 | ); 28 | } 29 | 30 | public function testInterfaceMethods() { 31 | 32 | $olFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\OpenLibrary\OLFilteredHttpResponseParser' ) 33 | ->disableOriginalConstructor() 34 | ->getMock(); 35 | 36 | $instance = new OLResponseParser( $olFilteredHttpResponseParser ); 37 | 38 | $this->assertNull( 39 | $instance->usesCache() 40 | ); 41 | 42 | $this->assertNull( 43 | $instance->getMessages() 44 | ); 45 | 46 | $this->assertNull( 47 | $instance->getFilteredRecord() 48 | ); 49 | 50 | $this->assertNull( 51 | $instance->getRawResponse( 42 ) 52 | ); 53 | } 54 | 55 | /** 56 | * @dataProvider idProvider 57 | */ 58 | public function testDoParseForId( $id, $expects ) { 59 | 60 | $record = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) 61 | ->disableOriginalConstructor() 62 | ->getMock(); 63 | 64 | $olFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\OpenLibrary\OLFilteredHttpResponseParser' ) 65 | ->disableOriginalConstructor() 66 | ->getMock(); 67 | 68 | $olFilteredHttpResponseParser->expects( $this->any() ) 69 | ->method( 'getFilteredRecord' ) 70 | ->will( $this->returnValue( $record ) ); 71 | 72 | $olFilteredHttpResponseParser->expects( $expects ) 73 | ->method( 'doFilterResponseFor' ); 74 | 75 | $instance = new OLResponseParser( $olFilteredHttpResponseParser ); 76 | $instance->doFilterResponseFor( $id ); 77 | } 78 | 79 | public function idProvider() { 80 | 81 | $provider[] = [ 82 | 'abc', 83 | $this->once() 84 | ]; 85 | 86 | $provider[] = [ 87 | 'OL54846467', 88 | $this->once() 89 | ]; 90 | 91 | return $provider; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/FilteredMetadata/OclcResponseParserTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\Onoi\Remi\Oclc\OclcFilteredHttpResponseParser' ) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | 24 | $this->assertInstanceOf( 25 | '\Onoi\Remi\ResponseParser', 26 | new OclcResponseParser( $oclcNumFilteredHttpResponseParser ) 27 | ); 28 | } 29 | 30 | public function testInterfaceMethods() { 31 | 32 | $oclcFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\Oclc\OclcFilteredHttpResponseParser' ) 33 | ->disableOriginalConstructor() 34 | ->getMock(); 35 | 36 | $instance = new OclcResponseParser( $oclcFilteredHttpResponseParser ); 37 | 38 | $this->assertNull( 39 | $instance->usesCache() 40 | ); 41 | 42 | $this->assertNull( 43 | $instance->getMessages() 44 | ); 45 | 46 | $this->assertNull( 47 | $instance->getFilteredRecord() 48 | ); 49 | 50 | $this->assertNull( 51 | $instance->getRawResponse( 42 ) 52 | ); 53 | } 54 | 55 | /** 56 | * @dataProvider idProvider 57 | */ 58 | public function testDoParseForId( $id, $expects ) { 59 | 60 | $record = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) 61 | ->disableOriginalConstructor() 62 | ->getMock(); 63 | 64 | $oclcFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\Oclc\OclcFilteredHttpResponseParser' ) 65 | ->disableOriginalConstructor() 66 | ->getMock(); 67 | 68 | $oclcFilteredHttpResponseParser->expects( $this->any() ) 69 | ->method( 'getFilteredRecord' ) 70 | ->will( $this->returnValue( $record ) ); 71 | 72 | $oclcFilteredHttpResponseParser->expects( $expects ) 73 | ->method( 'doFilterResponseFor' ); 74 | 75 | $instance = new OclcResponseParser( $oclcFilteredHttpResponseParser ); 76 | $instance->doFilterResponseFor( $id ); 77 | } 78 | 79 | public function idProvider() { 80 | 81 | $provider[] = [ 82 | 'abc', 83 | $this->never() 84 | ]; 85 | 86 | $provider[] = [ 87 | 'OCLC54846467', 88 | $this->once() 89 | ]; 90 | 91 | return $provider; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/FilteredMetadata/ViafResponseParserTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\Onoi\Remi\Viaf\ViafFilteredHttpResponseParser' ) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | 24 | $this->assertInstanceOf( 25 | '\Onoi\Remi\ResponseParser', 26 | new ViafResponseParser( $viafFilteredHttpResponseParser ) 27 | ); 28 | } 29 | 30 | public function testInterfaceMethods() { 31 | 32 | $viafFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\Viaf\ViafFilteredHttpResponseParser' ) 33 | ->disableOriginalConstructor() 34 | ->getMock(); 35 | 36 | $instance = new ViafResponseParser( $viafFilteredHttpResponseParser ); 37 | 38 | $this->assertNull( 39 | $instance->usesCache() 40 | ); 41 | 42 | $this->assertNull( 43 | $instance->getMessages() 44 | ); 45 | 46 | $this->assertNull( 47 | $instance->getFilteredRecord() 48 | ); 49 | 50 | $this->assertNull( 51 | $instance->getRawResponse( 42 ) 52 | ); 53 | } 54 | 55 | /** 56 | * @dataProvider idProvider 57 | */ 58 | public function testDoFilterResponseForId( $id, $expects ) { 59 | 60 | $record = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) 61 | ->disableOriginalConstructor() 62 | ->getMock(); 63 | 64 | $viafFilteredHttpResponseParser = $this->getMockBuilder( '\Onoi\Remi\Viaf\ViafFilteredHttpResponseParser' ) 65 | ->disableOriginalConstructor() 66 | ->getMock(); 67 | 68 | $viafFilteredHttpResponseParser->expects( $this->any() ) 69 | ->method( 'getFilteredRecord' ) 70 | ->will( $this->returnValue( $record ) ); 71 | 72 | $viafFilteredHttpResponseParser->expects( $expects ) 73 | ->method( 'doFilterResponseFor' ); 74 | 75 | $instance = new ViafResponseParser( $viafFilteredHttpResponseParser ); 76 | $instance->doFilterResponseFor( $id ); 77 | } 78 | 79 | public function idProvider() { 80 | 81 | $provider[] = [ 82 | 'abc', 83 | $this->never() 84 | ]; 85 | 86 | $provider[] = [ 87 | 'VIAF54846467', 88 | $this->once() 89 | ]; 90 | 91 | return $provider; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/MediaWikiContextInteractorTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\IContextSource' ) 25 | ->disableOriginalConstructor() 26 | ->getMock(); 27 | 28 | $this->assertInstanceOf( 29 | '\SCI\MediaWikiContextInteractor', 30 | new MediaWikiContextInteractor( $context ) 31 | ); 32 | } 33 | 34 | public function testHasAction() { 35 | 36 | $context = $this->getMockBuilder( '\IContextSource' ) 37 | ->disableOriginalConstructor() 38 | ->getMock(); 39 | 40 | $context->expects( $this->any() ) 41 | ->method( 'getActionName' ) 42 | ->willReturn( 'view'); 43 | 44 | $instance = new MediaWikiContextInteractor( $context ); 45 | 46 | $this->assertTrue( 47 | $instance->hasAction( 'view' ) 48 | ); 49 | } 50 | 51 | /** 52 | * @dataProvider oldidDirectionProvider 53 | */ 54 | public function testGetOldId( $direction ) { 55 | 56 | $context = $this->getMockBuilder( '\IContextSource' ) 57 | ->disableOriginalConstructor() 58 | ->getMock(); 59 | 60 | $webRequest = $this->getMockBuilder( '\WebRequest' ) 61 | ->disableOriginalConstructor() 62 | ->getMock(); 63 | 64 | $webRequest->expects( $this->any() ) 65 | ->method( 'getText' ) 66 | ->will( $this->returnValue( $direction ) ); 67 | 68 | $context->expects( $this->any() ) 69 | ->method( 'getRequest' ) 70 | ->will( $this->returnValue( $webRequest ) ); 71 | 72 | $context->expects( $this->any() ) 73 | ->method( 'getTitle' ) 74 | ->will( $this->returnValue( \Title::newFromText( __METHOD__ ) ) ); 75 | 76 | $instance = new MediaWikiContextInteractor( $context ); 77 | 78 | $this->assertInternalType( 79 | 'integer', 80 | $instance->getOldId() 81 | ); 82 | } 83 | 84 | public function oldidDirectionProvider() { 85 | 86 | $provider = []; 87 | 88 | $provider[] = [ 89 | 'next' 90 | ]; 91 | 92 | $provider[] = [ 93 | 'prev' 94 | ]; 95 | 96 | $provider[] = [ 97 | 'cur' 98 | ]; 99 | 100 | return $provider; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/MediaWikiNsContentMapperTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\SMW\MediaWiki\MediaWikiNsContentReader' ) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | 24 | $this->assertInstanceOf( 25 | '\SCI\MediaWikiNsContentMapper', 26 | new MediaWikiNsContentMapper( $mediaWikiNsContentReader ) 27 | ); 28 | } 29 | 30 | /** 31 | * @dataProvider fixedPropertyIdProvider 32 | */ 33 | public function testFindPropertyForId( $id, $expected ) { 34 | 35 | $mediaWikiNsContentReader = $this->getMockBuilder( '\SMW\MediaWiki\MediaWikiNsContentReader' ) 36 | ->disableOriginalConstructor() 37 | ->getMock(); 38 | 39 | $instance = new MediaWikiNsContentMapper( $mediaWikiNsContentReader ); 40 | 41 | $this->assertEquals( 42 | $expected, 43 | $instance->findPropertyForId( $id ) 44 | ); 45 | } 46 | 47 | public function fixedPropertyIdProvider() { 48 | 49 | $provider[] = [ 50 | 'viaf', 51 | SCI_PROP_VIAF 52 | ]; 53 | 54 | $provider[] = [ 55 | 'doi', 56 | SCI_PROP_DOI 57 | ]; 58 | 59 | $provider[] = [ 60 | 'oclc', 61 | SCI_PROP_OCLC 62 | ]; 63 | 64 | $provider[] = [ 65 | 'olid', 66 | SCI_PROP_OLID 67 | ]; 68 | 69 | $provider[] = [ 70 | 'pmcid', 71 | SCI_PROP_PMCID 72 | ]; 73 | 74 | $provider[] = [ 75 | 'pmid', 76 | SCI_PROP_PMID 77 | ]; 78 | 79 | $provider[] = [ 80 | 'reference', 81 | SCI_PROP_CITE_KEY 82 | ]; 83 | 84 | $provider[] = [ 85 | 'citation text', 86 | SCI_PROP_CITE_TEXT 87 | ]; 88 | 89 | $provider[] = [ 90 | 'sortkey', 91 | '_SKEY' 92 | ]; 93 | 94 | return $provider; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/OptionsTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf( 21 | '\SCI\Options', 22 | new Options() 23 | ); 24 | } 25 | 26 | public function testAddOption() { 27 | 28 | $instance = new Options(); 29 | 30 | $this->assertFalse( 31 | $instance->has( 'Foo' ) 32 | ); 33 | 34 | $instance->set( 'Foo', 42 ); 35 | 36 | $this->assertEquals( 37 | 42, 38 | $instance->get( 'Foo' ) 39 | ); 40 | } 41 | 42 | public function testUnregisteredKeyThrowsException() { 43 | 44 | $instance = new Options(); 45 | 46 | $this->expectException( 'InvalidArgumentException' ); 47 | $instance->get( 'Foo' ); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/ParserFunctionFactoryTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\Title' ) 27 | ->disableOriginalConstructor() 28 | ->getMock(); 29 | 30 | $title->expects( $this->any() ) 31 | ->method( 'getNamespace' ) 32 | ->will( $this->returnValue( NS_MAIN ) ); 33 | 34 | $parserOutput = $this->getMockBuilder( '\ParserOutput' ) 35 | ->disableOriginalConstructor() 36 | ->getMock(); 37 | 38 | $this->parser = $this->getMockBuilder( '\Parser' ) 39 | ->disableOriginalConstructor() 40 | ->getMock(); 41 | 42 | $this->parser->expects( $this->any() ) 43 | ->method( 'getTitle' ) 44 | ->will( $this->returnValue( $title ) ); 45 | 46 | $this->parser->expects( $this->any() ) 47 | ->method( 'getOutput' ) 48 | ->will( $this->returnValue( $parserOutput ) ); 49 | } 50 | 51 | public function testCanConstruct() { 52 | 53 | $this->assertInstanceOf( 54 | '\SCI\ParserFunctionFactory', 55 | new ParserFunctionFactory() 56 | ); 57 | } 58 | 59 | public function testNewSciteParserFunctionDefinition() { 60 | 61 | $this->parser->setTitle( Title::newFromText( __METHOD__ ) ); 62 | 63 | $instance = new ParserFunctionFactory(); 64 | 65 | $namespaceExaminer = $this->getMockBuilder( '\SMW\NamespaceExaminer' ) 66 | ->disableOriginalConstructor() 67 | ->getMock(); 68 | 69 | $options = $this->getMockBuilder( '\SCI\Options' ) 70 | ->disableOriginalConstructor() 71 | ->getMock(); 72 | 73 | list( $name, $definition, $flag ) = $instance->newSciteParserFunctionDefinition( 74 | $namespaceExaminer, 75 | $options 76 | ); 77 | 78 | $this->assertEquals( 79 | 'scite', 80 | $name 81 | ); 82 | 83 | $this->assertInstanceOf( 84 | '\Closure', 85 | $definition 86 | ); 87 | 88 | $text = ''; 89 | 90 | $this->assertNotEmpty( 91 | call_user_func_array( $definition, [ $this->parser, $text ] ) 92 | ); 93 | } 94 | 95 | public function textNewReferenceListParserFunctionDefinition() { 96 | 97 | $this->parser->setTitle( Title::newFromText( __METHOD__ ) ); 98 | 99 | $instance = new ParserFunctionFactory(); 100 | 101 | list( $name, $definition, $flag ) = $instance->newReferenceListParserFunctionDefinition(); 102 | 103 | $this->assertEquals( 104 | 'referencelist', 105 | $name 106 | ); 107 | 108 | $this->assertInstanceOf( 109 | '\Closure', 110 | $definition 111 | ); 112 | 113 | $text = ''; 114 | 115 | $this->assertNotEmpty( 116 | call_user_func_array( $definition, [ $this->parser, $text ] ) 117 | ); 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/PreTextFormatterTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf( 29 | '\SCI\PreTextFormatter', 30 | new PreTextFormatter() 31 | ); 32 | } 33 | 34 | /** 35 | * @dataProvider parametersProvider 36 | */ 37 | public function testFormat( $params ) { 38 | 39 | $instance = new PreTextFormatter(); 40 | 41 | $this->assertInternalType( 42 | 'array', 43 | $instance->format( $params ) 44 | ); 45 | } 46 | 47 | /** 48 | * @dataProvider parametersProvider 49 | */ 50 | public function testGetFormattedSciteFuncFrom( $params, $expected ) { 51 | 52 | $instance = new PreTextFormatter(); 53 | 54 | $this->assertSame( 55 | $expected, 56 | $instance->getFormattedSciteFuncFrom( $params ) 57 | ); 58 | } 59 | 60 | public function parametersProvider() { 61 | 62 | $provider[] = [ 63 | [ 64 | 'Bar', 65 | '@Foobar' 66 | ], 67 | "
        {{#scite:" . self::LF . " |Bar" . self::LF . "}}
        " 68 | ]; 69 | 70 | $provider[] = [ 71 | [ 72 | 'Bar', 73 | '+sep=,', 74 | '@Foobar', 75 | 'Foo' 76 | ], 77 | "
        {{#scite:" . self::LF . " |Bar|+sep=," . self::LF . " |Foo" . self::LF . "}}
        " 78 | ]; 79 | 80 | return $provider; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/PropertyRegistryTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf( 22 | '\SCI\PropertyRegistry', 23 | new PropertyRegistry() 24 | ); 25 | } 26 | 27 | /** 28 | * @dataProvider propertyIdProvider 29 | */ 30 | public function testRegisterTo( $id, $label ) { 31 | 32 | $corePropertyRegistry = CorePropertyRegistry::getInstance(); 33 | 34 | $instance = new PropertyRegistry(); 35 | $instance->registerTo( $corePropertyRegistry ); 36 | 37 | $this->assertNotEmpty( 38 | $corePropertyRegistry->findPropertyLabelById ( $id ) 39 | ); 40 | 41 | $this->assertSame( 42 | $label, 43 | $corePropertyRegistry->findPropertyLabelById ( $id ) 44 | ); 45 | } 46 | 47 | public function propertyIdProvider() { 48 | 49 | $provider[] = [ 50 | PropertyRegistry::SCI_DOI, 51 | 'DOI' 52 | ]; 53 | 54 | $provider[] = [ 55 | PropertyRegistry::SCI_PMCID, 56 | 'PMCID' 57 | ]; 58 | 59 | $provider[] = [ 60 | PropertyRegistry::SCI_CITE_KEY, 61 | 'Citation key' 62 | ]; 63 | 64 | $provider[] = [ 65 | PropertyRegistry::SCI_CITE_REFERENCE, 66 | 'Citation reference' 67 | ]; 68 | 69 | $provider[] = [ 70 | PropertyRegistry::SCI_CITE_TEXT, 71 | 'Citation text' 72 | ]; 73 | 74 | $provider[] = [ 75 | PropertyRegistry::SCI_CITE, 76 | 'Citation resource' 77 | ]; 78 | 79 | return $provider; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/ReferenceListFactoryTest.php: -------------------------------------------------------------------------------- 1 | store = $this->getMockBuilder( '\SMW\Store' ) 26 | ->disableOriginalConstructor() 27 | ->getMockForAbstractClass(); 28 | 29 | $this->namespaceExaminer = $this->getMockBuilder( '\SMW\NamespaceExaminer' ) 30 | ->disableOriginalConstructor() 31 | ->getMock(); 32 | 33 | $this->citationReferencePositionJournal = $this->getMockBuilder( '\SCI\CitationReferencePositionJournal' ) 34 | ->disableOriginalConstructor() 35 | ->getMock(); 36 | } 37 | 38 | public function testCanConstruct() { 39 | 40 | $this->assertInstanceOf( 41 | '\SCI\ReferenceListFactory', 42 | new ReferenceListFactory( $this->store, $this->namespaceExaminer, $this->citationReferencePositionJournal ) 43 | ); 44 | } 45 | 46 | public function testCanConstructReferenceListOutputRenderer() { 47 | 48 | $instance = new ReferenceListFactory( 49 | $this->store, 50 | $this->namespaceExaminer, 51 | $this->citationReferencePositionJournal 52 | ); 53 | 54 | $this->assertInstanceOf( 55 | '\SCI\ReferenceListOutputRenderer', 56 | $instance->newReferenceListOutputRenderer() 57 | ); 58 | } 59 | 60 | public function testCanConstructCachedReferenceListOutputRenderer() { 61 | 62 | $mediaWikiContextInteractor = $this->getMockBuilder( '\SCI\MediaWikiContextInteractor' ) 63 | ->disableOriginalConstructor() 64 | ->getMock(); 65 | 66 | $cache = $this->getMockBuilder( '\Onoi\Cache\Cache' ) 67 | ->disableOriginalConstructor() 68 | ->getMock(); 69 | 70 | $cacheKeyProvider = $this->getMockBuilder( '\SCI\CacheKeyProvider' ) 71 | ->disableOriginalConstructor() 72 | ->getMock(); 73 | 74 | $instance = new ReferenceListFactory( 75 | $this->store, 76 | $this->namespaceExaminer, 77 | $this->citationReferencePositionJournal 78 | ); 79 | 80 | $options = new Options( [ 81 | 'numberOfReferenceListColumns' => null, 82 | 'referenceListType' => null, 83 | 'browseLinkToCitationResource' => null, 84 | 'citationReferenceCaptionFormat' => null, 85 | 'responsiveMonoColumnCharacterBoundLength' => 100 86 | ] ); 87 | 88 | $this->assertInstanceOf( 89 | '\SCI\CachedReferenceListOutputRenderer', 90 | $instance->newCachedReferenceListOutputRenderer( $mediaWikiContextInteractor, $cache, $cacheKeyProvider, $options ) 91 | ); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/ReferenceListOutputRendererTest.php: -------------------------------------------------------------------------------- 1 | citationResourceMatchFinder = $this->getMockBuilder( '\SCI\CitationResourceMatchFinder' ) 29 | ->disableOriginalConstructor() 30 | ->getMock(); 31 | 32 | $this->citationReferencePositionJournal = $this->getMockBuilder( '\SCI\CitationReferencePositionJournal' ) 33 | ->disableOriginalConstructor() 34 | ->getMock(); 35 | 36 | $this->htmlColumnListRenderer = $this->getMockBuilder( '\SMW\MediaWiki\Renderer\HtmlColumnListRenderer' ) 37 | ->disableOriginalConstructor() 38 | ->getMock(); 39 | } 40 | 41 | public function testCanConstruct() { 42 | 43 | $this->assertInstanceOf( 44 | '\SCI\ReferenceListOutputRenderer', 45 | new ReferenceListOutputRenderer( 46 | $this->citationResourceMatchFinder, 47 | $this->citationReferencePositionJournal, 48 | $this->htmlColumnListRenderer 49 | ) 50 | ); 51 | } 52 | 53 | public function testSetterGetterForExternalUse() { 54 | 55 | $instance = new ReferenceListOutputRenderer( 56 | $this->citationResourceMatchFinder, 57 | $this->citationReferencePositionJournal, 58 | $this->htmlColumnListRenderer 59 | ); 60 | 61 | $instance->setNumberOfReferenceListColumns( 4 ); 62 | 63 | $this->assertEquals( 64 | 4, 65 | $instance->getNumberOfReferenceListColumns() 66 | ); 67 | 68 | $instance->setReferenceListType( 'ol' ); 69 | 70 | $this->assertEquals( 71 | 'ol', 72 | $instance->getReferenceListType() 73 | ); 74 | 75 | $instance->setBrowseLinkToCitationResourceVisibility( true ); 76 | 77 | $this->assertEquals( 78 | true, 79 | $instance->getBrowseLinkToCitationResourceVisibility() 80 | ); 81 | } 82 | 83 | public function testRenderReferenceListForIncompleteJournal() { 84 | 85 | $this->citationReferencePositionJournal->expects( $this->once() ) 86 | ->method( 'getJournalBySubject' ) 87 | ->will( $this->returnValue( [ 88 | 'reference-pos' => [ 'abc' => [] ], 89 | 'reference-list' => [ 'abc' => 123 ] ] ) ); 90 | 91 | $this->citationResourceMatchFinder->expects( $this->once() ) 92 | ->method( 'findCitationTextFor' ) 93 | ->will( $this->returnValue( [ [], '' ] ) ); 94 | 95 | $instance = new ReferenceListOutputRenderer( 96 | $this->citationResourceMatchFinder, 97 | $this->citationReferencePositionJournal, 98 | $this->htmlColumnListRenderer 99 | ); 100 | 101 | $instance->setNumberOfReferenceListColumns( 0 ); 102 | $instance->setResponsiveMonoColumnCharacterBoundLength( 100 ); 103 | $instance->setBrowseLinkToCitationResourceVisibility( true ); 104 | 105 | $this->assertInternalType( 106 | 'string', 107 | $instance->doRenderReferenceListFor( DIWikiPage::newFromText( 'Foo' ) ) 108 | ); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /tests/phpunit/Unit/Specials/CitableMetadata/HtmlResponseParserRendererTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder( '\Onoi\Remi\ResponseParser' ) 21 | ->disableOriginalConstructor() 22 | ->getMockForAbstractClass(); 23 | 24 | $this->assertInstanceOf( 25 | '\SCI\Specials\CitableMetadata\HtmlResponseParserRenderer', 26 | new HtmlResponseParserRenderer( $responseParser ) 27 | ); 28 | } 29 | 30 | public function testGetRawResponse() { 31 | 32 | $responseParser = $this->getMockBuilder( '\Onoi\Remi\ResponseParser' ) 33 | ->disableOriginalConstructor() 34 | ->getMockForAbstractClass(); 35 | 36 | $responseParser->expects( $this->once() ) 37 | ->method( 'getRawResponse' ) 38 | ->with( $this->identicalTo( 42 ) ); 39 | 40 | $instance = new HtmlResponseParserRenderer( 41 | $responseParser 42 | ); 43 | 44 | $instance->getRawResponse( 42 ); 45 | } 46 | 47 | public function testRenderText() { 48 | 49 | $bibliographicFilteredRecord = $this->getMockBuilder( '\SCI\FilteredMetadata\BibliographicFilteredRecord' ) 50 | ->disableOriginalConstructor() 51 | ->getMock(); 52 | 53 | $responseParser = $this->getMockBuilder( '\Onoi\Remi\ResponseParser' ) 54 | ->disableOriginalConstructor() 55 | ->getMockForAbstractClass(); 56 | 57 | $responseParser->expects( $this->once() ) 58 | ->method( 'doFilterResponseFor' ) 59 | ->with( $this->identicalTo( 42 ) ); 60 | 61 | $responseParser->expects( $this->atLeastOnce() ) 62 | ->method( 'getMessages' ) 63 | ->will( $this->returnValue( [] ) ); 64 | 65 | $responseParser->expects( $this->atLeastOnce() ) 66 | ->method( 'getFilteredRecord' ) 67 | ->will( $this->returnValue( $bibliographicFilteredRecord ) ); 68 | 69 | $instance = new HtmlResponseParserRenderer( 70 | $responseParser 71 | ); 72 | 73 | $instance->renderTextFor( 42 ); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /tests/travis/install-mediawiki.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | cd .. 5 | 6 | ## Use sha (master@5cc1f1d) to download a particular commit to avoid breakages 7 | ## introduced by MediaWiki core 8 | if [[ "$MW" == *@* ]] 9 | then 10 | arrMw=(${MW//@/ }) 11 | MW=${arrMw[0]} 12 | SOURCE=${arrMw[1]} 13 | else 14 | MW=$MW 15 | SOURCE=$MW 16 | fi 17 | 18 | wget https://github.com/wikimedia/mediawiki/archive/$SOURCE.tar.gz -O $MW.tar.gz 19 | 20 | tar -zxf $MW.tar.gz 21 | mv mediawiki-* mw 22 | 23 | cd mw 24 | 25 | composer self-update 26 | composer install 27 | 28 | if [ "$DB" == "postgres" ] 29 | then 30 | # See #458 31 | sudo /etc/init.d/postgresql stop 32 | sudo /etc/init.d/postgresql start 33 | 34 | psql -c 'create database its_a_mw;' -U postgres 35 | php maintenance/install.php --dbtype $DB --dbuser postgres --dbname its_a_mw --pass AdminPassword TravisWiki admin --scriptpath /TravisWiki 36 | else 37 | mysql -e 'create database its_a_mw;' 38 | php maintenance/install.php --dbtype $DB --dbuser root --dbname its_a_mw --dbpath $(pwd) --pass AdminPassword TravisWiki admin --scriptpath /TravisWiki 39 | fi 40 | -------------------------------------------------------------------------------- /tests/travis/install-semantic-cite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | BASE_PATH=$(pwd) 5 | MW_INSTALL_PATH=$BASE_PATH/../mw 6 | 7 | # Run Composer installation from the MW root directory 8 | function installToMediaWikiRoot { 9 | echo -e "Running MW root composer install build on $TRAVIS_BRANCH \n" 10 | 11 | cd $MW_INSTALL_PATH 12 | 13 | if [ "$PHPUNIT" != "" ] 14 | then 15 | composer require 'phpunit/phpunit='$PHPUNIT --update-with-dependencies 16 | else 17 | composer require 'phpunit/phpunit=6.5.*' --update-with-dependencies 18 | fi 19 | 20 | if [ "$SCI" != "" ] 21 | then 22 | composer require 'mediawiki/semantic-scite='$SCI --update-with-dependencies 23 | else 24 | composer init --stability dev 25 | composer require mediawiki/semantic-cite "dev-master" --dev 26 | 27 | cd extensions 28 | cd SemanticCite 29 | 30 | if [ "$TRAVIS_PULL_REQUEST" != "false" ] 31 | then 32 | git fetch origin +refs/pull/"$TRAVIS_PULL_REQUEST"/merge: 33 | git checkout -qf FETCH_HEAD 34 | else 35 | git fetch origin "$TRAVIS_BRANCH" 36 | git checkout -qf FETCH_HEAD 37 | fi 38 | 39 | cd ../.. 40 | fi 41 | 42 | # Rebuild the class map for added classes during git fetch 43 | composer dump-autoload 44 | } 45 | 46 | function updateConfiguration { 47 | 48 | cd $MW_INSTALL_PATH 49 | 50 | echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php 51 | echo 'ini_set("display_errors", 1);' >> LocalSettings.php 52 | echo '$wgShowExceptionDetails = true;' >> LocalSettings.php 53 | echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php 54 | echo "putenv( 'MW_INSTALL_PATH=$(pwd)' );" >> LocalSettings.php 55 | 56 | echo 'define("SMW_PHPUNIT_PULL_VERSION_FROM_GITHUB", true);' >> LocalSettings.php 57 | 58 | # SMW#1732 59 | echo 'wfLoadExtension( "SemanticMediaWiki" );' >> LocalSettings.php 60 | echo 'wfLoadExtension( "SemanticCite" );' >> LocalSettings.php 61 | 62 | php maintenance/update.php --quick 63 | } 64 | 65 | installToMediaWikiRoot 66 | updateConfiguration 67 | -------------------------------------------------------------------------------- /tests/travis/run-tests.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -ex 3 | 4 | BASE_PATH=$(pwd) 5 | MW_INSTALL_PATH=$BASE_PATH/../mw 6 | 7 | cd $MW_INSTALL_PATH/extensions/SemanticCite 8 | 9 | if [ "$TYPE" == "coverage" ] 10 | then 11 | composer phpunit -- --coverage-clover $BASE_PATH/build/coverage.clover 12 | else 13 | composer phpunit 14 | fi 15 | -------------------------------------------------------------------------------- /tests/travis/upload-coverage-report.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -ex 3 | 4 | BASE_PATH=$(pwd) 5 | 6 | if [ "$TYPE" == "coverage" ] 7 | then 8 | wget https://scrutinizer-ci.com/ocular.phar 9 | php ocular.phar code-coverage:upload --format=php-clover $BASE_PATH/build/coverage.clover 10 | fi --------------------------------------------------------------------------------