/** * Generate the module */ protected function compile() { global $objPage; $session = $this->Session->get('bmfilter') ?: array(); // Get the total number of items $objStore = \BmStoresModel::findByIdOrAlias(\Input::get('store')); if ($objStore === null) { // Do not index or cache the page $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); $this->Template->articles = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>'; return; } $storeData = $objStore->row(); // Kategorie if ((int) $storeData['category'] > 0) { $catObj = $this->Database->prepare('SELECT * FROM `tl_bm_stores_categories` WHERE `id`=? ')->limit(1)->execute($storeData['category']); if ($catObj->numRows > 0) { $storeData['category'] = $catObj->name; } } // Website $storeData['website_href'] = substr($storeData['website'], 0, 4) != 'http' ? 'http://' . $storeData['website'] : $storeData['website']; // facebook $storeData['facebook_href'] = substr($storeData['facebook'], 0, 4) != 'http' ? 'http://' . $storeData['facebook'] : $storeData['facebook']; // twitter $storeData['twitter_href'] = substr($storeData['twitter'], 0, 4) != 'http' ? 'http://' . $storeData['twitter'] : $storeData['twitter']; // gplus $storeData['gplus_href'] = substr($storeData['gplus'], 0, 4) != 'http' ? 'http://' . $storeData['gplus'] : $storeData['gplus']; // blog $storeData['blog_href'] = substr($storeData['blog'], 0, 4) != 'http' ? 'http://' . $storeData['blog'] : $storeData['blog']; // Email $this->import('String'); $storeData['email'] = $this->String->encodeEmail($storeData['email']); //for smartphone phonenumber clean for href $replaces = array(' ', ',', '/', '(', ')', '[', ']', '{', '}', '+'); $storeData['phone_href'] = str_replace($replaces, '', $storeData['telefon']); // Open-Status $storeData['open_status'] = $this->getCurrentOpenStatus($objLibrary); $GLOBALS['TL_JAVASCRIPT'][] = '.' . BN_PATH . '/assets/js/bn_fe.js'; // Google-Maps url-search-string $storeData['gmapsplace'] = ampersand($storeData['strasse'] . ' ' . $storeData['hausnummer'] . ', ' . $storeData['plz'] . ' ' . $storeData['ort']); //Bilder vorbereiten $scaletype = 'proportional'; $img_height = 250; $img_width = 250; $storeData['images'] = array(); for ($ic = 0; $ic <= 5; $ic++) { if (strlen($storeData['image_' . $ic]) > 0) { $storeData['images'][] = array('thumb' => \Image::get($storeData['image_' . $ic], $img_width, $img_height, $scaletype), 'src' => $storeData['image_' . $ic]); } } $this->Template->data = $storeData; $this->Template->articles = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; }
/** * replace bn-specific inserttag if get-paramter isset * bn::colname::alternative from objPage * @param string * @return string */ public function replaceBmInsertTags($strTag) { if (substr($strTag, 0, 4) == 'bn::') { global $objPage; $storeIdAlias = \Input::get('store'); $split = explode('::', $strTag); switch ($split[1]) { case 'fullname': if (!$storeIdAlias) { return $objPage->{$split}[2]; } $objStore = \BmStoresModel::findByIdOrAlias($storeIdAlias); $fullname = $objStore->filialname; return $fullname; break; case 'printbutton': return !$libId ? '' : '<a href="javascript:window.print()" class="printbutton"><i class="fa fa-print"></i></a>'; break; default: return $objStore->{$split}[1]; } } return false; }
/** * Generate the module */ protected function compile() { $offset = intval($this->skipFirst); $limit = null; $this->Template->libraries = array(); // Maximum number of items if ($this->numberOfItems > 0) { $limit = $this->numberOfItems; } $session = $this->Session->get('bmfilter') ?: 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 = \BmStoresModel::countStoreEntries($geodata, $session['distance']); // Filter anwenden um die Gesamtanzahl zuermitteln if ($intTotal > 0) { $filterStoresObj = \BmStoresModel::findStores($intTotal, 0, $geodata, $session['distance']); $counter = 0; $idArr = array(); while ($filterStoresObj->next()) { // aktuell offen if ($session['only_open'] && $this->getCurrentOpenStatus($filterStoresObj) != 'open') { continue; } // gehoert einer bestimmten Kategorie an if (strlen($session['category']) > 0 && !$this->hasCategory($filterStoresObj)) { continue; } //wenn alle Filter stimmen -> Werte setzen $idArr[] = $filterStoresObj->id; $counter++; } if ((int) $intTotal > $counter) { $intTotal = $counter; } } if ((int) $intTotal < 1) { $this->Template = new \FrontendTemplate('mod_bm_entries_empty'); $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyBmList']; return; } $total = $intTotal - $offset; // Split the results if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage)) { // Adjust the overall limit if (isset($limit)) { $total = min($limit, $total); } // Get the current page $id = 'page_n' . $this->id; $page = \Input::get($id) ?: 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) { global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; $objTarget = \PageModel::findByPk($objPage->id); if ($objTarget !== null) { $reloadUrl = ampersand($this->generateFrontendUrl($objTarget->row())); } $this->redirect($reloadUrl); } // Set limit and offset $limit = $this->perPage; $offset += (max($page, 1) - 1) * $this->perPage; $skip = intval($this->skipFirst); // Overall limit if ($offset + $limit > $total + $skip) { $limit = $total + $skip - $offset; } // Add the pagination menu $objPagination = new \Pagination($total, $this->perPage, $GLOBALS['TL_CONFIG']['maxPaginationLinks'], $id); $this->Template->pagination = $objPagination->generate("\n "); } // Get the items if (isset($limit)) { $storesObj = \BmStoresModel::findStores($limit, $offset, $geodata, $session['distance'], $idArr); } else { $storesObj = \BmStoresModel::findStores(0, $offset, $geodata, $session['distance'], $idArr); } // No items found if ($storesObj === null) { $this->Template = new \FrontendTemplate('mod_bm_entries_empty'); $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyBmList']; } else { $this->Template->stores = $this->parseStores($storesObj); } $GLOBALS['TL_JAVASCRIPT'][] = '.' . BM_PATH . '/assets/js/bm_fe.js'; $this->Template->isDistance = count($session) > 0 && strlen($session['plzcity']) > 0 ? true : false; $this->Template->filterActive = \Input::get('s') ? true : false; $this->Template->totalItems = $intTotal; }
/** * Generate the module */ protected function compile() { $this->import('FrontendUser', 'User'); $this->Template->session = false; $session = $this->Session->get('bmfilter') ?: array(); //Formular verarbeiten wenn es gesendet wurde if ($this->Input->post('FORM_SUBMIT') == 'tl_bm_search_form') { if ($this->Input->post('filter_reset') == 1) { $session = array(); } else { $geodata = $this->getGeoDataFromCurrentPosition(urlencode(\Input::post('plzcity'))); $session = array('plzcity' => $geodata['plzcity'], 'distance' => $this->Input->post('distance'), 'only_open' => $this->Input->post('only_open'), 'category' => $this->Input->post('category'), 'geo_lat' => $geodata['lat'], 'geo_lon' => $geodata['lon']); } $this->Session->set('bmfilter', $session); $this->Input->setPost('FORM_SUBMIT', ''); if ($this->jumpTo) { $objDetailPage = \PageModel::findByPk($this->jumpTo); $listUrl = ampersand($this->generateFrontendUrl($objDetailPage->row())); $this->redirect($listUrl); } $this->reload(); } 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 = \BmStoresModel::countStoreEntries($geodata, $session['distance']); // Filter anwenden um die Gesamtanzahl zuermitteln if ($intTotal > 0) { $filterStoresObj = \BmStoresModel::findStores($intTotal, 0, $geodata, $session['distance']); $counter = 0; $idArr = array(); while ($filterStoresObj->next()) { // aktuell offen if ($session['only_open'] && $this->getCurrentOpenStatus($filterStoresObj) != 'open') { continue; } // gehoert einer bestimmten Kategorie an if (strlen($session['category']) > 0 && !$this->hasCategory($filterStoresObj)) { continue; } //wenn alle Filter stimmen -> Werte setzen $idArr[] = $filterStoresObj->id; $counter++; } if ((int) $intTotal > $counter) { $intTotal = $counter; } } $this->Template->total = (int) $intTotal; if (count($session) > 0) { $this->Template->session = true; $this->Template->plzcity = $session['plzcity']; $this->Template->distance = $session['distance']; $this->Template->only_open = $session['only_open']; $this->Template->cid = $session['category']; } else { //default-Werte setzen $this->Template->distance = 15; } $GLOBALS['TL_CSS'][] = '.' . BM_PATH . '/assets/css/jquery-ui-autocomplete.min.css'; $GLOBALS['TL_CSS'][] = '.' . BM_PATH . '/assets/css/bm_autocomplete.css'; $GLOBALS['TL_JAVASCRIPT'][] = '.' . BM_PATH . '/assets/js/jquery-ui-autocomplete.min.js'; $GLOBALS['TL_BODY'][] = '<script> (function($){ $(document).ready(function(){ $("#plzcity").autocomplete({ source: document.URL+"?action=ajax&id=' . $this->id . '", minLength: 2, response: function( event, ui ) { console.log(ui.content); } }); }); })(jQuery); </script>'; //Kategorien-Optionen $categoriesArr = array(); $cObj = $this->Database->prepare('SELECT `id`,`title` FROM `tl_bm_stores_categories` ORDER BY `sorting` ASC')->execute(); if ($cObj->numRows > 0) { while ($cObj->next()) { $categoriesArr[$cObj->id] = $cObj->title; } } $this->Template->categories = $categoriesArr; }