ARC2::getTriplesFromIndex PHP Method

getTriplesFromIndex() static public method

static public getTriplesFromIndex ( $index )
    static function getTriplesFromIndex($index)
    {
        $r = array();
        foreach ($index as $s => $ps) {
            foreach ($ps as $p => $os) {
                foreach ($os as $o) {
                    $r[] = array('s' => $s, 'p' => $p, 'o' => $o['value'], 's_type' => preg_match('/^\\_\\:/', $s) ? 'bnode' : 'uri', 'o_type' => $o['type'], 'o_datatype' => isset($o['datatype']) ? $o['datatype'] : '', 'o_lang' => isset($o['lang']) ? $o['lang'] : '');
                }
            }
        }
        return $r;
    }

Usage Example

 function extractRDF()
 {
     $tc = 0;
     $t = '';
     $t_vals = array();
     foreach ($this->nodes as $n) {
         if ($n['tag'] != 'a') {
             continue;
         }
         if (!($href = $this->v('href uri', '', $n['a']))) {
             continue;
         }
         if (!($rels = $this->v('rel m', array(), $n['a']))) {
             continue;
         }
         if (!($vals = array_intersect($this->terms, $rels))) {
             continue;
         }
         $parts = preg_match('/^(.*\\/)([^\\/]+)\\/?$/', $href, $m) ? array('space' => $m[1], 'tag' => rawurldecode($m[2])) : array('space' => '', 'tag' => '');
         if ($tag = $parts['tag']) {
             $t_vals['s_' . $tc] = $this->getContainerResIDByClass($n, $this->containers);
             $t_vals['concept_' . $tc] = $this->createBnodeID() . '_concept';
             $t_vals['tag_' . $tc] = $tag;
             $t_vals['space_' . $tc] = $parts['space'];
             $t .= '?s_' . $tc . ' skos:subject [skos:prefLabel ?tag_' . $tc . ' ; skos:inScheme ?space_' . $tc . '] . ';
             $tc++;
         }
     }
     $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']);
     $this->addTs(ARC2::getTriplesFromIndex($doc));
 }
All Usage Examples Of ARC2::getTriplesFromIndex