Ejemplo n.º 1
0
/**
 * Create a treenode for a Treepanel based on ExtJS treenode structure.
 * 
 * @param $nodes
 *   The reference where the complete tree structure is bing storing.
 * @param $node
 *   The tree root node.
 * @param $class
 *   The object containing the fetched class information.
 * @param $disjointwith
 *   The array containing all the classes disjoinwith this.
 * @param $array_disjointwith
 *   Reference to the array of disjointwith found.
 * @param $array_references
 *   Reference to an array of all classes that have more that one 
 *   dependency (reference) in the tree.
 * @return 
 *   none
 */
function _neologism_gateway_create_class_treenode(&$nodes, $node, $class, array $disjointwith, &$array_disjointwith, &$array_references)
{
    // check if the data for the creation comes from the classes table
    if (!isset($class->superclass)) {
        $qname = $class->prefix . ':' . $class->id;
        $qtip = '<b>' . $class->label . '</b><br/>' . $class->comment;
    } else {
        $qname = $class->superclass;
        $qtip = '<em>This class is external and a description has not been provided.</em>';
    }
    $parent_path = '/' . $node;
    $children = neologism_gateway_get_class_children($qname, NULL, TRUE, $array_disjointwith, $parent_path, $array_references);
    $leaf = count($children) == 0;
    $nodes[] = array('text' => $qname, 'id' => $qname, 'leaf' => $leaf, 'iconCls' => 'class-samevoc', 'children' => $children, 'checked' => false, 'qtip' => $qtip, 'disjointwith' => $disjointwith, 'nodeStatus' => 0);
}
Ejemplo n.º 2
0
/**
 * This recurive function search for chindren of $node return class from the same $voc. 
 * If the parent does not belong to the $voc but has children that does, this parent is added as well.
 * @param object $node
 * @param object $voc
 * @param object $add_checkbox [optional]
 * @return 
 */
function neologism_gateway_get_class_children_old($node, $voc = NULL, $add_checkbox = FALSE, array &$disjointwith_array = NULL)
{
    $nodes = array();
    static $array_of_id = array();
    $children = db_query('select prefix, reference from {evoc_rdf_superclasses} where superclass = "' . $node . '"');
    while ($child = db_fetch_object($children)) {
        $class = db_fetch_object(db_query('select * from evoc_rdf_classes where prefix = "' . $child->prefix . '" and id = "' . $child->reference . '" '));
        if ($class) {
            $class->prefix = trim($class->prefix);
            $class->id = trim($class->id);
            $qname = $class->prefix . ':' . $class->id;
            // extra information needed by the treeview
            $extra_information = true;
            $realId = '';
            if (isset($array_of_id[$qname])) {
                $modified_id = $array_of_id[$qname] . '_' . $qname;
                $array_of_id[$qname] += 1;
                $realId = $qname;
            } else {
                $array_of_id[$qname] = 1;
                $extra_information = false;
            }
            //-----------------------------------------
            // fetch extra information
            // fetch the disjointwith
            $disjointwith = array();
            if ($class->ndisjointwith > 0) {
                $result = db_query('select disjointwith from {evoc_rdf_disjointwith} where prefix = "' . $class->prefix . '" and reference = "' . $class->id . '" ');
                while ($c = db_fetch_object($result)) {
                    $disjointwith[] = $c->disjointwith;
                }
                if (isset($disjointwith_array) && is_array($disjointwith_array)) {
                    $disjointwith_array[$qname] = $disjointwith;
                }
            }
            // fetch the superclasses
            $superclasses = array();
            if ($class->superclasses > 0) {
                $result = db_query('select superclass from {evoc_rdf_superclasses} where prefix = "' . $class->prefix . '" and reference = "' . $class->id . '" ');
                while ($s = db_fetch_object($result)) {
                    $superclasses[] = $s->superclass;
                }
            }
            $children_nodes = neologism_gateway_get_class_children($qname, $voc, $add_checkbox, $disjointwith_array);
            if ($voc) {
                if ($class->prefix == $voc || _neologism_gateway_in_nodes($voc, $children_nodes)) {
                    $leaf = count($children_nodes) == 0;
                    $qtip = '<b>' . $class->label . '</b><br/>' . $class->comment;
                    $nodes[] = array('text' => $qname, 'id' => !$extra_information ? $qname : $modified_id, 'leaf' => $leaf, 'iconCls' => $class->prefix == $voc ? 'class-samevoc' : 'class-diffvoc', 'cls' => $class->prefix == $voc ? 'currentvoc' : '', 'children' => $children_nodes, 'qtip' => $qtip, 'disjointwith' => $disjointwith, 'superclasses' => $superclasses, 'nodeStatus' => 0);
                    if ($extra_information) {
                        $nodes[count($nodes) - 1]['realid'] = $qname;
                    }
                    if ($add_checkbox) {
                        $nodes[count($nodes) - 1]['checked'] = false;
                    }
                }
            } else {
                $leaf = count($children_nodes) == 0;
                $qtip = '<b>' . $class->label . '</b><br/>' . $class->comment;
                $nodes[] = array('text' => $qname, 'id' => !$extra_information ? $qname : $modified_id, 'leaf' => $leaf, 'iconCls' => 'class-samevoc', 'children' => $children_nodes, 'qtip' => $qtip, 'disjointwith' => $disjointwith, 'superclasses' => $superclasses, 'nodeStatus' => 0);
                if ($extra_information) {
                    $nodes[count($nodes) - 1]['realid'] = $qname;
                }
                if ($add_checkbox) {
                    $nodes[count($nodes) - 1]['checked'] = false;
                }
            }
        }
    }
    return $nodes;
}