コード例 #1
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->import('FrontendUser', 'User');
     $session = $this->Session->get('bnfilter') ?: array();
     if (strlen($session['geo_lat']) > 0 && strlen($session['geo_lon']) > 0) {
         $geodata = array('lat' => $session['geo_lat'], 'lon' => $session['geo_lon']);
     } else {
         $geodata = $this->getGeoDataFromCurrentPosition();
     }
     // Get the total number of items
     $intTotal = \BnLibrariesModel::countLibEntries($geodata, $session['distance']);
     // Filter anwenden um die Gesamtanzahl zuermitteln
     if ($intTotal > 0) {
         $libsObj = \BnLibrariesModel::findLibs($intTotal, 0, $geodata, $session['distance']);
         $counter = 0;
         $libs = array();
         while ($libsObj->next()) {
             // aktuell offen
             if ($session['only_open'] && $this->getCurrentOpenStatus($libsObj) != 'open') {
                 continue;
             }
             // bietet eine bestimmte Leistung an
             if (strlen($session['leistungen']) > 0 && !$this->hasLeistung($libsObj)) {
                 continue;
             }
             // bietet eine bestimmte Medienart an
             if (strlen($session['medien']) > 0 && !$this->hasMedia($libsObj)) {
                 continue;
             }
             //Detail-Url
             if ($this->jumpTo) {
                 $objDetailPage = \PageModel::findByPk($this->jumpTo);
             }
             //wenn alle Filter stimmen -> Werte setzen
             $libs[] = array('lat' => $libsObj->lat, 'lon' => $libsObj->lon, 'name' => $libsObj->bibliotheksname, 'plz' => $libsObj->plz, 'ort' => $libsObj->ort, 'strasse' => $libsObj->strasse, 'hnr' => $libsObj->hausnummer, 'detailUrl' => ampersand($this->generateFrontendUrl($objDetailPage->row(), '/lib/' . $libsObj->id)), 'openstatus' => $this->getCurrentOpenStatus($libsObj));
             $counter++;
         }
     }
     if ((int) $intTotal > $counter) {
         $intTotal = $counter;
     }
     // //set fallback (Hannover)
     if ($geodata['lat'] == '') {
         $geodata['lat'] = 52.4544218;
     }
     if ($geodata['lon'] == '') {
         $geodata['lon'] = 9.918507699999999;
     }
     $GLOBALS['TL_JAVASCRIPT'][] = '.' . BN_PATH . '/assets/js/bn_fe.js';
     $this->Template->libs = $libs;
     $this->Template->filterActive = \Input::get('s') ? true : false;
     $this->Template->geodata = $geodata;
     $this->Template->zoomlevel = count($session) == 0 ? 7 : 9;
     $this->Template->totalItems = $intTotal;
     // $this->Template->showAllUrl = $this->generateFrontendUrl($objPage->row());
 }
コード例 #2
0
 public function getcurrentGeoData()
 {
     $geodata = array();
     $address = '';
     $oldAddressDataObj = \BnLibrariesModel::findLibByIdOrAlias($this->User->library_id);
     $oldAddressData = $oldAddressDataObj->row();
     $geodata = array('lat' => $oldAddressData['lat'], 'lon' => $oldAddressData['lon']);
     if ($oldAddressData['strasse'] != \Input::post('strasse') || $oldAddressData['hausnummer'] != \Input::post('hausnummer') || $oldAddressData['plz'] != \Input::post('plz') || $oldAddressData['ort'] != \Input::post('ort') || $oldAddressData['gemeinde'] != \Input::post('gemeinde') || $oldAddressData['landkreis'] != \Input::post('landkreis')) {
         $adddress = \Input::post('strasse') . ' ' . \Input::post('hausnummer') . ', ' . \Input::post('plz') . ' ' . \Input::post('ort') . ', ' . \Input::post('landkreis') . ', Niedersachsen';
         $newGeoData = $this->getGeoDataFromAddress($adddress);
         if (is_array($newGeoData) || count($newGeoData) > 0) {
             $geodata = $newGeoData;
         }
     }
     //___________ HIER GEHTS WEITER ________________________
     // print_r($geodata);
     // exit();
     //______________________________________________________
     return $geodata;
 }