/**
  * Generate the module
  */
 protected function compile()
 {
     //Categories selected in List-Module-Options
     $arrCategoriesToShow = deserialize($this->gloImmoConnectorTypeSelector);
     $filter = null;
     if (\Input::post('FORM_SUBMIT') == $this->_searchFormId) {
         $filter = array('objectType' => htmlspecialchars(\Input::post('objectType')), 'zipcode' => htmlspecialchars(\Input::post('zipcode')), 'city' => htmlspecialchars(\Input::post('city')), 'keyword' => htmlspecialchars(\Input::post('keyword')));
     }
     //Get Expose Page
     if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->_objTarget = $objTarget;
     }
     $objImmoConnector = new ImmoConnector('is24', \Config::get('gloImmoConnectorKey'), \Config::get('gloImmoConnectorSecret'));
     //User auf null setzen bzw. Username auslesen
     $objUser = \IcAuthModel::findByPk($this->gloImmoConnectorUser);
     if (is_null($objUser)) {
         throw new \Exception("Missing or invalid User selected for API-Connection", 1);
     }
     $objRes = $objImmoConnector->getAllUserObjects($objUser, $filter);
     $arrRes = $this->orderObjects(simplexml_import_dom($objRes));
     // Filtern auf die Kategorien der der Moduleinstellungen
     if (count($arrCategoriesToShow) > 0) {
         $arrRes = array_intersect_key($arrRes, array_flip($arrCategoriesToShow));
     }
     unset($objXml);
     $arrTypes = array_keys($arrRes);
     //Rendern der Objekt-Daten
     $arrRendered = array();
     foreach ($arrRes as $strType => $objList) {
         $arrRendered[$strType] = $this->renderObjectTypeGroup($strType, $objList);
     }
     unset($arrRes);
     $this->Template->realEstateObjects = $arrRendered;
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $objImmoConnector = new ImmoConnector('is24', \Config::get('gloImmoConnectorKey'), \Config::get('gloImmoConnectorSecret'));
     //User auf null setzen bzw. Username auslesen
     $objUser = \IcAuthModel::findByPk($this->gloImmoConnectorUser);
     if (is_null($objUser)) {
         throw new \Exception("Missing or invalid User selected for API-Connection", 1);
     }
     //Get Expose Page
     if ($this->gloImmoConnectorjumpTo && ($objTarget = $this->objModel->getRelated('gloImmoConnectorjumpTo')) !== null) {
         $this->_objTarget = $objTarget;
     }
     $objRes = $objImmoConnector->getAllUserObjects($objUser);
     $xpath = new \DOMXPath($objRes);
     $objList = $xpath->query("//realEstateElement");
     if ($objList->length > 0) {
         $index = rand(0, $objList->length - 1);
         //Zufalls-Item aus Liste laden
         $objRand = simplexml_import_dom($objList->item($index));
         $this->Template->title = $this->gloImmoConnectorRemoveTitleText != '' ? str_replace($this->gloImmoConnectorRemoveTitleText, '', $objRand->title) : (string) $objRand->title;
         if ($objRand->titlePicture) {
             foreach ($objRand->titlePicture->urls->url as $url) {
                 if ($url['scale'] == 'SCALE_AND_CROP') {
                     $this->Template->picture = array('url' => str_replace("%WIDTH%x%HEIGHT%", self::PICTURE_SIZE_FULL, $url['href']), 'title' => (string) $objRand->titlePicture->title);
                 }
             }
         }
         $this->Template->zipcode = (string) $objRand->address->postcode;
         $this->Template->city = (string) $objRand->address->city;
         $this->Template->exposeHref = $this->generateFrontendUrl($this->_objTarget->row(), '/object/' . $objRand['id']);
         $this->Template->objectType = $GLOBALS['TL_LANG']['immoConnector'][$this->getObjectType($objRand)];
         $this->Template->priceValue = (double) $objRand->price->value;
         $this->Template->priceCurrency = (string) $objRand->price->currency;
         switch ($this->getObjectType($objRand)) {
             case "houseBuy":
             case "apartmentBuy":
             case "investment":
             case "livingBuySite":
                 $this->Template->priceTitle = $GLOBALS['TL_LANG']['immoConnector']['buyPrice'];
                 break;
             case "houseRent":
             case "apartmentRent":
                 $this->Template->priceTitle = $GLOBALS['TL_LANG']['immoConnector']['rentPrice'];
                 break;
         }
     } else {
         $this->Template->noObjectFound = $GLOBALS['TL_LANG']['immoConnector']['noObjectFound'];
     }
 }