diff --git a/composer.json b/composer.json index 7fbc7b2658f64b25a328d4d0d520a21b55dee67a..c9e0a7a9c2d73659ccaf266c4a044d37dcb8c840 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "doctrine/annotations": "1.2.*", "guzzlehttp/guzzle": "~5.0", "symfony-cmf/routing": "1.3.*", - "easyrdf/easyrdf": "0.8.*", + "easyrdf/easyrdf": "0.9.*", "phpunit/phpunit": "4.1.*", "phpunit/phpunit-mock-objects": "dev-master#e60bb929c50ae4237aaf680a4f6773f4ee17f0a2", "zendframework/zend-feed": "2.2.*", diff --git a/composer.lock b/composer.lock index 635968be5694617be6a2c0b0504d89e75565133d..193d7e184b5ab61e6ed01510a77f8d0859c20a4c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "57cb0f99786ec791d5e89578b7ed4602", + "hash": "9f93d739d3134a5fb76d650043b3ba89", "packages": [ { "name": "doctrine/annotations", @@ -460,31 +460,30 @@ }, { "name": "easyrdf/easyrdf", - "version": "0.8.0", + "version": "0.9.0", "source": { "type": "git", "url": "https://github.com/njh/easyrdf.git", - "reference": "3e43ab7274004e9f4192e06b9fc147781e1f85c2" + "reference": "bb9fd99768d23af0c5b7b55cec5baddc201272b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/njh/easyrdf/zipball/3e43ab7274004e9f4192e06b9fc147781e1f85c2", - "reference": "3e43ab7274004e9f4192e06b9fc147781e1f85c2", + "url": "https://api.github.com/repos/njh/easyrdf/zipball/bb9fd99768d23af0c5b7b55cec5baddc201272b8", + "reference": "bb9fd99768d23af0c5b7b55cec5baddc201272b8", "shasum": "" }, "require": { + "ext-mbstring": "*", + "ext-pcre": "*", "php": ">=5.2.8" }, - "replace": { - "njh/easyrdf": "self.version" - }, "require-dev": { - "phpunit/phpunit": ">=3.5.15", - "sami/sami": "dev-master", - "squizlabs/php_codesniffer": ">=1.4.3" + "phpunit/phpunit": "~3.5", + "sami/sami": "~1.4", + "squizlabs/php_codesniffer": "~1.4.3" }, "suggest": { - "ml/json-ld": "dev-master" + "ml/json-ld": "~1.0" }, "type": "library", "autoload": { @@ -502,6 +501,11 @@ "email": "njh@aelius.com", "homepage": "http://www.aelius.com/njh/", "role": "Developer" + }, + { + "name": "Alexey Zakhlestin", + "email": "indeyets@gmail.com", + "role": "Developer" } ], "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", @@ -514,7 +518,7 @@ "rdfa", "sparql" ], - "time": "2013-12-30 22:31:37" + "time": "2014-11-07 18:02:16" }, { "name": "egulias/email-validator", @@ -2575,6 +2579,7 @@ "phpunit/phpunit-mock-objects": 20 }, "prefer-stable": false, + "prefer-lowest": false, "platform": { "php": ">=5.4.5" }, diff --git a/core/vendor/composer/ClassLoader.php b/core/vendor/composer/ClassLoader.php index 4a56396af559e9917b4239e6c02f469a852a7a6c..70d78bc3f4e37433765c793659ceba058e1e14f8 100644 --- a/core/vendor/composer/ClassLoader.php +++ b/core/vendor/composer/ClassLoader.php @@ -59,6 +59,7 @@ public function getPrefixes() if (!empty($this->prefixesPsr0)) { return call_user_func_array('array_merge', $this->prefixesPsr0); } + return array(); } diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 85cb45e9e28e6cec983796bb098cb423b9686033..e3366f47622874d7d01e3d6444b9f1e4477b85ad 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -409,66 +409,6 @@ "spl" ] }, - { - "name": "easyrdf/easyrdf", - "version": "0.8.0", - "version_normalized": "0.8.0.0", - "source": { - "type": "git", - "url": "https://github.com/njh/easyrdf.git", - "reference": "3e43ab7274004e9f4192e06b9fc147781e1f85c2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/njh/easyrdf/zipball/3e43ab7274004e9f4192e06b9fc147781e1f85c2", - "reference": "3e43ab7274004e9f4192e06b9fc147781e1f85c2", - "shasum": "" - }, - "require": { - "php": ">=5.2.8" - }, - "replace": { - "njh/easyrdf": "self.version" - }, - "require-dev": { - "phpunit/phpunit": ">=3.5.15", - "sami/sami": "dev-master", - "squizlabs/php_codesniffer": ">=1.4.3" - }, - "suggest": { - "ml/json-ld": "dev-master" - }, - "time": "2013-12-30 22:31:37", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "EasyRdf_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nicholas Humfrey", - "email": "njh@aelius.com", - "homepage": "http://www.aelius.com/njh/", - "role": "Developer" - } - ], - "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", - "homepage": "http://www.easyrdf.org/", - "keywords": [ - "Linked Data", - "RDF", - "Semantic Web", - "Turtle", - "rdfa", - "sparql" - ] - }, { "name": "react/promise", "version": "v2.1.0", @@ -2652,5 +2592,69 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com" + }, + { + "name": "easyrdf/easyrdf", + "version": "0.9.0", + "version_normalized": "0.9.0.0", + "source": { + "type": "git", + "url": "https://github.com/njh/easyrdf.git", + "reference": "bb9fd99768d23af0c5b7b55cec5baddc201272b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/njh/easyrdf/zipball/bb9fd99768d23af0c5b7b55cec5baddc201272b8", + "reference": "bb9fd99768d23af0c5b7b55cec5baddc201272b8", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-pcre": "*", + "php": ">=5.2.8" + }, + "require-dev": { + "phpunit/phpunit": "~3.5", + "sami/sami": "~1.4", + "squizlabs/php_codesniffer": "~1.4.3" + }, + "suggest": { + "ml/json-ld": "~1.0" + }, + "time": "2014-11-07 18:02:16", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "EasyRdf_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nicholas Humfrey", + "email": "njh@aelius.com", + "homepage": "http://www.aelius.com/njh/", + "role": "Developer" + }, + { + "name": "Alexey Zakhlestin", + "email": "indeyets@gmail.com", + "role": "Developer" + } + ], + "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", + "homepage": "http://www.easyrdf.org/", + "keywords": [ + "Linked Data", + "RDF", + "Semantic Web", + "Turtle", + "rdfa", + "sparql" + ] } ] diff --git a/core/vendor/easyrdf/easyrdf/CHANGELOG.md b/core/vendor/easyrdf/easyrdf/CHANGELOG.md index f902b3c9e13e23dad770058a44a9e5fdf497cb04..6ac65fb11846ae0948917747d56ca59c72c16d19 100644 --- a/core/vendor/easyrdf/easyrdf/CHANGELOG.md +++ b/core/vendor/easyrdf/easyrdf/CHANGELOG.md @@ -1,3 +1,61 @@ +EasyRdf 0.9.0 +============= + +* code-style fix + +EasyRdf 0.9.0-rc.4 +================== + +* fixed compatibility with php < 5.4.8 (see issue #212) +* tweaked unit-tests + +EasyRdf 0.9.0-rc.3 +================== + +* fixed documentation generation + +EasyRdf 0.9.0-rc.2 +================== + +* tweaked unit-tests + +EasyRdf 0.9.0-rc.1 +================== + +Major new features +------------------ +* Framing support in `EasyRdf_Serialiser_JsonLd` +* JSON-LD Parser + +API changes +----------- +* `EasyRdf_Literal_Decimal` returns strings, instead of floats to avoid losing precision (see issue #178) +* `EasyRdf_Literal_Decimal` requires input-strings which conform to `xs:decimal` format +* `EasyRdf_GraphStore` supports operations over default graph now +* `EasyRdf_Literal` typed as `xs:double` is used for PHP-floats instead of `EasyRdf_Literal_Decimal` +* Exceptions thrown from `EasyRdf_Graph::resource()` use different message-texts now (see issue #159) + +Enhancements +------------ +* Synced list of default namespaces against [RDFa Core Initial Context](http://www.w3.org/2011/rdfa-context/rdfa-1.1) rev.2014-01-17 +* Added support for empty prefixes (see issue #183) +* `EasyRdf_Graph::newAndLoad` throws `EasyRdf_Http_Exception` in case of failure, which gives access to status and response-body. (see issue #149) +* `EasyRdf_Graph` and `EasyRdf_Resource` have 'typesAsResources()' methods now + +Bug Fixes +--------- +* Fix for Turtle serialisation of FALSE (see issue #179) +* Fix for edge-case in RDF/XML serialisation (see issue #186) +* SPARQL-queries against endpoints which have query-params in their URL (see issue #184) +* Float values are properly handled if locale with "other" separator is active +* Fixed parsing of Turtle-documents with higher utf-8 characters (see issue #195) +* Namespace-prefixes are compliant with RDFXML QName spec (see issue #185) +* `EasyRdf_Namespace` won't generate "short" names with "/" in them anymore (see issue #115) +* `EasyRdf_Parser_RdfXml` respects "base" specified for the document (see issue #157) +* HTML documents are correctly detected now, not as "n-triples" (see issue #206) +* Accept-headers are formatted in locale-independent fashion now (see issue #208) + + EasyRdf 0.8.0 ============= diff --git a/core/vendor/easyrdf/easyrdf/DEVELOPER.md b/core/vendor/easyrdf/easyrdf/DEVELOPER.md index a4516ef577db9a94284163743ba2636523562176..f9c6dac4dc4f96e102a1d4416963e0d3f0e39430 100644 --- a/core/vendor/easyrdf/easyrdf/DEVELOPER.md +++ b/core/vendor/easyrdf/easyrdf/DEVELOPER.md @@ -1,32 +1,31 @@ Contributing to EasyRdf ======================= - Contributions to the EasyRdf codebase are welcome using the usual Github pull request workflow. To run the code style checker: + ``` make cs - ``` + You can run the PHP unit test suite with: + ``` -make test +make test-lib ``` Unit tests are automatically run after being received by Github: http://ci.aelius.com/job/easyrdf/ -The tests for the examples are run in a sperate test: +The tests for the examples are run separately: http://ci.aelius.com/job/easyrdf-examples/ Notes ----- -* Please ask on the [mailing list] before starting work on any significant chnages +* Please ask on the [mailing list] before starting work on any significant changes * Please write tests for any new features or bug fixes. The tests should be checked in the same commit as the code. - - [mailing list]:http://groups.google.com/group/easyrdf diff --git a/core/vendor/easyrdf/easyrdf/LICENSE.md b/core/vendor/easyrdf/easyrdf/LICENSE.md index 274a8e6a3265731d983a9eaeb9c04b1c26182a7b..c5e2f5db412bc3785089006783c48e7d05818e83 100644 --- a/core/vendor/easyrdf/easyrdf/LICENSE.md +++ b/core/vendor/easyrdf/easyrdf/LICENSE.md @@ -21,3 +21,400 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +OTHER LICENSES +============== + +Parts of this program or documentation is available under different +licensing terms. These are as following. + +The appendix in the documentation about RDF formats (APPENDIX A) is a +derivative work under CC-BY-SA-3.0. It consists of two documents: + +1. The RDF/PHP Specification was written/edited 2008 by Ian Davis and Keith + Alexander +2. The RDF/JSON Specification was written/edited 2007, 2008 by Keith + Alexander, Danny Ayers, Sam Tunnicliffe, Fellahst, Ian Davis and Robman + +These two documents have been translated 2014 into markdown by hakre. + + +Creative Commons Attribution-ShareAlike 3.0 Unported +==================================================== + +CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE +LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN +ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION +ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE +INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM +ITS USE. + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE +COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY +COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS +AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY +BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS +CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND +CONDITIONS. + +1. Definitions + +a. "Adaptation" means a work based upon the Work, or upon the Work and +other pre-existing works, such as a translation, adaptation, derivative +work, arrangement of music or other alterations of a literary or +artistic work, or phonogram or performance and includes cinematographic +adaptations or any other form in which the Work may be recast, +transformed, or adapted including in any form recognizably derived from +the original, except that a work that constitutes a Collection will not +be considered an Adaptation for the purpose of this License. For the +avoidance of doubt, where the Work is a musical work, performance or +phonogram, the synchronization of the Work in timed-relation with a +moving image ("synching") will be considered an Adaptation for the +purpose of this License. + +b. "Collection" means a collection of literary or artistic works, such +as encyclopedias and anthologies, or performances, phonograms or +broadcasts, or other works or subject matter other than works listed in +Section 1(f) below, which, by reason of the selection and arrangement of +their contents, constitute intellectual creations, in which the Work is +included in its entirety in unmodified form along with one or more other +contributions, each constituting separate and independent works in +themselves, which together are assembled into a collective whole. A work +that constitutes a Collection will not be considered an Adaptation (as +defined below) for the purposes of this License. + +c. "Creative Commons Compatible License" means a license that is listed +at http://creativecommons.org/compatiblelicenses that has been approved +by Creative Commons as being essentially equivalent to this License, +including, at a minimum, because that license: (i) contains terms that +have the same purpose, meaning and effect as the License Elements of +this License; and, (ii) explicitly permits the relicensing of +adaptations of works made available under that license under this +License or a Creative Commons jurisdiction license with the same License +Elements as this License. + +d. "Distribute" means to make available to the public the original and +copies of the Work or Adaptation, as appropriate, through sale or other +transfer of ownership. + +e. "License Elements" means the following high-level license attributes +as selected by Licensor and indicated in the title of this License: +Attribution, ShareAlike. + +f. "Licensor" means the individual, individuals, entity or entities that +offer(s) the Work under the terms of this License. + +g. "Original Author" means, in the case of a literary or artistic work, +the individual, individuals, entity or entities who created the Work or +if no individual or entity can be identified, the publisher; and in +addition (i) in the case of a performance the actors, singers, +musicians, dancers, and other persons who act, sing, deliver, declaim, +play in, interpret or otherwise perform literary or artistic works or +expressions of folklore; (ii) in the case of a phonogram the producer +being the person or legal entity who first fixes the sounds of a +performance or other sounds; and, (iii) in the case of broadcasts, the +organization that transmits the broadcast. + +h. "Work" means the literary and/or artistic work offered under the +terms of this License including without limitation any production in the +literary, scientific and artistic domain, whatever may be the mode or +form of its expression including digital form, such as a book, pamphlet +and other writing; a lecture, address, sermon or other work of the same +nature; a dramatic or dramatico-musical work; a choreographic work or +entertainment in dumb show; a musical composition with or without words; +a cinematographic work to which are assimilated works expressed by a +process analogous to cinematography; a work of drawing, painting, +architecture, sculpture, engraving or lithography; a photographic work +to which are assimilated works expressed by a process analogous to +photography; a work of applied art; an illustration, map, plan, sketch +or three-dimensional work relative to geography, topography, +architecture or science; a performance; a broadcast; a phonogram; a +compilation of data to the extent it is protected as a copyrightable +work; or a work performed by a variety or circus performer to the extent +it is not otherwise considered a literary or artistic work. + +i. "You" means an individual or entity exercising rights under this +License who has not previously violated the terms of this License with +respect to the Work, or who has received express permission from the +Licensor to exercise rights under this License despite a previous +violation. + +j. "Publicly Perform" means to perform public recitations of the Work +and to communicate to the public those public recitations, by any means +or process, including by wire or wireless means or public digital +performances; to make available to the public Works in such a way that +members of the public may access these Works from a place and at a place +individually chosen by them; to perform the Work to the public by any +means or process and the communication to the public of the performances +of the Work, including by public digital performance; to broadcast and +rebroadcast the Work by any means including signs, sounds or images. + +k. "Reproduce" means to make copies of the Work by any means including +without limitation by sound or visual recordings and the right of +fixation and reproducing fixations of the Work, including storage of a +protected performance or phonogram in digital form or other electronic +medium. + +2. Fair Dealing Rights. Nothing in this License is intended to reduce, +limit, or restrict any uses free from copyright or rights arising from +limitations or exceptions that are provided for in connection with the +copyright protection under copyright law or other applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, +Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license to +exercise the rights in the Work as stated below: + +a. to Reproduce the Work, to incorporate the Work into one or more +Collections, and to Reproduce the Work as incorporated in the +Collections; + +b. to create and Reproduce Adaptations provided that any such +Adaptation, including any translation in any medium, takes reasonable +steps to clearly label, demarcate or otherwise identify that changes +were made to the original Work. For example, a translation could be +marked "The original work was translated from English to Spanish," or a +modification could indicate "The original work has been modified."; + +c. to Distribute and Publicly Perform the Work including as incorporated +in Collections; and, + +d. to Distribute and Publicly Perform Adaptations. + +e. For the avoidance of doubt: + +i. Non-waivable Compulsory License Schemes. In those jurisdictions in +which the right to collect royalties through any statutory or compulsory +licensing scheme cannot be waived, the Licensor reserves the exclusive +right to collect such royalties for any exercise by You of the rights +granted under this License; + +ii. Waivable Compulsory License Schemes. In those jurisdictions in which +the right to collect royalties through any statutory or compulsory +licensing scheme can be waived, the Licensor waives the exclusive right +to collect such royalties for any exercise by You of the rights granted +under this License; and, + +iii. Voluntary License Schemes. The Licensor waives the right to collect +royalties, whether individually or, in the event that the Licensor is a +member of a collecting society that administers voluntary licensing +schemes, via that society, from any exercise by You of the rights +granted under this License. + +The above rights may be exercised in all media and formats whether now +known or hereafter devised. The above rights include the right to make +such modifications as are technically necessary to exercise the rights +in other media and formats. Subject to Section 8(f), all rights not +expressly granted by Licensor are hereby reserved. + +4. Restrictions. The license granted in Section 3 above is expressly +made subject to and limited by the following restrictions: + +a. You may Distribute or Publicly Perform the Work only under the terms +of this License. You must include a copy of, or the Uniform Resource +Identifier (URI) for, this License with every copy of the Work You +Distribute or Publicly Perform. You may not offer or impose any terms on +the Work that restrict the terms of this License or the ability of the +recipient of the Work to exercise the rights granted to that recipient +under the terms of the License. You may not sublicense the Work. You +must keep intact all notices that refer to this License and to the +disclaimer of warranties with every copy of the Work You Distribute or +Publicly Perform. When You Distribute or Publicly Perform the Work, You +may not impose any effective technological measures on the Work that +restrict the ability of a recipient of the Work from You to exercise the +rights granted to that recipient under the terms of the License. This +Section 4(a) applies to the Work as incorporated in a Collection, but +this does not require the Collection apart from the Work itself to be +made subject to the terms of this License. If You create a Collection, +upon notice from any Licensor You must, to the extent practicable, +remove from the Collection any credit as required by Section 4(c), as +requested. If You create an Adaptation, upon notice from any Licensor +You must, to the extent practicable, remove from the Adaptation any +credit as required by Section 4(c), as requested. + +b. You may Distribute or Publicly Perform an Adaptation only under the +terms of: (i) this License; (ii) a later version of this License with +the same License Elements as this License; (iii) a Creative Commons +jurisdiction license (either this or a later license version) that +contains the same License Elements as this License (e.g., +Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible +License. If you license the Adaptation under one of the licenses +mentioned in (iv), you must comply with the terms of that license. If +you license the Adaptation under the terms of any of the licenses +mentioned in (i), (ii) or (iii) (the "Applicable License"), you must +comply with the terms of the Applicable License generally and the +following provisions: (I) You must include a copy of, or the URI for, +the Applicable License with every copy of each Adaptation You Distribute +or Publicly Perform; (II) You may not offer or impose any terms on the +Adaptation that restrict the terms of the Applicable License or the +ability of the recipient of the Adaptation to exercise the rights +granted to that recipient under the terms of the Applicable License; +(III) You must keep intact all notices that refer to the Applicable +License and to the disclaimer of warranties with every copy of the Work +as included in the Adaptation You Distribute or Publicly Perform; (IV) +when You Distribute or Publicly Perform the Adaptation, You may not +impose any effective technological measures on the Adaptation that +restrict the ability of a recipient of the Adaptation from You to +exercise the rights granted to that recipient under the terms of the +Applicable License. This Section 4(b) applies to the Adaptation as +incorporated in a Collection, but this does not require the Collection +apart from the Adaptation itself to be made subject to the terms of the +Applicable License. + +c. If You Distribute, or Publicly Perform the Work or any Adaptations or +Collections, You must, unless a request has been made pursuant to +Section 4(a), keep intact all copyright notices for the Work and +provide, reasonable to the medium or means You are utilizing: (i) the +name of the Original Author (or pseudonym, if applicable) if supplied, +and/or if the Original Author and/or Licensor designate another party or +parties (e.g., a sponsor institute, publishing entity, journal) for +attribution ("Attribution Parties") in Licensor's copyright notice, +terms of service or by other reasonable means, the name of such party or +parties; (ii) the title of the Work if supplied; (iii) to the extent +reasonably practicable, the URI, if any, that Licensor specifies to be +associated with the Work, unless such URI does not refer to the +copyright notice or licensing information for the Work; and (iv) , +consistent with Ssection 3(b), in the case of an Adaptation, a credit +identifying the use of the Work in the Adaptation (e.g., "French +translation of the Work by Original Author," or "Screenplay based on +original Work by Original Author"). The credit required by this Section +4(c) may be implemented in any reasonable manner; provided, however, +that in the case of a Adaptation or Collection, at a minimum such credit +will appear, if a credit for all contributing authors of the Adaptation +or Collection appears, then as part of these credits and in a manner at +least as prominent as the credits for the other contributing authors. +For the avoidance of doubt, You may only use the credit required by this +Section for the purpose of attribution in the manner set out above and, +by exercising Your rights under this License, You may not implicitly or +explicitly assert or imply any connection with, sponsorship or +endorsement by the Original Author, Licensor and/or Attribution Parties, +as appropriate, of You or Your use of the Work, without the separate, +express prior written permission of the Original Author, Licensor and/or +Attribution Parties. + +d. Except as otherwise agreed in writing by the Licensor or as may be +otherwise permitted by applicable law, if You Reproduce, Distribute or +Publicly Perform the Work either by itself or as part of any Adaptations +or Collections, You must not distort, mutilate, modify or take other +derogatory action in relation to the Work which would be prejudicial to +the Original Author's honor or reputation. Licensor agrees that in those +jurisdictions (e.g. Japan), in which any exercise of the right granted +in Section 3(b) of this License (the right to make Adaptations) would be +deemed to be a distortion, mutilation, modification or other derogatory +action prejudicial to the Original Author's honor and reputation, the +Licensor will waive or not assert, as appropriate, this Section, to the +fullest extent permitted by the applicable national law, to enable You +to reasonably exercise Your right under Section 3(b) of this License +(right to make Adaptations) but not otherwise. + +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY +KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, +INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE +LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR +ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES +ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + +a. This License and the rights granted hereunder will terminate +automatically upon any breach by You of the terms of this License. +Individuals or entities who have received Adaptations or Collections +from You under this License, however, will not have their licenses +terminated provided such individuals or entities remain in full +compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will +survive any termination of this License. + +b. Subject to the above terms and conditions, the license granted here +is perpetual (for the duration of the applicable copyright in the Work). +Notwithstanding the above, Licensor reserves the right to release the +Work under different license terms or to stop distributing the Work at +any time; provided, however that any such election will not serve to +withdraw this License (or any other license that has been, or is +required to be, granted under the terms of this License), and this +License will continue in full force and effect unless terminated as +stated above. + +8. Miscellaneous + +a. Each time You Distribute or Publicly Perform the Work or a +Collection, the Licensor offers to the recipient a license to the Work +on the same terms and conditions as the license granted to You under +this License. + +b. Each time You Distribute or Publicly Perform an Adaptation, Licensor +offers to the recipient a license to the original Work on the same terms +and conditions as the license granted to You under this License. + +c. If any provision of this License is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this License, and without further action +by the parties to this agreement, such provision shall be reformed to +the minimum extent necessary to make such provision valid and +enforceable. + +d. No term or provision of this License shall be deemed waived and no +breach consented to unless such waiver or consent shall be in writing +and signed by the party to be charged with such waiver or consent. + +e. This License constitutes the entire agreement between the parties +with respect to the Work licensed here. There are no understandings, +agreements or representations with respect to the Work not specified +here. Licensor shall not be bound by any additional provisions that may +appear in any communication from You. This License may not be modified +without the mutual written agreement of the Licensor and You. + +f. The rights granted under, and the subject matter referenced, in this +License were drafted utilizing the terminology of the Berne Convention +for the Protection of Literary and Artistic Works (as amended on +September 28, 1979), the Rome Convention of 1961, the WIPO Copyright +Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and +the Universal Copyright Convention (as revised on July 24, 1971). These +rights and subject matter take effect in the relevant jurisdiction in +which the License terms are sought to be enforced according to the +corresponding provisions of the implementation of those treaty +provisions in the applicable national law. If the standard suite of +rights granted under applicable copyright law includes additional rights +not granted under this License, such additional rights are deemed to be +included in the License; this License is not intended to restrict the +license of any rights under applicable law. + + + +Creative Commons Notice + +Creative Commons is not a party to this License, and makes no warranty +whatsoever in connection with the Work. Creative Commons will not be +liable to You or any party on any legal theory for any damages +whatsoever, including without limitation any general, special, +incidental or consequential damages arising in connection to this +license. Notwithstanding the foregoing two (2) sentences, if Creative +Commons has expressly identified itself as the Licensor hereunder, it +shall have all rights and obligations of Licensor. + +Except for the limited purpose of indicating to the public that the Work +is licensed under the CCPL, Creative Commons does not authorize the use +by either party of the trademark "Creative Commons" or any related +trademark or logo of Creative Commons without the prior written consent +of Creative Commons. Any permitted use will be in compliance with +Creative Commons' then-current trademark usage guidelines, as may be +published on its website or otherwise made available upon request from +time to time. For the avoidance of doubt, this trademark restriction +does not form part of the License. + +Creative Commons may be contacted at http://creativecommons.org/. diff --git a/core/vendor/easyrdf/easyrdf/composer.json b/core/vendor/easyrdf/easyrdf/composer.json index 15be804810767e9d3038e11da84f5d18e849434b..030e087a96b0fb847a3b94bc6d0e1340ac45acb7 100644 --- a/core/vendor/easyrdf/easyrdf/composer.json +++ b/core/vendor/easyrdf/easyrdf/composer.json @@ -1,7 +1,7 @@ { "name": "easyrdf/easyrdf", "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", - "version": "0.8.0", + "version": "0.9.0", "type": "library", "keywords": ["RDF", "Semantic Web", "Linked Data", "Turtle", "RDFa", "SPARQL"], "homepage": "http://www.easyrdf.org/", @@ -12,6 +12,11 @@ "email": "njh@aelius.com", "homepage": "http://www.aelius.com/njh/", "role": "Developer" + }, + { + "name": "Alexey Zakhlestin", + "email": "indeyets@gmail.com", + "role": "Developer" } ], "support": { @@ -20,18 +25,17 @@ "irc": "irc://chat.freenode.net/easyrdf" }, "require": { - "php": ">=5.2.8" + "php": ">=5.2.8", + "ext-mbstring": "*", + "ext-pcre": "*" }, "suggest": { - "ml/json-ld": "dev-master" + "ml/json-ld": "~1.0" }, "require-dev": { - "phpunit/PHPUnit": ">=3.5.15", - "squizlabs/php_codesniffer": ">=1.4.3", - "sami/sami": "dev-master" - }, - "replace": { - "njh/easyrdf": "self.version" + "phpunit/PHPUnit": "~3.5", + "squizlabs/php_codesniffer": "~1.4.3", + "sami/sami": "~1.4" }, "autoload": { "psr-0": { "EasyRdf_": "lib/" } diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Format.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Format.php index 031a51dd32311dd81ac59612c8ff4a0664d21d15..d6eb670f97f07e728563b689c5ad9f2bbc8cc84a 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Format.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Format.php @@ -107,7 +107,7 @@ public static function getHttpAcceptHeader($extraTypes = array()) if ($q == 1.0) { $acceptStr .= $type; } else { - $acceptStr .= sprintf("%s;q=%1.1f", $type, $q); + $acceptStr .= sprintf("%s;q=%1.1F", $type, $q); } } return $acceptStr; @@ -238,7 +238,7 @@ public static function guessFormat($data, $filename = null) } // First try and identify by the filename - if ($filename and preg_match("/\.(\w+)$/", $filename, $matches)) { + if ($filename and preg_match('/\.(\w+)$/', $filename, $matches)) { foreach (self::$formats as $format) { if (in_array($matches[1], $format->extensions)) { return $format; @@ -248,21 +248,21 @@ public static function guessFormat($data, $filename = null) // Then try and guess by the first 1024 bytes of content $short = substr($data, 0, 1024); - if (preg_match("/^\s*\{/", $short)) { + if (preg_match('/^\s*\{/', $short)) { return self::getFormat('json'); - } elseif (preg_match("/<rdf:/i", $short)) { + } elseif (preg_match('/<rdf:/i', $short)) { return self::getFormat('rdfxml'); - } elseif (preg_match("/@prefix\s|@base\s/", $short)) { - return self::getFormat('turtle'); - } elseif (preg_match("/^\s*<.+> <.+>/m", $short)) { - return self::getFormat('ntriples'); - } elseif (preg_match("|http://www.w3.org/2005/sparql-results|", $short)) { + } elseif (preg_match('|http://www.w3.org/2005/sparql-results|', $short)) { return self::getFormat('sparql-xml'); - } elseif (preg_match("/\WRDFa\W/i", $short)) { + } elseif (preg_match('/\WRDFa\W/i', $short)) { return self::getFormat('rdfa'); - } elseif (preg_match("/<!DOCTYPE html|<html/i", $short)) { + } elseif (preg_match('/<!DOCTYPE html|<html/i', $short)) { # We don't support any other microformats embedded in HTML return self::getFormat('rdfa'); + } elseif (preg_match('/@prefix\s|@base\s/', $short)) { + return self::getFormat('turtle'); + } elseif (preg_match('/^\s*<.+> <.+>/m', $short)) { + return self::getFormat('ntriples'); } else { return null; } @@ -541,6 +541,16 @@ public function __toString() array('json') ); +EasyRdf_Format::register( + 'jsonld', + 'JSON-LD', + 'http://www.w3.org/TR/json-ld/', + array( + 'application/ld+json' => 1.0 + ), + array('jsonld') +); + EasyRdf_Format::register( 'ntriples', 'N-Triples', @@ -668,6 +678,7 @@ public function __toString() */ EasyRdf_Format::registerParser('json', 'EasyRdf_Parser_Json'); +EasyRdf_Format::registerParser('jsonld', 'EasyRdf_Parser_JsonLd'); EasyRdf_Format::registerParser('ntriples', 'EasyRdf_Parser_Ntriples'); EasyRdf_Format::registerParser('php', 'EasyRdf_Parser_RdfPhp'); EasyRdf_Format::registerParser('rdfxml', 'EasyRdf_Parser_RdfXml'); diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php index ba8ca825a3b70306186b3e75f75ca19a0fb91227..46ccc1708a2080f6d551cac9c85862311025039b 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php @@ -322,8 +322,11 @@ public function load($uri = null, $format = null) // If we didn't get any location, stop redirecting break; } else { - throw new EasyRdf_Exception( - "HTTP request for $requestUrl failed: ".$response->getMessage() + throw new EasyRdf_Http_Exception( + "HTTP request for {$requestUrl} failed: ".$response->getMessage(), + $response->getStatus(), + null, + $response->getBody() ); } } while ($redirectCounter < $this->maxRedirects); @@ -431,7 +434,7 @@ protected function checkResourceParam(&$resource, $allowNull = false) } } elseif ($resource === null) { throw new InvalidArgumentException( - "\$resource cannot be null" + "\$resource should be either IRI, blank-node identifier or EasyRdf_Resource. got null" ); } @@ -442,7 +445,7 @@ protected function checkResourceParam(&$resource, $allowNull = false) } elseif (is_string($resource)) { if ($resource == '') { throw new InvalidArgumentException( - "\$resource cannot be an empty string" + "\$resource should be either IRI, blank-node identifier or EasyRdf_Resource. got empty string" ); } elseif (preg_match("|^<(.+)>$|", $resource, $matches)) { $resource = $matches[1]; @@ -451,7 +454,7 @@ protected function checkResourceParam(&$resource, $allowNull = false) } } else { throw new InvalidArgumentException( - "\$resource should be a string or an EasyRdf_Resource" + "\$resource should be either IRI, blank-node identifier or EasyRdf_Resource" ); } } @@ -1395,13 +1398,10 @@ public function dumpResource($resource, $format = 'html') */ public function type($resource = null) { - $this->checkResourceParam($resource, true); + $type = $this->typeAsResource($resource); - if ($resource) { - $type = $this->get($resource, 'rdf:type', 'resource'); - if ($type) { - return EasyRdf_Namespace::shorten($type); - } + if ($type) { + return EasyRdf_Namespace::shorten($type); } return null; @@ -1437,18 +1437,32 @@ public function typeAsResource($resource = null) */ public function types($resource = null) { - $this->checkResourceParam($resource, true); + $resources = $this->typesAsResources($resource); $types = array(); - if ($resource) { - foreach ($this->all($resource, 'rdf:type', 'resource') as $type) { - $types[] = EasyRdf_Namespace::shorten($type); - } + foreach ($resources as $type) { + $types[] = EasyRdf_Namespace::shorten($type); } return $types; } + /** + * Get the resource types of the graph as a EasyRdf_Resource + * + * @return EasyRdf_Resource[] + */ + public function typesAsResources($resource = null) + { + $this->checkResourceParam($resource, true); + + if ($resource) { + return $this->all($resource, 'rdf:type', 'resource'); + } + + return array(); + } + /** Check if a resource is of the specified type * * @param string $resource The resource to check the type of diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/GraphStore.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/GraphStore.php index 19095751ef7f904294463c03653336f28cd7afac..40cbf63a93386c0c0516eda05a4c8c4a84a5e03b 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/GraphStore.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/GraphStore.php @@ -45,6 +45,11 @@ */ class EasyRdf_GraphStore { + /** + * Use to reference default graph of triplestore + */ + const DEFAULT_GRAPH = 'urn:easyrdf:default-graph'; + /** The address of the GraphStore endpoint */ private $uri = null; private $parsedUri = null; @@ -75,17 +80,34 @@ public function getUri() * a URI relative to the URI of the graph store. * * @param string $uriRef The URI of graph desired - * @return object EasyRdf_Graph The graph requested + * @return EasyRdf_Graph The graph requested */ public function get($uriRef) { - $graphUri = $this->parsedUri->resolve($uriRef)->toString(); - $dataUrl = $this->urlForGraph($graphUri); - $graph = new EasyRdf_Graph($graphUri); + if ($uriRef === self::DEFAULT_GRAPH) { + $dataUrl = $this->urlForGraph(self::DEFAULT_GRAPH); + $graph = new EasyRdf_Graph(); + } else { + $graphUri = $this->parsedUri->resolve($uriRef)->toString(); + $dataUrl = $this->urlForGraph($graphUri); + + $graph = new EasyRdf_Graph($graphUri); + } + $graph->load($dataUrl); + return $graph; } + /** + * Fetch default graph from the graph store + * @return EasyRdf_Graph + */ + public function getDefault() + { + return $this->get(self::DEFAULT_GRAPH); + } + /** Send some graph data to the graph store * * This method is used by insert() and replace() @@ -95,7 +117,7 @@ public function get($uriRef) protected function sendGraph($method, $graph, $uriRef, $format) { if (is_object($graph) and $graph instanceof EasyRdf_Graph) { - if ($uriRef == null) { + if ($uriRef === null) { $uriRef = $graph->getUri(); } $data = $graph->serialise($format); @@ -103,11 +125,19 @@ protected function sendGraph($method, $graph, $uriRef, $format) $data = $graph; } + if ($uriRef === null) { + throw new InvalidArgumentException('Graph IRI is not specified'); + } + $formatObj = EasyRdf_Format::getFormat($format); $mimeType = $formatObj->getDefaultMimeType(); - $graphUri = $this->parsedUri->resolve($uriRef)->toString(); - $dataUrl = $this->urlForGraph($graphUri); + if ($uriRef === self::DEFAULT_GRAPH) { + $dataUrl = $this->urlForGraph(self::DEFAULT_GRAPH); + } else { + $graphUri = $this->parsedUri->resolve($uriRef)->toString(); + $dataUrl = $this->urlForGraph($graphUri); + } $client = EasyRdf_Http::getDefaultHttpClient(); $client->resetParameters(true); @@ -115,12 +145,15 @@ protected function sendGraph($method, $graph, $uriRef, $format) $client->setMethod($method); $client->setRawData($data); $client->setHeaders('Content-Type', $mimeType); + $response = $client->request(); + if (!$response->isSuccessful()) { throw new EasyRdf_Exception( - "HTTP request for $dataUrl failed: ".$response->getMessage() + "HTTP request for {$dataUrl} failed: ".$response->getMessage() ); } + return $response; } @@ -135,16 +168,34 @@ protected function sendGraph($method, $graph, $uriRef, $format) * The $format parameter can be given to specify the serialisation * used to send the graph data to the graph store. * - * @param object EasyRdfGraph $graph The URI of graph desired - * @param string $uriRef The URI of graph to be replaced - * @param string $format The format of the data to send to the graph store - * @return object EasyRdf_Http_Response The response from the graph store + * @param EasyRdf_Graph|string $graph Data + * @param string $uriRef The URI of graph to be replaced + * @param string $format The format of the data to send to the graph store + * @return EasyRdf_Http_Response The response from the graph store */ public function replace($graph, $uriRef = null, $format = 'ntriples') { return $this->sendGraph('PUT', $graph, $uriRef, $format); } + /** + * Replace the contents of default graph in the graph store with new data + * + * The $graph parameter is the EasyRdf_Graph object to be sent to the + * graph store. Alternatively it can be a string, already serialised. + * + * The $format parameter can be given to specify the serialisation + * used to send the graph data to the graph store. + * + * @param EasyRdf_Graph|string $graph Data + * @param string $format The format of the data to send to the graph store + * @return EasyRdf_Http_Response The response from the graph store + */ + public function replaceDefault($graph, $format = 'ntriples') + { + return self::replace($graph, self::DEFAULT_GRAPH, $format); + } + /** Add data to a graph in the graph store * * The $graph parameter is the EasyRdf_Graph object to be sent to the @@ -156,9 +207,9 @@ public function replace($graph, $uriRef = null, $format = 'ntriples') * The $format parameter can be given to specify the serialisation * used to send the graph data to the graph store. * - * @param object EasyRdfGraph $graph The URI of graph desired - * @param string $uriRef The URI of graph to be added to - * @param string $format The format of the data to send to the graph store + * @param EasyRdf_Graph|string $graph Data + * @param string $uriRef The URI of graph to be added to + * @param string $format The format of the data to send to the graph store * @return object EasyRdf_Http_Response The response from the graph store */ public function insert($graph, $uriRef = null, $format = 'ntriples') @@ -166,41 +217,81 @@ public function insert($graph, $uriRef = null, $format = 'ntriples') return $this->sendGraph('POST', $graph, $uriRef, $format); } - /** Delete a graph from the graph store + /** + * Add data to default graph of the graph store + * + * The $graph parameter is the EasyRdf_Graph object to be sent to the + * graph store. Alternatively it can be a string, already serialised. + * + * The $format parameter can be given to specify the serialisation + * used to send the graph data to the graph store. + * + * @param EasyRdf_Graph|string $graph Data + * @param string $format The format of the data to send to the graph store + * @return object EasyRdf_Http_Response The response from the graph store + */ + public function insertIntoDefault($graph, $format = 'ntriples') + { + return $this->insert($graph, self::DEFAULT_GRAPH, $format); + } + + /** Delete named graph content from the graph store * * The URI can either be a full absolute URI or * a URI relative to the URI of the graph store. * * @param string $uriRef The URI of graph to be added to - * @return object EasyRdf_Http_Response The response from the graph store + * + * @throws EasyRdf_Exception + * @return EasyRdf_Http_Response The response from the graph store */ public function delete($uriRef) { - $graphUri = $this->parsedUri->resolve($uriRef)->toString(); - $dataUrl = $this->urlForGraph($graphUri); + if ($uriRef === self::DEFAULT_GRAPH) { + $dataUrl = $this->urlForGraph(self::DEFAULT_GRAPH); + } else { + $graphUri = $this->parsedUri->resolve($uriRef)->toString(); + $dataUrl = $this->urlForGraph($graphUri); + } $client = EasyRdf_Http::getDefaultHttpClient(); $client->resetParameters(true); $client->setUri($dataUrl); $client->setMethod('DELETE'); $response = $client->request(); + if (!$response->isSuccessful()) { throw new EasyRdf_Exception( - "HTTP request to delete $dataUrl failed: ".$response->getMessage() + "HTTP request to delete {$dataUrl} failed: ".$response->getMessage() ); } + return $response; } + /** + * Delete default graph content from the graph store + * + * @return EasyRdf_Http_Response + * @throws EasyRdf_Exception + */ + public function deleteDefault() + { + return $this->delete(self::DEFAULT_GRAPH); + } + /** Work out the full URL for a graph store request. * by checking if if it is a direct or indirect request. * @ignore */ protected function urlForGraph($url) { - if (strpos($url, $this->uri) === false) { + if ($url === self::DEFAULT_GRAPH) { + $url = $this->uri.'?default'; + } elseif (strpos($url, $this->uri) === false) { $url = $this->uri."?graph=".urlencode($url); } + return $url; } diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http.php index 47e8bdb14a174f93df9ee7bf4e921f9c4baeb374..c978463f0f5d1c7b275014393e184288ff1cd76b 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http.php @@ -50,8 +50,8 @@ class EasyRdf_Http /** Set the HTTP Client object used to fetch RDF data * - * @param object mixed $httpClient The new HTTP client object - * @return object mixed The new HTTP client object + * @param EasyRdf_Http_Client|Zend_Http_Client $httpClient The new HTTP client object + * @return EasyRdf_Http_Client|Zend_Http_Client The new HTTP client object */ public static function setDefaultHttpClient($httpClient) { @@ -70,7 +70,7 @@ public static function setDefaultHttpClient($httpClient) * If no HTTP Client has previously been set, then a new * default (EasyRdf_Http_Client) client will be created. * - * @return object mixed The HTTP client object + * @return EasyRdf_Http_Client|Zend_Http_Client The HTTP client object */ public static function getDefaultHttpClient() { diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Exception.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Exception.php new file mode 100644 index 0000000000000000000000000000000000000000..4e4c0739e01f97feeba49470bdca3b1256947fd3 --- /dev/null +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Exception.php @@ -0,0 +1,18 @@ +<?php + + +class EasyRdf_Http_Exception extends EasyRdf_Exception +{ + private $body; + + public function __construct($message = "", $code = 0, Exception $previous = null, $body = '') + { + parent::__construct($message, $code, $previous); + $this->body = $body; + } + + public function getBody() + { + return $this->body; + } +} diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Response.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Response.php index 80edfc225049114e2f963dd9790a599de090fcd2..21f986a83b22baeb6175aeba6162255a23f0bf2c 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Response.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Http/Response.php @@ -321,7 +321,7 @@ public static function decodeChunkedBody($body) $decBody = ''; while (trim($body)) { - if (preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) { + if (preg_match('/^([\da-fA-F]+)[^\r\n]*\r\n/sm', $body, $m)) { $length = hexdec(trim($m[1])); $cut = strlen($m[0]); $decBody .= substr($body, $cut, $length); diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php index 8030e4e785919117e11825901a955c9c603319c6..b6e5a71c1f8345eea0e73c3902818bdc91704658 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php @@ -176,7 +176,7 @@ public static function deleteDatatypeMapping($datatype) public static function getDatatypeForValue($value) { if (is_float($value)) { - return 'http://www.w3.org/2001/XMLSchema#decimal'; + return 'http://www.w3.org/2001/XMLSchema#double'; } elseif (is_int($value)) { return 'http://www.w3.org/2001/XMLSchema#integer'; } elseif (is_bool($value)) { @@ -223,8 +223,13 @@ public function __construct($value, $lang = null, $datatype = null) } } - // Cast value to string - settype($this->value, 'string'); + if (is_float($this->value)) { + // special handling of floats, as they suffer from locale [mis]configuration + $this->value = rtrim(sprintf('%F', $this->value), '0'); + } else { + // Cast value to string + settype($this->value, 'string'); + } } /** Returns the value of the literal. diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Decimal.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Decimal.php index 59b2cd1bab3b8a0ed54b0d1bd6a740b5a67d2d6a..51c59c84018f39c8a681495b9fb536bd76710c7a 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Decimal.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Decimal.php @@ -45,24 +45,82 @@ */ class EasyRdf_Literal_Decimal extends EasyRdf_Literal { + /** + * written according to http://www.w3.org/TR/xmlschema-2/#decimal + */ + const DECIMAL_REGEX = '^([+\-]?)(((\d+)?\.(\d+))|((\d+)\.?))$'; + /** Constructor for creating a new decimal literal * - * @param mixed $value The value of the literal - * @param string $lang Should be null (literals with a datatype can't have a language) - * @param string $datatype Optional datatype (default 'xsd:decimal') - * @return object EasyRdf_Literal_Decimal + * @param double|int|string $value The value of the literal + * @param string $lang Should be null (literals with a datatype can't have a language) + * @param string $datatype Optional datatype (default 'xsd:decimal') + * + * @throws UnexpectedValueException + * @return EasyRdf_Literal_Decimal */ public function __construct($value, $lang = null, $datatype = null) { + if (is_string($value)) { + self::validate($value); + } elseif (is_double($value) or is_int($value)) { + $locale_data = localeconv(); + $value = str_replace($locale_data['decimal_point'], '.', strval($value)); + } else { + throw new UnexpectedValueException('EasyRdf_Literal_Decimal expects int/float/string as value'); + } + + $value = self::canonicalise($value); + parent::__construct($value, null, $datatype); } - /** Return the value of the literal cast to a PHP double + /** Return the value of the literal cast to a PHP string * - * @return double + * @return string */ public function getValue() { - return (double)$this->value; + return strval($this->value); + } + + /** + * @param string $value + * + * @throws UnexpectedValueException + */ + public static function validate($value) + { + if (!mb_ereg_match(self::DECIMAL_REGEX, $value)) { + throw new UnexpectedValueException("'{$value}' doesn't look like a valid decimal"); + } + } + + /** + * Converts valid xsd:decimal literal to Canonical representation + * see http://www.w3.org/TR/xmlschema-2/#decimal + * + * @param string $value Valid xsd:decimal literal + * + * @return string + */ + public static function canonicalise($value) + { + $pieces = array(); + mb_ereg(self::DECIMAL_REGEX, $value, $pieces); + + $sign = $pieces[1] === '-' ? '-' : ''; // '+' is not allowed + $integer = ltrim(($pieces[4] !== false) ? $pieces[4] : $pieces[7], '0'); + $fractional = rtrim($pieces[5], '0'); + + if (empty($integer)) { + $integer = '0'; + } + + if (empty($fractional)) { + $fractional = '0'; + } + + return "{$sign}{$integer}.{$fractional}"; } } diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/HexBinary.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/HexBinary.php index 75ed24e2ca53d5403d6070b2fee6a3f4b4d5e382..7301a1014565a6063205a10ac233bbe93a82c7ae 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/HexBinary.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/HexBinary.php @@ -59,7 +59,7 @@ public function __construct($value, $lang = null, $datatype = null) $value = strtoupper($value); // Validate the data - if (preg_match("/[^A-F0-9]/", $value)) { + if (preg_match('/[^A-F0-9]/', $value)) { throw new InvalidArgumentException( "Literal of type xsd:hexBinary contains non-hexadecimal characters" ); diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Namespace.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Namespace.php index 353d3ba84f327466a7248dfe03f5d3c138e25cf1..8990e82a5d590855af0506572d573216a095f74f 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Namespace.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Namespace.php @@ -5,7 +5,7 @@ * * LICENSE * - * Copyright (c) 2009-2013 Nicholas J Humfrey. All rights reserved. + * Copyright (c) 2009-2014 Nicholas J Humfrey. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package EasyRdf - * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey + * @copyright Copyright (c) 2009-2014 Nicholas J Humfrey * @license http://www.opensource.org/licenses/bsd-license.php */ @@ -39,7 +39,7 @@ * A namespace registry and manipulation class. * * @package EasyRdf - * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey + * @copyright Copyright (c) 2009-2014 Nicholas J Humfrey * @license http://www.opensource.org/licenses/bsd-license.php */ class EasyRdf_Namespace @@ -52,46 +52,54 @@ class EasyRdf_Namespace * With a few extras added. * */ - private static $namespaces = array( - 'bibo' => 'http://purl.org/ontology/bibo/', - 'cc' => 'http://creativecommons.org/ns#', - 'cert' => 'http://www.w3.org/ns/auth/cert#', - 'ctag' => 'http://commontag.org/ns#', - 'dc' => 'http://purl.org/dc/terms/', - 'dc11' => 'http://purl.org/dc/elements/1.1/', - 'dcterms' => 'http://purl.org/dc/terms/', - 'doap' => 'http://usefulinc.com/ns/doap#', - 'exif' => 'http://www.w3.org/2003/12/exif/ns#', - 'foaf' => 'http://xmlns.com/foaf/0.1/', - 'geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#', - 'gr' => 'http://purl.org/goodrelations/v1#', - 'grddl' => 'http://www.w3.org/2003/g/data-view#', - 'ical' => 'http://www.w3.org/2002/12/cal/icaltzd#', - 'ma' => 'http://www.w3.org/ns/ma-ont#', - 'og' => 'http://ogp.me/ns#', - 'owl' => 'http://www.w3.org/2002/07/owl#', - 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', - 'rdfa' => 'http://www.w3.org/ns/rdfa#', - 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', - 'rev' => 'http://purl.org/stuff/rev#', - 'rif' => 'http://www.w3.org/2007/rif#', - 'rss' => 'http://purl.org/rss/1.0/', - 'schema' => 'http://schema.org/', - 'sioc' => 'http://rdfs.org/sioc/ns#', - 'skos' => 'http://www.w3.org/2004/02/skos/core#', - 'skosxl' => 'http://www.w3.org/2008/05/skos-xl#', - 'synd' => 'http://purl.org/rss/1.0/modules/syndication/', - 'v' => 'http://rdf.data-vocabulary.org/#', - 'vcard' => 'http://www.w3.org/2006/vcard/ns#', - 'void' => 'http://rdfs.org/ns/void#', - 'wdr' => 'http://www.w3.org/2007/05/powder#', - 'wdrs' => 'http://www.w3.org/2007/05/powder-s#', - 'wot' => 'http://xmlns.com/wot/0.1/', - 'xhv' => 'http://www.w3.org/1999/xhtml/vocab#', - 'xml' => 'http://www.w3.org/XML/1998/namespace', - 'xsd' => 'http://www.w3.org/2001/XMLSchema#', + private static $initial_namespaces = array( + 'bibo' => 'http://purl.org/ontology/bibo/', + 'cc' => 'http://creativecommons.org/ns#', + 'cert' => 'http://www.w3.org/ns/auth/cert#', + 'ctag' => 'http://commontag.org/ns#', + 'dc' => 'http://purl.org/dc/terms/', + 'dc11' => 'http://purl.org/dc/elements/1.1/', + 'dcat' => 'http://www.w3.org/ns/dcat#', + 'dcterms' => 'http://purl.org/dc/terms/', + 'doap' => 'http://usefulinc.com/ns/doap#', + 'exif' => 'http://www.w3.org/2003/12/exif/ns#', + 'foaf' => 'http://xmlns.com/foaf/0.1/', + 'geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#', + 'gr' => 'http://purl.org/goodrelations/v1#', + 'grddl' => 'http://www.w3.org/2003/g/data-view#', + 'ical' => 'http://www.w3.org/2002/12/cal/icaltzd#', + 'ma' => 'http://www.w3.org/ns/ma-ont#', + 'og' => 'http://ogp.me/ns#', + 'org' => 'http://www.w3.org/ns/org#', + 'owl' => 'http://www.w3.org/2002/07/owl#', + 'prov' => 'http://www.w3.org/ns/prov#', + 'qb' => 'http://purl.org/linked-data/cube#', + 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + 'rdfa' => 'http://www.w3.org/ns/rdfa#', + 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', + 'rev' => 'http://purl.org/stuff/rev#', + 'rif' => 'http://www.w3.org/2007/rif#', + 'rr' => 'http://www.w3.org/ns/r2rml#', + 'rss' => 'http://purl.org/rss/1.0/', + 'schema' => 'http://schema.org/', + 'sd' => 'http://www.w3.org/ns/sparql-service-description#', + 'sioc' => 'http://rdfs.org/sioc/ns#', + 'skos' => 'http://www.w3.org/2004/02/skos/core#', + 'skosxl' => 'http://www.w3.org/2008/05/skos-xl#', + 'synd' => 'http://purl.org/rss/1.0/modules/syndication/', + 'v' => 'http://rdf.data-vocabulary.org/#', + 'vcard' => 'http://www.w3.org/2006/vcard/ns#', + 'void' => 'http://rdfs.org/ns/void#', + 'wdr' => 'http://www.w3.org/2007/05/powder#', + 'wdrs' => 'http://www.w3.org/2007/05/powder-s#', + 'wot' => 'http://xmlns.com/wot/0.1/', + 'xhv' => 'http://www.w3.org/1999/xhtml/vocab#', + 'xml' => 'http://www.w3.org/XML/1998/namespace', + 'xsd' => 'http://www.w3.org/2001/XMLSchema#', ); + private static $namespaces = null; + private static $default = null; /** Counter for numbering anonymous namespaces */ @@ -104,9 +112,22 @@ class EasyRdf_Namespace */ public static function namespaces() { + if (self::$namespaces === null) { + self::resetNamespaces(); + } + return self::$namespaces; } + /** + * Resets list of namespaces to the one, which is provided by EasyRDF + * useful for tests, among other things + */ + public static function resetNamespaces() + { + self::$namespaces = self::$initial_namespaces; + } + /** * Return a namespace given its prefix. * @@ -115,7 +136,7 @@ public static function namespaces() */ public static function get($prefix) { - if (!is_string($prefix) or $prefix === null or $prefix === '') { + if (!is_string($prefix) or $prefix === null) { throw new InvalidArgumentException( "\$prefix should be a string and cannot be null or empty" ); @@ -128,8 +149,10 @@ public static function get($prefix) } $prefix = strtolower($prefix); - if (array_key_exists($prefix, self::$namespaces)) { - return self::$namespaces[$prefix]; + $namespaces = self::namespaces(); + + if (array_key_exists($prefix, $namespaces)) { + return $namespaces[$prefix]; } else { return null; } @@ -143,16 +166,42 @@ public static function get($prefix) */ public static function set($prefix, $long) { - if (!is_string($prefix) or $prefix === null or $prefix === '') { + if (!is_string($prefix) or $prefix === null) { throw new InvalidArgumentException( "\$prefix should be a string and cannot be null or empty" ); } - if (preg_match('/\W/', $prefix)) { - throw new InvalidArgumentException( - "\$prefix should only contain alpha-numeric characters" - ); + if ($prefix !== '') { + // prefix ::= Name minus ":" // see: http://www.w3.org/TR/REC-xml-names/#NT-NCName + // Name ::= NameStartChar (NameChar)* // see: http://www.w3.org/TR/REC-xml/#NT-Name + // NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | + // [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | + // [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] + // NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] + + $_name_start_char = + 'A-Z_a-z\xc0-\xD6\xd8-\xf6\xf8-\xff\x{0100}-\x{02ff}\x{0370}-\x{037d}' . + '\x{037F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}' . + '\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}'; + + $_name_char = + $_name_start_char . + '\-.0-9\xb7\x{0300}-\x{036f}\x{203f}-\x{2040}'; + + $regex = "#^[{$_name_start_char}]{1}[{$_name_char}]{0,}$#u"; + + $match_result = preg_match($regex, $prefix); + + if ($match_result === false) { + throw new LogicException('regexp error'); + } + + if ($match_result === 0) { + throw new InvalidArgumentException( + "\$prefix should match RDFXML-QName specification. got: {$prefix}" + ); + } } if (!is_string($long) or $long === null or $long === '') { @@ -162,7 +211,11 @@ public static function set($prefix, $long) } $prefix = strtolower($prefix); - self::$namespaces[$prefix] = $long; + + $namespaces = self::namespaces(); + $namespaces[$prefix] = $long; + + self::$namespaces = $namespaces; } /** @@ -193,14 +246,16 @@ public static function setDefault($namespace) { if (is_null($namespace) or $namespace === '') { self::$default = null; - } elseif (preg_match("/^\w+$/", $namespace)) { - if (isset(self::$namespaces[$namespace])) { - self::$default = self::$namespaces[$namespace]; - } else { + } elseif (preg_match('/^\w+$/', $namespace)) { + $namespaces = self::namespaces(); + + if (!isset($namespaces[$namespace])) { throw new InvalidArgumentException( "Unable to set default namespace to unknown prefix: $namespace" ); } + + self::$default = $namespaces[$namespace]; } else { self::$default = $namespace; } @@ -220,6 +275,7 @@ public static function delete($prefix) } $prefix = strtolower($prefix); + self::namespaces(); // make sure, that self::$namespaces is initialized if (isset(self::$namespaces[$prefix])) { unset(self::$namespaces[$prefix]); } @@ -265,16 +321,25 @@ public static function splitUri($uri, $createNamespace = false) ); } - foreach (self::$namespaces as $prefix => $long) { - if (substr($uri, 0, strlen($long)) == $long) { - return array($prefix, substr($uri, strlen($long))); + foreach (self::namespaces() as $prefix => $long) { + if (substr($uri, 0, strlen($long)) !== $long) { + continue; + } + + $local_part = substr($uri, strlen($long)); + + if (strpos($local_part, '/') !== false) { + // we can't have '/' in local part + continue; } + + return array($prefix, $local_part); } if ($createNamespace) { // Try and create a new namespace # FIXME: check the valid characters for an XML element name - if (preg_match("/^(.+?)([\w\-]+)$/", $uri, $matches)) { + if (preg_match('/^(.+?)([\w\-]+)$/', $uri, $matches)) { $prefix = "ns".(self::$anonymousNamespaceCount++); self::set($prefix, $matches[1]); return array($prefix, $matches[2]); @@ -333,15 +398,16 @@ public static function expand($shortUri) "\$shortUri should be a string and cannot be null or empty" ); } - + if ($shortUri === 'a') { - return self::$namespaces['rdf'] . 'type'; - } elseif (preg_match("/^(\w+?):([\w\-]+)$/", $shortUri, $matches)) { + $namespaces = self::namespaces(); + return $namespaces['rdf'] . 'type'; + } elseif (preg_match('/^(\w+?):([\w\-]+)$/', $shortUri, $matches)) { $long = self::get($matches[1]); if ($long) { return $long . $matches[2]; } - } elseif (preg_match("/^(\w+)$/", $shortUri) and isset(self::$default)) { + } elseif (preg_match('/^(\w+)$/', $shortUri) and isset(self::$default)) { return self::$default . $shortUri; } diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser.php index b15b4493c861a3507753ac4f269eb0be204cef25..196388dd3900c49a0d454870277f020ee16c4497 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser.php @@ -56,6 +56,9 @@ class EasyRdf_Parser /** The base URI for the document currently being parsed */ protected $baseUri = null; + + protected $tripleCount = 0; + /** * Create a new, unique bnode identifier from a source identifier. * If the source identifier has previously been seen, the diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php index ee31d1d8567abb1e3a1cf39597962bf610c7d688..924abdcd8fff2ac99332dc4383d86c5eaa52d2b2 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php @@ -39,6 +39,7 @@ * A pure-php class to parse RDF/JSON with no dependancies. * * http://n2.talis.com/wiki/RDF_JSON_Specification + * docs/appendix-a-rdf-formats-json.md * * @package EasyRdf * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/JsonLd.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/JsonLd.php new file mode 100644 index 0000000000000000000000000000000000000000..d0efc12ef25190fcfbb0d7165de924f4b09aef53 --- /dev/null +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/JsonLd.php @@ -0,0 +1,42 @@ +<?php + +/** + * EasyRdf + * + * LICENSE + * + * Copyright (c) 2009-2013 Nicholas J Humfrey. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author 'Nicholas J Humfrey" may be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package EasyRdf + * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey + * @license http://www.opensource.org/licenses/bsd-license.php + */ + +if (PHP_MAJOR_VERSION > 5 or (PHP_MAJOR_VERSION == 5 and PHP_MINOR_VERSION >= 3)) { + require dirname(__FILE__).'/JsonLdImplementation.php'; +} else { + throw new LogicException("JSON-LD support requires PHP 5.3+"); +} diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/JsonLdImplementation.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/JsonLdImplementation.php new file mode 100644 index 0000000000000000000000000000000000000000..d2e22c49d05cb8369fae9b56f1fe6b56b1745b3d --- /dev/null +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/JsonLdImplementation.php @@ -0,0 +1,120 @@ +<?php + +/** + * EasyRdf + * + * LICENSE + * + * Copyright (c) 2009-2013 Nicholas J Humfrey. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author 'Nicholas J Humfrey" may be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package EasyRdf + * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey + * @license http://www.opensource.org/licenses/bsd-license.php + */ + +/** + * Class to parse JSON-LD to an EasyRdf_Graph + * + * @package EasyRdf + * @copyright Copyright (c) 2014 Markus Lanthaler + * @author Markus Lanthaler <mail@markus-lanthaler.com> + * @license http://www.opensource.org/licenses/bsd-license.php + */ +class EasyRdf_Parser_JsonLd extends EasyRdf_Parser +{ + /** + * Parse a JSON-LD document into an EasyRdf_Graph + * + * Attention: Since JSON-LD supports datasets, a document may contain + * multiple graphs and not just one. This parser returns only the + * default graph. An alternative would be to merge all graphs. + * + * @param object EasyRdf_Graph $graph the graph to load the data into + * @param string $data the RDF document data + * @param string $format the format of the input data + * @param string $baseUri the base URI of the data being parsed + * @return integer The number of triples added to the graph + */ + public function parse($graph, $data, $format, $baseUri) + { + parent::checkParseParams($graph, $data, $format, $baseUri); + + if ($format != 'jsonld') { + throw new EasyRdf_Exception( + "EasyRdf_Parser_JsonLd does not support $format" + ); + } + + try { + $quads = \ML\JsonLD\JsonLD::toRdf($data, array('base' => $baseUri)); + } catch (\ML\JsonLD\Exception\JsonLdException $e) { + throw new EasyRdf_Parser_Exception($e->getMessage()); + } + + foreach ($quads as $quad) { + // Ignore named graphs + if (null !== $quad->getGraph()) { + continue; + } + + $subject = (string) $quad->getSubject(); + if ('_:' === substr($subject, 0, 2)) { + $subject = $this->remapBnode($subject); + } + + $predicate = (string) $quad->getProperty(); + + if ($quad->getObject() instanceof \ML\IRI\IRI) { + $object = array( + 'type' => 'uri', + 'value' => (string) $quad->getObject() + ); + + if ('_:' === substr($object['value'], 0, 2)) { + $object = array( + 'type' => 'bnode', + 'value' => $this->remapBnode($object['value']) + ); + } + } else { + $object = array( + 'type' => 'literal', + 'value' => $quad->getObject()->getValue() + ); + + if ($quad->getObject() instanceof \ML\JsonLD\LanguageTaggedString) { + $object['lang'] = $quad->getObject()->getLanguage(); + } else { + $object['datatype'] = $quad->getObject()->getType(); + } + } + + $this->addTriple($subject, $predicate, $object); + } + + return $this->tripleCount; + } +} diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Ntriples.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Ntriples.php index 1392b5bf80075b880bb48b66e96c46f0254795a1..01ebf9dc63acba8cf74bd4e0d5deaa1163fc3a8a 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Ntriples.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Ntriples.php @@ -183,19 +183,19 @@ public function parse($graph, $data, $format, $baseUri) ); } - $lines = preg_split("/\x0D?\x0A/", strval($data)); + $lines = preg_split('/\x0D?\x0A/', strval($data)); foreach ($lines as $index => $line) { $lineNum = $index + 1; - if (preg_match("/^\s*#/", $line)) { + if (preg_match('/^\s*#/', $line)) { # Comment continue; - } elseif (preg_match("/^\s*(.+?)\s+<([^<>]+?)>\s+(.+?)\s*\.\s*$/", $line, $matches)) { + } elseif (preg_match('/^\s*(.+?)\s+<([^<>]+?)>\s+(.+?)\s*\.\s*$/', $line, $matches)) { $this->addTriple( $this->parseNtriplesSubject($matches[1], $lineNum), $this->unescapeString($matches[2]), $this->parseNtriplesObject($matches[3], $lineNum) ); - } elseif (preg_match("/^\s*$/", $line)) { + } elseif (preg_match('/^\s*$/', $line)) { # Blank line continue; } else { diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfPhp.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfPhp.php index cea3c8a7d78e9aec96f38cdf5458501d865fd0ab..cd0ec82905e206da7f8474e67497cf220c5b0699 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfPhp.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfPhp.php @@ -39,6 +39,7 @@ * Class to parse RDF with no external dependancies. * * http://n2.talis.com/wiki/RDF_PHP_Specification + * docs/appendix-a-rdf-formats-php.md * * @package EasyRdf * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php index b7d59fece0908f86ebf680c850cff86345cb0997..bfbbd30c0c96b6e92b3118ae9a1451e7aaff0b90 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/RdfXml.php @@ -270,6 +270,10 @@ protected function startState0($t, $a) $this->state = 1; if ($t !== $this->rdf.'RDF') { $this->startState1($t, $a); + } else { + if (isset($a[$this->xml.'base'])) { + $this->xBase = $this->xBase->resolve($a[$this->xml.'base']); + } } } @@ -758,7 +762,7 @@ protected function cdataState4($d) protected function cdataState6($d) { if ($s = $this->getParentS()) { - if (isset($s['o_xml_data']) || preg_match("/[\n\r]/", $d) || trim($d)) { + if (isset($s['o_xml_data']) || preg_match('/[\n\r]/', $d) || trim($d)) { $d = htmlspecialchars($d, ENT_NOQUOTES); $s['o_xml_data'] = isset($s['o_xml_data']) ? $s['o_xml_data'] . $d : $d; } diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php index 5811fb23bf3deae3a8063c7e01a25df02ce45e22..58eebe614b8b53e0d40e01a9a4019537440c2660 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php @@ -162,17 +162,17 @@ protected function printNode($node, $depth) protected function guessTimeDatatype($value) { - if (preg_match("/^-?\d{4}-\d{2}-\d{2}(Z|[\-\+]\d{2}:\d{2})?$/", $value)) { + if (preg_match('/^-?\d{4}-\d{2}-\d{2}(Z|[\-\+]\d{2}:\d{2})?$/', $value)) { return 'http://www.w3.org/2001/XMLSchema#date'; - } elseif (preg_match("/^\d{2}:\d{2}:\d{2}(Z|[\-\+]\d{2}:\d{2})?$/", $value)) { + } elseif (preg_match('/^\d{2}:\d{2}:\d{2}(Z|[\-\+]\d{2}:\d{2})?$/', $value)) { return 'http://www.w3.org/2001/XMLSchema#time'; - } elseif (preg_match("/^-?\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[\-\+]\d{2}:\d{2})?$/", $value)) { + } elseif (preg_match('/^-?\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[\-\+]\d{2}:\d{2})?$/', $value)) { return 'http://www.w3.org/2001/XMLSchema#dateTime'; - } elseif (preg_match("/^P(\d+Y)?(\d+M)?(\d+D)?T?(\d+H)?(\d+M)?(\d+S)?$/", $value)) { + } elseif (preg_match('/^P(\d+Y)?(\d+M)?(\d+D)?T?(\d+H)?(\d+M)?(\d+S)?$/', $value)) { return 'http://www.w3.org/2001/XMLSchema#duration'; - } elseif (preg_match("/^\d{4}$/", $value)) { + } elseif (preg_match('/^\d{4}$/', $value)) { return 'http://www.w3.org/2001/XMLSchema#gYear'; - } elseif (preg_match("/^\d{4}-\d{2}$/", $value)) { + } elseif (preg_match('/^\d{4}-\d{2}$/', $value)) { return 'http://www.w3.org/2001/XMLSchema#gYearMonth'; } else { return null; @@ -209,7 +209,7 @@ protected function initialContext() protected function expandCurie($node, &$context, $value) { - if (preg_match("/^(\w*?):(.*)$/", $value, $matches)) { + if (preg_match('/^(\w*?):(.*)$/', $value, $matches)) { list (, $prefix, $local) = $matches; $prefix = strtolower($prefix); if ($prefix === '_') { @@ -231,7 +231,7 @@ protected function expandCurie($node, &$context, $value) protected function processUri($node, &$context, $value, $isProp = false) { - if (preg_match("/^\[(.*)\]$/", $value, $matches)) { + if (preg_match('/^\[(.*)\]$/', $value, $matches)) { // Safe CURIE return $this->expandCurie($node, $context, $matches[1]); } elseif (preg_match(self::TERM_REGEXP, $value) and $isProp) { @@ -268,7 +268,7 @@ protected function processUriList($node, $context, $values) } $uris = array(); - foreach (preg_split("/\s+/", $values) as $value) { + foreach (preg_split('/\s+/', $values) as $value) { $uri = $this->processUri($node, $context, $value, true); if ($uri) { array_push($uris, $uri); @@ -343,7 +343,7 @@ protected function processNode($node, &$context, $depth = 1) } } if ($node->hasAttribute('prefix')) { - $mappings = preg_split("/\s+/", $node->getAttribute('prefix')); + $mappings = preg_split('/\s+/', $node->getAttribute('prefix')); while (count($mappings)) { $prefix = strtolower(array_shift($mappings)); $uri = array_shift($mappings); @@ -381,7 +381,7 @@ protected function processNode($node, &$context, $depth = 1) } else { // Only keep CURIEs. $curies = array(); - foreach (preg_split("/\s+/", $node->getAttribute($attr)) as $token) { + foreach (preg_split('/\s+/', $node->getAttribute($attr)) as $token) { if (strpos($token, ':')) { $curies[] = $token; } diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php index 3915e32790bec0af1d91dac73159cbb160c1acf9..760cf7bdfc37ba0fc041ba16b87b8c5d77299df3 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php @@ -129,7 +129,7 @@ protected function parseStatement() } } - if (preg_match("/^(@|prefix$|base$)/i", $directive)) { + if (preg_match('/^(@|prefix$|base$)/i', $directive)) { $this->parseDirective($directive); $this->skipWSC(); // SPARQL BASE and PREFIX lines do not end in . @@ -155,7 +155,7 @@ protected function parseDirective($directive) $this->parsePrefixID(); } elseif ($directive == "base" || $directive == '@base') { $this->parseBase(); - } elseif (mb_strlen($directive) == 0) { + } elseif (mb_strlen($directive, "UTF-8") == 0) { throw new EasyRdf_Parser_Exception( "Turtle Parse Error: directive name is missing, expected @prefix or @base", $this->line, @@ -752,7 +752,7 @@ protected function parseLongString($closingCharacter) } } - return mb_substr($str, 0, -3); + return mb_substr($str, 0, -3, "UTF-8"); } /** @@ -792,7 +792,7 @@ protected function parseNumber() $c = $this->read(); } - if (mb_strlen($value) == 1) { + if (mb_strlen($value, "UTF-8") == 1) { // We've only parsed a '.' throw new EasyRdf_Parser_Exception( "Turtle Parse Error: object for statement missing", @@ -805,7 +805,7 @@ protected function parseNumber() $datatype = EasyRdf_Namespace::get('xsd').'decimal'; } } else { - if (mb_strlen($value) == 0) { + if (mb_strlen($value, "UTF-8") == 0) { // We've only parsed an 'e' or 'E' throw new EasyRdf_Parser_Exception( "Turtle Parse Error: object for statement missing", @@ -1157,7 +1157,7 @@ protected function processComment() protected function read() { if (!empty($this->data)) { - $c = mb_substr($this->data, 0, 1); + $c = mb_substr($this->data, 0, 1, "UTF-8"); // Keep tracks of which line we are on (0A = Line Feed) if ($c == "\x0A") { $this->line += 1; @@ -1165,7 +1165,13 @@ protected function read() } else { $this->column += 1; } - $this->data = mb_substr($this->data, 1); + + if (version_compare(PHP_VERSION, '5.4.8', '<')) { + // versions of PHP prior to 5.4.8 treat "NULL" length parameter as 0 + $this->data = mb_substr($this->data, 1, mb_strlen($this->data), "UTF-8"); + } else { + $this->data = mb_substr($this->data, 1, null, "UTF-8"); + } return $c; } else { return -1; @@ -1180,7 +1186,7 @@ protected function read() protected function peek() { if (!empty($this->data)) { - return mb_substr($this->data, 0, 1); + return mb_substr($this->data, 0, 1, "UTF-8"); } else { return -1; } @@ -1194,7 +1200,7 @@ protected function peek() protected function unread($c) { # FIXME: deal with unreading new lines - $this->column -= mb_strlen($c); + $this->column -= mb_strlen($c, "UTF-8"); $this->data = $c . $this->data; } diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Resource.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Resource.php index e5d1e91afd34ae13f6650dbb62e838f15642cf85..3cb2805edff9fe59d8a4214bd69937468118254b 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Resource.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Resource.php @@ -564,9 +564,22 @@ public function type() */ public function typeAsResource() { + $this->checkHasGraph(); return $this->graph->typeAsResource($this->uri); } + /** + * Get a list of types for a resource, as Resources. + * + * @return EasyRdf_Resource[] + * @throws EasyRdf_Exception + */ + public function typesAsResources() + { + $this->checkHasGraph(); + return $this->graph->typesAsResources($this->uri); + } + /** Check if a resource is of the specified type * * @param string $type The type to check (e.g. foaf:Person) diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Json.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Json.php index bc0ae7a41cffa1ece0a0c484e7e8852e6c0374b7..2ff3f5983913914ce48945ae3d2e1272154c7a75 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Json.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Json.php @@ -49,6 +49,7 @@ class EasyRdf_Serialiser_Json extends EasyRdf_Serialiser_RdfPhp * Method to serialise an EasyRdf_Graph to RDF/JSON * * http://n2.talis.com/wiki/RDF_JSON_Specification + * docs/appendix-a-rdf-formats-json.md * * @param EasyRdf_Graph $graph An EasyRdf_Graph object. * @param string $format The name of the format to convert to. diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/JsonLd_real.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/JsonLd_real.php index a744f0f08461835c1cd15527cc07638753aeff5d..4fb6c49da1880fccd9129e8778306820cf77a72f 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/JsonLd_real.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/JsonLd_real.php @@ -115,10 +115,16 @@ public function serialise($graph, $format, array $options = array()) // OPTIONS $use_native_types = !(isset($options['expand_native_types']) and $options['expand_native_types'] == true); $should_compact = (isset($options['compact']) and $options['compact'] == true); + $should_frame = isset($options['frame']); // expanded form $data = $ld_graph->toJsonLd($use_native_types); + if ($should_frame) { + $data = \ML\JsonLD\JsonLD::frame($data, $options['frame'], $options); + + } + if ($should_compact) { // compact form $compact_context = isset($options['context']) ? $options['context'] : null; diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/RdfPhp.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/RdfPhp.php index 7ec80b031bcf274378ad4c159874e100ecb920a0..ed851af260199720d969a6505e0a2b43033b0fa2 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/RdfPhp.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/RdfPhp.php @@ -49,6 +49,7 @@ class EasyRdf_Serialiser_RdfPhp extends EasyRdf_Serialiser * Method to serialise an EasyRdf_Graph to RDF/PHP * * http://n2.talis.com/wiki/RDF_PHP_Specification + * docs/appendix-a-rdf-formats-php.md * * @param EasyRdf_Graph $graph An EasyRdf_Graph object. * @param string $format The name of the format to convert to. diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/RdfXml.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/RdfXml.php index d4485789aab392d056b63f8767b5362b7576fd5f..289d7dcfe9b09153c72e87388e4f0013f3bcacaf 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/RdfXml.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/RdfXml.php @@ -56,12 +56,17 @@ class EasyRdf_Serialiser_RdfXml extends EasyRdf_Serialiser protected function rdfxmlObject($property, $obj, $depth) { $indent = str_repeat(' ', $depth); + + if ($property[0] === ':') { + $property = substr($property, 1); + } + if (is_object($obj) and $obj instanceof EasyRdf_Resource) { $pcount = count($obj->propertyUris()); $rpcount = $this->reversePropertyCount($obj); $alreadyOutput = isset($this->outputtedResources[$obj->getUri()]); - $tag = "$indent<$property"; + $tag = "{$indent}<{$property}"; if ($obj->isBNode()) { if ($alreadyOutput or $rpcount > 1 or $pcount == 0) { $tag .= " rdf:nodeID=\"".htmlspecialchars($obj->getBNodeId()).'"'; @@ -104,7 +109,7 @@ protected function rdfxmlObject($property, $obj, $depth) $value = htmlspecialchars(strval($obj)); } - return "$indent<$property$atrributes>$value</$property>\n"; + return "{$indent}<{$property}{$atrributes}>{$value}</{$property}>\n"; } else { throw new EasyRdf_Exception( "Unable to serialise object to xml: ".getType($obj) @@ -159,7 +164,7 @@ protected function rdfxmlResource($res, $showNodeId, $depth = 1) if ($short) { $this->addPrefix($short); $objects = $res->all("<$property>"); - if ($short == 'rdf:type') { + if ($short == 'rdf:type' && $type != 'rdf:Description') { array_shift($objects); } foreach ($objects as $object) { @@ -224,10 +229,16 @@ public function serialise($graph, $format, array $options = array()) $namespaceStr = ''; foreach ($this->prefixes as $prefix => $count) { $url = EasyRdf_Namespace::get($prefix); + if (strlen($namespaceStr)) { $namespaceStr .= "\n "; } - $namespaceStr .= ' xmlns:'.$prefix.'="'.htmlspecialchars($url).'"'; + + if (strlen($prefix) === 0) { + $namespaceStr .= ' xmlns="'.htmlspecialchars($url).'"'; + } else { + $namespaceStr .= ' xmlns:'.$prefix.'="'.htmlspecialchars($url).'"'; + } } return "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n". diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php index 0a89d38cd87a68ea980ee755e3d44c9d12cc1b87..b268201a0bc68eb0655cd84b60fa05214daaf254 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Turtle.php @@ -71,7 +71,7 @@ public static function escapeIri($resourceIri) */ public static function quotedString($value) { - if (preg_match("/[\t\n\r]/", $value)) { + if (preg_match('/[\t\n\r]/', $value)) { $escaped = str_replace(array('\\', '"""'), array('\\\\', '\\"""'), $value); return '"""'.$escaped.'"""'; } else { @@ -94,18 +94,19 @@ public function serialiseResource($resource, $createNamespace = false) if (is_object($resource)) { if ($resource->isBNode()) { return $resource->getUri(); - } else { - $resource = $resource->getUri(); } + + $resource = $resource->getUri(); } $short = EasyRdf_Namespace::shorten($resource, $createNamespace); + if ($short) { $this->addPrefix($short); return $short; - } else { - return self::escapeIri($resource); } + + return self::escapeIri($resource); } /** @@ -125,11 +126,11 @@ public function serialiseLiteral($literal) if ($datatype == 'http://www.w3.org/2001/XMLSchema#integer') { return sprintf('%d', $value); } elseif ($datatype == 'http://www.w3.org/2001/XMLSchema#decimal') { - return sprintf('%g', $value); + return sprintf('%s', $value); } elseif ($datatype == 'http://www.w3.org/2001/XMLSchema#double') { return sprintf('%e', $value); } elseif ($datatype == 'http://www.w3.org/2001/XMLSchema#boolean') { - return sprintf('%s', $value ? 'true' : 'false'); + return sprintf('%s', $value); } else { $escaped = $this->serialiseResource($datatype, true); return sprintf('%s^^%s', $quoted, $escaped); @@ -284,7 +285,7 @@ protected function serialisePrefixes() /** * @ignore */ - protected function serialiseSubjects($graph, $filterType) + protected function serialiseSubjects(EasyRdf_Graph $graph, $filterType) { $turtle = ''; foreach ($graph->resources() as $resource) { @@ -303,17 +304,19 @@ protected function serialiseSubjects($graph, $filterType) if ($thisType == 'bnode') { $id = $resource->getBNodeId(); + if (isset($this->outputtedBnodes[$id])) { // Already been serialised continue; + } + + $this->outputtedBnodes[$id] = true; + $rpcount = $this->reversePropertyCount($resource); + + if ($rpcount == 0) { + $turtle .= '[]'; } else { - $this->outputtedBnodes[$id] = true; - $rpcount = $this->reversePropertyCount($resource); - if ($rpcount == 0) { - $turtle .= '[]'; - } else { - $turtle .= $this->serialiseResource($resource); - } + $turtle .= $this->serialiseResource($resource); } } else { $turtle .= $this->serialiseResource($resource); diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Client.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Client.php index 2cf9ad55808dec1a3e8c9f504634405404f7d362..5f97138a81cd5d544b05dd45c952205a5158ef03 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Client.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Sparql/Client.php @@ -47,13 +47,11 @@ class EasyRdf_Sparql_Client /** The query/read address of the SPARQL Endpoint */ private $queryUri = null; + private $queryUri_has_params = false; + /** The update/write address of the SPARQL Endpoint */ private $updateUri = null; - /** Configuration settings */ - private $config = array(); - - /** Create a new SPARQL endpoint client * * If the query and update endpoints are the same, then you @@ -65,6 +63,13 @@ class EasyRdf_Sparql_Client public function __construct($queryUri, $updateUri = null) { $this->queryUri = $queryUri; + + if (strlen(parse_url($queryUri, PHP_URL_QUERY)) > 0) { + $this->queryUri_has_params = true; + } else { + $this->queryUri_has_params = false; + } + if ($updateUri) { $this->updateUri = $updateUri; } else { @@ -209,7 +214,7 @@ public function clear($graphUri, $silent = false) if ($silent) { $query .= " SILENT"; } - if (preg_match("/^all|named|default$/i", $graphUri)) { + if (preg_match('/^all|named|default$/i', $graphUri)) { $query .= " $graphUri"; } else { $query .= " GRAPH <$graphUri>"; @@ -255,8 +260,10 @@ protected function request($type, $query) // 2046 = 2kB minus 1 for '?' and 1 for NULL-terminated string on server $encodedQuery = 'query='.urlencode($prefixes . $query); if (strlen($encodedQuery) + strlen($this->queryUri) <= 2046) { + $delimiter = $this->queryUri_has_params ? '&' : '?'; + $client->setMethod('GET'); - $client->setUri($this->queryUri.'?'.$encodedQuery); + $client->setUri($this->queryUri.$delimiter.$encodedQuery); } else { // Fall back to POST instead (which is un-cacheable) $client->setMethod('POST'); diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Utils.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Utils.php index 1c2d7dde620ffa41fe2b084f35a0d4a4944af9f4..d8542522fd6324f968dd4fc9d5ab667adeb7620c 100644 --- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Utils.php +++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Utils.php @@ -61,7 +61,7 @@ class EasyRdf_Utils public static function camelise($str) { $cc = ''; - foreach (preg_split("/[\W_]+/", $str) as $part) { + foreach (preg_split('/[\W_]+/', $str) as $part) { $cc .= ucfirst(strtolower($part)); } return $cc; @@ -210,7 +210,7 @@ public static function parseMimeType($mimeType) $type = trim(array_shift($parts)); $params = array(); foreach ($parts as $part) { - if (preg_match("/^\s*(\w+)\s*=\s*(.+?)\s*$/", $part, $matches)) { + if (preg_match('/^\s*(\w+)\s*=\s*(.+?)\s*$/', $part, $matches)) { $params[$matches[1]] = $matches[2]; } }