예제 #1
0
function outputDetail($dt, $value, $rt, $recInfos, $depth = 0, $outputStub, $parentID)
{
    global $DTN, $DTT, $TL, $RQS, $INV, $GEO_TYPES, $MAX_DEPTH, $INCLUDE_FILE_CONTENT, $SUPRESS_LOOPBACKS, $relTypDT;
    $attrs = array('id' => $dt, 'conceptID' => getDetailTypeConceptID($dt));
    if (array_key_exists($dt, $DTN)) {
        $attrs['type'] = $DTN[$dt];
    }
    if (array_key_exists($rt, $RQS) && array_key_exists($dt, $RQS[$rt])) {
        $attrs['name'] = $RQS[$rt][$dt];
    }
    if ($dt === $relTypDT && array_key_exists($value, $INV) && $INV[$value] && array_key_exists($INV[$value], $TL)) {
        //saw Enum change
        $attrs['inverse'] = $TL[$INV[$value]]['trm_Label'];
        $attrs['invTermConceptID'] = getTermConceptID($INV[$value]);
    }
    if (is_array($value)) {
        if (array_key_exists('id', $value)) {
            // record pointer
            $attrs['isRecordPointer'] = "true";
            if ($MAX_DEPTH == 0 && $outputStub) {
                openTag('detail', $attrs);
                $recinfo = loadRecord_NoCache($value['id'], true);
                outputRecordStub($recinfo);
                //$recInfos[$value['id']]['record']);
                closeTag('detail');
            } else {
                makeTag('detail', $attrs, $value['id']);
            }
        } else {
            if (array_key_exists('file', $value)) {
                $file = $value['file'];
                if (@$_REQUEST['includeresources'] == '1' && @$_REQUEST['mode'] == '1') {
                    $file = get_uploaded_file_info_internal($file['id'], false);
                    unset($file['thumbURL']);
                    if ($file['fullpath'] && file_exists($file['fullpath'])) {
                        //if path is relative then we copy file
                        if (@$file['ulf_FilePath'] == null || $file['ulf_FilePath'] == '' || substr($file['ulf_FilePath'], 1) != '/') {
                            //$path_parts = pathinfo($file['fullpath']);
                            //$dirname = $path_parts['dirname'].'/';
                            //copy file and create required folders
                            chdir(HEURIST_FILESTORE_DIR);
                            // relatively db root
                            $fpath = realpath($file['fullpath']);
                            $fpath = str_replace('\\', '/', $fpath);
                            recurse_copy(HEURIST_FILESTORE_DIR, HEURIST_FILESTORE_DIR . 'backup/' . HEURIST_DBNAME . '/', null, $fpath);
                            $file['URL'] = @$file['ulf_FilePath'] . @$file['ulf_FileName'];
                            //relative path to db root
                        } else {
                            //otherwise skip copy and use downloadURL
                            //$file['URL'] - it is already has  downloadFile or remote URL
                        }
                        /* this code is not use anymore - we copy the entire file_uploads folder
                                            // backup file into backup/user folder
                                            $folder = HEURIST_FILESTORE_DIR . "backup/" . get_user_username() . "/resources/";
                        
                                            if(!file_exists($folder) && !mkdir($folder, 0777, true)){
                                            print "<p class='error'>'Failed to create folder for file resources: ".$folder.'</p>';
                                            break;
                                            }
                        
                                            $path_parts = pathinfo($file['fullpath']);
                                            $file['URL'] = $path_parts['basename'];
                                            $filename_bk = $folder . $file['URL'];
                                            copy($file['fullpath'], $filename_bk);
                                            $file['URL'] = 'resources/'.$file['URL'];
                                            */
                    }
                }
                openTag('detail', $attrs);
                openTag('file');
                makeTag('id', null, $file['id']);
                makeTag('nonce', null, $file['nonce']);
                makeTag('origName', null, $file['origName']);
                if (@$file['mimeType']) {
                    makeTag('mimeType', null, $file['mimeType']);
                }
                if (@$file['fileSize']) {
                    makeTag('fileSize', array('units' => 'kB'), $file['fileSize']);
                }
                if (@$file['date']) {
                    makeTag('date', null, $file['date']);
                }
                if (@$file['description']) {
                    makeTag('description', null, $file['description']);
                }
                if (@$file['URL']) {
                    makeTag('url', null, $file['URL']);
                }
                if (@$file['thumbURL']) {
                    makeTag('thumbURL', null, $file['thumbURL']);
                }
                if ($INCLUDE_FILE_CONTENT !== false && $INCLUDE_FILE_CONTENT >= $depth) {
                    makeFileContentNode($file);
                }
                closeTag('file');
                closeTag('detail');
            } else {
                if (array_key_exists('geo', $value)) {
                    openTag('detail', $attrs);
                    openTag('geo');
                    makeTag('type', null, $GEO_TYPES[$value['geo']['type']]);
                    makeTag('wkt', null, $value['geo']['wkt']);
                    closeTag('geo');
                    closeTag('detail');
                }
            }
        }
    } else {
        if ($DTT[$dt] === 'date') {
            openTag('detail', $attrs);
            if (strpos($value, "|") === false) {
                outputDateDetail($attrs, $value);
            } else {
                outputTemporalDetail($attrs, $value);
            }
            closeTag('detail');
        } else {
            if ($DTT[$dt] === 'resource') {
                $attrs['isRecordPointer'] = "true";
                if ($MAX_DEPTH == 0 && $outputStub) {
                    openTag('detail', $attrs);
                    $recinfo = loadRecord_NoCache($value['id'], true);
                    outputRecordStub($recinfo);
                    //$recInfos[$value['id']]['record']);
                    closeTag('detail');
                } else {
                    makeTag('detail', $attrs, $value['id']);
                }
            } else {
                if (($DTT[$dt] === 'enum' || $DTT[$dt] === 'relationtype') && array_key_exists($value, $TL)) {
                    $attrs['termID'] = $value;
                    $attrs['termConceptID'] = getTermConceptID($value);
                    if (@$TL[$value]['trm_ParentTermID']) {
                        $attrs['ParentTerm'] = $TL[$TL[$value]['trm_ParentTermID']]['trm_Label'];
                    }
                    makeTag('detail', $attrs, $TL[$value]['trm_Label']);
                } else {
                    makeTag('detail', $attrs, replaceIllegalChars($value));
                }
            }
        }
    }
}
예제 #2
0
function outputDetail($dt, $value, $rt, &$reverse_pointers, &$relationships, $depth = 0, $outputStub, $parentID)
{
    global $DTN, $DTT, $TL, $RQS, $INV, $GEO_TYPES, $MAX_DEPTH, $INCLUDE_FILE_CONTENT, $SUPRESS_LOOPBACKS, $relTypDT, $relTrgDT, $relSrcDT;
    /*****DEBUG****/
    //error_log("in outputDetail dt = $dt value = ". print_r($value,true));
    $attrs = array('id' => $dt, 'conceptID' => getDetailTypeConceptID($dt));
    if (array_key_exists($dt, $DTN)) {
        $attrs['type'] = $DTN[$dt];
    }
    if (array_key_exists($rt, $RQS) && array_key_exists($dt, $RQS[$rt])) {
        $attrs['name'] = $RQS[$rt][$dt];
    }
    if ($dt === $relTypDT && array_key_exists($value, $INV) && $INV[$value] && array_key_exists($INV[$value], $TL)) {
        //saw Enum change
        $attrs['inverse'] = $TL[$INV[$value]]['trm_Label'];
        $attrs['invTermConceptID'] = getTermConceptID($INV[$value]);
    }
    if (is_array($value)) {
        if (array_key_exists('id', $value)) {
            // record pointer
            if ($dt === $relSrcDT || $dt === $relTrgDT) {
                // in a relationship record don't expand from side
                if ($value['id'] == $parentID) {
                    $attrs['direction'] = "from";
                    if ($dt === $relTrgDT) {
                        $attrs['useInverse'] = 'true';
                    }
                    if ($SUPRESS_LOOPBACKS) {
                        openTag('detail', $attrs);
                        if ($outputStub) {
                            outputRecordStub(loadRecordStub($value['id']));
                        } else {
                            echo $value['id'];
                        }
                        closeTag('detail');
                        return;
                    }
                } else {
                    $attrs['direction'] = "to";
                    if ($dt === $relSrcDT) {
                        $attrs['useInverse'] = 'true';
                    }
                }
                openTag('detail', $attrs);
                outputRecord(loadRecord($value['id']), $reverse_pointers, $relationships, $depth + 1, $outputStub, $parentID);
                closeTag('detail');
            } else {
                if ($depth < $MAX_DEPTH) {
                    openTag('detail', $attrs);
                    outputRecord(loadRecord($value['id']), $reverse_pointers, $relationships, $depth + 1, $outputStub, $parentID);
                    closeTag('detail');
                } else {
                    if ($outputStub) {
                        openTag('detail', $attrs);
                        outputRecordStub(loadRecordStub($value['id']));
                        closeTag('detail');
                    } else {
                        makeTag('detail', $attrs, $value['id']);
                    }
                }
            }
        } else {
            if (array_key_exists('file', $value)) {
                $file = $value['file'];
                /*****DEBUG****/
                //error_log(" in outputDetail file = \n".print_r($file,true));
                openTag('detail', $attrs);
                openTag('file');
                makeTag('id', null, $file['id']);
                makeTag('nonce', null, $file['nonce']);
                makeTag('origName', null, $file['origName']);
                makeTag('type', null, $file['type']);
                makeTag('size', array('units' => 'kB'), $file['size']);
                makeTag('date', null, $file['date']);
                makeTag('description', null, $file['description']);
                makeTag('url', null, $file['URL']);
                makeTag('thumbURL', null, $file['thumbURL']);
                if ($INCLUDE_FILE_CONTENT) {
                    makeFileContentNode($file);
                }
                closeTag('file');
                closeTag('detail');
            } else {
                if (array_key_exists('geo', $value)) {
                    openTag('detail', $attrs);
                    openTag('geo');
                    makeTag('type', null, $GEO_TYPES[$value['geo']['type']]);
                    makeTag('wkt', null, $value['geo']['wkt']);
                    closeTag('geo');
                    closeTag('detail');
                }
            }
        }
    } else {
        if ($DTT[$dt] === 'date') {
            openTag('detail', $attrs);
            if (strpos($value, "|") === false) {
                outputDateDetail($attrs, $value);
            } else {
                outputTemporalDetail($attrs, $value);
            }
            closeTag('detail');
        } else {
            if ($DTT[$dt] === 'resource') {
                openTag('detail', $attrs);
                outputRecord(loadRecord($value), $reverse_pointers, $relationships, $depth + 1, $outputStub, $parentID);
                closeTag('detail');
            } else {
                if (($DTT[$dt] === 'enum' || $DTT[$dt] === 'relationtype') && array_key_exists($value, $TL)) {
                    $attrs['termConceptID'] = getTermConceptID($value);
                    if (@$TL[$value]['trm_ParentTermID']) {
                        $attrs['ParentTerm'] = $TL[$TL[$value]['trm_ParentTermID']]['trm_Label'];
                    }
                    /*****DEBUG****/
                    //error_log("value = ".$value." label = ".$TL[$value]['trm_Label']);
                    makeTag('detail', $attrs, $TL[$value]['trm_Label']);
                } else {
                    makeTag('detail', $attrs, replaceIllegalChars($value));
                }
            }
        }
    }
}
예제 #3
0
/**
 * description
 * @global    type description of global variable usage in a function
 * @staticvar type [$varname] description of static variable usage in function
 * @param     type [$varname] description
 * @return    type description
 * @link      URL
 * @see       name of another element (function or object) used in this function
 * @throws    list of exceptions thrown in this code
 * @uses      code_element_name description of use
 */
