function neologism_gateway_get_property_children($node, $voc = NULL, $add_checkbox = FALSE, array &$array_inverses, $parent_path, &$references) { $nodes = array(); $children = db_query(db_rewrite_sql("select prefix, reference from {evoc_rdf_superproperties} where superproperty = '%s'"), $node); while ($child = db_fetch_object($children)) { $property = db_fetch_object(db_query(db_rewrite_sql("select * from {evoc_rdf_properties} where prefix='%s' and id = '%s'"), $child->prefix, $child->reference)); if ($property) { $property->prefix = trim($property->prefix); $property->id = trim($property->id); $qname = $property->prefix . ':' . $property->id; $array_domain = array(); if ($property->domains > 0) { $array_domain = _neologism_get_domain_terms($property->prefix, $property->id); } $array_ranges = array(); if ($property->ranges > 0) { $array_ranges = _neologism_get_range_terms($property->prefix, $property->id); } // fetch the superproperties $superproperties = array(); if ($property->superproperties > 0) { $superproperties = _neologism_get_superproperties_terms($property->prefix, $property->id); } // fetch the inverses $inverses = array(); if ($property->inverses > 0) { $inverses = _neologism_get_inverseof_terms($property->prefix, $property->id); // add inverses to the main array to use it after build the nodes $array_inverses[$qname] = $inverses; } // extra information needed by the treeview $extra_information = true; $realId = ''; if (isset($references[$qname])) { $references[$qname]['references'] += 1; $modified_id = $references[$qname]['references'] . '_' . $qname; $references[$qname]['paths'][] = $parent_path . '/' . $modified_id; $realId = $qname; } else { $references[$qname]['paths'] = array($parent_path . '/' . $qname); $references[$qname]['references'] = 0; $extra_information = false; } $real_parent_path = $parent_path . '/' . (!$extra_information ? $qname : $modified_id); $children_nodes = neologism_gateway_get_property_children($qname, $voc, $add_checkbox, $array_inverses, $real_parent_path, $references); if ($voc) { if ($property->prefix == $voc || _neologism_gateway_in_nodes($voc, $children_nodes)) { $leaf = count($children_nodes) == 0; $qtip = '<b>' . $property->label . '</b><br/>' . $property->comment; $nodes[] = array('text' => $qname, 'id' => !$extra_information ? $qname : $modified_id, 'leaf' => $leaf, 'iconCls' => $property->prefix == $voc ? 'property-samevoc' : 'property-diffvoc', 'cls' => $property->prefix == $voc ? 'currentvoc' : '', 'children' => $children_nodes, 'qtip' => $qtip, 'domain' => $array_domain, 'range' => $array_ranges, 'superproperties' => $superproperties, 'inverses' => $inverses); if ($add_checkbox) { $nodes[count($nodes) - 1]['checked'] = false; } if ($extra_information) { $nodes[count($nodes) - 1]['realid'] = $qname; } } } else { $leaf = count($children_nodes) == 0; $qtip = '<b>' . $property->label . '</b><br/>' . $property->comment; $nodes[] = array('text' => $qname, 'id' => !$extra_information ? $qname : $modified_id, 'leaf' => $leaf, 'iconCls' => 'property-samevoc', 'children' => $children_nodes, 'qtip' => $qtip, 'domain' => $array_domain, 'range' => $array_ranges, 'superproperties' => $superproperties, 'inverses' => $inverses); if ($add_checkbox) { $nodes[count($nodes) - 1]['checked'] = false; } if ($extra_information) { $nodes[count($nodes) - 1]['realid'] = $qname; } } } } return $nodes; }
/** * Construct the tree structure for a Tree using ExtJS Tree structure * @return json with the tree structure */ function neologism_gateway_get_full_properties_tree() { $nodes = array(); $node = $_REQUEST['node']; if ($node == 'root') { $properties = db_query(db_rewrite_sql('SELECT * FROM {evoc_rdf_properties} where superproperties = "0"')); while ($property = db_fetch_object($properties)) { $qname = $property->prefix . ':' . $property->id; $domain = array(); if ($property->domains > 0) { $domains = db_query(db_rewrite_sql('SELECT * FROM {evoc_rdf_propertiesdomains} WHERE prefix = "%s" AND reference = "%s"'), $property->prefix, $property->id); while ($obj = db_fetch_object($domains)) { $domain[] = $obj->rdf_domain; } } $range = array(); if ($property->ranges > 0) { $ranges = db_query(db_rewrite_sql('SELECT * FROM {evoc_rdf_propertiesranges} WHERE prefix = "%s" AND reference = "%s"'), $property->prefix, $property->id); while ($obj = db_fetch_object($ranges)) { $range[] = $obj->rdf_range; } } $children = neologism_gateway_get_property_children($qname, NULL, TRUE); $qtip = '<b>' . $property->label . '</b><br/>' . $property->comment; $leaf = count($children) == 0; $nodes[] = array('text' => $qname, 'id' => $qname, 'leaf' => $leaf, 'iconCls' => 'property-samevoc', 'children' => $children, 'checked' => false, 'qtip' => $qtip, 'domain' => $domain, 'range' => $range); } } drupal_json($nodes); }