function __construct() { $this->rtStructs = getAllRectypeStructures(true); $this->dtStructs = getAllDetailTypeStructures(true); $this->dtTerms = getTerms(true); $this->loaded_recs = array(); }
/** * main form generation code build the model to approximate HML, the form UI and the binding between UI and model * @staticvar array [$dettypes] array detail type definitions for this database * @staticvar object [$di] field name to index mapping for detail type definition * @staticvar array [$rectypes] array record type structure definitions for this database * @staticvar object [$ri] field name to index mapping for record field structure definition * @staticvar object [$ti] field name to index mapping for term definition * @staticvar array [$termLookup] array term structure definitions for the enumerations in this database * @staticvar array [$relnLookup] array term structure definitions for the relationships in this database * @param integer [$rt_id] the rectype locally unique identifier * @return object an array of strings representing form, rtName, rtConceptID, rtDescription, and report on success * @uses getXFormTypeFromBaseType() * @uses createRecordLookup() * @uses createTermSelect() * @uses getTerms() * @uses getAllDetailTypeStructures() * @uses getAllRectypeStructures() * @uses HEURIST_UPLOAD_DIR * @uses HEURIST_BASE_URL * @uses HEURIST_DBNAME */ function buildform($rt_id) { // mappings and lookups - static so we only retrieve once per service call static $dettypes, $di, $rectypes, $ri, $rid, $terms, $ti, $termLookup, $relnLookup; if (!$dettypes || !$di) { $dettypes = getAllDetailTypeStructures(); $dettypes = $dettypes['typedefs']; $di = $dettypes['fieldNamesToIndex']; } if (!$rectypes || !$ri || !$rid) { $rectypes = getAllRectypeStructures(); $ri = $rectypes['typedefs']['commonNamesToIndex']; $rid = $rectypes['typedefs']['dtFieldNamesToIndex']; } if (!$terms || !$ti || !$termLookup || !$relnLookup) { $terms = getTerms(); $ti = $terms['fieldNamesToIndex']; $termLookup = $terms['termsByDomainLookup']['enum']; $relnLookup = $terms['termsByDomainLookup']['relation']; } if (!array_key_exists($rt_id, $rectypes['typedefs'])) { error_log("rectypes " . print_r($rectypes['typedefs'][$rt_id], true)); return array(null, null, null, null, "Rectype# {$rt_id} not found"); } $report = ""; $rectype = $rectypes['typedefs'][$rt_id]; // error_log("rectype is ".print_r($rectype,true)); //record type info $rtName = $rectypes['names'][$rt_id]; //detail or field type info $fieldTypeConceptIDIndex = $di['dty_ConceptID']; $fieldTypeNameIndex = $di['dty_Name']; $fieldBaseTypeIndex = $di['dty_Type']; //record field info $fieldNameIndex = $rid['rst_DisplayName']; $fieldDefaultValIndex = $rid['rst_DefaultValue']; $fieldHelpTextIndex = $rid['rst_DisplayHelpText']; $fieldTermsListIndex = $rid['rst_FilteredJsonTermIDTree']; $fieldTermHeaderListIndex = $rid['rst_TermIDTreeNonSelectableIDs']; $fieldPtrRectypeIDsListIndex = $rid['rst_PtrFilteredIDs']; $fieldMaxRepeatIndex = $rid['rst_MaxValues']; $rtConceptID = $rectype['commonFields'][$ri['rty_ConceptID']]; if (!$rtConceptID) { $rtConceptID = "0-" . $rt_id; } $rtDescription = $rectype['commonFields'][$ri['rty_Description']]; // output structure variables $model = "<instance>\n" . "<fhml id=\"heuristscholar.org:{$rtConceptID}\" version=\"" . date("Ymd") . "\">\n" . "<database id=\"" . HEURIST_DBID . "\" urlBase=\"" . HEURIST_BASE_URL . "\">" . HEURIST_DBNAME . "</database>\n" . "<query depth=\"0\" db=\"" . HEURIST_DBNAME . "\" q=\"t:{$rt_id}\" />\n" . "<generatedBy userID=\"" . get_user_id() . "\">" . get_user_name() . "</generatedBy>\n" . "<createdBy/>\n" . "<deviceID/>\n" . "<createTime/>\n" . "<uuid/>\n" . "<records count=\"1\">\n" . "<record depth=\"0\">\n" . "<type>\n" . "<conceptID>{$rtConceptID}</conceptID>\n" . "<label>{$rtName}</label>\n" . "</type>\n" . "<nonce/>\n" . "<details>\n"; $bind = "<bind nodeset=\"createdBy\" type=\"string\" jr:preload=\"property\" jr:preloadParams=\"username\"/>\n" . "<bind nodeset=\"createTime\" type=\"dateTime\" jr:preload=\"timestamp\" jr:preloadParams=\"start\"/>\n" . "<bind nodeset=\"deviceID\" type=\"string\" jr:preload=\"property\" jr:preloadParams=\"deviceid\"/>\n" . "<bind nodeset=\"uuid\" type=\"string\" readonly=\"true()\" calculate=\"uuid()\"/>\n" . "<bind nodeset=\"records/record/nonce\" type=\"string\" readonly=\"true()\" calculate=\"concat(/fhml/deviceID,'|',/fhml/createTime,'|',/fhml/uuid)\"/>\n"; $body = "<h:body>\n" . "<group appearance=\"field-list\">\n"; $groupSeparator = "</group>\n" . "<group appearance=\"field-list\">\n"; //@todo - sort by rst_DisplayOrder $fieldsLeft = count($rectype['dtFields']); $atGroupStart = true; //init separator detection for repatables foreach ($rectype['dtFields'] as $dt_id => $rt_dt) { if ($rt_dt[$rid['rst_NonOwnerVisibility']] == 'hidden') { continue; } --$fieldsLeft; // count down fields so we know when we hit the last one $dettype = $dettypes[$dt_id]['commonFields']; //get detail type description $baseType = $dettype[$fieldBaseTypeIndex]; $fieldTypeName = $dettype[$fieldTypeNameIndex]; $fieldName = $rt_dt[$fieldNameIndex]; $fieldtype = getXFormTypeFromBaseType($baseType); $fieldMaxCount = $rt_dt[$fieldMaxRepeatIndex]; $isRepeatable = $fieldMaxCount > 1 || $fieldMaxCount == NULL; //skip any unsupport field types if (!$fieldtype) { $report = $report . " {$rtName}." . $dettype[$fieldTypeNameIndex] . " ignored since type " . $baseType . " not supported<br/>"; continue; // not supported } if ($fieldtype == "groupbreak" && $atGroupStart) { //skip double separator, note that this includes separators before non supported types continue; } if ($baseType == "resource") { $rtIDs = $dettype[$di['dty_PtrTargetRectypeIDs']]; if (!$rtIDs || $rtIDs == "") { //unconstrained pointers not supported $report = $report . " {$rtName}." . $dettype[$fieldTypeNameIndex] . " ignored since unconstrained resource pointers are not supported<br/>"; continue; } } $dt_conceptid = $dettype[$fieldTypeConceptIDIndex]; if (!$dt_conceptid) { $dt_conceptid = "0-" . $dt_id; } $defaultValue = $rt_dt[$fieldDefaultValIndex]; // load default value //for controlled vocabs convert any local term ID to it's concept ID if ($baseType == "enum" && array_key_exists("{$defaultValue}", $termLookup)) { $termID = $termLookup[$defaultValue][$ti['trm_ConceptID']]; if ($termID) { $defaultValue = $termID; } else { $defaultValue = HEURIST_DBID . "-" . $defaultValue; } } else { if ($baseType == "relation" && array_key_exists("{$defaultValue}", $relnLookup)) { $termID = $relnLookup[$defaultValue][$ti['trm_ConceptID']]; if ($termID) { $defaultValue = $termID; } else { $defaultValue = HEURIST_DBID . "-" . $defaultValue; } } } if ($fieldtype != "groupbreak") { $model = $model . "<dt{$dt_id} conceptID=\"{$dt_conceptid}\" type=\"{$fieldTypeName}\" name=\"{$fieldName}\">" . ($defaultValue ? htmlentities($defaultValue) : "") . "</dt" . $dt_id . ">\n"; } if ($rt_dt[$rid['rst_RequirementType']] == 'required') { $isrequired = 'required="true()"'; } else { if ($rt_dt[$rid['rst_RequirementType']] == 'forbidden') { $isrequired = 'readonly="true()"'; } else { $isrequired = ''; } } $constraint = ''; /* @todo if($rt_dt[$rid['rst_MinValues']]=='required'){ //constraint=". > 10.51 and . < 18.39" jr:constraintMsg="number must be between 10.51 and 18.39" } */ // if repeatable vocab make it multi select. TODO: we should extend Heurist to include multi-select which is different than repeatable if ($fieldtype == "select1" && $isRepeatable) { $fieldtype = "select"; $isRepeatable = false; } $label = htmlentities($rt_dt[$fieldNameIndex]); $hint = htmlentities($rt_dt[$fieldHelpTextIndex]); $inputDefBody = "<label>{$label}</label>\n" . "<hint>{$hint}</hint>\n"; $xpathPrefix = "/fhml/records/record/details/"; $groupRepeatHdr = ($atGroupStart ? "" : $groupSeparator) . "<label>{$label}</label>\n" . "<repeat nodeset=\"/fhml/records/record/details/dt{$dt_id}\">\n"; $groupRepeatFtr = "</repeat>\n" . ($fieldsLeft ? $groupSeparator : ""); $atGroupStart = false; // past detection code so if ($fieldtype != "groupbreak") { $bind = $bind . "<bind nodeset=\"records/record/details/dt{$dt_id}\" type=\"{$fieldtype}\" {$isrequired} {$constraint}/>\n"; } if ($isRepeatable) { $body .= $groupRepeatHdr; } if ($fieldtype == "select1" || $fieldtype == "select") { if ($baseType == "resource") { $body = $body . "<{$fieldtype} appearance=\"minimal\" ref=\"" . $xpathPrefix . "dt" . $dt_id . "\">\n" . $inputDefBody . createRecordLookup($rtIDs) . "</{$fieldtype}>\n"; } else { $termIDTree = $dettype[$di['dty_JsonTermIDTree']]; $disabledTermIDsList = $dettype[$di['dty_TermIDTreeNonSelectableIDs']]; $fieldLookup = $baseType == "relation" ? $relnLookup : $termLookup; $body = $body . "<{$fieldtype} appearance=\"minimal\" ref=\"" . $xpathPrefix . "dt" . $dt_id . "\">\n" . $inputDefBody . createTermSelect($termIDTree, $disabledTermIDsList, $fieldLookup, false, $ti) . "</{$fieldtype}>\n"; } } else { if ($fieldtype == "binary") { //todo check for sketch type $isDrawing = false; $appearance = $dt_id == DT_DRAWING ? "draw" : "annotate"; $body = $body . "<upload ref=\"" . $xpathPrefix . "dt{$dt_id}\" appearance=\"{$appearance}\" mediatype=\"image/*\">\n" . $inputDefBody . "</upload>\n"; } else { if ($fieldtype == "groupbreak") { // if we get to here we have a legitament sepearator so break $body .= $groupSeparator; $atGroupStart = true; } else { if ($dt_id == DT_COUNTER) { //we have a counter field so let's launch the Inventory Counter $body = $body . "<input appearance=\"ex:faims.android.INVENTORYCOUNT\" ref=\"" . $xpathPrefix . "dt{$dt_id}\">\n" . $inputDefBody . "</input>\n"; } else { //all others and $fieldtype=="geopoint" as well $body = $body . "<input ref=\"" . $xpathPrefix . "dt{$dt_id}\">\n" . $inputDefBody . "</input>\n"; } } } } if ($isRepeatable) { $body .= $groupRepeatFtr; if ($fieldsLeft > 0) { $atGroupStart = true; } } } $model = $model . "</details>\n" . "</record>\n" . "</records>\n" . "</fhml>\n" . "</instance>\n"; $body = $body . "</group>\n" . "</h:body>\n"; $form = "<?xml version=\"1.0\"?>\n" . "<h:html xmlns=\"http://www.w3.org/2002/forms\" xmlns:h=\"http://www.w3.org/1999/xhtml\" " . "xmlns:ev=\"http://www.w3.org/2001/xml-events\" " . "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " . "xmlns:jr=\"http://openrosa.org/javarosa\">\n" . "<h:head>\n" . "<h:title>{$rtName}</h:title>\n" . "<model>\n" . $model . $bind . "</model>\n" . "</h:head>\n" . $body . "</h:html>"; return array($form, $rtName, $rtConceptID, $rtDescription, $report); }
} else { array_push($rv, updateRectypeGroup($colNames, $rtgID, $rt)); } } if (!array_key_exists('error', $rv)) { $rv['rectypes'] = getAllRectypeStructures(); } break; case 'deleteRTG': $rtgID = @$_REQUEST['rtgID']; if (!$rtgID) { error_exit("Invalid or no record type group ID sent with deleteRectypeGroup method call to saveStructure.php"); } $rv = deleteRectypeGroup($rtgID); if (!array_key_exists('error', $rv)) { $rv['rectypes'] = getAllRectypeStructures(); } break; case 'saveDTG': // Field (detail) type group if (!array_key_exists('dettypegroups', $data) || !array_key_exists('colNames', $data['dettypegroups']) || !array_key_exists('defs', $data['dettypegroups'])) { error_exit("Invalid data structure sent with saveDetailTypeGroup method call to saveStructure.php"); } $colNames = $data['dettypegroups']['colNames']; foreach ($data['dettypegroups']['defs'] as $dtgID => $rt) { if ($dtgID == -1) { // new dettype group array_push($rv, createDettypeGroups($colNames, $rt)); } else { array_push($rv, updateDettypeGroup($colNames, $dtgID, $rt)); }
* @version 3.1.0 * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0 * @package Heurist academic knowledge management system * @subpackage !!!subpackagename for file such as Administration, Search, Edit, Application, Library */ require_once dirname(__FILE__) . '/../../common/config/initialise.php'; require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php'; require_once dirname(__FILE__) . '/../../common/php/dbMySqlWrappers.php'; require_once dirname(__FILE__) . '/../../common/php/getRecordInfoLibrary.php'; require_once dirname(__FILE__) . '/../../search/getSearchResults.php'; // Deals with all the database connections stuff mysql_connection_select(DATABASE); //place code here //echo DATABASE."\n"; //echo json_format(getVocabTree('reltype'),true)."<br><br><br>"; echo json_format(getAllRectypeStructures(), true) . "<br><br><br>"; /* echo $st = microtime(true)."<br><br><br>"; echo json_format(getAllRelatedRecords2(205),true)."<br><br><br>"; echo (($et = microtime(true))-$st)."<br><br><br>"; echo json_format(getAllRelatedRecords(205),true)."<br><br><br>"; echo microtime(true) - $et; */ /* ($str = '{"3001":{"3108":{}},"3406":{"3083":{},"3084":{},"3087":{},"3088":{},"3089":{},"3090":{},"3092":{},"3094":{},"3095":{},"3099":{},"3100":{},"3103":{},"3104":{},"3105":{}},"3407":{"3006":{},"3009":{},"3013":{},"3014":{},"3015":{},"3016":{},"3017":{},"3018":{},"3025":{},"3026":{},"3027":{},"3028":{},"3029":{},"3030":{},"3031":{},"3032":{},"3033":{},"3034":{},"3041":{},"3042":{},"3043":{},"3044":{},"3045":{},"3046":{},"3047":{},"3048":{},"3049":{},"3050":{},"3051":{},"3052":{},"3055":{},"3056":{},"3059":{},"3060":{},"3070":{},"3071":{}},"3408":{"3004":{},"3021":{},"3022":{},"3039":{},"3040":{},"3053":{},"3054":{},"3067":{},"3072":{},"3073":{},"3074":{},"3075":{},"3076":{},"3077":{},"3078":{},"3079":{},"3106":{},"3107":{}},"3409":{"3005":{},"3011":{},"3012":{},"3091":{}},"3410":{"3019":{},"3020":{},"3023":{},"3024":{},"3035":{},"3036":{},"3037":{},"3038":{},"3057":{},"3058":{},"3061":{},"3062":{},"3063":{},"3064":{},"3065":{},"3066":{},"3068":{},"3069":{},"3101":{},"3102":{}}}'; echo (strpos($str,"[")===false?0:1). "<br />"; $temp = preg_replace("/[\{\}\",]/","",$str); echo strrpos($temp,":"). "<br />"; echo strlen($temp). "<br />"; $temp = substr($temp,0, strlen($temp)-1); echo $temp. "<br />";
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied * See the License for the specific language governing permissions and limitations under the License. */ require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php'; require_once dirname(__FILE__) . '/../../common/php/getRecordInfoLibrary.php'; // Although the relationships are part of record strucutre, this also outputs the actual counts, hence login if (!is_logged_in()) { header("HTTP/1.1 401 Unauthorized"); exit; } // We are going to represent JSON. Must be on top. header("Content-Type: application/json"); // Code below is to grab data; copied from listRectypeRelations.php // and removed unneccessary parts to just generate XML for entities and relationships mysql_connection_select(DATABASE); $rtStructs = getAllRectypeStructures(true); $rtTerms = getTerms(true); $rtTerms = $rtTerms['termsByDomainLookup']['relation']; $image_base_url = HEURIST_SERVER_URL . "/HEURIST/HEURIST_FILESTORE/" . HEURIST_DBNAME . "/rectype-icons/"; $idx_dt_type = $rtStructs['typedefs']['dtFieldNamesToIndex']['dty_Type']; $idx_dt_pointers = $rtStructs['typedefs']['dtFieldNamesToIndex']['rst_PtrFilteredIDs']; $idx_dt_name = $rtStructs['typedefs']['dtFieldNamesToIndex']['rst_DisplayName']; $idx_dt_req = $rtStructs['typedefs']['dtFieldNamesToIndex']['rst_RequirementType']; $idx_dt_max = $rtStructs['typedefs']['dtFieldNamesToIndex']['rst_MaxValues']; $resrt = array(); foreach ($rtStructs['typedefs'] as $rt_id => $rt) { if (!is_numeric($rt_id)) { continue; } // ??? what does this do ??? $details = array();
/** * Main function * * @param mixed $_REQUEST */ function executeSmartyTemplate($params) { global $smarty, $outputfile, $isJSout, $rtStructs, $dtStructs, $dtTerms, $gparams; mysql_connection_overwrite(DATABASE); //AO: mysql_connection_select - does not work since there is no access to stored procedures(getTemporalDateString) Steve uses in some query //TODO SAW grant ROuser EXECUTE on getTemporalDate and any other readonly procs //load definitions (USE CACHE) $rtStructs = getAllRectypeStructures(true); $dtStructs = getAllDetailTypeStructures(true); $dtTerms = getTerms(true); $params["f"] = 1; //always search (do not use cache) $isJSout = array_key_exists("mode", $params) && $params["mode"] == "js"; //use javascript wrap $outputfile = array_key_exists("output", $params) ? $params["output"] : null; $publishmode = array_key_exists("publish", $params) ? intval($params['publish']) : 0; $gparams = $params; //keep to use in other functions if (!array_key_exists("limit", $params)) { //not defined $limit = intval(@$_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["display-preferences"]['report-output-limit']); if (!$limit || $limit < 1) { $limit = 1000; //default limit in dispPreferences } $params["limit"] = $limit; //force limit } $qresult = loadSearch($params); //from search/getSearchResults.php - loads array of records based og GET request /*****DEBUG****/ //error_log(print_r($qresult,true)); if (!array_key_exists('records', $qresult) || $qresult['resultCount'] == 0) { if ($publishmode > 0) { $error = "<b><font color='#ff0000'>Note: There are no records in this view. The URL will only show records to which the viewer has access. Unless you are logged in to the database, you can only see records which are marked as Public visibility</font></b>"; } else { $error = "<b><font color='#ff0000'>Search or Select records to see template output</font></b>"; } if ($isJSout) { $error = add_javascript_wrap4($error, null); } echo $error; if ($publishmode > 0 && $outputfile != null) { //save empty outpurt inot file save_report_output2("<div style=\"padding:20px;font-size:110%\">Currently there are no results</div>"); } exit; } //get name of template file $template_file = array_key_exists('template', $params) ? $params['template'] : null; //get template body from request (for execution from editor) $template_body = array_key_exists('template_body', $params) ? $params['template_body'] : null; //convert to array that will assigned to smarty variable $records = $qresult["records"]; $results = array(); $k = 0; foreach ($records as $rec) { $res1 = getRecordForSmarty($rec, 0, $k); $k++; array_push($results, $res1); } //activate default template - generic list of records $smarty->assign('results', $results); ini_set('display_errors', 'false'); // 'stdout' ); $smarty->error_reporting = 0; if ($template_body) { //execute template from string - modified temoplate in editor /*****DEBUG****/ //error_log(">>>".$template_body."<<<"); /*****DEBUG****/ //error_log(">>>>>>>".$replevel."<<<<<<"); //error report level: 1 notices, 2 all, 3 debug mode $replevel = array_key_exists('replevel', $params) ? $params['replevel'] : 0; if ($replevel == "1" || $replevel == "2") { ini_set('display_errors', 'true'); // 'stdout' ); $smarty->debugging = false; if ($replevel == "2") { $smarty->error_reporting = E_ALL & ~E_STRICT & ~E_NOTICE; } else { $smarty->error_reporting = E_NOTICE; } } else { $smarty->debugging = $replevel == "3"; } $smarty->debug_tpl = dirname(__FILE__) . '/debug_html.tpl'; //save temporary template //this is user name $template_file = "_temp.tpl"; $template_file = "_" . get_user_username() . ".tpl"; $file = fopen($smarty->template_dir . $template_file, "w"); fwrite($file, $template_body); fclose($file); //$smarty->display('string:'.$template_body); } else { // usual way - from file if (!$template_file) { $template_file = 'test01.tpl'; } $smarty->debugging = false; $smarty->error_reporting = 0; if ($outputfile != null) { $smarty->registerFilter('output', 'save_report_output'); } else { if ($isJSout) { $smarty->registerFilter('output', 'add_javascript_wrap5'); } } //$smarty->unregisterFilter('post','add_javascript_wrap'); } try { $smarty->display($template_file); } catch (Exception $e) { echo 'Exception on execution: ', $e->getMessage(), "\n"; } //$tpl_vars = $smarty->get_template_vars(); //var_dump($tpl_vars); //DEBUG stuff //@todo - return the list of record types - to obtain the applicable templates //echo "query result = ".print_r($qresult,true)."\n"; //header("Content-type: text/javascript"); //header('Content-type: text/html; charset=utf-8'); //echo json_format( $qresult, true); //echo "<br/>***<br/>"; //echo json_format( $results, true); //END DEBUG stuff }
$mask = $def_rts[$rtyID]['commonFields'][$idx_titlemask_canonical]; // note we use special global array $fields_correspondence - for proper conversion of remote id to concept code $res = updateTitleMask($rectypes_correspondence[$rtyID], $mask); if (!is_numeric($res)) { error_exit($res); } } } $mysqli->commit(); $mysqli->close(); // ------------------------------------------------------------------------------------------------ // Confirmation of import results if ($outputFormat == "json") { header("Content-type: text/javascript"); } else { $trg_rectypes = getAllRectypeStructures(); $trg_fieldtypes = getAllDetailTypeStructures(); $trg_terms = getTerms(); ?> <html> <head> <link rel="stylesheet" type="text/css" href="../../../common/css/global.css"> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body class="popup" title="Annotated template import"> <h4>Record type and associated structures imported</h4>
$_SERVER['REQUEST_URI'] = @$_SERVER['HTTP_REFERER']; // URI of the containing page if (array_key_exists('alt', $_REQUEST)) { define('use_alt_db', 1); } require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php'; require_once dirname(__FILE__) . '/../../common/php/dbMySqlWrappers.php'; require_once dirname(__FILE__) . '/../../common/php/Temporal.php'; mysql_connection_select(DATABASE); require_once dirname(__FILE__) . '/../../common/php/getRecordInfoLibrary.php'; require_once dirname(__FILE__) . '/../../records/woot/woot.php'; require_once dirname(__FILE__) . '/../../records/files/uploadFile.php'; $noclutter = array_key_exists('noclutter', $_REQUEST); $is_map_popup = array_key_exists('mapPopup', $_REQUEST) && $_REQUEST['mapPopup'] == 1; $is_reloadPopup = array_key_exists('reloadPopup', $_REQUEST) && $_REQUEST['reloadPopup'] == 1; $rectypesStructure = getAllRectypeStructures(); $terms = getTerms(); // get a list of workgroups the user belongs to. - ARTEM - NOT USED $ACCESSABLE_OWNER_IDS = mysql__select_array('sysUsrGrpLinks left join sysUGrps grp on grp.ugr_ID=ugl_GroupID', 'ugl_GroupID', 'ugl_UserID=' . get_user_id() . ' and grp.ugr_Type != "user" order by ugl_GroupID'); if (is_logged_in()) { array_push($ACCESSABLE_OWNER_IDS, get_user_id()); if (!in_array(0, $ACCESSABLE_OWNER_IDS)) { array_push($ACCESSABLE_OWNER_IDS, 0); } } // if we get a record id then see if there is a personal bookmark for it. if (@$_REQUEST['recID'] && !@$_REQUEST['bkmk_id']) { $res = mysql_query('select * from usrBookmarks where bkm_recID = ' . intval($_REQUEST['recID']) . ' and bkm_UGrpID = ' . get_user_id()); if ($res && mysql_num_rows($res) > 0) { $row = mysql_fetch_assoc($res); $_REQUEST['bkmk_id'] = $row['bkm_ID'];
/** * simple description * detailed desription * @global type description of global variable usage in a 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 */ function parseImportForm($fhmlFilename, $resources) { global $xmlForms, $formImportDir, $resourceUriRoot; static $dettypes, $di, $rectypes, $ri, $rid, $terms, $ti, $termLookup, $relnLookup; if (!$dettypes || !$di) { $dettypes = getAllDetailTypeStructures(); $dettypes = $dettypes['typedefs']; $di = $dettypes['fieldNamesToIndex']; } if (!$rectypes || !$ri || !$rid) { $rectypes = getAllRectypeStructures(); $ri = $rectypes['typedefs']['commonNamesToIndex']; $rid = $rectypes['typedefs']['dtFieldNamesToIndex']; } if (!$terms || !$ti || !$termLookup || !$relnLookup) { $terms = getTerms(); $ti = $terms['fieldNamesToIndex']; $termLookup = $terms['termsByDomainLookup']['enum']; $relnLookup = $terms['termsByDomainLookup']['relation']; } $dtyIDTrans = array("15" => "327", "28" => "119", "332" => "520", "336" => "510", "337" => "511", "322" => "508", 15 => 327, 28 => 119, 332 => 520, 336 => 510, 337 => 511, 322 => 508); //Survey Unit $fhmlDoc = simplexml_load_file($xmlForms["form"][$fhmlFilename]); $header = array(); $dataRow = array(); $recType = $fhmlDoc->xpath("/fhml/records/record/type/label"); echo "processing rectype: \"" . $recType[0] . "\" from: " . $fhmlFilename . "<br>"; // echo "rectyp: ".$recType[0]."<br>"; array_push($header, "rectype"); array_push($dataRow, $recType[0]); $formID = $fhmlDoc->xpath("/fhml/@id"); // echo "nonce: ".$nonce[0]."<br>"; array_push($header, "formID"); array_push($dataRow, $formID[0]); $formVer = $fhmlDoc->xpath("/fhml/@version"); // echo "nonce: ".$nonce[0]."<br>"; array_push($header, "formVer"); array_push($dataRow, $formVer[0]); $nonce = $fhmlDoc->xpath("/fhml/records/record/nonce"); // echo "nonce: ".$nonce[0]."<br>"; array_push($header, "nonce"); array_push($dataRow, $nonce[0]); // error_log("nonce = ".print_r($nonce,true)); $database = $fhmlDoc->xpath("/fhml/database"); $database = $database[0]; $dbID = $database->attributes(); $dbID = $dbID["id"]; $dateStamp = @$fhmlDoc->xpath("/fhml/dateStamp"); $createTime = @$fhmlDoc->xpath("/fhml/createTime"); if (!@$dateStamp[0] && @$createTime[0]) { $dateStamp = $createTime; } // echo "dataStamp: ".$dateStamp[0]."<br>"; array_push($header, "dateStamp"); array_push($dataRow, $dateStamp[0]); $deviceID = $fhmlDoc->xpath("/fhml/deviceID"); array_push($header, "deviceID"); array_push($dataRow, $deviceID[0]); $details = $fhmlDoc->xpath("/fhml/records/record/details"); foreach ($details[0]->children() as $detail) { // if ("".$detail == "") continue; $attr = $detail->attributes(); $dtyID = $detail->getName(); // error_log("dtyID ".print_r($dtyID,true)); $dtyID = preg_replace("/dt/", "", $dtyID); if ($dtyID == "15" || $dtyID == "345") { $detail = findRecorder($detail); } if ($dtyID == "322" || $dtyID == "344") { $detail = findSurveyUnit($detail); } //error_log("form dtyID ".print_r($dtyID,true)); $dtyID = @$dtyIDTrans[$dtyID] ? $dtyIDTrans[$dtyID] : $dtyID; // SPECIAL FOR ZAGORA IMPORT REMOVE!!!!!!!!!!!!!!!! //error_log("detailtype $dtyID ".print_r($dettypes[intval($dtyID)]['commonFields'],true)); $dtBaseType = $dettypes[intval($dtyID)]['commonFields'][$di['dty_Type']]; $detailName = $attr["name"] ? $attr["name"] : $detail->getName(); if ($dtBaseType == "freetext" || $dtBaseType == "blocktext") { //text so enclose in quotes if (preg_match("/\"/", $detail)) { $detail = preg_replace("/\"/", "'", $detail); //strip any quotes for non string values } $detail = "\"" . $detail . "\""; } else { $detail = preg_replace("/\"/", "", $detail); //strip any quotes for non string values } $dbConceptPrefix = $dbID . "-"; error_log("basetype = " . print_r($dtBaseType, true)); if ($dtBaseType == "enum" || $dtBaseType == 'relation') { $detail = preg_replace("/{$dbConceptPrefix}/", "", $detail); } else { if ($dtBaseType == 'geo') { preg_match_all("/\\d+\\.\\d+/", $detail, $match); //error_log("match".print_r($match,true)); $detail = "POINT(" . $match[0][1] . " " . $match[0][0] . ")"; } } // error_log("attr = ".$attr["name"]); // echo "".($attr["name"] ? $attr["name"] : $detail->getName()).": ". $detail."<br>"; array_push($header, $detailName); if ("" . $detail != "" && $resourceUriRoot && ($dtyID == DT_IMAGES || $dtyID == DT_DRAWING)) { // echo "has resource $inputFormResourceDir/$detail<br>"; //error_log("Photo magic= ".DT_IMAGES." dtyID= $dtyID"); //error_log("Sketch magic= ".DT_DRAWING." dtyID= $dtyID"); if (array_key_exists($detail, $resources)) { array_push($dataRow, $resourceUriRoot . $resources[$detail]); } else { array_push($dataRow, "resource file {$detail} not found"); } } else { array_push($dataRow, $detail); } } // echo "scratchPad: ".$fhmlDoc->asXML()."<br><br>"; array_push($header, "scratchPad"); $fhmlDoc->addChild('filename', $fhmlFilename); $fhml = $fhmlDoc->asXML(); $fhml = preg_replace("/^\\<\\?xml[^\\?]+\\?\\>/", "", $fhml); $fhml = "\"" . preg_replace("/\"/", "'", $fhml) . "\""; $fhml = "\"" . preg_replace("/\\</", "<", $fhml) . "\""; $fhml = "\"" . preg_replace("/\\>/", ">", $fhml) . "\""; array_push($dataRow, $fhml); array_push($header, "importFilename"); array_push($dataRow, $fhmlFilename); // echo join(",", $header); // echo "<br>"; // echo join(",", $dataRow); // echo "<br>"; // echo "<br>"; return array($recType[0], join(",", $header), join(",", $dataRow)); }
} else { $is_direct_call = false; } if (!defined('SAVE_URI')) { define("SAVE_URI", "disabled"); } // using ob_gzhandler makes this stuff up on IE6- //ini_set("zlib.output_compression_level", 5); //ob_start('ob_gzhandler'); require_once dirname(__FILE__) . "/../connect/applyCredentials.php"; require_once dirname(__FILE__) . "/getRecordInfoLibrary.php"; mysql_connection_select(DATABASE); if ($is_direct_call) { ob_start(); header("Content-type: text/javascript"); } $rv = array(); if (@$_REQUEST['action'] == 'usageCount') { $rv = getRecTypeUsageCount(); } else { $rv['rectypes'] = getAllRectypeStructures(false); $rv['detailTypes'] = getAllDetailTypeStructures(false); $rv['terms'] = getTerms(false); $rv['icon_url'] = HEURIST_ICON_URL; //HEURIST_SERVER_URL. } print json_encode($rv); //print json_format($rv); if ($is_direct_call) { ob_end_flush(); }
print "top.HEURIST.database = {};\n"; print "top.HEURIST.database.id = " . json_format(HEURIST_DBID) . ";\n"; print "top.HEURIST.database.name = " . json_format(HEURIST_DBNAME) . ";\n"; print "top.HEURIST.database.sessionPrefix = " . json_format(HEURIST_SESSION_DB_PREFIX) . ";\n"; print "top.HEURIST.database.version = " . json_format(HEURIST_DBVERSION) . ";\n"; print "if (!top.HEURIST.baseURL_V3) top.HEURIST.baseURL_V3 = " . json_format(HEURIST_BASE_URL) . ";\n"; print "if (!top.HEURIST.baseURL_V4) top.HEURIST.baseURL_V4 = " . json_format(HEURIST_BASE_URL) . ";\n"; print "if (!top.HEURIST.iconDir) top.HEURIST.iconDir = " . json_format(HEURIST_ICON_DIR) . ";\n"; print "if (!top.HEURIST.iconBaseURL) top.HEURIST.iconBaseURL = top.HEURIST.baseURL_V4+ 'hserver/dbaccess/rt_icon.php?db='+top.HEURIST.database.name+'&id=';\n"; //.json_format(HEURIST_ICON_URL) . ";\n"; //print "alert(top.HEURIST.iconBaseURL);"; // $cache=true - use cache //$cache = (!array_keys(@$_REQUEST, 'cache') || @$_REQUEST['cache']=="1"); /* rectypes are an array of names sorted alphabetically, and lists of primary (bibliographic) and other rectypes, also sorted alphbetically */ print "top.HEURIST.rectypes = " . json_format(getAllRectypeStructures(true)) . ";\n"; /* detailTypes */ print "top.HEURIST.detailTypes = " . json_format(getAllDetailTypeStructures(true)) . ";\n\n"; print "\ntop.HEURIST.terms = \n" . json_format(getTerms(true), true) . ";\n"; print "\ntop.HEURIST.transforms = \n" . json_format(getTransformsByOwnerGroup(), true) . ";\n"; print "\ntop.HEURIST.tools = \n" . json_format(getToolsByTransform(), true) . ";\n"; /*print "\ntop.HEURIST.terms.termsByDomainLookup = \n" . json_format(getTerms(),true) . ";\n"; print "\ntop.HEURIST.terms.treesByDomain = { 'relation' : " . json_format(getTermTree("reltype","prefix"),true).",\n 'enum' : " . json_format(getTermTree("enum","prefix"),true)." };\n"; */ ?> top.HEURIST.ratings = {"0": "not rated", "1": "*", "2": "**",
function createMappingForm($config) { global $sourcedbname, $db_prefix, $dbPrefix, $is_h2, $password, $username; $sourcedb = $db_prefix . $sourcedbname; print "<br>\n"; print "Source database: <b>{$sourcedb}</b> <br>\n"; if ($is_h2) { $res = mysql_query("select * from `{$sourcedb}`.Users"); } else { $res = mysql_query("select * from {$sourcedb}.sysIdentification"); } if (!$res) { die("<p>Unable to open source database <b>{$sourcedb}</b>. Make sure you have included prefix"); } print "<form id='mapping' name='mappings' action='getRecordsFromDB.php' method='post'>"; print "<input id='mode' name='mode' value='5' type='hidden'>"; // calls the transfer function print "<input name='db' value='" . HEURIST_DBNAME . "' type='hidden'>"; print "<input name='h2' value='" . ($is_h2 ? 1 : 0) . "' type='hidden'>"; print "<input name='sourcedbname' value='{$sourcedbname}' type='hidden'>"; if (!$is_h2) { print "<input name='username' value='{$username}' type='hidden'>"; print "<input name='password' value='{$password}' type='hidden'>"; } print "<input name='reportlevel' value='1' type='checkbox' checked='checked'> Report level: show errors only<br>"; print "Check the code mappings below, then click <input type='button' value='Import data' onclick='{document.getElementById(\"mode\").value=5; document.forms[\"mappings\"].submit();}'>\n"; // alert(document.getElementById(\"mode\").value); print "<input type='button' value='Print mapping' onclick='{printMapping();}'> "; print "<input type='button' value='Save settings' onclick='{document.getElementById(\"mode\").value=3; document.forms[\"mappings\"].submit();}'>"; $filename = HEURIST_UPLOAD_DIR . "settings/importfrom_" . $sourcedbname . ".cfg"; if (file_exists($filename)) { print " <input type='submit' value='Load settings' onclick='{document.getElementById(\"mode\").value=4; document.forms[\"mappings\"].submit();}'>\n"; } print "<p><hr>\n"; // -------------------------------------------------------------------------------------------------------------------- // Get the record type mapping, by default assume that the code is unchanged so select the equivalent record type if available $allrectypes = getAllRectypeStructures(); //in current database $entnames = $allrectypes['names']; $seloptions = createOptions("or", $entnames); if ($is_h2) { $query1 = "SELECT DISTINCT `rec_type`,`rt_name`, '0' as cnt FROM `{$sourcedb}`.`records`,`{$sourcedb}`.`rec_types` where `rec_type`=`rt_id`"; } else { $query1 = "SELECT rty_ID, rty_Name, count(rec_ID) as cnt, rty_OriginatingDBID, rty_IDInOriginatingDB " . "from `{$sourcedb}`.`Records` " . "left join `{$sourcedb}`.`defRecTypes` on rec_RecTypeID=rty_ID " . "group by rty_ID"; } $res1 = mysql_query($query1); if (mysql_num_rows($res1) == 0) { die("<p><b>Sorry, there are no data records in this database, or database is bad format</b>"); } print "<h3>Record type mappings</h3>[RT code] <b>{$sourcedb}</b> (use count) ==> <b>{$dbPrefix}" . HEURIST_DBNAME . "</b><p>"; // . "<p>"; print "<table>"; while ($row1 = mysql_fetch_array($res1)) { $rt = $row1[0]; //0=rec_RecTypeID $cnt = $row1[2]; $selopts = $seloptions; $selectedId = null; $bgcolor = ""; if ($config) { $selectedId = getPresetId($config, "cbr" . $rt); } else { if (!$is_h2) { //find by concept code $selectedId = findByRtConceptCode($row1[3], $row1[4], $allrectypes); if ($selectedId) { $bgcolor = "style='background-color:#ccffcc;'"; } } if (!$selectedId) { //find the closest name $selectedId = findClosestName($row1[1], $entnames); //1=rty_Name if ($selectedId < 0) { //exact match $bgcolor = "style='background-color:#ccc;'"; $selectedId = -$selectedId; } } } if ($selectedId) { $repl = "value='" . $selectedId . "'"; $selopts = str_replace($repl, $repl . " selected='selected' ", $selopts); } print "<tr {$bgcolor}><td><label id='lblr{$rt}'>[ {$rt} ] " . $row1[1] . ($is_h2 ? "" : "({$cnt}) ") . "</label></td>" . "<td>==> <select id='cbr{$rt}' name='cbr{$rt}' class='rectypes'><option id='or0' value='0'></option>" . $selopts . "</select></td></tr>\n"; } // loop through record types print "</table>"; // -------------------------------------------------------------------------------------------------------------------- // Get the field type mapping, by default assume that the code is unchanged so select the equivalent detail type if available //create the string for combobox $alldettypes = getAllDetailTypeStructures(); //in current database $entnames = $alldettypes['names']; $seloptions = createOptionsDt($alldettypes); print "<h3>Field type mappings</h3>[FT code] <b>{$sourcedb}</b> ==> <b>{$dbPrefix}" . HEURIST_DBNAME . "</b><p>"; // . "<p>"; if ($is_h2) { $query1 = "SELECT DISTINCT `rd_type`,`rdt_name`,`rdt_type` FROM `{$sourcedb}`.`rec_details`,`{$sourcedb}`.`rec_detail_types` " . "where `rd_type`=`rdt_id`"; } else { $query1 = "SELECT DISTINCT `dtl_DetailTypeID`,`dty_Name`,`dty_Type`,`dty_OriginatingDBID`,`dty_IDInOriginatingDB` FROM `{$sourcedb}`.`recDetails`,`{$sourcedb}`.`defDetailTypes` " . "where `dtl_DetailTypeID`=`dty_ID`"; } $res1 = mysql_query($query1); print "<table>"; while ($row1 = mysql_fetch_array($res1)) { $ft = $row1[0]; //0=dtl_DetailTypeID $selopts = $seloptions; $bgcolor = ""; $selectedId = null; //find the closest name if ($config) { $selectedId = getPresetId($config, "cbd" . $ft); } else { if (!$is_h2) { //find by concept code $selectedId = findByDtConceptCode($row1[3], $row1[4], $alldettypes); if ($selectedId) { $bgcolor = "style='background-color:#ccffcc;'"; } } if (!$selectedId) { //find the closest name $selectedId = findClosestName($row1[1], $entnames); //dty_Name if ($selectedId < 0) { //exact match $bgcolor = "style='background-color:#ccc;'"; $selectedId = -$selectedId; } } } if ($selectedId) { $repl = "value='" . $selectedId . "'"; $selopts = str_replace($repl, $repl . " selected='selected' ", $selopts); } print "<tr {$bgcolor}><td><label id='lbld{$ft}'>[ {$ft} - " . $row1[2] . " ] " . $row1[1] . "</label></td>" . "<td>==> <select id='cbd{$ft}' name='cbd{$ft}' class='detailTypes'><option id='od0' value='0'></option>" . $selopts . "</select></td></tr>\n"; } // loop through field types print "</table>"; // -------------------------------------------------------------------------------------------------------------------- createTermsOptions($config, 'enum'); createTermsOptions($config, 'relation'); print "</form>"; }
?> <div style="width: 600px;"> This function writes a set of FAIMS project definition files (db schema, ui schema, ui logic, A16N) to a zip file, based on the record types selected from the Heurist database, along with any required image or map data files. These files can be loaded into the FAIMS server to create a new module.<p/> </div> <?php print "<form id='startform' name='startform' action='exportFAIMS.php' method='get'>"; print "<input id='rt_selected' name='rt' type='hidden'>"; print "<input name='step' value='1' type='hidden'>"; print "<input name='db' value='" . HEURIST_DBNAME . "' type='hidden'>"; print "<div><div class='lbl_form'>Module name</div><input name='projname' value='" . ($projname ? $projname : HEURIST_DBNAME) . "' size='25'></div>"; // List of record types for export print "<div id='selectedRectypes' style='width:100%;color:black;'></div>"; $rtStructs = getAllRectypeStructures(false); $int_rt_dt_type = $rtStructs['typedefs']['dtFieldNamesToIndex']["dty_Type"]; $rt_geoenabled = array(); $rt_invalid_masks = array(); if ($rt_toexport && count($rt_toexport) > 0) { //validate title masks $rtIDs = mysql__select_assoc("defRecTypes", "rty_ID", "rty_Name", " rty_ID in (" . implode(",", $rt_toexport) . ") order by rty_ID"); foreach ($rtIDs as $rtID => $rtName) { $mask = mysql__select_array("defRecTypes", "rty_TitleMask", "rty_ID={$rtID}"); $mask = $mask[0]; $res = titlemask_make($mask, $rtID, 2, null, _ERR_REP_MSG); //get human readable if (is_array($res)) { //invalid mask array_push($rt_invalid_masks, $rtName); }
function print_linked_details($bib) { global $relRT; $res = mysql_query('select * from recDetails left join defDetailTypes on dty_ID = dtl_DetailTypeID left join Records on rec_ID = dtl_RecID where dty_Type = "resource" and dtl_DetailTypeID = dty_ID and dtl_Value = ' . $bib['rec_ID'] . ' and rec_RecTypeID != ' . $relRT); if (mysql_num_rows($res) <= 0) { return; } ?> <div class=detailRowHeader>Linked from <div class=detailRow> <div class=detailType>Referencing records</div> <div class=detail><a href="<?php echo HEURIST_SITE_PATH; ?> search/search.html?db=<?php echo HEURIST_DBNAME; ?> &w=all&q=linkto:<?php echo $bib['rec_ID']; ?> " onClick="top.location.href = this.href; return false;"><b>Show list below as search results</b></a> <!-- <br> <i>Search = linkto:<?php echo $bib['rec_ID']; ?> <br>(returns records pointing TO this record)</i> --> </div></div> <?php $rectypesStructure = getAllRectypeStructures(); while ($row = mysql_fetch_assoc($res)) { print '<div class=detailRow>'; print '<div class=detailType>Linked from</div>'; print '<div class=detail>'; print '<img class="rft" style="background-image:url(' . HEURIST_ICON_SITE_PATH . $row['rec_RecTypeID'] . '.png)" title="' . $rectypesStructure['names'][$row['rec_RecTypeID']] . '" src="' . HEURIST_SITE_PATH . 'common/images/16x16.gif"> '; print '<a target=_new href="' . HEURIST_SITE_PATH . 'records/view/renderRecordData.php?db=' . HEURIST_DBNAME . '&recID=' . $row['rec_ID'] . (defined('use_alt_db') ? '&alt' : '') . '" onclick="return link_open(this);">' . htmlspecialchars($row['rec_Title']) . '</a>'; print '</div></div>'; } }
/** * get rectype usageCount and update cache value if exist * usageCount = {rtyID:nonzero-count,...} * @return object non-zero usage counts indexed by rtyID * @uses DATABASE * @uses getCachedData() * @uses setCachedData() * @uses getAllRectypeStructures() */ function updateRecTypeUsageCount() { $cacheKey = DATABASE . ":AllRecTypeInfo"; $rtStructs = getCachedData($cacheKey); if ($rtStructs) { $usageCount = getRecTypeUsageCount(); $rtStructs['usageCount'] = $usageCount; //save into cache setCachedData($cacheKey, $rtStructs); return $usageCount; } else { //there is no cache - create entire structure $rtStructs = getAllRectypeStructures(true); return $rtStructs['usageCount']; } }
function addDefaultFieldForNewRecordType($rtyID) { $dt = getAllDetailTypeStructures(); $dt = $dt['typedefs']; $rv = getAllRectypeStructures(); $dtFieldNames = $rv['typedefs']['dtFieldNames']; $di = $dt['fieldNamesToIndex']; $ri = $rv['typedefs']['dtFieldNamesToIndex']; $data = array(); $data['dtFields'] = array(DT_NAME => getInitRty($ri, $di, $dt, DT_NAME, array('required', 1, 40)), DT_SHORT_SUMMARY => getInitRty($ri, $di, $dt, DT_SHORT_SUMMARY, array('recommended', 1, 60))); updateRecStructure($dtFieldNames, $rtyID, $data); }
/** * put your comment there... * * * @param mixed $config */ function createMappingForm($config) { global $sourcedbname, $db_prefix, $dbPrefix, $is_h2, $useOriginalID; $sourcedb = $db_prefix . $sourcedbname; print "<br>\n"; //print "Source database: <b>$sourcedb</b> <br>\n"; if ($is_h2) { $res = mysql_query("select * from `{$sourcedb}`.Users"); } else { $res = mysql_query("select * from {$sourcedb}.sysIdentification"); } if (!$res) { die("<p>Unable to open source database <b>{$sourcedb}</b>. Make sure you have included prefix"); } print "<form name='mappings' action='compareStructure.php' method='post'>"; print "<input id='mode' name='mode' value='5' type='hidden'>"; // calls the transfer function print "<input name='db' value='" . HEURIST_DBNAME . "' type='hidden'>"; print "<input name='h2' value='" . ($is_h2 ? 1 : 0) . "' type='hidden'>"; //print "<input name='sourcedbname' value='$sourcedbname' type='hidden'>"; //print "<input name='reportlevel' value='1' type='checkbox' checked='checked'>Report level: show errors only<br>"; //print "Check the code mappings below, then click <input type='button' value='Import data' onclick='{document.getElementById(\"mode\").value=5; document.forms[\"mappings\"].submit();}'>\n"; // alert(document.getElementById(\"mode\").value); /* print "<input type='button' value='Save settings' onclick='{document.getElementById(\"mode\").value=3; document.forms[\"mappings\"].submit();}'>"; $filename = HEURIST_FILESTORE_DIR."settings/importfrom_".$sourcedbname.".cfg"; if(file_exists($filename)){ print "<input type='submit' value='Load settings' onclick='{document.getElementById(\"mode\").value=4; document.forms[\"mappings\"].submit();}'>\n"; } */ print "<p><hr>\n"; // -------------------------------------------------------------------------------------------------------------------- // Get the record type mapping, by default assume that the code is unchanged so select the equivalent record type if available $d_rectypes = getAllRectypeStructures(); //in current database $d_dettypes = getAllDetailTypeStructures(); $d_rtnames = $d_rectypes['names']; mysql_connection_overwrite($sourcedb); $s_rectypes = getAllRectypeStructures(false); $s_dettypes = getAllDetailTypeStructures(false); $s_rtnames = $s_rectypes['names']; print "<table border='1' width='900'><tr><td width='300'>" . $sourcedbname . "</td><td colspan='2'>" . HEURIST_DBNAME . "</td></tr>"; $fi_type = $s_dettypes['typedefs']['fieldNamesToIndex']['dty_Type']; $fi_name = $s_dettypes['typedefs']['fieldNamesToIndex']['dty_Name']; $fi_rt_concept = $s_rectypes['typedefs']['commonNamesToIndex']['rty_ConceptID']; $fi_dt_concept = $s_dettypes['typedefs']['fieldNamesToIndex']['dty_ConceptID']; foreach ($s_rtnames as $s_id => $s_name) { $s_conceptid = $s_rectypes['typedefs'][$s_id]['commonFields'][$fi_rt_concept]; $dest_id = null; $dest_name = null; //find record type in destination foreach ($d_rtnames as $d_id => $d_name) { if ($useOriginalID && $d_rectypes['typedefs'][$d_id]['commonFields'][$fi_rt_concept] == $s_conceptid || !$useOriginalID && $d_name == $s_name) { //print "[".$d_id."] ".$d_name."<br/>"; //print structure in the same order as source rectype $dest_id = $d_id; $dest_name = $d_name; break; } } //Header <tr><td colspan='2'><table border='1' width='100%'> print "<tr style='background-color:#AAAAAA;'><td width='250'><b>[" . $s_id . "] " . $s_name . "</b>(" . $s_conceptid . ")</td><td width='250'>"; if ($dest_id == null) { print "...not found"; } else { print "<b>[" . $dest_id . "] " . $dest_name . "</b>"; } print "</td><td width='400'> </td></tr>"; //list of field types $s_flds = $s_rectypes['typedefs'][$s_id]['dtFields']; foreach ($s_flds as $sft_id => $sft_desc) { $fld_in_dest_rectype = " "; $fld_in_dest_all = " "; $s_conceptid = $s_dettypes['typedefs'][$sft_id]['commonFields'][$fi_dt_concept]; $s_fitype = $s_dettypes['typedefs'][$sft_id]['commonFields'][$fi_type]; //find in destination record type if ($dest_id != null) { $d_flds = $d_rectypes['typedefs'][$dest_id]['dtFields']; foreach ($d_flds as $dft_id => $dft_desc) { //compare by original field name and by type if ($useOriginalID && $d_dettypes['typedefs'][$dft_id]['commonFields'][$fi_dt_concept] == $s_conceptid || !$useOriginalID && $s_dettypes['names'][$sft_id] == $d_dettypes['names'][$dft_id] && $s_fitype == $d_dettypes['typedefs'][$dft_id]['commonFields'][$fi_type]) { $fld_in_dest_rectype = "[" . $dft_id . "] " . $dft_desc[0]; break; } } } //if not found try to find in entire list of field types if ($fld_in_dest_rectype == " ") { $d_flds = $d_dettypes['typedefs']; foreach ($d_flds as $dft_id => $dft_def) { //compare by original field name and by type if ($useOriginalID && $dft_def['commonFields'][$fi_dt_concept] == $s_conceptid || !$useOriginalID && $s_dettypes['names'][$sft_id] == $dft_def['commonFields'][$fi_name] && $s_fitype == $dft_def['commonFields'][$fi_type]) { $fld_in_dest_all = "[" . $dft_id . "] " . $dft_def['commonFields'][$fi_name] . " (" . $s_fitype . ")"; break; } } } print "<tr><td>[" . $sft_id . "] " . $sft_desc[0] . " (" . $s_conceptid . ")</td><td>" . $fld_in_dest_rectype . "</td><td>" . $fld_in_dest_all . "</td></tr>"; } ///print "</table></td><tr>"; } print "</table>"; return; $entnames = $entnames['names']; $seloptions = createOptions("or", $entnames); if ($is_h2) { $query1 = "SELECT DISTINCT `rec_type`,`rt_name` FROM `{$sourcedb}`.`records`,`{$sourcedb}`.`rec_types` where `rec_type`=`rt_id`"; } else { $query1 = "SELECT rty_ID, rty_Name, count(rec_ID) as cnt " . "from `{$sourcedb}`.`Records` " . "left join `{$sourcedb}`.`defRecTypes` on rec_RecTypeID=rty_ID " . "group by rty_ID"; } $res1 = mysql_query($query1); if (mysql_num_rows($res1) == 0) { die("<p><b>Sorry, there are no data records in this database, or database is bad format</b>"); } print "<h3>Record type mappings</h3> [RT code] <b>{$sourcedb}</b> (use count) ==> <b>{$dbPrefix}" . HEURIST_DBNAME . "</b><p>"; // . "<p>"; print "<table>"; while ($row1 = mysql_fetch_array($res1)) { $rt = $row1[0]; //0=rec_RecTypeID $cnt = $row1[2]; $selopts = $seloptions; $selectedId = getPresetId($config, "cbr" . $rt); if (!$selectedId) { //find the closest name $selectedId = findClosestName($row1[1], $entnames); //1=rty_Name } if ($selectedId) { $repl = "value='" . $selectedId . "'"; $selopts = str_replace($repl, $repl . " selected='selected' ", $selopts); } print "<tr><td>" . $row1[1] . " [ {$rt} ] n=({$cnt}) </td>" . "<td>==> <select id='cbr{$rt}' name='cbr{$rt}' class='rectypes'><option id='or0' value='0'></option>" . $selopts . "</select></td></tr>\n"; } // loop through record types print "</table>"; // -------------------------------------------------------------------------------------------------------------------- // Get the field type mapping, by default assume that the code is unchanged so select the equivalent detail type if available //create the string for combobox $entnames = getAllDetailTypeStructures(); //in current database $entnames = $entnames['names']; $seloptions = createOptions("od", $entnames); print "<h3>Field type mappings</h3>[FT code] <b>{$sourcedb}</b> ==> <b>{$dbPrefix}" . HEURIST_DBNAME . "</b><p>"; // . "<p>"; if ($is_h2) { $query1 = "SELECT DISTINCT `rd_type`,`rdt_name`,`rdt_type` FROM `{$sourcedb}`.`rec_details`,`{$sourcedb}`.`rec_detail_types` " . "where `rd_type`=`rdt_id`"; } else { $query1 = "SELECT DISTINCT `dtl_DetailTypeID`,`dty_Name`,`dty_Type` FROM `{$sourcedb}`.`recDetails`,`{$sourcedb}`.`defDetailTypes` " . "where `dtl_DetailTypeID`=`dty_ID`"; } $res1 = mysql_query($query1); print "<table>"; while ($row1 = mysql_fetch_array($res1)) { $ft = $row1[0]; //0=dtl_DetailTypeID $selopts = $seloptions; //find the closest name $selectedId = getPresetId($config, "cbd" . $ft); if (!$selectedId) { //find the closest name $selectedId = findClosestName($row1[1], $entnames); //dty_Name } if ($selectedId) { $repl = "value='" . $selectedId . "'"; $selopts = str_replace($repl, $repl . " selected='selected' ", $selopts); } print "<tr><td>[ {$ft} ] - " . $row1[2] . " " . $row1[1] . " </td>" . "<td>==> <select id='cbd{$ft}' name='cbd{$ft}' class='detailTypes'><option id='od0' value='0'></option>" . $selopts . "</select></td></tr>\n"; } // loop through field types print "</table>"; // -------------------------------------------------------------------------------------------------------------------- createTermsOptions($config, 'enum'); createTermsOptions($config, 'relation'); print "</form>"; }
<a href="#" onclick="getValues(0);return false;"><img src="../../common/images/calendar-ll-arrow.gif" /></a> <a href="#" onclick="getValues(-1);return false;"><img src="../../common/images/calendar-l-arrow.gif" /></a> Values in row <span id="currrow_1"></span> <a href="#" onclick="getValues(1);return false;"><img src="../../common/images/calendar-r-arrow.gif" /></a> <a href="#" onclick="getValues(recCount);return false;"><img src="../../common/images/calendar-rr-arrow.gif" /></a> </th></tr> </thead> <?php // // render mapping table with list of columns and datatype selectors // $sIndexes = ""; $sRemain = ""; $sProcessed = ""; $recStruc = getAllRectypeStructures(true); $idx_dt_name = $recStruc['typedefs']['dtFieldNamesToIndex']['rst_DisplayName']; //$idx_rt_name = $recStruc['commonNamesToIndex']['rty_Name']; for ($i = 0; $i < $len; $i++) { $isProcessed = @$imp_session["mapping"]["field_" . $i]; $isIndex = false; // set up checkboxes for selection of fields to insert / update if ($isProcessed) { $checkbox = '<td align="center"><input type="checkbox" disabled="disabled" /></td>'; //processed } else { $rectype = @$imp_session['indexes']["field_" . $i]; $isIndex = $rectype != null; $checkbox = '<td align="center"> <span style="display:none;"><input type="checkbox" id="cbsa_dt_' . $i . '" onchange="{showHideSelect(' . $i . ');}"/></span></td>'; } $s = '<tr>' . $checkbox;