Exemplo n.º 1
0
function code_lookup()
{
    if ($_SESSION['logged_in'] != "yes") {
        not_logged_in();
    }
    // set things up
    $rets = new phRETS();
    $rets->AddHeader("Accept", "*/*");
    $rets->AddHeader("RETS-Version", "RETS/{$_SESSION['rets_version']}");
    $rets->AddHeader("User-Agent", $_SESSION['user_agent']);
    $rets->SetParam("compression_enabled", true);
    if ($_SESSION['force_basic'] == "true") {
        $rets->SetParam("force_basic_authentication", true);
    }
    // make first connection
    $connect = $rets->Connect($_SESSION['login_url'], $_SESSION['username'], $_SESSION['password'], $_SESSION['ua_pwd']);
    if (!$connect) {
        $error_details = $rets->Error();
        $error_text = strip_tags($error_details['text']);
        $error_type = strtoupper($error_details['type']);
        show_error_page("<center><span style='color:red;font-weight:bold;'>{$error_type} ({$error_details['code']}) {$error_text}</span></center>");
    }
    // make lookup request
    $rets_lookup_values = $rets->GetLookupValues($_REQUEST['r_resource'], $_REQUEST['r_lookupname']);
    $field_bg = "white-bg";
    $lookup_table = "";
    if (is_array($rets_lookup_values) && count($rets_lookup_values) > 0) {
        // loop through loopup values returned
        foreach ($rets_lookup_values as $lookup) {
            $lookup_table .= "<tr class='{$field_bg}'><td>{$lookup['Value']}</td><td>{$lookup['ShortValue']}</td><td>{$lookup['LongValue']}</td></tr>\n";
            $field_bg = $field_bg == "light-bg" ? "white-bg" : "light-bg";
        }
    } elseif (is_array($rets_lookup_values) && count($rets_lookup_values) == 0) {
        $lookup_table .= "<tr class='white-bg'><td align='center' colspan='3'>No available lookups for this field</td></tr>\n";
    } else {
        $lookup_table .= "<tr><td colspan='3'>" . print_r($rets->Error(), true) . "</td></tr>\n";
    }
    // disconnect from the RETS server
    $rets->Disconnect();
    ?>

<div class='box'>
	<a name='md-details'></a>
	<div class='box_heading dark-bg'><?php 
    echo $_REQUEST['r_resource'] . ':' . $_REQUEST['r_lookupname'];
    ?>
 Lookup Values</div>
	<div class='box_content light-bg'>

<table border='0' cellpadding='2' cellspacing='0' width='100%' class='metadata_details_fields'>
<tr><td width='15%'><b>Value</b></td><td width='35%'><b>Short Value</b></td><td width='50%'><b>Long Value</b></td></tr>
<?php 
    echo $lookup_table;
    ?>
</table>

	</div>
</div>


<?php 
}