Пример #1
0
function &arrayMergeRecursiveDistinct(array &$array1, &$array2 = null)
{
    $merged = $array1;
    if (is_array($array2)) {
        foreach ($array2 as $key => $val) {
            if (is_array($array2[$key])) {
                $merged[$key] = isset($merged[$key]) && is_array($merged[$key]) ? arrayMergeRecursiveDistinct($merged[$key], $array2[$key]) : $array2[$key];
            } else {
                $merged[$key] = $val;
            }
        }
    }
    return $merged;
}
Пример #2
0
	public function __construct(){
		parent::__construct();
		$this->property = array();
		$this->project = $_SESSION['project'];
		$this->items = $_SESSION['sheetData'];
		$this->definitionType = $this->project['eg:definitionType'];
		$property = $this->project['eg:property'];
		if(is_array($property) && $property !== array()){
			$namespaces = array();
			foreach($property as $key => $value){
				if(!empty($value['eg:additional'])){
					foreach($value['eg:additional'] as $a){
						if(!empty($a["eg:targetType"])){
							$tree = explode('-', $a['eg:tree']);
							foreach($tree as $t){
								$namespaces[] = explode(':',$t)[0];
							}
							$nest_property = convertRdfPHP($tree, $a);
							if($this->property == array()){
								$this->property = $nest_property;
							}else{
								$this->property = arrayMergeRecursiveDistinct($nest_property, $this->property);
							}
						}
					}
				}elseif(!empty($value["eg:targetType"])){
					$this->property[convertURI($value['eg:predicate'])] = $value;
					$namespaces[] = explode(':',$value['eg:predicate'])[0];
				}
			}
			$prefix = $this->app->config('prefix');
			$namespaces = array_unique($namespaces);
			foreach($namespaces as $n){
				if(array_key_exists($n, $prefix)){
					EasyRdf_Namespace::set($n, $prefix[$n]['namespace']);
				}
			}
			EasyRdf_Namespace::set('ic', 'http://imi.ipa.go.jp/ns/core/2/');
			$this->graph = new EasyRdf_Graph();
		}
	}