コード例 #1
0
ファイル: flathml2.php プロジェクト: HeuristNetwork/heurist
/**
* Outputs the set of records as an xml stream or separate files per record (if $intofile set)
*
* @param mixed $result
*/
function outputRecords($result)
{
    global $OUTPUT_STUBS, $FRESH, $MAX_DEPTH, $intofile, $hunifile;
    $recSet = array('count' => 0, 'relatedSet' => array());
    $rec_ids = explode(",", $result['recIDs']);
    if (array_key_exists('expandColl', $_REQUEST)) {
        $rec_ids = expandCollections($rec_ids);
    }
    if (!is_array($rec_ids)) {
        $rec_ids = array();
    }
    if (count($rec_ids) > 1000) {
        set_time_limit(30 * count($rec_ids) % 1000);
    }
    foreach ($rec_ids as $recID) {
        if ($recID > 0) {
            $recSet['relatedSet'][$recID] = array('depth' => 0, 'recID' => $recID);
        }
    }
    buildGraphStructure($rec_ids, $recSet);
    $recSet['count'] = count($recSet['relatedSet']);
    /* ARTEM: avoid memory overflow
       foreach ($recSet['relatedSet'] as $recID => $recInfo) {
       $recSet['relatedSet'][$recID]['record'] = loadRecord_NoCache($recID, true); //loadRecord($recID, $FRESH, true);
       }
       */
    $resout = array();
    if (!$intofile) {
        openTag('records', array('count' => $recSet['count']));
    }
    foreach ($recSet['relatedSet'] as $recID => $recInfo) {
        if (intval($recInfo['depth']) <= $MAX_DEPTH) {
            // output one record - returs rec_RecTypeID for given record
            $res = outputRecord($recInfo, $recSet['relatedSet'], $OUTPUT_STUBS);
            // close the file if using HuNI manifest + separate files output
            // The file is opened in outputRecord but left open!
            if ($intofile && $hunifile) {
                fclose($hunifile);
            }
            if ($res) {
                $resout[$recID] = $res;
                //$recInfo['record']['rec_RecTypeID'];
            } else {
                if ($intofile && file_exists(HEURIST_HML_DIR . $recID . ".xml")) {
                    unlink(HEURIST_HML_DIR . $record['rec_ID'] . ".xml");
                }
            }
        }
    }
    if (!$intofile) {
        closeTag('records');
    }
    return $resout;
}
コード例 #2
0
ファイル: flathml.php プロジェクト: beoutsports/heurist-v3-1
/**
 * 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 outputRecords($result)
{
    global $OUTPUT_STUBS, $FRESH, $MAX_DEPTH;
    $recSet = array('count' => 0, 'relatedSet' => array());
    $rec_ids = explode(",", $result['recIDs']);
    if (array_key_exists('expandColl', $_REQUEST)) {
        $rec_ids = expandCollections($rec_ids);
    }
    foreach ($rec_ids as $recID) {
        $recSet['relatedSet'][$recID] = array('depth' => 0);
    }
    buildGraphStructure($rec_ids, $recSet);
    $recSet['count'] = count($recSet['relatedSet']);
    foreach ($recSet['relatedSet'] as $recID => $recInfo) {
        $recSet['relatedSet'][$recID]['record'] = loadRecord($recID, $FRESH, true);
    }
    openTag('records', array('count' => $recSet['count']));
    foreach ($recSet['relatedSet'] as $recID => $recInfo) {
        if (intval($recInfo['depth']) <= $MAX_DEPTH) {
            outputRecord($recInfo, $recSet['relatedSet'], $OUTPUT_STUBS);
        }
    }
    closeTag('records');
}