static function getCleanedIndex() { /* removes triples from a given index */ $indexes = func_get_args(); $r = $indexes[0]; for ($i = 1, $i_max = count($indexes); $i < $i_max; $i++) { $index = $indexes[$i]; foreach ($index as $s => $ps) { if (!isset($r[$s])) { continue; } foreach ($ps as $p => $os) { if (!isset($r[$s][$p])) { continue; } $r_os = $r[$s][$p]; $new_os = array(); foreach ($r_os as $r_o) { $r_o_val = is_array($r_o) ? $r_o['value'] : $r_o; $keep = 1; foreach ($os as $o) { $del_o_val = is_array($o) ? $o['value'] : $o; if ($del_o_val == $r_o_val) { $keep = 0; break; } } if ($keep) { $new_os[] = $r_o; } } if ($new_os) { $r[$s][$p] = $new_os; } else { unset($r[$s][$p]); } } } } /* check r */ $has_data = 0; foreach ($r as $s => $ps) { if ($ps) { $has_data = 1; break; } } return $has_data ? $r : array(); }
function delete($doc, $g = 'http://localhost/') { $index = $this->v($g, array(), $this->data); $this->data[$g] = ARC2::getCleanedIndex($index, $this->toIndex($doc)); }