示例#1
0
 /**
  *
  * @param type $arrSubmitted
  * @param type $arrLabels
  * @param type $objForm
  */
 public function emailNearestStore(&$arrSubmitted, $arrLabels, $objForm)
 {
     if ($objForm->anystores_emailNearestStore == 1) {
         // if there is no postal field
         if (!strlen($arrSubmitted['postal'])) {
             \System::log("No postal field for email nearest store", __METHOD__, TL_ERROR);
             return;
         }
         $arrSearch[] = $arrSubmitted['street'] ?: null;
         $arrSearch[] = $arrSubmitted['postal'] ?: null;
         $arrSearch[] = $arrSubmitted['city'] ?: null;
         $arrSearch[] = $arrSubmitted['country'] ?: null;
         // drop empty arrays
         $arrSearch = array_filter($arrSearch, 'count');
         // query string
         $strSearch = implode(', ', $arrSearch);
         $objStore = AnyStoresModel::findPublishedByAdressAndCountryAndCategory($strSearch, null, deserialize($objForm->anystores_categories), 1);
         if (!$objStore) {
             \System::log("No store found for email", __METHOD__, TL_ERROR);
             return;
         }
         if (\Validator::isEmail($objStore->email)) {
             // legagy contao
             $objForm->recipient .= ',' . $objStore->email;
             // efg
             $objForm->formattedMailRecipient .= ',' . $objStore->email;
         }
     }
 }
 /**
  * Generate module
  */
 protected function compile()
 {
     // hide list when details shown
     //@todo make optinonal in module
     if (strlen(\Input::get('auto_item')) || strlen(\Input::get('store'))) {
         return;
     }
     // localized url parameter
     //@todo use $GLOBALS['TL_URL_PARAMS']...
     $this->strSearchKey = $GLOBALS['TL_LANG']['anystores']['url_params']['search'];
     $this->strSearchValue = \Input::get($this->strSearchKey);
     $this->strCountryKey = $GLOBALS['TL_LANG']['anystores']['url_params']['country'];
     $this->strCountryValue = \Input::get($this->strCountryKey) ?: $this->anystores_defaultCountry;
     // if no empty search is allowed
     if (!$this->anystores_allowEmptySearch && !$this->strSearchValue && $this->strCountryValue) {
         $this->Template->error = $GLOBALS['TL_LANG']['anystores']['noResults'];
         return;
     }
     if (!$this->strSearchValue) {
         // order
         $arrOptions = array();
         if (strlen($this->anystores_sortingOrder)) {
             $arrOptions['order'] = $this->anystores_sortingOrder;
         }
         $objStore = AnyStoresModel::findPublishedByCategoryAndCountry(deserialize($this->anystores_categories), $this->strCountryValue, $arrOptions);
     } else {
         $objStore = AnyStoresModel::findPublishedByAdressAndCountryAndCategory($this->strSearchValue, $this->strCountryValue, deserialize($this->anystores_categories), $this->anystores_listLimit, $this->anystores_limitDistance ? $this->anystores_maxDistance : null);
     }
     if (!$objStore) {
         $this->Template->error = $GLOBALS['TL_LANG']['anystores']['noResults'];
         return;
     }
     while ($objStore->next()) {
         $objTemplate = new \Contao\FrontendTemplate($this->anystores_detailTpl);
         // generate jump to
         if ($this->jumpTo) {
             if (($objLocation = \PageModel::findByPk($this->jumpTo)) !== null) {
                 //@todo language parameter
                 $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/';
                 $strStoreValue = $objStore->alias;
                 $objStore->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue);
             }
         }
         $arrStore = $objStore->current()->loadDetails()->row();
         $objTemplate->setData($arrStore);
         $arrStores[] = $objTemplate->parse();
         $arrRawStores[] = $arrStore;
     }
     $this->Template->stores = $arrStores;
     $this->Template->rawstores = $arrRawStores;
     // set licence hint
     $this->Template->licence = $GLOBALS['ANYSTORES_GEODATA_LICENCE_HINT'];
 }