コード例 #1
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());
 }
コード例 #2
0
  */
 $paArray = UrlVar('paddlingAreas', array());
 if (!empty($paArray)) {
     include_once 'lib/Util.php';
     $sitesArray = array();
     // I am working on another method called FilteredSiteListInAreas
     // which will work using Attribute filters - this will hopefully
     // be more robust and ignore minor spelling differences
     $siteList = json_decode(UrlVar('siteList', '[]'));
     if (is_array($siteList) && !empty($siteList)) {
         GeoliveHelper::QueriedSiteListInAreasInIdList($paArray, $siteList, function ($row) use(&$sitesArray) {
             $sitesArray[] = get_object_vars($row);
         });
     } else {
         GeoliveHelper::QueriedSiteListInAreas($paArray, function ($row) use(&$sitesArray) {
             $sitesArray[] = get_object_vars($row);
         });
     }
     // die(Core::GetDatasource()->getQuery());
     if (UrlVar('exportOutput') == 'kml') {
         // export kmz file, this requires writing
         // to a temprotary file, kmz is a zip file with
         // .kmz extensions
         $filename = tempnam(__DIR__, 'zip');
         include_once 'lib/KmlWriter.php';
         $kmlWriter = new KmlWriter();
         $zip = new ZipArchive();
         $zip->open($filename);
         // add kml file
         if (count($sitesArray) == 0) {
             throw new Exception('No sites in site list:' . json_encode($siteList) . ' or paddling areas: ' . json_encode($paArray) . '  --  ' . GeoliveHelper::Database()->lastQuery());