Пример #1
0
function outputLocidSelectionForm($locSql, $urlparams)
{
    global $tplname, $locline, $stylepath, $bgcolor1, $bgcolor2;
    require_once $stylepath . '/selectlocid.inc.php';
    unset($urlparams['queryid']);
    unset($urlparams['locid']);
    $urlparams['searchto'] = 'search' . $urlparams['searchtype'];
    unset($urlparams['searchtype']);
    $tplname = 'selectlocid';
    // urlparams zusammenbauen
    $urlparamString = '';
    foreach ($urlparams as $name => $param) {
        // workaround for attribs
        if (is_array($param)) {
            $pnew = '';
            foreach ($param as $p) {
                if ($pnew != '') {
                    $pnew .= ';' . $p;
                } else {
                    $pnew .= $p;
                }
            }
            $param = $pnew;
        }
        if ($urlparamString != '') {
            $urlparamString .= '&' . $name . '=' . urlencode($param);
        } else {
            $urlparamString = $name . '=' . urlencode($param);
        }
    }
    $urlparamString .= '&locid={locid}';
    sql('CREATE TEMPORARY TABLE `locids` ENGINE=MEMORY ' . $locSql);
    sql('ALTER TABLE `locids` ADD PRIMARY KEY (`loc_id`)');
    $rs = sql('SELECT `geodb_textdata`.`loc_id` `loc_id`, `geodb_textdata`.`text_val` `text_val` FROM `geodb_textdata`, `locids` WHERE `locids`.`loc_id`=`geodb_textdata`.`loc_id` AND `geodb_textdata`.`text_type`=500100000 ORDER BY `text_val`');
    $nr = 1;
    $locations = '';
    while ($r = sql_fetch_array($rs)) {
        $thislocation = $locline;
        // locationsdings zusammenbauen
        $locString = '';
        $land = landFromLocid($r['loc_id']);
        if ($land != '') {
            $locString .= htmlspecialchars($land, ENT_COMPAT, 'UTF-8');
        }
        $rb = regierungsbezirkFromLocid($r['loc_id']);
        if ($rb != '') {
            $locString .= ' > ' . htmlspecialchars($rb, ENT_COMPAT, 'UTF-8');
        }
        $lk = landkreisFromLocid($r['loc_id']);
        if ($lk != '') {
            $locString .= ' > ' . htmlspecialchars($lk, ENT_COMPAT, 'UTF-8');
        }
        $thislocation = mb_ereg_replace('{parentlocations}', $locString, $thislocation);
        // koordinaten ermitteln
        $r['loc_id'] = $r['loc_id'] + 0;
        $rsCoords = sql('SELECT `lon`, `lat` FROM `geodb_coordinates` WHERE loc_id=' . $r['loc_id'] . ' LIMIT 1');
        if ($rCoords = sql_fetch_array($rsCoords)) {
            $coordString = help_latToDegreeStr($rCoords['lat']) . ' ' . help_lonToDegreeStr($rCoords['lon']);
        } else {
            $coordString = '[keine Koordinaten vorhanden]';
        }
        $thislocation = mb_ereg_replace('{coords}', htmlspecialchars($coordString, ENT_COMPAT, 'UTF-8'), $thislocation);
        $thislocation = mb_ereg_replace('{locationname}', htmlspecialchars($r['text_val'], ENT_COMPAT, 'UTF-8'), $thislocation);
        $thislocation = mb_ereg_replace('{urlparams}', $urlparamString, $thislocation);
        $thislocation = mb_ereg_replace('{locid}', urlencode($r['loc_id']), $thislocation);
        $thislocation = mb_ereg_replace('{nr}', $nr, $thislocation);
        $thislocation = mb_ereg_replace('{secondlocationname}', '', $thislocation);
        if ($nr % 2) {
            $thislocation = mb_ereg_replace('{bgcolor}', $bgcolor1, $thislocation);
        } else {
            $thislocation = mb_ereg_replace('{bgcolor}', $bgcolor2, $thislocation);
        }
        $nr++;
        $locations .= $thislocation . "\n";
    }
    tpl_set_var('locations', $locations);
    tpl_set_var('resultscount', mysql_num_rows($rs));
    tpl_set_var('pages', $first_img_inactive . ' ' . $prev_img_inactive . ' 1 ' . $next_img_inactive . ' ' . $last_img_inactive);
    tpl_BuildTemplate();
    exit;
}
Пример #2
0
        $locid = $r['loc_id'];
        $admtxt1 = landFromLocid($locid);
        if ($admtxt1 == '0') {
            $admtxt1 = '';
        }
        // bundesland ermitteln
        $rsAdm2 = sql("SELECT `full_name`, `short_form` FROM `gns_locations` WHERE `rc`='&1' AND `fc`='A' AND `dsg`='ADM1' AND `cc1`='&2' AND `adm1`='&3' AND `nt`='N' LIMIT 1", $rLocations['rc'], $rLocations['cc1'], $rLocations['adm1']);
        if (mysql_num_rows($rsAdm2) == 1) {
            $rAdm2 = sql_fetch_array($rsAdm2);
            $admtxt2 = $rAdm2['short_form'];
            if ($admtxt2 == '') {
                $admtxt2 = $rAdm2['full_name'];
            }
        } else {
            $admtxt3 = '';
        }
        $admtxt3 = regierungsbezirkFromLocid($locid);
        if ($admtxt3 == '0') {
            $admtxt3 = '';
        }
        $admtxt4 = landkreisFromLocid($locid);
        if ($admtxt4 == '0') {
            $admtxt4 = '';
        }
        sql("UPDATE `gns_locations` SET `admtxt1`='&1', `admtxt2`='&2', `admtxt3`='&3', `admtxt4`='&4' WHERE uni='&5'", $admtxt1, $admtxt2, $admtxt3, $admtxt4, $rLocations['uni']);
    } else {
        // was tun?
    }
}
mysql_free_result($rsLocations);
/* end search index rebuild */