本文整理汇总了PHP中ARC2::getStructType方法的典型用法代码示例。如果您正苦于以下问题:PHP ARC2::getStructType方法的具体用法?PHP ARC2::getStructType怎么用?PHP ARC2::getStructType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARC2
的用法示例。
在下文中一共展示了ARC2::getStructType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArraySerialization
function getArraySerialization($v, $context)
{
$v_type = ARC2::getStructType($v);
/* string|array|triples|index */
$pf = ARC2::getPreferredFormat();
/* string */
if ($v_type == 'string') {
return $v;
}
/* simple array (e.g. from SELECT) */
if ($v_type == 'array') {
return join(', ', $v);
$m = method_exists($this, 'toLegacy' . $pf) ? 'toLegacy' . $pf : 'toLegacyXML';
}
/* rdf */
if ($v_type == 'triples' || $v_type == 'index') {
$m = method_exists($this, 'to' . $pf) ? 'to' . $pf : ($context == 'query' ? 'toNTriples' : 'toRDFXML');
}
/* else */
return $this->{$m}($v);
}
示例2: dot
/**
* Construct dot source file based on a query result.
*
* @param array $res
* @param array $infos
* @param String $format = 'dot'
* @return string
* @access public
*/
function dot($triples, $format = 'dot')
{
if (!in_array($format, array('dot', 'png', 'svg'))) {
return $this->addError('Unsupported format "' . $format . '"');
}
if (ARC2::getStructType($triples) != 'triples') {
return $this->addError('Input structure is not a triples array.');
}
$dot = 'digraph arc2 {' . "\n";
$ns = $this->v('ns', array(), $this->a);
$nsc = 0;
$dot .= '_ns_box_';
// dot general graph parameters
$dot .= 'rankdir=LR;' . 'ranksep=3;' . 'nodesep=0.3;' . "\n";
//$vars= & $res['variables'];
$nodes = array('uri' => array(), 'bnode' => array(), 'literal' => array());
$edges = array('uri' => array());
foreach ($triples as $i => $t) {
$type = isset($t['s type']) ? $t['s type'] : $t['s_type'];
if (!($s = array_search($t['s'], $nodes[$type]))) {
$s = 's' . $i;
switch ($type) {
case 'uri':
case 'bnode':
$nodes[$type][$s] =& $t['s'];
break;
default:
alert('Invalid type ' . $type);
return '';
}
}
$type = isset($t['o type']) ? $t['o type'] : $t['o_type'];
if (!($o = array_search($t['o'], $nodes[$type]))) {
$o = 'o' . $i;
switch ($type) {
case 'uri':
case 'bnode':
$nodes[$type][$o] =& $t['o'];
break;
case 'literal':
$nodes[$type][$o] =& $t['o'];
break;
default:
alert('Invalid type ' . $type);
return '';
}
}
/* p */
$type = 'uri';
switch ($type) {
case 'uri':
$edges[$type][] = array('label' => &$t['p'], 's' => $s, 'o' => $o);
break;
default:
alert('Invalid edge type ' . $type);
return '';
}
}
// dot uri parameters
$dot .= "node [shape=ellipse,fontsize=20,style=filled,fillcolor=limegreen];\n";
foreach ($nodes['uri'] as $i => $nd) {
$label = self::guessNamespace($nd);
$prefix = array_search($label, $ns);
if ($prefix) {
$label = self::guessName($nd);
$label = $label ? $prefix . ':' . $label : $nd;
} else {
$label = $nd;
}
$dot .= $i . '[label="' . $label . '"];' . "\n";
}
// dot blanknode parameters
$dot .= "node [fillcolor=greenyellow];\n";
foreach ($nodes['bnode'] as $i => $nd) {
$dot .= $i . ';' . "\n";
}
// dot literal parameters
$dot .= "node [shape=box,fontsize=20,style=filled,fillcolor=orange];\n";
foreach ($nodes['literal'] as $i => $nd) {
$label = substr(strip_tags($nd), 0, 80);
$dot .= $i . '[label="' . $label . '"];' . "\n";
}
// dot arrows (edge) parameters
$dot .= "edge [samehead,fontsize=20];\n";
foreach ($edges['uri'] as $nd) {
$label = $nd['label'];
if (preg_match('/^(.*[\\/#])([^\\/\\#]*)$/', $nd['label'], $m)) {
$ns_uri = $m[1];
$lname = $m[2];
if (!($prefix = array_search($ns_uri, $ns))) {
$ns['ns' . $nsc] = $ns_uri;
//.........这里部分代码省略.........