当前位置: 首页>>代码示例>>PHP>>正文


PHP EasyRdf_Graph::newBNode方法代码示例

本文整理汇总了PHP中EasyRdf_Graph::newBNode方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Graph::newBNode方法的具体用法?PHP EasyRdf_Graph::newBNode怎么用?PHP EasyRdf_Graph::newBNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EasyRdf_Graph的用法示例。


在下文中一共展示了EasyRdf_Graph::newBNode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     if (PHP_MAJOR_VERSION < 5 or PHP_MAJOR_VERSION == 5 and PHP_MINOR_VERSION < 3) {
         $this->markTestSkipped("JSON-LD support requires PHP 5.3+");
     }
     if (!class_exists('\\ML\\JsonLD\\JsonLD')) {
         $this->markTestSkipped('"ml/json-ld" dependency is not installed');
     }
     $this->graph = new EasyRdf_Graph('http://example.com/');
     $this->serialiser = new EasyRdf_Serialiser_JsonLd();
     $joe = $this->graph->resource('http://www.example.com/joe#me', 'foaf:Person');
     $joe->set('foaf:name', new EasyRdf_Literal('Joe Bloggs', 'en'));
     $joe->set('foaf:age', 59);
     $joe->set('foaf:homepage', $this->graph->resource('http://foo/bar/me'));
     $project = $this->graph->newBNode();
     $project->add('foaf:name', 'Project Name');
     $joe->add('foaf:project', $project);
     EasyRdf_Namespace::set('dc', 'http://purl.org/dc/elements/1.1/');
     EasyRdf_Namespace::set('ex', 'http://example.org/vocab#');
     EasyRdf_Namespace::set('xsd', 'http://www.w3.org/2001/XMLSchema#');
     EasyRdf_Namespace::set('', 'http://foo/bar/');
     $chapter = $this->graph->resource('http://example.org/library/the-republic#introduction', 'ex:Chapter');
     $chapter->set('dc:description', new EasyRdf_Literal('An introductory chapter on The Republic.'));
     $chapter->set('dc:title', new EasyRdf_Literal('The Introduction'));
     $book = $this->graph->resource('http://example.org/library/the-republic', 'ex:Book');
     $book->set('dc:creator', new EasyRdf_Literal('Plato'));
     $book->set('dc:title', new EasyRdf_Literal('The Republic'));
     $book->addResource('ex:contains', $chapter);
     $library = $this->graph->resource('http://example.org/library', 'ex:Library');
     $library->addResource('ex:contains', $book);
 }
开发者ID:takin,项目名称:workshop-semantic-web,代码行数:31,代码来源:JsonLdTest.php

