'geoloc_administrativeareas', 'subAdministrativeArea' => 'geoloc_subadministrativeareas', 'locality' => 'geoloc_localities', ); $areaName = $area . 'Name'; $areaId = $area . 'Id'; if (!is_null($address->$areaName) && isset($databases[$area])) { $res = XDB::query('SELECT id FROM ' . $databases[$area] . ' WHERE name = {?}', $address->$areaName); if ($res->numRows() == 0) { XDB::execute('INSERT INTO ' . $databases[$area] . ' (name, country) VALUES ({?}, {?})', $address->$areaName, $address->countryId); $address->$areaId = XDB::insertId(); } else { $address->$areaId = $res->fetchOneCell(); } } elseif (empty($address->$areaId)) { $address->$areaId = null; } } // Returns the part of the text preceeding the line with the postal code // and the city name, within the limit of $limit number of lines. static public function getFirstLines($text, $postalCode, $limit) { $textArray = explode("\n", $text); for ($i = 0; $i < count($textArray); ++$i) { if ($i > $limit || strpos($textLine, $postalCode) !== false) { $limit = $i; break; } } return implode("\n", array_slice($textArray, 0, $limit)); } // Returns the number of non geocoded addresses for a user. static public function countNonGeocoded($pid, $jobid = null, $type = Address::LINK_PROFILE) { $where = array(); if (!is_null($pid)) { $where[] = XDB::format('pid = {?}', $pid); } if (!is_null($jobid)) { $where[] = XDB::format('jobid = {?}', $jobid); } $where[] = XDB::format('FIND_IN_SET({?}, type) AND accuracy = 0', $type); $res = XDB::query('SELECT COUNT(*) FROM profile_addresses WHERE ' . implode(' AND ', $where), $pid); return $res->fetchOneCell(); } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>