Exemple #1
0
function generate_table($table)
{
    extract($table);
    if ($project_id == '') {
        $project_id = $project_info['project_id'];
    }
    $R = array('db' => $db, 'project_id' => $project_id, 'subject' => $resource_info['entity'], 'object' => '!=UID');
    $rules = list_shared_rules($R);
    ###Fetch all the objects and all of the verbs to create the header
    if (empty($_SESSION['show_me'])) {
        if (is_array($rules)) {
            $verbs = array_map('grab_verb', $rules);
        }
    } else {
        $verbs = array_map('grab_verb', $_SESSION['show_me']);
    }
    $total_objects = 0;
    if (is_array($verbs)) {
        foreach ($verbs as $i => $value) {
            #Make a new query on rules, this time to find the object that has this specific verb
            if (empty($_SESSION['show_me'])) {
                $objects = array_map('grab_object', $rules, $verbs);
            } else {
                $objects = array_map('grab_object', $_SESSION['show_me'], $verbs);
            }
            $total_objects += count($objects);
        }
    }
    $total_objects += 2;
    $All = array('db' => $db, 'entity' => $resource_info['entity'], 'project_id' => $project_id, 'rules' => $rules, 'verbs' => $verbs, 'objects' => $objects, 'format' => 'html', 'color' => 'on');
    #Create the html part of the table
    #$out = sprintf("%s\n", '<table width=100% border=1 style="border-collapse: collapse;">');
    $out .= sprintf("%s\n", '	<tr><td colspan="' . $total_objects . '">Data of ' . $entity . ' (Project: ' . $project['name'] . ')</td></tr>');
    $out .= sprintf("%s\n", '	<tr><td colspan="' . $total_objects . '">Page ' . $_SESSION['current_page'] . '</td></tr>');
    $out .= create_datamatrix_header($All);
    $out .= render_datamatrix_values($All);
    #$out.= sprintf("%s\n", '</table>');
    return $out;
}
Exemple #2
0
        $s3ql['where']['object'] = "!='UID'";
        $rules = S3QLaction($s3ql);
        #$rules = include_all_class_id(compact('rules', 'project_id', 'db'));
    } else {
        #Building the query
        $ruleScope = array();
        foreach ($inputs as $key => $value) {
            $ruleScope[ereg_replace('^R', '', $key)] = stripslashes($value);
        }
        $q = array('rules' => array_keys($ruleScope), 'logical' => array_fill(0, count($inputs), 'and'), 'RuleValuePair' => $ruleScope, 'db' => $db);
        $instances = query_statements($q);
    }
    ##Find the values that are to be sent to datamatrix.php, both header and data
    if (is_array($rules) && !empty($rules)) {
        $verbs = array_map('grab_verb', $rules);
        foreach ($verbs as $i => $value) {
            $objects = array_map('grab_object', $rules, $verbs);
        }
    }
    #echo '<pre>';print_r($objects);
    #A matrix will need to be built that has rules on top,  resource_id as rows and statements in the middle
    #Create the header, which will not differ for listall or query
    $head = array('key' => $key, 'user_id' => $user_id, 'db' => $db, 'resource_class_id' => $class_info['resource_id'], 'class_info' => $class_info, 'project_id' => $project_id, 'rules' => $rules, 'objects' => $objects, 'verbs' => $verbs, 'instances' => $instances, 'format' => strval($s3ql['format']), 'color' => strval($s3ql['color']));
    $display .= create_datamatrix_header($head);
    if (is_array($instances)) {
        $display .= render_datamatrix_values($head);
    } else {
        echo '<table><tr><td>Your query returned no results.</td></tr></table>';
    }
    echo $display;
}