コード例 #1
0
 public static function CountSites()
 {
     $args = json_decode(UrlVar('json', '{}'));
     $sites = array();
     if (is_array($args->paddlingAreas)) {
         $count = GeoliveHelper::CountSitesInAreas($args->paddlingAreas);
     }
     echo json_encode(array('count' => $count, 'success' => true), JSON_PRETTY_PRINT);
 }
コード例 #2
0
 public function testSiteCount()
 {
     include_once dirname(__DIR__) . '/lib/GeoliveHelper.php';
     include_once dirname(__DIR__) . '/lib/AjaxRequest.php';
     $access = array('public', 'special', 'site-planning');
     $c = GeoliveHelper::CountSitesInAreas(array("Douglas Gardner"), $access);
     $this->assertEquals(22, $c);
     $count = 0;
     GeoliveHelper::QueriedSiteListInAreas(array("Douglas Gardner"), function ($i) use(&$count) {
         $count++;
     }, $access);
     $this->assertEquals(22, $count, GeoliveHelper::Database()->lastQuery());
 }
コード例 #3
0
                    $regionObj->areas[] = $paddleObj;
                }
                $regionObjArray[] = $regionObj;
                file_put_contents(__DIR__ . DS . 'regions.json', json_encode($regionObjArray, JSON_PRETTY_PRINT));
            }
        } else {
            $regionObjArray = json_decode(file_get_contents(__DIR__ . DS . 'regions.json'));
        }
        if (empty($regionObjArray)) {
            throw new Exception('There were no regions');
        }
        // HtmlBock is used to seperate templates from code
        // look in scaffolds/html.form.select.php
        HtmlBlock('form.select', array('regions' => $regionObjArray, 'layers' => array_map(function ($layer) {
            return array('id' => $layer->getId(), 'name' => $layer->getName());
        }, GeoliveHelper::VisibleLayers()), 'url' => UrlFrom(__FILE__)), __DIR__ . DS . 'scaffolds');
        if (false && Core::Client()->isAdmin()) {
            // disabled
            // link to test for admin
            ?>
<a href="<?php 
            echo UrlFrom(__FILE__);
            ?>
?task=unit_test">run
	unit tests</a><?php 
        }
    } else {
        throw new Exception("Unrecognized Execution Environment");
    }
} catch (Exception $e) {
    die(print_r($e, true));
コード例 #4
0
 public static function QueriedSiteListInAreasInIdList($areas, $ids, $iteratorCallback)
 {
     $from = "FROM " . GeoliveHelper::AttributeTable() . " a inner join " . GeoliveHelper::MapitemTable() . " m on a.mapitem = m.id WHERE m.lid IN (" . implode(', ', array_map(function ($layer) {
         return $layer->getId();
     }, self::VisibleLayers())) . ") AND m.id IN(" . implode(', ', array_map(function ($id) {
         return (int) $id;
     }, $ids)) . ")";
     $paWhere = 'AND (' . implode(' OR ', array_map(function ($pa) {
         return 'lower(trim(a.paddlingArea))  = lower(trim(\'' . GeoliveHelper::Database()->escape($pa) . '\'))';
     }, $areas)) . ')';
     $query = "SELECT * {$from} {$paWhere} order by m.name";
     self::Database()->iterate($query, $iteratorCallback);
 }
コード例 #5
0
<?php

/**
 * This is the access point for displaying the map, paddlingArea, selection tool
 */
try {
    include_once __DIR__ . '/lib/GeoliveHelper.php';
    error_reporting(E_ALL ^ E_NOTICE);
    // report everything except notices
    ini_set('display_errors', 1);
    ini_set('log_errors', 1);
    ini_set('error_log', '../logs/siteSearch.log');
    if (GeoliveHelper::ScriptWasAccessedDirectlyFromUrl()) {
        HtmlBlock('paddlingareas.map', array(), __DIR__ . DS . 'scaffolds');
    } else {
        throw new Exception("Unrecognized Execution Environment");
    }
} catch (Exception $e) {
    die(print_r($e, true));
}