<?php

$table = $params["table"];
// echo '<pre>';var_dump($params); echo '</pre>';
// ist feld google_geocode vorhanden ?
$fields = rex_xform_manager_table::getXFormFields($table["table_name"], array("type_id" => "value", "type_name" => "google_geocode"));
if (count($fields) > 0) {
    $func = rex_request("geo_func", "string");
    $field = rex_request("geo_field", "string");
    if ($func == "get_data") {
        $data = array();
        ob_end_clean();
        if (array_key_exists($field, $fields)) {
            $address_fields = explode(",", $fields[$field]["f3"]);
            $fs = array();
            foreach ($address_fields as $f) {
                $fs[] = '`' . mysql_real_escape_string(trim($f)) . '`';
            }
            $concat = 'CONCAT(' . implode(' , ",", ', $fs) . ') as address';
            $pos_fields = explode(",", $fields[$field]["f2"]);
            if (count($pos_fields) == 2) {
                $pos_lng = $pos_fields[0];
                $pos_lat = $pos_fields[1];
                $gd = rex_sql::factory();
                // $gd->debugsql = 1;
                $gd->setQuery('select id, ' . $concat . ' from ' . $table["table_name"] . ' where ' . $pos_lng . '="" or ' . $pos_lng . ' IS NULL or ' . $pos_lat . '="" or ' . $pos_lat . ' IS NULL LIMIT 200');
                // 1000
                $data = $gd->getArray();
            }
        }
        echo json_encode($data);
<?php

/**
 * XForm
 * @author jan.kristinus[at]redaxo[dot]org Jan Kristinus
 * @author <a href="http://www.yakamara.de">www.yakamara.de</a>
 */
$table = $params['table'];
// ist feld google_geocode vorhanden ?
$fields = rex_xform_manager_table::getXFormFields($table['table_name'], array('type_id' => 'value', 'type_name' => 'google_geocode'));
if (count($fields) > 0) {
    $func = rex_request('geo_func', 'string');
    $field = rex_request('geo_field', 'string');
    if ($func == 'get_data') {
        $data = array();
        ob_end_clean();
        if (array_key_exists($field, $fields)) {
            $address_fields = explode(',', $fields[$field]['f3']);
            $fs = array();
            foreach ($address_fields as $f) {
                $fs[] = '`' . mysql_real_escape_string(trim($f)) . '`';
            }
            $concat = 'CONCAT(' . implode(' , ",", ', $fs) . ') as address';
            $pos_fields = explode(',', $fields[$field]['label']);
            if (count($pos_fields) == 2) {
                $pos_lng = $pos_fields[0];
                $pos_lat = $pos_fields[1];
                $gd = rex_sql::factory();
                // $gd->debugsql = 1;
                $gd->setQuery('select id, ' . $concat . ' from ' . $table['table_name'] . ' where ' . $pos_lng . '="" or ' . $pos_lng . ' IS NULL or ' . $pos_lat . '="" or ' . $pos_lat . ' IS NULL LIMIT 200');
                // 1000
 function getMissingFields($table_name)
 {
     $xfields = rex_xform_manager_table::getXFormFields($table_name);
     $rfields = rex_xform_manager_table::getFields($table_name);
     $c = array();
     foreach ($rfields as $k => $v) {
         if (!array_key_exists($k, $xfields)) {
             $c[$k] = $k;
         }
     }
     return $c;
 }