Example #1
0
 * limitations under the License.
 * 
 */
require '../../vendor/autoload.php';
use BOTK\Core\EndPointFactory, BOTK\Core\ErrorManager;
// Control errors
use Geocodit\View\GoogleAnalyticsEnabledRenderer;
// for CSS
use BOTK\Context\Context;
// get config vars and other inputs
use BOTK\Context\ContextNameSpace as CX;
// search configs files in  in config and /etc/geocodit directories
if (!isset($_ENV['BOTK_CONFIGDIR'])) {
    if (file_exists(__DIR__ . '/../../config/geocodit.ini')) {
        $_ENV['BOTK_CONFIGDIR'] = realpath(__DIR__ . '/../../config');
    } elseif (is_dir('/etc/geocodit')) {
        $_ENV['BOTK_CONFIGDIR'] = '/etc/geocodit';
    }
}
// Enable Universal Analytics code
$UA = Context::factory()->ns('geocodit')->getValue('UA', CX::NULL_AS_DEFAULT);
GoogleAnalyticsEnabledRenderer::$UniversalAnalyticsId = $UA;
// Enable the catching of PHP errors
$errorManager = ErrorManager::getInstance()->registerErrorHandler();
try {
    $endpoint = EndPointFactory::make('Geocodit\\ApiEndpoint');
    $result = $endpoint->run();
} catch (Exception $e) {
    $result = ErrorManager::getInstance()->render($e);
}
echo $result;
Example #2
0
if (!isset($_ENV['BOTK_CONFIGDIR'])) {
    if (file_exists(__DIR__ . '/../config/geocodit.ini')) {
        $_ENV['BOTK_CONFIGDIR'] = realpath(__DIR__ . '/../config');
    } elseif (is_dir('/etc/geocodit')) {
        $_ENV['BOTK_CONFIGDIR'] = '/etc/geocodit';
    }
}
$config = \BOTK\Context\Context::factory()->ns('geocodit');
$penality = $config->getValue('penality', 2);
$endpoint = $config->getValue('endpoint', DEMO_ENDPOINT);
$defaultAddress = $config->getValue('defaultAddress', 'Via Montefiori 13, Esino Lario');
// test google maps and bing maps credentials
$googleApiKeyNotSetWarning = $config->getValue('googleApiKey', '') ? '' : "<li style='color: red'>WARNING: google maps api key not available (continue at your risk)</li>";
$bingApiKeyNotSetWarning = $config->getValue('bingApiKey', '') ? '' : "<li style='color: red' >WARNING: bing maps api key not available, bing maps will return errors</li>";
// Enable Universal Analytics code
$UASnippet = \Geocodit\View\GoogleAnalyticsEnabledRenderer::GoogleAnalyticsSnippet($config->getValue('UA', ''));
$passwordHint = $endpoint == DEMO_ENDPOINT ? ' (demo/demo)' : '';
?>
<!DOCTYPE html>
<html>
    <head>
		<meta charset='utf-8'>
		<link rel='stylesheet' type='text/css' href='http://linkeddata.center/resources/v4/css/doc.css'/>
		<style type='text/css'>
		    main {
		        font-family: monospace;
		        white-space: pre;
		    }
		</style>
        <title>GeocodIT demo</title>
    </head>