Beispiel #1
0
 /**
  * Shows the map
  * @param int $highlight Id of the Object to be highlighted
  * @return void
  */
 function _showMap()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $this->_objTpl->loadTemplateFile("modules/immo/template/frontend_map_template.html");
     // Check if something has to be highlighted
     $highlight = isset($_GET['highlight']) ? intval($_GET['highlight']) : 0;
     // Extract all Placeholders out of the message
     $subQueryPart = "";
     $first = true;
     $matches = array();
     preg_match_all("/%([^%]+)%/", $this->arrSettings['message'], $matches);
     setlocale(LC_ALL, "de_CH");
     foreach ($matches[1] as $match) {
         if ($first) {
             $first = false;
         } else {
             $subQueryPart .= " OR ";
         }
         $subQueryPart .= "lower(name) = '" . strtolower($match) . "'";
     }
     // Get All the immo objects
     $query = " SELECT immo.id as `id`,\n                        immo.reference AS `ref` ,\n                        immo.visibility,\n                        immo.object_type AS otype,\n                        immo.new_building AS `new` ,\n                        immo.property_type AS ptype,\n                        immo.longitude as `long`,\n                        immo.latitude as `lat`,\n                        immo.zoom as `zoom`,\n                        immo.logo as `logo`\n                    FROM " . DBPREFIX . "module_immo AS immo\n                    WHERE immo.visibility = 'listing'";
     $objResult = $objDatabase->Execute($query);
     if ($objResult) {
         $keyCounter = 0;
         while (!$objResult->EOF) {
             unset($data);
             // This is the one we want to highlight. So we scroll to it
             if ($objResult->fields['id'] == $highlight) {
                 $startX = $objResult->fields['long'];
                 $startY = $objResult->fields['lat'];
                 $startZoom = $objResult->fields['zoom'];
             }
             $data = array('reference' => $objResult->fields['ref'], 'object_type' => $_ARRAYLANG['TXT_IMMO_OBJECTTYPE' . strtoupper($objResult->fields['object_type'])], 'new_building' => $objResult->fields['new_building'] ? $_ARRAYLANG['TXT_IMMO_YES'] : $_ARRAYLANG['TXT_IMMO_NO'], 'property_type' => $_ARRAYLANG['TXT_IMMO_PROPERTYTYPE' . strtoupper($objResult->fields['property_type'])], 'longitude' => $objResult->fields['longitude'], 'latitude' => $objResult->fields['latitude']);
             $query = "  SELECT content.field_id AS `field_id` ,\n                                fieldnames.name AS `field_name` ,\n                                fieldvalue AS `value` ,\n                                image.uri AS `uri` ,\n                                field.type AS `type`\n                            FROM " . DBPREFIX . "module_immo_content AS `content`\n                            INNER JOIN " . DBPREFIX . "module_immo_fieldname AS `fieldnames` ON fieldnames.field_id = content.field_id\n                            AND fieldnames.lang_id = '" . $this->frontLang . "'\n                            AND content.lang_id = '" . $this->frontLang . "'\n                            AND fieldnames.field_id\n                            IN (\n                                SELECT field_id\n                                FROM `" . DBPREFIX . "module_immo_fieldname` AS fieldn\n                                WHERE\n                                " . $subQueryPart . "\n                            )\n                            AND content.immo_id ='" . $objResult->fields['id'] . "'\n                            LEFT OUTER JOIN " . DBPREFIX . "module_immo_image AS `image` ON image.field_id = content.field_id\n                            AND image.immo_id = '" . $objResult->fields['id'] . "'\n                            LEFT OUTER JOIN " . DBPREFIX . "module_immo_field AS `field` ON content.field_id = field.id";
             $objResult2 = $objDatabase->Execute($query);
             while (!$objResult2->EOF) {
                 $data[strtolower($objResult2->fields['field_name'])] = $objResult2->fields['type'] == "img" || $objResult2->fields['type'] == "panorama" ? !empty($objResult2->fields['uri']) ? $objResult2->fields['uri'] : "../core/Core/View/Media/icons/pixel.gif" : $objResult2->fields['value'];
                 $objResult2->MoveNext();
             }
             // Line breaks are evil
             $message = str_replace("\r", "", $this->arrSettings['message']);
             $message = str_replace("\n", "", $message);
             // get all fieldnames + -contents from the highlighted immo ID
             if (!empty($highlight)) {
                 $this->_getFieldNames($highlight);
             }
             // replace the placeholder in the message with the date (if provided)
             foreach ($matches[1] as $match) {
                 $toReplace = isset($data[strtolower($match)]) ? $data[strtolower($match)] : "";
                 //custom values for "price" field
                 if ($match == strtoupper($this->arrFields['price'])) {
                     $toReplace = number_format($toReplace, $this->_arrPriceFormat[$this->frontLang]['dec'], $this->_arrPriceFormat[$this->frontLang]['dec_sep'], $this->_arrPriceFormat[$this->frontLang]['thousand_sep']);
                     $status = $this->_getFieldFromText('status');
                     if ($this->_getFieldFromText($this->arrFields['price']) == 0) {
                         $status = "null";
                     }
                     $toReplace = $this->arrSettings['currency_lang_' . $this->frontLang] . " " . $toReplace . " " . $this->_currencySuffix;
                     switch ($status) {
                         case 'verkauft':
                             $toReplace = '<strike>' . $toReplace . '</strike>  &nbsp;<span style=\\"color: red;\\">(verkauft)</span>';
                             break;
                         case 'versteckt':
                             $toReplace = '<span style=\\"color: red;\\">verkauft</span>';
                             break;
                             //                            case 'null':
                             //                                $toReplace = '<span style=\"color: red;\">verkauft</span>';
                             //                                break;
                         //                            case 'null':
                         //                                $toReplace = '<span style=\"color: red;\">verkauft</span>';
                         //                                break;
                         case 'reserviert':
                             $toReplace .= '  &nbsp;<span style=\\"color: red;\\">(reserviert)</span>';
                             break;
                     }
                 }
                 $message = str_replace("%" . $match . "%", $toReplace, $message);
             }
             $this->_objTpl->setVariable(array('IMMO_KEY_NUMBER' => $keyCounter, 'IMMO_MARKER_LAT' => $objResult->fields['lat'], 'IMMO_MARKER_LONG' => $objResult->fields['long'], 'IMMO_MARKER_MSG' => $message, 'IMMO_MARKER_ID' => $objResult->fields['id'], 'IMMO_MARKER_HIGHLIGHT' => $objResult->fields['id'] == $highlight ? 1 : 0, 'IMMO_MARKER_LOGO' => $objResult->fields['logo']));
             $this->_objTpl->parse("setmarker");
             $keyCounter++;
             $objResult->MoveNext();
         }
     }
     // Nothing is highlighted. Start at the default start point
     if (!$highlight || !isset($startX)) {
         $startX = $this->arrSettings['lat_frontend'];
         $startY = $this->arrSettings['lon_frontend'];
         $startZoom = $this->arrSettings['zoom_frontend'];
     }
     $googleKey = empty($this->arrSettings['GOOGLE_API_KEY_' . $_SERVER['SERVER_NAME']]) ? $_CONFIG['googleMapsAPIKey'] : $this->arrSettings['GOOGLE_API_KEY_' . $_SERVER['SERVER_NAME']];
     $this->_objTpl->setVariable(array('IMMO_GOOGLE_API_KEY' => $googleKey, 'IMMO_START_X' => $startX, 'IMMO_START_Y' => $startY, 'IMMO_START_ZOOM' => $startZoom, 'IMMO_LANG' => $this->frontLang, 'IMMO_TXT_LOOK' => $_ARRAYLANG['TXT_IMMO_LOOK']));
     if (!empty($_GET['bigone']) && $_GET['bigone'] == 1) {
         $this->_objTpl->touchBlock("big");
         $this->_objTpl->parse("big");
     } else {
         $this->_objTpl->touchBlock("small");
         $this->_objTpl->parse("small");
     }
     $this->_objTpl->getBlockList();
     $this->_objTpl->parse("map");
     $this->_objTpl->show("map");
     die;
 }