本文整理汇总了PHP中ARC2::inc方法的典型用法代码示例。如果您正苦于以下问题:PHP ARC2::inc方法的具体用法?PHP ARC2::inc怎么用?PHP ARC2::inc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARC2
的用法示例。
在下文中一共展示了ARC2::inc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
function parse($path, $data = '')
{
$this->state = 0;
/* reader */
if (!$this->v('reader')) {
ARC2::inc('Reader');
$this->reader =& new ARC2_Reader($this->a, $this);
}
$this->reader->setAcceptHeader('Accept: sparql-results+xml; q=0.9, */*; q=0.1');
$this->reader->activate($path, $data);
$this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base;
/* xml parser */
$this->initXMLParser();
/* parse */
$first = true;
while ($d = $this->reader->readStream()) {
if (!xml_parse($this->xml_parser, $d, false)) {
$error_str = xml_error_string(xml_get_error_code($this->xml_parser));
$line = xml_get_current_line_number($this->xml_parser);
$this->tmp_error = 'XML error: "' . $error_str . '" at line ' . $line . ' (parsing as ' . $this->getEncoding() . ')';
return $this->addError($this->tmp_error);
}
}
$this->target_encoding = xml_parser_get_option($this->xml_parser, XML_OPTION_TARGET_ENCODING);
xml_parser_free($this->xml_parser);
$this->reader->closeStream();
return $this->done();
}
示例2: runQuery
function runQuery($infos, $keep_bnode_ids = 0)
{
$this->infos = $infos;
$con = $this->store->getDBCon();
ARC2::inc('StoreDumper');
$d = new ARC2_StoreDumper($this->a, $this->store);
$d->dumpSPOG();
return 1;
}
示例3: parse
function parse($path, $data = '', $iso_fallback = false)
{
/* reader */
if (!$this->v('reader')) {
ARC2::inc('Reader');
$this->reader = new ARC2_Reader($this->a, $this);
}
$this->reader->setAcceptHeader('Accept: application/rdf+xml; q=0.9, */*; q=0.1');
$this->reader->activate($path, $data);
$this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base;
/* xml parser */
$this->initXMLParser();
/* parse */
$first = true;
while ($d = $this->reader->readStream()) {
if (!$this->keep_time_limit) {
@set_time_limit($this->v('time_limit', 60, $this->a));
}
if ($iso_fallback && $first) {
$d = '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n" . preg_replace('/^\\<\\?xml [^\\>]+\\?\\>\\s*/s', '', $d);
$first = false;
}
preg_match_all('/<<<(.+?\\s*?)*?>>>/', $d, $res);
if (isset($res)) {
foreach ($res[0] as $templ) {
$key = 'template_' . count($this->templates);
$this->templates[$key] = str_replace('<<<', '', str_replace('>>>', '', $templ));
$d = str_replace($templ, $key, $d);
}
}
if (!xml_parse($this->xml_parser, $d, false)) {
$error_str = xml_error_string(xml_get_error_code($this->xml_parser));
$line = xml_get_current_line_number($this->xml_parser);
$this->tmp_error = 'XML error: "' . $error_str . '" at line ' . $line . ' (parsing as ' . $this->getEncoding() . ')';
if (!$iso_fallback && preg_match("/Invalid character/i", $error_str)) {
xml_parser_free($this->xml_parser);
unset($this->xml_parser);
$this->reader->closeStream();
$this->__init();
$this->encoding = 'ISO-8859-1';
unset($this->xml_parser);
unset($this->reader);
return $this->parse($path, $data, true);
} else {
return $this->addError($this->tmp_error);
}
}
}
$this->target_encoding = xml_parser_get_option($this->xml_parser, XML_OPTION_TARGET_ENCODING);
xml_parser_free($this->xml_parser);
$this->reader->closeStream();
unset($this->reader);
return $this->done();
}
示例4: setNegotiators
public function setNegotiators()
{
if ($handle = opendir('./')) {
while (false !== ($file = readdir($handle))) {
if (substr($file, 0, 12) == 'negotiators_' && $file != 'negotiators_DataNegotiatorPlugin' && substr($file, -1) != '~') {
ARC2::inc(rtrim($file, '.php'));
$this->negotiators[] = rtrim($file, '.php');
}
}
closedir($handle);
}
}
示例5: testInc
public function testInc()
{
$actual = ARC2::inc('Class');
$this->assertNotEquals(0, $actual);
$actual = ARC2::inc('RDFParser');
$this->assertNotEquals(0, $actual);
$actual = ARC2::inc('ARC2_RDFParser');
$this->assertNotEquals(0, $actual);
$actual = ARC2::inc('Foo');
$this->assertEquals(0, $actual);
$actual = ARC2::inc('Vendor_Foo');
$this->assertEquals(0, $actual);
}
示例6: runQuery
function runQuery($infos, $keep_bnode_ids = 0)
{
$this->infos = $infos;
$con = $this->store->getDBCon();
/* insert */
if (!$this->v('pattern', array(), $this->infos['query'])) {
return $this->store->insert($this->infos['query']['construct_triples'], $this->infos['query']['target_graph'], $keep_bnode_ids);
} else {
ARC2::inc('StoreConstructQueryHandler');
$h =& new ARC2_StoreConstructQueryHandler($this->a, $this->store);
$sub_r = $h->runQuery($this->infos);
return $this->store->insert($sub_r, $this->infos['query']['target_graph'], $keep_bnode_ids);
}
}
示例7: parse
function parse($path, $data = '', $iso_fallback = false)
{
$this->nodes = array();
$this->node_count = 0;
$this->level = 0;
/* reader */
if (!$this->v('reader')) {
ARC2::inc('Reader');
$this->reader = new ARC2_Reader($this->a, $this);
}
$this->reader->setAcceptHeader('Accept: application/xml; q=0.9, */*; q=0.1');
$this->reader->activate($path, $data);
$this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base;
$this->base = $this->x_base;
$this->doc_url = $this->reader->base;
/* xml parser */
$this->initXMLParser();
/* parse */
$first = true;
while ($d = $this->reader->readStream(1)) {
if ($iso_fallback && $first) {
$d = '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n" . preg_replace('/^\\<\\?xml [^\\>]+\\?\\>\\s*/s', '', $d);
}
if (!xml_parse($this->xml_parser, $d, false)) {
$error_str = xml_error_string(xml_get_error_code($this->xml_parser));
$line = xml_get_current_line_number($this->xml_parser);
if (!$iso_fallback && preg_match("/Invalid character/i", $error_str)) {
xml_parser_free($this->xml_parser);
unset($this->xml_parser);
$this->reader->closeStream();
unset($this->reader);
$this->__init();
$this->encoding = 'ISO-8859-1';
$this->initXMLParser();
return $this->parse($path, $data, true);
} else {
return $this->addError('XML error: "' . $error_str . '" at line ' . $line . ' (parsing as ' . $this->getEncoding() . ')');
}
}
$first = false;
}
$this->target_encoding = xml_parser_get_option($this->xml_parser, XML_OPTION_TARGET_ENCODING);
xml_parser_free($this->xml_parser);
$this->reader->closeStream();
unset($this->reader);
return $this->done();
}
示例8: parse
function parse($path, $data = '')
{
/* reader */
if (!isset($this->reader)) {
ARC2::inc('Reader');
$this->reader =& new ARC2_Reader($this->a, $this);
}
$this->reader->activate($path, $data);
/* format detection */
$mappings = array('rdfxml' => 'RDFXML', 'turtle' => 'Turtle', 'sparqlxml' => 'SPOG', 'ntriples' => 'Turtle', 'html' => 'SemHTML', 'rss' => 'RSS', 'atom' => 'Atom', 'sgajson' => 'SGAJSON', 'cbjson' => 'CBJSON');
$format = $this->reader->getFormat();
if (!$format || !isset($mappings[$format])) {
return $this->addError('No parser available for "' . $format . '".');
}
/* format parser */
$suffix = $mappings[$format] . 'Parser';
ARC2::inc($suffix);
$cls = 'ARC2_' . $suffix;
$this->parser =& new $cls($this->a, $this);
$this->parser->setReader($this->reader);
return $this->parser->parse($path, $data);
}
示例9: parse
function parse($path, $data = '')
{
$this->state = 0;
/* reader */
if (!$this->v('reader')) {
ARC2::inc('Reader');
$this->reader =& new ARC2_Reader($this->a, $this);
}
$this->reader->setAcceptHeader('Accept: application/json; q=0.9, */*; q=0.1');
$this->reader->activate($path, $data);
$this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base;
/* parse */
$doc = '';
while ($d = $this->reader->readStream()) {
$doc .= $d;
}
$this->reader->closeStream();
$doc = preg_replace('/^[^\\{]*(.*\\})[^\\}]*$/is', '\\1', $doc);
$this->unparsed_code = $doc;
list($this->struct, $rest) = $this->extractObject($doc);
return $this->done();
}
示例10: runQuery
function runQuery($infos, $keep_bnode_ids = 0)
{
$this->infos = $infos;
$con = $this->store->getDBCon();
/* insert */
if (!$this->v('pattern', array(), $this->infos['query'])) {
$triples = $this->infos['query']['construct_triples'];
/* don't execute empty INSERTs as they trigger a LOAD on the graph URI */
if ($triples) {
return $this->store->insert($triples, $this->infos['query']['target_graph'], $keep_bnode_ids);
} else {
return array('t_count' => 0, 'load_time' => 0);
}
} else {
$keep_bnode_ids = 1;
ARC2::inc('StoreConstructQueryHandler');
$h = new ARC2_StoreConstructQueryHandler($this->a, $this->store);
$sub_r = $h->runQuery($this->infos);
if ($sub_r) {
return $this->store->insert($sub_r, $this->infos['query']['target_graph'], $keep_bnode_ids);
}
return array('t_count' => 0, 'load_time' => 0);
}
}
示例11: extractRDF
<?php
/*
homepage: http://arc.semsol.org/
license: http://arc.semsol.org/license
class: ARC2 DC Extractor
author: Benjamin Nowack
version: 2010-11-16
*/
ARC2::inc('RDFExtractor');
class ARC2_DcExtractor extends ARC2_RDFExtractor
{
function __construct($a, &$caller)
{
parent::__construct($a, $caller);
}
function __init()
{
parent::__init();
$this->a['ns']['dc'] = 'http://purl.org/dc/elements/1.1/';
}
/* */
function extractRDF()
{
$t_vals = array();
$t = '';
foreach ($this->nodes as $n) {
foreach (array('title', 'link', 'meta') as $tag) {
if ($n['tag'] == $tag) {
$m = 'extract' . ucfirst($tag);
示例12: getComponent
function getComponent($name, $a = '')
{
ARC2::inc($name);
$prefix = 'ARC2';
if (preg_match('/^([^\\_]+)\\_(.+)$/', $name, $m)) {
$prefix = $m[1];
$name = $m[2];
}
$cls = $prefix . '_' . $name;
return new $cls($a, new stdClass());
}
示例13: handleQueryRequest
function handleQueryRequest($q)
{
if (preg_match('/^dump/i', $q)) {
$infos = array('query' => array('type' => 'dump'));
$this->is_dump = 1;
} else {
ARC2::inc('SPARQLPlusParser');
$p = new ARC2_SPARQLPlusParser($this->a, $this);
$p->parse($q);
$infos = $p->getQueryInfos();
}
/* errors? */
if ($errors = $this->getErrors()) {
$this->setHeader('http', 'HTTP/1.1 400 Bad Request');
$this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
$this->result = htmlspecialchars(join("\n", $errors));
return true;
}
$qt = $infos['query']['type'];
/* wrong read key? */
if ($this->read_key && $this->p('key') != $this->read_key && preg_match('/^(select|ask|construct|describe|dump)$/', $qt)) {
$this->setHeader('http', 'HTTP/1.1 401 Access denied');
$this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
$this->result = 'Access denied. Missing or wrong "key" parameter.';
return true;
}
/* wrong write key? */
if ($this->write_key && $this->p('key') != $this->write_key && preg_match('/^(load|insert|delete|update)$/', $qt)) {
$this->setHeader('http', 'HTTP/1.1 401 Access denied');
$this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
$this->result = 'Access denied. Missing or wrong "key" parameter.';
return true;
}
/* non-allowed query type? */
if (!in_array($qt, $this->getFeatures())) {
$this->setHeader('http', 'HTTP/1.1 401 Access denied');
$this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
$this->result = 'Access denied for "' . $qt . '" query';
return true;
}
/* load/insert/delete via GET */
if (in_array($qt, array('load', 'insert', 'delete')) && isset($_GET['query'])) {
$this->setHeader('http', 'HTTP/1.1 501 Not Implemented');
$this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
$this->result = 'Query type "' . $qt . '" not supported via GET';
return true;
}
/* unsupported query type */
if (!in_array($qt, array('select', 'ask', 'describe', 'construct', 'load', 'insert', 'delete', 'dump'))) {
$this->setHeader('http', 'HTTP/1.1 501 Not Implemented');
$this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
$this->result = 'Unsupported query type "' . $qt . '"';
return true;
}
/* adjust infos */
$infos = $this->adjustQueryInfos($infos);
$t1 = ARC2::mtime();
$r = array('result' => $this->runQuery($infos, $qt));
$t2 = ARC2::mtime();
$r['query_time'] = $t2 - $t1;
/* query errors? */
if ($errors = $this->getErrors()) {
$this->setHeader('http', 'HTTP/1.1 400 Bad Request');
$this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
$this->result = 'Error: ' . join("\n", $errors);
return true;
}
/* result */
$m = 'get' . ucfirst($qt) . 'ResultDoc';
if (method_exists($this, $m)) {
$this->result = $this->{$m}($r);
} else {
$this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
$this->result = 'Result serializer not available, dumping raw data:' . "\n" . print_r($r, 1);
}
}
示例14: substr
<?php
/**
* ARC2 SPARQL Parser
*
* @author Benjamin Nowack
* @license <http://arc.semsol.org/license>
* @homepage <http://arc.semsol.org/>
* @package ARC2
* @version 2010-11-16
*/
ARC2::inc('TurtleParser');
class ARC2_SPARQLParser extends ARC2_TurtleParser
{
function __construct($a, &$caller)
{
parent::__construct($a, $caller);
}
function __init()
{
parent::__init();
$this->bnode_prefix = $this->v('bnode_prefix', 'arc' . substr(md5(uniqid(rand())), 0, 4) . 'b', $this->a);
$this->bnode_id = 0;
$this->bnode_pattern_index = array('patterns' => array(), 'bnodes' => array());
}
/* */
function parse($q, $src = '', $iso_fallback = 'ignore')
{
$this->setDefaultPrefixes();
$this->base = $src ? $this->calcBase($src) : ARC2::getRequestURI();
$this->r = array('base' => '', 'vars' => array(), 'prefixes' => array());
示例15: toHTML
function toHTML($v, $ns = '')
{
ARC2::inc('MicroRDFSerializer');
if (!$ns) {
$ns = isset($this->a['ns']) ? $this->a['ns'] : array();
}
$ser = new ARC2_MicroRDFSerializer(array_merge($this->a, array('ns' => $ns)), $this);
return isset($v[0]) && isset($v[0]['s']) ? $ser->getSerializedTriples($v) : $ser->getSerializedIndex($v);
}