示例2: testNewBNode

 public function testNewBNode()
 {
     $graph = new EasyRdf_Graph();
     $bnodeOne = $graph->newBNode();
     $this->assertEquals('_:genid1', $bnodeOne->getUri());
     $bnodeTwo = $graph->newBNode();
     $this->assertEquals('_:genid2', $bnodeTwo->getUri());
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:8,代码来源:GraphTest.php

示例3: convert_to_rdf

function convert_to_rdf($path)
{
    //get processed array
    $uris = get_uris();
    $result = process_spreadsheet($path);
    init_vocabularies();
    global $voc_keys;
    $root = new EasyRdf_Graph();
    $courses = $root->newBNode('rdf:Seq');
    //create container
    //iterate through array and create nodes
    foreach ($result as $key => $value) {
        $resource_uri = $uris[$key];
        $temp_cours = new EasyRdf_Resource($resource_uri, $root);
        $courses->append($temp_cours);
        foreach ($value as $propName => $propValue) {
            if ($propName == null || $propName == "" || $propName == "id") {
                continue;
            }
            $predicate_url = $voc_keys[$propName];
            //add to resource predicate with property. probably addLiteral method
            $temp_cours->addLiteral($predicate_url, $propValue);
        }
    }
    return $root->serialise("rdfxml");
}
开发者ID:aw3s0me,项目名称:RDF_Parser,代码行数:26,代码来源:convert.php

示例4: setUp

 public function setUp()
 {
     if (PHP_MAJOR_VERSION < 5 or PHP_MAJOR_VERSION >= 5 and PHP_MINOR_VERSION < 3) {
         $this->markTestSkipped("JSON-LD support requires PHP 5.3+");
     }
     if (!class_exists('\\ML\\JsonLD\\JsonLD')) {
         $this->markTestSkipped('"ml/json-ld" dependency is not installed');
     }
     $this->graph = new EasyRdf_Graph('http://example.com/');
     $this->serialiser = new EasyRdf_Serialiser_JsonLd();
     $joe = $this->graph->resource('http://www.example.com/joe#me', 'foaf:Person');
     $joe->set('foaf:name', new EasyRdf_Literal('Joe Bloggs', 'en'));
     $joe->set('foaf:age', 59);
     $project = $this->graph->newBNode();
     $project->add('foaf:name', 'Project Name');
     $joe->add('foaf:project', $project);
 }
开发者ID:gitter-badger,项目名称:mexproject,代码行数:17,代码来源:JsonLdTest.php

示例5:

$composer = json_decode(file_get_contents('composer.json'));
// Start building up a RDF graph
$doap = new EasyRdf_Graph($composer->homepage . 'doap.rdf');
$easyrdf = $doap->resource('#easyrdf', 'doap:Project', 'foaf:Project');
$easyrdf->addLiteral('doap:name', 'EasyRDF');
$easyrdf->addLiteral('doap:shortname', 'easyrdf');
$easyrdf->addLiteral('doap:revision', $composer->version);
$easyrdf->addLiteral('doap:shortdesc', $composer->description, 'en');
$easyrdf->addResource('doap:homepage', $composer->homepage);
$easyrdf->addLiteral('doap:programming-language', 'PHP');
$easyrdf->addLiteral('doap:description', 'EasyRdf is a PHP library designed to make it easy to consume and produce RDF. ' . 'It was designed for use in mixed teams of experienced and inexperienced RDF developers. ' . 'It is written in Object Oriented PHP and has been tested extensively using PHPUnit.', 'en');
$easyrdf->addResource('doap:license', 'http://usefulinc.com/doap/licenses/bsd');
$easyrdf->addResource('doap:download-page', 'http://github.com/njh/easyrdf/downloads');
$easyrdf->addResource('doap:download-page', 'http://github.com/njh/easyrdf/downloads');
$easyrdf->addResource('doap:bug-database', 'http://github.com/njh/easyrdf/issues');
$easyrdf->addResource('doap:mailing-list', 'http://groups.google.com/group/easyrdf');
$easyrdf->addResource('doap:category', 'http://dbpedia.org/resource/Resource_Description_Framework');
$easyrdf->addResource('doap:category', 'http://dbpedia.org/resource/PHP');
$easyrdf->addResource('doap:category', 'http://dbpedialite.org/things/24131#id');
$easyrdf->addResource('doap:category', 'http://dbpedialite.org/things/53847#id');
$repository = $doap->newBNode('doap:GitRepository');
$repository->addResource('doap:browse', 'http://github.com/njh/easyrdf');
$repository->addResource('doap:location', 'git://github.com/njh/easyrdf.git');
$easyrdf->addResource('doap:repository', $repository);
$njh = $doap->resource('http://njh.me/', 'foaf:Person');
$njh->addLiteral('foaf:name', 'Nicholas J Humfrey');
$njh->addResource('foaf:homepage', 'http://www.aelius.com/njh/');
$easyrdf->add('doap:maintainer', $njh);
$easyrdf->add('doap:developer', $njh);
$easyrdf->add('foaf:maker', $njh);
print $doap->serialise('rdfxml');
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:doap.php

示例6: outputRDF

 /**
  * Output data in RDF and Turtle format
  *
  * @param array   $data       The items to output
  * @param string  $format     The output format
  * @param string  $predicate  The predicate for the list
  * @param string  $namespaces An associative array with the namespace, e.g. [ 'foaf' => 'http://xmlns.com/foaf/0.1/' ].
  *                            Note that EasyRDF already adds the standard prefixes, such as dc, foaf, etc.
  * @param integer $status     HTTP status code
  *
  * @uses \EasyRdf_Graph
  *
  * @throws \SameAsLite\Exception\ContentTypeException An exception may be thrown if the requested MIME type
  * is not supported
  */
 protected function outputRDF(array $data = array(), $format = 'list', $predicate = 'owl:sameAs', array $namespaces = array(), $status = null)
 {
     // how to: escape
     // array_walk($list, '\SameAsLite\Helper::escapeInputArray');
     if (!is_null($status)) {
         $this->app->response->setStatus($status);
     }
     //end if
     // get the query parameters
     $symbol = $this->app->request()->params('string');
     if (!$symbol) {
         $symbol = $this->app->request()->params('symbol');
     }
     //end if
     $symbol = $symbol ? urldecode($symbol) : false;
     $store = $this->store ? $this->store : false;
     $storeurl = $this->app->request()->getURL() . $this->app->request()->getRootUri() . '/datasets/' . urlencode($store);
     // EASY RDF
     $graph = new \EasyRdf_Graph();
     //-----------
     // namespaces
     // ----------
     if (!empty($namespaces)) {
         foreach ($namespaces as $prefix => $uri) {
             \EasyRdf_Namespace::set($prefix, $uri);
         }
     }
     //-------------
     // result block
     // ------------
     if ($symbol && strpos($symbol, 'http') === 0) {
         $graph_uri = $meta_uri = $graph->resource($symbol);
     } else {
         $graph_uri = $graph->newBNode();
     }
     $result_block = $graph->resource($graph_uri);
     //-------------
     // meta block
     // ------------
     $meta_uri = $this->app->request()->getURL() . $_SERVER['REQUEST_URI'];
     $meta_block = $graph->resource($meta_uri);
     // if this part is added, EasyRDF will merge the result block with the meta block
     // $meta_block->add('foaf:primaryTopic', $graph->resource( '_:' . $result_block->getBNodeId() ));
     $meta_block->set('dc:creator', 'sameAsLite');
     // TODO: maybe also add info about store (storename, URI)?
     if ($store) {
         $meta_block->set('dc:source', $graph->resource($storeurl));
     }
     // $meta_block->set('dc:title', 'Co-references from sameAs.org for ' . $symbol);
     if (isset($this->appOptions['license']['url'])) {
         $meta_block->add('dct:license', $graph->resource($this->appOptions['license']['url']));
     }
     // list
     if ($format === 'list') {
         // simple list
         foreach ($data as $str) {
             if (strpos($str, 'http') === 0) {
                 // resource
                 $result_block->add($predicate, $graph->resource(urldecode($str)));
             } else {
                 // literal values - not technically correct, because sameAs expects a resource
                 // but validates in W3C Validator
                 $result_block->add($predicate, $str);
             }
         }
     } elseif ($format === 'table') {
         // table output
         // data is in the form of:
         // [ [header1, header2, ...], [row1_1, row1_2, ...], [row2_1, row2_2, ...] ]
         $preds = array_shift($data);
         foreach ($data as $arr) {
             // if (isset($val['url'])) {
             //     $url = $val['url'];
             //     unset($val['url']);
             // } else {
             //     $url = $graph_uri;
             // }
             $resources = array();
             for ($i = 0, $s = count($arr); $i < $s; $i++) {
                 $resources[$i] = $graph->resource($storeurl);
                 // TODO
                 for ($k = 0, $t = count($preds); $k < $t; $k++) {
                     if (strpos($arr[$i], 'http') === 0) {
                         // resource
                         $graph->addResource($resources[$i], $preds[$k], $graph->resource(urldecode($arr[$i])));
//.........这里部分代码省略.........
开发者ID:joetm,项目名称:sameAs-Lite,代码行数:101,代码来源:WebApp.php

示例7: addMetaTriples

 /**
  * Add void and hydra meta-data to an existing graph
  *
  * @param EasyRdf_Graph $graph    The graph to which meta data has to be added
  * @param integer       $count    The total amount of triples that match the URI
  *
  * @return EasyRdf_Graph $graph
  */
 public function addMetaTriples($graph, $limit, $offset, $count)
 {
     // Add the void and hydra namespace to the EasyRdf framework
     \EasyRdf_Namespace::set('hydra', 'http://www.w3.org/ns/hydra/core#');
     \EasyRdf_Namespace::set('void', 'http://rdfs.org/ns/void#');
     \EasyRdf_Namespace::set('dcterms', 'http://purl.org/dc/terms/');
     // Add the meta data semantics to the graph
     $root = \Request::root();
     $root .= '/';
     $base_uri = $root . 'all';
     $identifier = str_replace($root, '', $base_uri);
     $graph->addResource($base_uri . '#dataset', 'a', 'void:Dataset');
     $graph->addResource($base_uri . '#dataset', 'a', 'hydra:Collection');
     $resource = $graph->resource($base_uri);
     $subject_temp_mapping = $graph->newBNode();
     $subject_temp_mapping->addResource('a', 'hydra:IriTemplateMapping');
     $subject_temp_mapping->addLiteral('hydra:variable', 'subject');
     $subject_temp_mapping->addResource('hydra:property', 'rdf:subject');
     $predicate_temp_mapping = $graph->newBNode();
     $predicate_temp_mapping->addResource('a', 'hydra:IriTemplateMapping');
     $predicate_temp_mapping->addLiteral('hydra:variable', 'predicate');
     $predicate_temp_mapping->addResource('hydra:property', 'rdf:predicate');
     $object_temp_mapping = $graph->newBNode();
     $object_temp_mapping->addResource('a', 'hydra:IriTemplateMapping');
     $object_temp_mapping->addLiteral('hydra:variable', 'object');
     $object_temp_mapping->addResource('hydra:property', 'rdf:object');
     $iri_template = $graph->newBNode();
     $iri_template->addResource('a', 'hydra:IriTemplate');
     $iri_template->addLiteral('hydra:template', $root . 'all' . '{?subject,predicate,object}');
     $iri_template->addResource('hydra:mapping', $subject_temp_mapping);
     $iri_template->addResource('hydra:mapping', $predicate_temp_mapping);
     $iri_template->addResource('hydra:mapping', $object_temp_mapping);
     // Add the template to the requested URI resource in the graph
     $graph->addResource($base_uri . '#dataset', 'hydra:search', $iri_template);
     $is_deferenced = false;
     if (strtolower(\Request::segment(1)) != 'all') {
         $full_url = \Request::root() . '/' . \Request::path();
         $is_deferenced = true;
     } else {
         $full_url = $base_uri . '?';
     }
     $template_url = $full_url;
     $templates = array('subject', 'predicate', 'object');
     $has_param = false;
     $query_string = $_SERVER['QUERY_STRING'];
     $query_parts = explode('&', $query_string);
     foreach ($query_parts as $part) {
         if (!empty($part)) {
             $couple = explode('=', $part);
             if (strtolower($couple[0]) == 'subject') {
                 $template_url .= $couple[0] . '=' . $couple[1] . '&';
                 $has_param = true;
             }
             if (strtolower($couple[0]) == 'predicate') {
                 $template_url .= $couple[0] . '=' . $couple[1] . '&';
                 $has_param = true;
             }
             if (strtolower($couple[0]) == 'object') {
                 $template_url .= $couple[0] . '=' . $couple[1] . '&';
                 $has_param = true;
             }
             $full_url .= $couple[0] . '=' . $couple[1] . '&';
         }
     }
     $full_url = rtrim($full_url, '?');
     $full_url = rtrim($full_url, '&');
     $template_url = rtrim($template_url, '?');
     $template_url = rtrim($template_url, '&');
     $full_url = str_replace('#', '%23', $full_url);
     $template_url = str_replace('#', '%23', $template_url);
     if ($is_deferenced) {
         $full_url .= '#dataset';
     }
     // Add paging information
     $graph->addLiteral($full_url, 'hydra:totalItems', \EasyRdf_Literal::create($count, null, 'xsd:integer'));
     $graph->addLiteral($full_url, 'void:triples', \EasyRdf_Literal::create($count, null, 'xsd:integer'));
     $graph->addLiteral($full_url, 'hydra:itemsPerPage', \EasyRdf_Literal::create($limit, null, 'xsd:integer'));
     $graph->addResource($full_url, 'void:subset', \Request::root() . '/all#dataset');
     $paging_info = $this->getPagingInfo($limit, $offset, $count);
     foreach ($paging_info as $key => $info) {
         switch ($key) {
             case 'next':
                 if ($has_param) {
                     $glue = '&';
                 } else {
                     $glue = '?';
                 }
                 $graph->addResource($full_url, 'hydra:nextPage', $template_url . $glue . 'limit=' . $info['limit'] . '&offset=' . $info['offset']);
                 break;
             case 'previous':
                 if ($has_param) {
                     $glue = '&';
//.........这里部分代码省略.........
开发者ID:tdt,项目名称:triples,代码行数:101,代码来源:TripleRepository.php

示例8: foreach

 if (isset($_REQUEST['foaf:knows']) && strlen($_REQUEST['foaf:knows'][0]) > 0) {
     foreach ($_REQUEST['foaf:knows'] as $key => $person_uri) {
         if (strlen($person_uri) > 0) {
             $graph->addResource($me, 'foaf:knows', $person_uri);
         }
     }
 }
 // ----- pingback:to relation ----- //
 $graph->addResource($me, 'pingback:to', $base_uri . '/pingback.php');
 // certificates
 // write certificates' public keys (if we have more than one)
 foreach ($_REQUEST['modulus'] as $key => $val) {
     if (strlen($val) > 0) {
         $modulus = preg_replace('/\\s+/', '', $val);
         $exponent = strlen($_REQUEST['exponent'][$key]) > 0 ? trim($_REQUEST['exponent'][$key]) : '65537';
         $cert = $graph->newBNode('cert:RSAPublicKey');
         $cert->add('cert:modulus', array('type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#hexBinary', 'value' => $modulus));
         $cert->add('cert:exponent', array('type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#int', 'value' => $exponent));
         $me->add('cert:key', $cert);
     }
 }
 // ----- GENERATE CERTIFICATE ----- //
 // Do not generate a certificate if we're just editing the profile
 if ($_REQUEST["action"] == 'new') {
     // append other webids after the local one
     $foafLocation = array();
     $foafLocation[] = $webid;
     foreach ($_REQUEST['webid_uri'] as $val) {
         if (strlen($val) > 0) {
             $foafLocation[] = $val;
         }
开发者ID:ASDAFF,项目名称:myprofile,代码行数:31,代码来源:profile.php

示例9: buildGraphFromJsonRecipeResult

/**
 * Erzeugt einen Graph aus dem JSON Dokument der spezifischen Rezeptsuche.
 * 
 * @param Array $jsonObject        	
 * @return EasyRdf_Graph
 */
function buildGraphFromJsonRecipeResult($jsonObject)
{
    $baseURL = 'http://chefkoch.de/rezept/';
    //$wrapperURL = "http://chefkoch:8888/index.php/lookup/";
    $graph = new EasyRdf_Graph();
    $rezeptNamespace = new EasyRdf_Namespace();
    $rezeptNamespace->set('arecipe', "http://purl.org/amicroformat/arecipe/");
    $rezeptNamespace->set('rezept', "http://manke-hosting.de/ns-syntax#");
    $rezeptNamespace->set('wrapper', HOST . "index.php/lookup/");
    $rezeptNamespace->set('owl', "http://www.w3.org/2002/07/owl#");
    $rezeptNamespace->set('reweSuche', HOST . "index.php/reweSuche/");
    //$rezeptNamespace->set('reweSuche', "http://manke-hosting.de/wrapper/index.php/reweSuche/");
    //$rezeptNamespace->set('reweSuche', "http://localhost/wrapper/index.php/reweSuche/");
    $url = $baseURL . $jsonObject['rezept_show_id'];
    $me = $graph->resource($url, 'arecipe:Recipe');
    foreach ($jsonObject as $key => $value) {
        $type = gettype($value);
        $namespace = "rezept";
        if ($type == "string") {
            $me->set($namespace . ':' . $key, $value);
        } elseif ($type == "array" && !empty($value)) {
            switch ($key) {
                case 'rezept_videos':
                    // TODO
                    break;
                case 'rezept_bilder':
                    $bn = $graph->newBNode();
                    $me->set($namespace . ':' . $key, $bn);
                    buildTree($graph, $bn, $value, 'rezept');
                    break;
                case 'rezept_zutaten':
                    foreach ($value as $rezept_zutaten => $zutat) {
                        $bn = $graph->newBNode();
                        $me->add($namespace . ":" . $key, $bn);
                        foreach ($zutat as $attribut => $attributWert) {
                            if ($attribut == "name" && $zutat["id"] != "") {
                                $attributWert = $str = str_replace(array('ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü'), array('ae', 'oe', 'ue', 'ss', 'Ae', 'Oe', 'Ue'), $attributWert);
                                $attributWert = preg_replace('/[^a-zA-Z0-9]+/', '', $attributWert);
                                $bn->addResource('rezept:reweSuche', 'reweSuche:' . $attributWert);
                                $bn->addLiteral($namespace . ":" . $attribut, $attributWert);
                            } elseif ($attribut == "menge") {
                                $attributWert = str_replace(".", ",", $attributWert);
                                $bn->addLiteral($namespace . ":" . $attribut, $attributWert);
                            } else {
                                $bn->addLiteral($namespace . ":" . $attribut, $attributWert);
                            }
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }
    return $graph;
}
开发者ID:RaphaelManke,项目名称:chefkochWrapperToRDF,代码行数:62,代码来源:rezeptsuche.php

示例10: getBody


//.........这里部分代码省略.........
                     $view = 'dataset.tabular';
                     $data = $dataObj->data;
                 } else {
                     $view = 'dataset.code';
                     $data = self::displayTree($dataObj->data);
                 }
                 break;
             case 'SHP':
                 $view = 'dataset.map';
                 $data = $dataset_link . '.map' . $query_string;
                 break;
             case 'XML':
                 $view = 'dataset.code';
                 $data = self::displayTree($dataObj->data, 'xml');
                 break;
             default:
                 if ($dataObj->is_semantic) {
                     // This data object is always semantic
                     $view = 'dataset.turtle';
                     // Check if a configuration is given
                     $conf = array();
                     if (!empty($dataObj->semantic->conf)) {
                         $conf = $dataObj->semantic->conf;
                     }
                     $data = $dataObj->data->serialise('turtle');
                 } else {
                     $view = 'dataset.code';
                     $data = self::displayTree($dataObj->data);
                 }
                 break;
         }
     } elseif ($dataObj->is_semantic) {
         // The data object can be semantic without a specified source type
         $view = 'dataset.code';
         $data = $dataObj->data->serialise('turtle');
     } else {
         // Collection view
         $view = 'dataset.collection';
         $data = $dataObj->data;
     }
     // Gather meta-data to inject as a JSON-LD document so it can be picked up by search engines
     $definition = $dataObj->definition;
     $uri = \Request::root();
     $graph = new \EasyRdf_Graph();
     // Create the dataset uri
     $dataset_uri = $uri . "/" . $definition['collection_uri'] . "/" . $definition['resource_name'];
     $dataset_uri = str_replace(' ', '%20', $dataset_uri);
     // Add the dataset resource and its description
     $graph->addResource($dataset_uri, 'a', 'schema:Dataset');
     // Add the title to the dataset resource of the catalog
     if (!empty($definition['title'])) {
         $graph->addLiteral($dataset_uri, 'schema:headline', $definition['title']);
     }
     // Add the description, identifier, issues, modified of the dataset
     $graph->addLiteral($dataset_uri, 'schema:description', @$definition['description']);
     $graph->addLiteral($dataset_uri, 'schema:dateCreated', date(\DateTime::ISO8601, strtotime($definition['created_at'])));
     $graph->addLiteral($dataset_uri, 'schema:dateModified', date(\DateTime::ISO8601, strtotime($definition['updated_at'])));
     // Add the publisher resource to the dataset
     if (!empty($definition['publisher_name']) && !empty($definition['publisher_uri'])) {
         $graph->addResource($dataset_uri, 'schema:publisher', $definition['publisher_uri']);
     }
     // Optional dct terms
     $optional = array('date', 'language');
     $languages = \App::make('Tdt\\Core\\Repositories\\Interfaces\\LanguageRepositoryInterface');
     $licenses = \App::make('Tdt\\Core\\Repositories\\Interfaces\\LicenseRepositoryInterface');
     foreach ($optional as $dc_term) {
         if (!empty($definition[$dc_term])) {
             if ($dc_term == 'language') {
                 $lang = $languages->getByName($definition[$dc_term]);
                 if (!empty($lang)) {
                     $graph->addResource($dataset_uri, 'schema:inLanguage', 'http://lexvo.org/id/iso639-3/' . $lang['lang_id']);
                 }
             } else {
                 $graph->addLiteral($dataset_uri, 'schema:datasetTimeInterval', $definition[$dc_term]);
             }
         }
     }
     // Add the distribution of the dataset for SEO
     $format = '.json';
     if ($definition['source_type'] == 'ShpDefinition') {
         $format = '.geojson';
     }
     $dataDownload = $graph->newBNode();
     $graph->addResource($dataset_uri, 'schema:distribution', $dataDownload);
     $graph->addResource($dataDownload, 'a', 'schema:DataDownload');
     $graph->addResource($dataDownload, 'schema:contentUrl', $dataset_uri . $format);
     // Add the license to the distribution
     if (!empty($definition['rights'])) {
         $license = $licenses->getByTitle($definition['rights']);
         if (!empty($license) && !empty($license['url'])) {
             $graph->addResource($dataset_uri, 'schema:license', $license['url']);
         }
         if (!empty($license)) {
             $dataObj->definition['rights_uri'] = $license['url'];
         }
     }
     $jsonld = $graph->serialise('jsonld');
     // Render the view
     return \View::make($view)->with('title', 'Dataset: ' . $dataObj->definition['collection_uri'] . "/" . $dataObj->definition['resource_name'] . ' | The Datatank')->with('body', $data)->with('page_title', $dataObj->definition['collection_uri'] . "/" . $dataObj->definition['resource_name'])->with('definition', $dataObj->definition)->with('paging', $dataObj->paging)->with('source_definition', $dataObj->source_definition)->with('formats', $dataObj->formats)->with('dataset_link', $dataset_link)->with('prev_link', $prev_link)->with('next_link', $next_link)->with('query_string', $query_string)->with('json_ld', $jsonld);
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:101,代码来源:HTMLFormatter.php


注:本文中的EasyRdf_Graph::newBNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。