function outputDetail($dt, $value, $rt, $recInfos, $depth = 0, $outputStub, $parentID)
{
    global $DTN, $DTT, $TL, $RQS, $INV, $GEO_TYPES, $MAX_DEPTH, $INCLUDE_FILE_CONTENT, $SUPRESS_LOOPBACKS, $relTypDT;
    $attrs = array('id' => $dt, 'conceptID' => getDetailTypeConceptID($dt));
    if (array_key_exists($dt, $DTN)) {
        $attrs['type'] = $DTN[$dt];
    }
    if (array_key_exists($rt, $RQS) && array_key_exists($dt, $RQS[$rt])) {
        $attrs['name'] = $RQS[$rt][$dt];
    }
    if ($dt === $relTypDT && array_key_exists($value, $INV) && $INV[$value] && array_key_exists($INV[$value], $TL)) {
        //saw Enum change
        $attrs['inverse'] = $TL[$INV[$value]]['trm_Label'];
        $attrs['invTermConceptID'] = getTermConceptID($INV[$value]);
    }
    if (is_array($value)) {
        if (array_key_exists('id', $value)) {
            // record pointer
            $attrs['isRecordPointer'] = "true";
            if ($MAX_DEPTH == 0 && $outputStub) {
                openTag('detail', $attrs);
                outputRecordStub($recInfos[$value['id']]['record']);
                closeTag('detail');
            } else {
                makeTag('detail', $attrs, $value['id']);
            }
        } else {
            if (array_key_exists('file', $value)) {
                $file = $value['file'];
                if (@$_REQUEST['includeresources'] == '1' && @$_REQUEST['mode'] == '1') {
                    $file = get_uploaded_file_info_internal($file['id'], false);
                    if ($file['fullpath'] && file_exists($file['fullpath'])) {
                        //backup file inot backup/user folder
                        $folder = HEURIST_UPLOAD_DIR . "backup/" . get_user_username() . "/";
                        $path_parts = pathinfo($file['fullpath']);
                        $file['URL'] = $path_parts['basename'];
                        $filename_bk = $folder . $file['URL'];
                        copy($file['fullpath'], $filename_bk);
                        unset($file['thumbURL']);
                    }
                }
                openTag('detail', $attrs);
                openTag('file');
                makeTag('id', null, $file['id']);
                makeTag('nonce', null, $file['nonce']);
                makeTag('origName', null, $file['origName']);
                if (@$file['mimeType']) {
                    makeTag('mimeType', null, $file['mimeType']);
                }
                if (@$file['fileSize']) {
                    makeTag('fileSize', array('units' => 'kB'), $file['fileSize']);
                }
                if (@$file['date']) {
                    makeTag('date', null, $file['date']);
                }
                if (@$file['description']) {
                    makeTag('description', null, $file['description']);
                }
                if (@$file['URL']) {
                    makeTag('url', null, $file['URL']);
                }
                if (@$file['thumbURL']) {
                    makeTag('thumbURL', null, $file['thumbURL']);
                }
                if ($INCLUDE_FILE_CONTENT !== false && $INCLUDE_FILE_CONTENT >= $depth) {
                    makeFileContentNode($file);
                }
                closeTag('file');
                closeTag('detail');
            } else {
                if (array_key_exists('geo', $value)) {
                    openTag('detail', $attrs);
                    openTag('geo');
                    makeTag('type', null, $GEO_TYPES[$value['geo']['type']]);
                    makeTag('wkt', null, $value['geo']['wkt']);
                    closeTag('geo');
                    closeTag('detail');
                }
            }
        }
    } else {
        if ($DTT[$dt] === 'date') {
            openTag('detail', $attrs);
            if (strpos($value, "|") === false) {
                outputDateDetail($attrs, $value);
            } else {
                outputTemporalDetail($attrs, $value);
            }
            closeTag('detail');
        } else {
            if ($DTT[$dt] === 'resource') {
                $attrs['isRecordPointer'] = "true";
                if ($MAX_DEPTH == 0 && $outputStub) {
                    openTag('detail', $attrs);
                    outputRecordStub($recInfos[$value['id']]['record']);
                    closeTag('detail');
                } else {
                    makeTag('detail', $attrs, $value['id']);
                }
            } else {
                if (($DTT[$dt] === 'enum' || $DTT[$dt] === 'relationtype') && array_key_exists($value, $TL)) {
                    $attrs['termID'] = $value;
                    $attrs['termConceptID'] = getTermConceptID($value);
                    if (@$TL[$value]['trm_ParentTermID']) {
                        $attrs['ParentTerm'] = $TL[$TL[$value]['trm_ParentTermID']]['trm_Label'];
                    }
                    makeTag('detail', $attrs, $TL[$value]['trm_Label']);
                } else {
                    makeTag('detail', $attrs, replaceIllegalChars($value));
                }
            }
        }
    }
}