function listEntries($objTpl, $intView, $googleMapPlaceholder = null)
    {
        global $_ARRAYLANG, $_CORELANG, $objDatabase;
        $objFWUser = \FWUser::getFWUserObject();
        $intToday = time();
        $i = 0;
        switch ($intView) {
            case 1:
                //Backend View
                if (!empty($this->arrEntries)) {
                    foreach ($this->arrEntries as $key => $arrEntry) {
                        if (intval($arrEntry['entryAddedBy']) != 0) {
                            if ($objUser = $objFWUser->objUser->getUser(intval($arrEntry['entryAddedBy']))) {
                                $strAddedBy = $objUser->getUsername();
                            } else {
                                $strAddedBy = "unknown";
                            }
                        } else {
                            $strAddedBy = "unknown";
                        }
                        if ($arrEntry['entryActive'] == 1) {
                            $strStatus = '../core/Core/View/Media/icons/status_green.gif';
                            $intStatus = 0;
                            if (($arrEntry['entryDurationStart'] > $intToday || $arrEntry['entryDurationEnd'] < $intToday) && $arrEntry['entryDurationType'] == 2) {
                                $strStatus = '../core/Core/View/Media/icons/status_yellow.gif';
                            }
                        } else {
                            $strStatus = '../core/Core/View/Media/icons/status_red.gif';
                            $intStatus = 1;
                        }
                        $objForm = new MediaDirectoryForm($arrEntry['entryFormId'], $this->moduleName);
                        //get votes
                        if ($this->arrSettings['settingsAllowVotes']) {
                            $objVoting = new MediaDirectoryVoting($this->moduleName);
                            $objVoting->getVotes($objTpl, $arrEntry['entryId']);
                            if ($objTpl->blockExists('mediadirEntryVotes')) {
                                $objTpl->parse('mediadirEntryVotes');
                            }
                        } else {
                            if ($objTpl->blockExists('mediadirEntryVotes')) {
                                $objTpl->hideBlock('mediadirEntryVotes');
                            }
                        }
                        //get comments
                        if ($this->arrSettings['settingsAllowComments']) {
                            $objComment = new MediaDirectoryComment($this->moduleName);
                            $objComment->getComments($objTpl, $arrEntry['entryId']);
                            if ($objTpl->blockExists('mediadirEntryComments')) {
                                $objTpl->parse('mediadirEntryComments');
                            }
                        } else {
                            if ($objTpl->blockExists('mediadirEntryComments')) {
                                $objTpl->hideBlock('mediadirEntryComments');
                            }
                        }
                        $objTpl->setVariable(array($this->moduleLangVar . '_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_ENTRY_ID' => $arrEntry['entryId'], $this->moduleLangVar . '_ENTRY_STATUS' => $strStatus, $this->moduleLangVar . '_ENTRY_SWITCH_STATUS' => $intStatus, $this->moduleLangVar . '_ENTRY_VALIDATE_DATE' => date("H:i:s - d.m.Y", $arrEntry['entryValdateDate']), $this->moduleLangVar . '_ENTRY_CREATE_DATE' => date("H:i:s - d.m.Y", $arrEntry['entryCreateDate']), $this->moduleLangVar . '_ENTRY_AUTHOR' => htmlspecialchars($strAddedBy, ENT_QUOTES, CONTREXX_CHARSET), $this->moduleLangVar . '_ENTRY_HITS' => $arrEntry['entryHits'], $this->moduleLangVar . '_ENTRY_FORM' => $objForm->arrForms[$arrEntry['entryFormId']]['formName'][0]));
                        foreach ($arrEntry['entryFields'] as $key => $strFieldValue) {
                            $intPos = $key + 1;
                            $objTpl->setVariable(array($this->moduleLangVar . '_ENTRY_FIELD_' . $intPos . '_POS' => contrexx_raw2xhtml(substr($strFieldValue, 0, 255))));
                        }
                        //get order
                        if ($this->arrSettings['settingsIndividualEntryOrder'] == 1) {
                            $objTpl->setVariable(array($this->moduleLangVar . '_ENTRY_ORDER' => '<input name="entriesOrder[' . $arrEntry['entryId'] . ']" style="width: 30px; margin-right: 5px;" value="' . $arrEntry['entryOrder'] . '" onfocus="this.select();" type="text">'));
                            if (intval($objTpl->blockExists($this->moduleNameLC . 'EntriesSaveOrder')) != 0) {
                                $objTpl->touchBlock($this->moduleNameLC . 'EntriesSaveOrder');
                            }
                        } else {
                            if (intval($objTpl->blockExists($this->moduleNameLC . 'EntriesSaveOrder')) != 0) {
                                $objTpl->hideBlock($this->moduleNameLC . 'EntriesSaveOrder');
                            }
                        }
                        $i++;
                        $objTpl->parse($this->strBlockName);
                        $objTpl->hideBlock('noEntriesFound');
                        $objTpl->clearVariables();
                    }
                } else {
                    $objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_NO_ENTRIES_FOUND' => $_ARRAYLANG['TXT_MEDIADIR_NO_ENTRIES_FOUND']));
                    $objTpl->touchBlock('noEntriesFound');
                    $objTpl->clearVariables();
                }
                break;
            case 2:
                //Frontend View
                if (!empty($this->arrEntries)) {
                    foreach ($this->arrEntries as $key => $arrEntry) {
                        if ($arrEntry['entryDurationStart'] < $intToday && $arrEntry['entryDurationEnd'] > $intToday || $arrEntry['entryDurationType'] == 1) {
                            $objInputfields = new MediaDirectoryInputfield(intval($arrEntry['entryFormId']), false, $arrEntry['entryTranslationStatus'], $this->moduleName);
                            $objInputfields->listInputfields($objTpl, 3, intval($arrEntry['entryId']));
                            if (intval($arrEntry['entryAddedBy']) != 0) {
                                if ($objUser = $objFWUser->objUser->getUser(intval($arrEntry['entryAddedBy']))) {
                                    $strAddedBy = $objUser->getUsername();
                                } else {
                                    $strAddedBy = "unknown";
                                }
                            } else {
                                $strAddedBy = "unknown";
                            }
                            $strCategoryLink = $this->intCatId != 0 ? '&amp;cid=' . $this->intCatId : null;
                            $strLevelLink = $this->intLevelId != 0 ? '&amp;lid=' . $this->intLevelId : null;
                            if ($this->checkPageCmd('detail' . intval($arrEntry['entryFormId']))) {
                                $strDetailCmd = 'detail' . intval($arrEntry['entryFormId']);
                            } else {
                                $strDetailCmd = 'detail';
                            }
                            if ($arrEntry['entryReadyToConfirm'] == 1 || $arrEntry['entryConfirmed'] == 1) {
                                $strDetailUrl = 'index.php?section=' . $this->moduleName . '&amp;cmd=' . $strDetailCmd . $strLevelLink . $strCategoryLink . '&amp;eid=' . $arrEntry['entryId'];
                            } else {
                                $strDetailUrl = '#';
                            }
                            $objForm = new MediaDirectoryForm($arrEntry['entryFormId'], $this->moduleName);
                            $objTpl->setVariable(array($this->moduleLangVar . '_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_ENTRY_ID' => $arrEntry['entryId'], $this->moduleLangVar . '_ENTRY_TITLE' => contrexx_raw2xhtml($arrEntry['entryFields'][0]), $this->moduleLangVar . '_ENTRY_TITLE_URL_ENCODED' => urlencode($arrEntry['entryFields'][0]), $this->moduleLangVar . '_ENTRY_VALIDATE_DATE' => date("H:i:s - d.m.Y", $arrEntry['entryValdateDate']), $this->moduleLangVar . '_ENTRY_CREATE_DATE' => date("H:i:s - d.m.Y", $arrEntry['entryCreateDate']), $this->moduleLangVar . '_ENTRY_AUTHOR' => htmlspecialchars($strAddedBy, ENT_QUOTES, CONTREXX_CHARSET), $this->moduleLangVar . '_ENTRY_CATEGORIES' => $this->getCategoriesLevels(1, $arrEntry['entryId'], $objForm->arrForms[$arrEntry['entryFormId']]['formCmd']), $this->moduleLangVar . '_ENTRY_LEVELS' => $this->getCategoriesLevels(2, $arrEntry['entryId'], $objForm->arrForms[$arrEntry['entryFormId']]['formCmd']), $this->moduleLangVar . '_ENTRY_HITS' => $arrEntry['entryHits'], $this->moduleLangVar . '_ENTRY_POPULAR_HITS' => $arrEntry['entryPopularHits'], $this->moduleLangVar . '_ENTRY_DETAIL_URL' => $strDetailUrl, $this->moduleLangVar . '_ENTRY_EDIT_URL' => 'index.php?section=' . $this->moduleName . '&amp;cmd=edit&amp;eid=' . $arrEntry['entryId'], $this->moduleLangVar . '_ENTRY_DELETE_URL' => 'index.php?section=' . $this->moduleName . '&amp;cmd=delete&amp;eid=' . $arrEntry['entryId'], 'TXT_' . $this->moduleLangVar . '_ENTRY_DELETE' => $_ARRAYLANG['TXT_MEDIADIR_DELETE'], 'TXT_' . $this->moduleLangVar . '_ENTRY_EDIT' => $_ARRAYLANG['TXT_MEDIADIR_EDIT'], 'TXT_' . $this->moduleLangVar . '_ENTRY_DETAIL' => $_ARRAYLANG['TXT_MEDIADIR_DETAIL'], 'TXT_' . $this->moduleLangVar . '_ENTRY_CATEGORIES' => $_ARRAYLANG['TXT_MEDIADIR_CATEGORIES'], 'TXT_' . $this->moduleLangVar . '_ENTRY_LEVELS' => $_ARRAYLANG['TXT_MEDIADIR_LEVELS']));
                            $this->parseCategoryLevels(1, $arrEntry['entryId'], $objTpl);
                            $this->parseCategoryLevels(2, $arrEntry['entryId'], $objTpl);
                            foreach ($arrEntry['entryFields'] as $key => $strFieldValue) {
                                $intPos = $key + 1;
                                $objTpl->setVariable(array('MEDIADIR_ENTRY_FIELD_' . $intPos . '_POS' => substr($strFieldValue, 0, 255)));
                            }
                            if ($this->arrSettings['settingsAllowVotes']) {
                                $objVoting = new MediaDirectoryVoting($this->moduleName);
                                if (intval($objTpl->blockExists($this->moduleNameLC . 'EntryVoteForm')) != 0) {
                                    $objVoting->getVoteForm($objTpl, $arrEntry['entryId']);
                                }
                                if (intval($objTpl->blockExists($this->moduleNameLC . 'EntryVotes')) != 0) {
                                    $objVoting->getVotes($objTpl, $arrEntry['entryId']);
                                }
                            }
                            if ($this->arrSettings['settingsAllowComments']) {
                                $objComment = new MediaDirectoryComment($this->moduleName);
                                if (intval($objTpl->blockExists($this->moduleNameLC . 'EntryComments')) != 0) {
                                    $objComment->getComments($objTpl, $arrEntry['entryId']);
                                }
                                if (intval($objTpl->blockExists($this->moduleNameLC . 'EntryCommentForm')) != 0) {
                                    $objComment->getCommentForm($objTpl, $arrEntry['entryId']);
                                }
                            }
                            if (!$this->arrSettings['settingsAllowEditEntries'] && intval($objTpl->blockExists($this->moduleNameLC . 'EntryEditLink')) != 0) {
                                $objTpl->hideBlock($this->moduleNameLC . 'EntryEditLink');
                            }
                            if (!$this->arrSettings['settingsAllowDelEntries'] && intval($objTpl->blockExists($this->moduleNameLC . 'EntryDeleteLink')) != 0) {
                                $objTpl->hideBlock($this->moduleNameLC . 'EntryDeleteLink');
                            }
                            $i++;
                            $objTpl->parse($this->strBlockName);
                            $objTpl->clearVariables();
                        }
                    }
                } else {
                    $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_SEARCH_MESSAGE' => $_ARRAYLANG['TXT_MEDIADIR_NO_ENTRIES_FOUND']));
                    $objTpl->parse($this->moduleNameLC . 'NoEntriesFound');
                    $objTpl->clearVariables();
                }
                break;
            case 3:
                //Alphabetical View
                if (!empty($this->arrEntries)) {
                    $arrAlphaIndexes = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0-9', '#');
                    $arrAlphaGroups = array();
                    foreach ($this->arrEntries as $key => $arrEntry) {
                        $strTitle = $arrEntry['entryFields'][0];
                        $strAlphaIndex = strtoupper(substr($strTitle, 0, 1));
                        if (!in_array($strAlphaIndex, $arrAlphaIndexes)) {
                            if (is_numeric($strAlphaIndex)) {
                                $strAlphaIndex = '0-9';
                            } else {
                                $strAlphaIndex = '#';
                            }
                        }
                        $arrAlphaGroups[$strAlphaIndex][] = $arrEntry;
                    }
                    if (intval($objTpl->blockExists($this->moduleNameLC . 'AlphaIndex')) != 0) {
                        $objTpl->touchBlock($this->moduleNameLC . 'AlphaIndex');
                        foreach ($arrAlphaIndexes as $key => $strIndex) {
                            if (array_key_exists($strIndex, $arrAlphaGroups)) {
                                $strAlphaIndex = '<a href="#' . $strIndex . '">' . $strIndex . '</a>';
                            } else {
                                $strAlphaIndex = '' . $strIndex . '';
                            }
                            $objTpl->setVariable(array($this->moduleLangVar . '_ALPHA_INDEX_LINK' => $strAlphaIndex));
                            $objTpl->parse($this->moduleNameLC . 'AlphaIndexElement');
                        }
                    }
                    foreach ($arrAlphaGroups as $strAlphaIndex => $arrEntries) {
                        if (intval($objTpl->blockExists($this->moduleNameLC . 'AlphabeticalTitle')) != 0) {
                            $objTpl->setVariable(array($this->moduleLangVar . '_ALPHABETICAL_ANCHOR' => $strAlphaIndex, 'TXT_' . $this->moduleLangVar . '_ALPHABETICAL_TITLE' => $strAlphaIndex));
                            $objTpl->parse($this->moduleNameLC . 'AlphabeticalTitle');
                        }
                        foreach ($arrEntries as $key => $arrEntry) {
                            if ($arrEntry['entryDurationStart'] < $intToday && $arrEntry['entryDurationEnd'] > $intToday || $arrEntry['entryDurationType'] == 1) {
                                $objInputfields = new MediaDirectoryInputfield(intval($arrEntry['entryFormId']), false, $arrEntry['entryTranslationStatus'], $this->moduleName);
                                $objInputfields->listInputfields($objTpl, 3, intval($arrEntry['entryId']));
                                $strStatus = $arrEntry['entryActive'] == 1 ? 'active' : 'inactive';
                                if (intval($arrEntry['entryAddedBy']) != 0) {
                                    if ($objUser = $objFWUser->objUser->getUser(intval($arrEntry['entryAddedBy']))) {
                                        $strAddedBy = $objUser->getUsername();
                                    } else {
                                        $strAddedBy = "unknown";
                                    }
                                } else {
                                    $strAddedBy = "unknown";
                                }
                                $strCategoryLink = $this->intCatId != 0 ? '&amp;cid=' . $this->intCatId : null;
                                $strLevelLink = $this->intLevelId != 0 ? '&amp;lid=' . $this->intLevelId : null;
                                if ($this->checkPageCmd('detail' . intval($arrEntry['entryFormId']))) {
                                    $strDetailCmd = 'detail' . intval($arrEntry['entryFormId']);
                                } else {
                                    $strDetailCmd = 'detail';
                                }
                                if ($arrEntry['entryReadyToConfirm'] == 1 || $arrEntry['entryConfirmed'] == 1) {
                                    $strDetailUrl = 'index.php?section=' . $this->moduleName . '&amp;cmd=' . $strDetailCmd . $strLevelLink . $strCategoryLink . '&amp;eid=' . $arrEntry['entryId'];
                                } else {
                                    $strDetailUrl = '#';
                                }
                                $objForm = new MediaDirectoryForm($arrEntry['entryFormId'], $this->moduleName);
                                $objTpl->setVariable(array($this->moduleLangVar . '_ROW_CLASS' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_ENTRY_ID' => $arrEntry['entryId'], $this->moduleLangVar . '_ENTRY_TITLE' => contrexx_raw2xhtml($arrEntry['entryFields'][0]), $this->moduleLangVar . '_ENTRY_TITLE_URL_ENCODED' => urlencode($arrEntry['entryFields'][0]), $this->moduleLangVar . '_ENTRY_STATUS' => $strStatus, $this->moduleLangVar . '_ENTRY_VALIDATE_DATE' => date("H:i:s - d.m.Y", $arrEntry['entryValdateDate']), $this->moduleLangVar . '_ENTRY_CREATE_DATE' => date("H:i:s - d.m.Y", $arrEntry['entryCreateDate']), $this->moduleLangVar . '_ENTRY_AUTHOR' => htmlspecialchars($strAddedBy, ENT_QUOTES, CONTREXX_CHARSET), $this->moduleLangVar . '_ENTRY_CATEGORIES' => $this->getCategoriesLevels(1, $arrEntry['entryId'], $objForm->arrForms[$arrEntry['entryFormId']]['formCmd']), $this->moduleLangVar . '_ENTRY_LEVELS' => $this->getCategoriesLevels(2, $arrEntry['entryId'], $objForm->arrForms[$arrEntry['entryFormId']]['formCmd']), $this->moduleLangVar . '_ENTRY_HITS' => $arrEntry['entryHits'], $this->moduleLangVar . '_ENTRY_POPULAR_HITS' => $arrEntry['entryPopularHits'], $this->moduleLangVar . '_ENTRY_DETAIL_URL' => $strDetailUrl, $this->moduleLangVar . '_ENTRY_EDIT_URL' => 'index.php?section=' . $this->moduleName . '&amp;cmd=edit&amp;eid=' . $arrEntry['entryId'], $this->moduleLangVar . '_ENTRY_DELETE_URL' => 'index.php?section=' . $this->moduleName . '&amp;cmd=delete&amp;eid=' . $arrEntry['entryId'], 'TXT_' . $this->moduleLangVar . '_ENTRY_DELETE' => $_ARRAYLANG['TXT_MEDIADIR_DELETE'], 'TXT_' . $this->moduleLangVar . '_ENTRY_EDIT' => $_ARRAYLANG['TXT_MEDIADIR_EDIT'], 'TXT_' . $this->moduleLangVar . '_ENTRY_DETAIL' => $_ARRAYLANG['TXT_MEDIADIR_DETAIL'], 'TXT_' . $this->moduleLangVar . '_ENTRY_CATEGORIES' => $_ARRAYLANG['TXT_MEDIADIR_CATEGORIES'], 'TXT_' . $this->moduleLangVar . '_ENTRY_LEVELS' => $_ARRAYLANG['TXT_MEDIADIR_LEVELS']));
                                $this->parseCategoryLevels(1, $arrEntry['entryId'], $objTpl);
                                $this->parseCategoryLevels(2, $arrEntry['entryId'], $objTpl);
                                foreach ($arrEntry['entryFields'] as $key => $strFieldValue) {
                                    $intPos = $key + 1;
                                    $objTpl->setVariable(array('MEDIADIR_ENTRY_FIELD_' . $intPos . '_POS' => contrexx_raw2xhtml(substr($strFieldValue, 0, 255))));
                                }
                                if ($this->arrSettings['settingsAllowVotes']) {
                                    $objVoting = new MediaDirectoryVoting($this->moduleName);
                                    if (intval($objTpl->blockExists($this->moduleNameLC . 'EntryVoteForm')) != 0) {
                                        $objVoting->getVoteForm($objTpl, $arrEntry['entryId']);
                                    }
                                    if (intval($objTpl->blockExists($this->moduleNameLC . 'EntryVotes')) != 0) {
                                        $objVoting->getVotes($objTpl, $arrEntry['entryId']);
                                    }
                                }
                                if ($this->arrSettings['settingsAllowComments']) {
                                    $objComment = new MediaDirectoryComment($this->moduleName);
                                    if (intval($objTpl->blockExists($this->moduleNameLC . 'EntryComments')) != 0) {
                                        $objComment->getComments($objTpl, $arrEntry['entryId']);
                                    }
                                    if (intval($objTpl->blockExists($this->moduleNameLC . 'EntryCommentForm')) != 0) {
                                        $objComment->getCommentForm($objTpl, $arrEntry['entryId']);
                                    }
                                }
                                if (!$this->arrSettings['settingsAllowEditEntries'] && intval($objTpl->blockExists($this->moduleNameLC . 'EntryEditLink')) != 0) {
                                    $objTpl->hideBlock($this->moduleNameLC . 'EntryEditLink');
                                }
                                if (!$this->arrSettings['settingsAllowDelEntries'] && intval($objTpl->blockExists($this->moduleNameLC . 'EntryDeleteLink')) != 0) {
                                    $objTpl->hideBlock($this->moduleNameLC . 'EntryDeleteLink');
                                }
                                $i++;
                                $objTpl->parse($this->moduleNameLC . 'EntryList');
                                $objTpl->clearVariables();
                            }
                        }
                    }
                } else {
                    $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_SEARCH_MESSAGE' => $_ARRAYLANG['TXT_MEDIADIR_NO_ENTRIES_FOUND']));
                    $objTpl->parse($this->moduleNameLC . 'NoEntriesFound');
                    $objTpl->clearVariables();
                }
            case 4:
                //Google Map
                if (!isset($googleMapPlaceholder)) {
                    $googleMapPlaceholder = $this->moduleLangVar . '_GOOGLE_MAP';
                }
                // abort in case the relevant placeholder is missing in the template
                if (!$objTpl->placeholderExists($googleMapPlaceholder)) {
                    break;
                }
                $objGoogleMap = new \googleMap();
                $objGoogleMap->setMapId($this->moduleNameLC . 'GoogleMap');
                $objGoogleMap->setMapStyleClass('mapLarge');
                $objGoogleMap->setMapType($this->arrSettings['settingsGoogleMapType']);
                $arrValues = explode(',', $this->arrSettings['settingsGoogleMapStartposition']);
                $objGoogleMap->setMapZoom($arrValues[2]);
                $objGoogleMap->setMapCenter($arrValues[1], $arrValues[0]);
                foreach ($this->arrEntries as $key => $arrEntry) {
                    if ($arrEntry['entryDurationStart'] < $intToday && $arrEntry['entryDurationEnd'] > $intToday || $arrEntry['entryDurationType'] == 1) {
                        $intEntryId = intval($arrEntry['entryId']);
                        $intEntryFormId = intval($arrEntry['entryFormId']);
                        $query = "\n                            SELECT\n                                inputfield.`id` AS `id`,\n                                rel_inputfield.`value` AS `value`\n                            FROM\n                                " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_inputfields AS inputfield,\n                                " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_inputfields AS rel_inputfield\n                            WHERE\n                                inputfield.`form` = '" . $intEntryFormId . "'\n                            AND\n                                inputfield.`type`= '15'\n                            AND\n                                rel_inputfield.`field_id` = inputfield.`id`\n                            AND\n                                rel_inputfield.`entry_id` = '" . $intEntryId . "'\n                            LIMIT 1\n                        ";
                        $objRSMapKoordinates = $objDatabase->Execute($query);
                        if ($objRSMapKoordinates === false || empty($objRSMapKoordinates->fields['value'])) {
                            continue;
                        }
                        $arrValues = explode(',', $objRSMapKoordinates->fields['value']);
                        $strValueLon = empty($arrValues[1]) ? 0 : $arrValues[1];
                        $strValueLat = empty($arrValues[0]) ? 0 : $arrValues[0];
                        if (empty($strValueLon) && empty($strValueLat)) {
                            continue;
                        }
                        if ($this->checkPageCmd('detail' . intval($arrEntry['entryFormId']))) {
                            $strDetailCmd = 'detail' . intval($arrEntry['entryFormId']);
                        } else {
                            $strDetailCmd = 'detail';
                        }
                        $strEntryLink = '<a href="index.php?section=' . $this->moduleName . '&amp;cmd=' . $strDetailCmd . '&amp;eid=' . $arrEntry['entryId'] . '">' . $_ARRAYLANG['TXT_MEDIADIR_DETAIL'] . '</a>';
                        $strEntryTitle = '<b>' . contrexx_raw2xhtml($arrEntry['entryFields']['0']) . '</b>';
                        $mapIndex = $objGoogleMap->getMapIndex();
                        $clickFunction = <<<JSCODE
infoWindow = cx.variables.get('map_{$mapIndex}_infoWindow', '{$objGoogleMap->getMapId()}');
if (infoWindow) {
    infoWindow.close();
}
mapMarker = cx.variables.get('map_{$mapIndex}_markers', '{$objGoogleMap->getMapId()}')[{$intEntryId}];
infoWindow.setContent(mapMarker.info);
infoWindow.open(map_{$mapIndex}, mapMarker.marker);
JSCODE;
                        $objGoogleMap->addMapMarker($intEntryId, $strValueLon, $strValueLat, $strEntryTitle . "<br />" . $strEntryLink, true, $clickFunction);
                    }
                }
                $objTpl->setVariable(array($googleMapPlaceholder => $objGoogleMap->getMap()));
                break;
        }
    }
 public function getGoogleMapParcours($params = array())
 {
     $html = "";
     $idParcours = 0;
     if (isset($this->variablesGet['archiIdParcours']) && $this->variablesGet['archiIdParcours'] != '') {
         $idParcours = $this->variablesGet['archiIdParcours'];
     }
     if (isset($params['idParcours']) && $params['idParcours'] != '') {
         $idParcours = $params['idParcours'];
     }
     $width = 500;
     if (isset($params['width']) && $params['width'] != '') {
         $width = $params['width'];
     }
     if ($idParcours != 0) {
         $gm = new googleMap(array('googleMapKey' => $this->googleMapKey, 'width' => $width));
         $html .= $gm->getJsFunctions();
         $reqParcours = "SELECT idEtape,idEvenementGroupeAdresse,position FROM etapesParcoursArt WHERE idParcours='" . $idParcours . "' ORDER BY position ASC";
         $resParcours = $this->connexionBdd->requete($reqParcours);
         $numEtape = 1;
         $arrayEtapes = array();
         $i = 0;
         while ($fetchParcours = mysql_fetch_assoc($resParcours)) {
             $idAdresse = $this->getIdAdresseFromIdEvenementGroupeAdresse($fetchParcours['idEvenementGroupeAdresse']);
             $coordonnees = $this->getCoordonneesFrom($fetchParcours['idEvenementGroupeAdresse'], 'idEvenementGroupeAdresse');
             $intituleAdresse = $this->getIntituleAdresseFrom($fetchParcours['idEvenementGroupeAdresse'], 'idEvenementGroupeAdresse');
             // attention ceci concernera une adresse parmi plusieurs possible dans le groupe d'adresse , a modifier
             $intituleAdresseRechercheGeo = $this->getIntituleAdresseFrom($fetchParcours['idEvenementGroupeAdresse'], 'idEvenementGroupeAdresse', array('noQuartier' => true, 'noSousQuartier' => true));
             $arrayEtapes[$i]['latitude'] = $coordonnees['latitude'];
             $arrayEtapes[$i]['longitude'] = $coordonnees['longitude'];
             $arrayEtapes[$i]['libelle'] = '';
             $arrayEtapes[$i]['adresseForGeolocalisation'] = $intituleAdresseRechercheGeo;
             $arrayEtapes[$i]['label'] = $intituleAdresse;
             $arrayEtapes[$i]['jsCodeOnMouseOverMarker'] = "currentLabel.show();";
             $arrayEtapes[$i]['jsCodeOnMouseOutMarker'] = "currentLabel.hide();";
             $arrayEtapes[$i]['jsCodeOnClickMarker'] = "location.href='" . $this->creerUrl('', '', array('archiAffichage' => 'adresseDetail', "archiIdAdresse" => $idAdresse, "archiIdEvenementGroupeadresse" => $fetchParcours['idEvenementGroupeAdresse']), false, false) . "';";
             $numEtape++;
             $i++;
         }
         if (isset($params['getCoordonneesParcours']) && $params['getCoordonneesParcours'] == true) {
             $html .= $gm->getMap(array('idDivDisplayEtapesText' => 'parcoursDetail', 'travelMode' => 'walking', 'listeCoordonneesParcours' => $arrayEtapes, 'urlImageIcon' => $this->getUrlImage() . "pointGM.png", 'pathImageIcon' => $this->getCheminPhysique() . "images/pointGM.png", 'getCoordonneesParcours' => true, 'actionFormOnSubmitVertices' => $this->creerUrl('', '', array()), 'noDisplayParcoursGoogleAutomaticDescription' => true));
         } else {
             $polyline = mysql_fetch_object($this->connexionBdd->requete("SELECT trace, levels FROM parcoursArt WHERE idParcours = '{$idParcours}'"));
             $html .= $gm->getMap(array('idDivDisplayEtapesText' => 'parcoursDetail', 'travelMode' => 'walking', 'listeCoordonneesParcours' => $arrayEtapes, 'urlImageIcon' => $this->getUrlImage() . "pointGM.png", 'pathImageIcon' => $this->getCheminPhysique() . "images/pointGM.png", "polyline" => $polyline->trace, "levels" => $polyline->levels));
         }
         if (isset($this->variablesPost['submitVertices'])) {
             // on recupere donc les vertices du parcours
             // enregistrement dans la table et reperage des etapes
             // d'abord on supprime les valeurs precedentes
             $reqSupprVertices = "DELETE FROM verticesParcours WHERE idParcours='" . $idParcours . "'";
             $resSupprVertices = $this->connexionBdd->requete($reqSupprVertices);
             foreach ($this->variablesPost['longitudes'] as $indice => $valueLongitude) {
                 $valueLatitude = $this->variablesPost['latitudes'][$indice];
                 $reqAddVertices = "INSERT INTO verticesParcours (idParcours,idEtape,longitude,latitude,position) VALUES ('" . $idParcours . "','0','" . $valueLongitude . "','" . $valueLatitude . "','" . ($indice + 1) . "')";
                 $resAddVertices = $this->connexionBdd->requete($reqAddVertices);
             }
             // ensuite on affiche chacun des points avec des marqueurs deplacables
         }
     }
     return $html;
 }
 function getContent($intEntryId, $arrInputfield, $arrTranslationStatus)
 {
     global $objDatabase, $_CONFIG, $_ARRAYLANG;
     $intId = intval($arrInputfield['id']);
     $objInputfieldValue = $objDatabase->Execute("\n            SELECT\n                `value`\n            FROM\n                " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_inputfields\n            WHERE\n                field_id=" . $intId . "\n            AND\n                entry_id=" . $intEntryId . "\n            LIMIT 1\n        ");
     $strValue = htmlspecialchars($objInputfieldValue->fields['value'], ENT_QUOTES, CONTREXX_CHARSET);
     $arrValues = explode(',', $strValue);
     $strValueLat = $arrValues[0];
     $strValueLon = $arrValues[1];
     $strValueZoom = $arrValues[2];
     $strValueLink = '<a href="http://maps.google.com/maps?q=' . $strValueLat . ',' . $strValueLon . '" target="_blank">' . $_ARRAYLANG['TXT_MEDIADIR_GOOGLEMAPS_LINK'] . '</a>';
     $strValueLinkHref = 'http://maps.google.com/maps?q=' . $strValueLat . ',' . $strValueLon;
     if (!empty($strValue)) {
         $objGoogleMap = new \googleMap();
         $objGoogleMap->setMapId($this->moduleNameLC . 'Inputfield_' . $intId . '_' . $intEntryId . '_map');
         $objGoogleMap->setMapStyleClass('map');
         $objGoogleMap->setMapZoom($strValueZoom);
         $objGoogleMap->setMapCenter($strValueLon, $strValueLat);
         $objGoogleMap->setMapIndex($intId . '_' . $intEntryId);
         $objGoogleMap->addMapMarker($intId, $strValueLon, $strValueLat, null, true);
         $arrContent['TXT_' . $this->moduleLangVar . '_INPUTFIELD_NAME'] = htmlspecialchars($arrInputfield['name'][0], ENT_QUOTES, CONTREXX_CHARSET);
         $arrContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = $objGoogleMap->getMap();
         $arrContent[$this->moduleLangVar . '_INPUTFIELD_LINK'] = $strValueLink;
         $arrContent[$this->moduleLangVar . '_INPUTFIELD_LINK_HREF'] = $strValueLinkHref;
     } else {
         $arrContent = null;
     }
     return $arrContent;
 }
 /**
  * Affichage du formulaire d'ajout d'un nouveau dossier (groupe d'adresse + evenement construction)
  * 
  * @param array  $parametres Paramètres
  * @param string $type       Type (adresse ou personne)
  * 
  * @return void
  * */
 public function afficheFormulaireNouveauDossier($parametres = array(), $type = "adresse")
 {
     $html = "";
     // initialisation de l'objet googlemap pour la recuperation des coordonnees
     $paramsGoogleMap = array('googleMapKey' => $this->googleMapKey);
     $googleMap = new googleMap($paramsGoogleMap);
     $html .= $googleMap->getJsFunctions();
     $html .= $googleMap->getJSInitGeoCoder();
     $t = new Template('modules/archi/templates/');
     $t->set_filenames(array('nouveauDossier' => 'nouveauDossier.tpl'));
     if ($type == "personne") {
         $formAction = "ajoutNouvelPersonne";
         $t->assign_block_vars("ajoutPersonne", array());
         $resJobs = $this->connexionBdd->requete("SELECT * FROM `metier`");
         $jobList = "";
         while ($job = mysql_fetch_assoc($resJobs)) {
             if (!empty($job["nom"])) {
                 $jobList .= "<option value='" . $job["idMetier"] . "'";
                 if (isset($_POST["metier"]) && $job["idMetier"] == $_POST["metier"]) {
                     $jobList .= " selected='selected' ";
                 }
                 $jobList .= ">" . $job["nom"] . "</option>";
             }
         }
         $t->assign_vars(array('titrePage' => _("Ajout d'une nouvelle personne (physique ou morale)"), "jobList" => $jobList, "typeBoutonValidation" => "submit"));
         if (!empty($_POST) && !isset($_POST["archiLogin"])) {
             $t->assign_vars(array("firstname" => $_POST["prenom"], "name" => $_POST["nom"], "birth" => $_POST["dateNaissance"], "death" => $_POST["dateDeces"], "desc" => $_POST["descriptionPerson"]));
         }
     } else {
         $formAction = "ajoutNouveauDossier";
         if (!isset($arrayJsCoordonneesFromGoogleMap['jsFunctionCall'])) {
             $arrayJsCoordonneesFromGoogleMap['jsFunctionCall'] = 0;
         }
         // assignation du titre de la page
         $t->assign_vars(array('titrePage' => _("Ajout d'une nouvelle adresse"), 'typeBoutonValidation' => "submit"));
         // ********
         // on affiche la partie ajout d'une adresse
         $t->assign_block_vars('isNotAjoutSousEvenement', array());
         // ********
     }
     // ********
     // on affiche la partie "ajout d'un evenement"
     $t->assign_block_vars('afficheAjoutEvenement', array());
     // *******
     // ******
     // si la personne n'est pas admin elle verra une version simplifiée du formulaire
     $authentification = new archiAuthentification();
     $u = new archiUtilisateur();
     if ($authentification->estConnecte() && ($authentification->estAdmin() || $u->canAddWithoutStreet(array('idUtilisateur' => $authentification->getIdUtilisateur())))) {
         $t->assign_block_vars('afficheAjoutEvenement.isAdmin', array());
         $t->assign_vars(array("displayQuartiers" => 'table-row'));
         $t->assign_vars(array("displaySousQuartiers" => 'table-row'));
     } else {
         $t->assign_block_vars('afficheAjoutEvenement.isNotAdmin', array());
         $t->assign_vars(array("displayQuartiers" => 'none'));
         $t->assign_vars(array("displaySousQuartiers" => 'none'));
     }
     // ******
     $typeStructure = 0;
     if (isset($this->variablesPost['typeStructure']) && $this->variablesPost['typeStructure'] != '') {
         $typeStructure = $this->variablesPost['typeStructure'];
     }
     $groupeTypeEvenement = 2;
     // par defaut on selectionne les evenement de type 'travaux'
     if (isset($this->variablesPost['typeGroupeEvenement']) && $this->variablesPost['typeGroupeEvenement'] != '') {
         $groupeTypeEvenement = $this->variablesPost['typeGroupeEvenement'];
     }
     $typeEvenement = 0;
     if (isset($this->variablesPost['typeEvenement']) && $this->variablesPost['typeEvenement'] != '') {
         $typeEvenement = $this->variablesPost['typeEvenement'];
     }
     if (!(isset($this->variablesPost['typeEvenement']) && $this->variablesPost['typeEvenement'] != '') && isset($this->variablesGet['archiOptionAjoutDossier']) && $this->variablesGet["archiOptionAjoutDossier"] == "nouvelleDemolition") {
         $groupeTypeEvenement = 2;
         // travaux
         $typeEvenement = 6;
     }
     if (!(isset($this->variablesPost['typeEvenement']) && $this->variablesPost['typeEvenement'] != '') && isset($this->variablesGet['archiOptionAjoutDossier']) && $this->variablesGet["archiOptionAjoutDossier"] == "nouvelEvenementCulturel") {
         $groupeTypeEvenement = 1;
         // travaux
         $typeEvenement = 0;
     }
     $ISMH = false;
     if (isset($this->variablesPost['ISMH'])) {
         $ISMH = true;
     }
     $MH = false;
     if (isset($this->variablesPost['MH'])) {
         $MH = true;
     }
     $isDateDebutEnviron = false;
     if (isset($this->variablesPost['isDateDebutEnviron'])) {
         $isDateDebutEnviron = true;
     }
     $personnes = array();
     if (isset($this->variablesPost['personnes']) && count($this->variablesPost['personnes']) > 0) {
         $personnes = $this->variablesPost['personnes'];
     }
     $ville = 0;
     if (isset($this->variablesPost['ville']) && $this->variablesPost['ville'] != '0' && $this->variablesPost['ville'] != '') {
         $ville = $this->variablesPost['ville'];
     }
     // ***********************************************************************************
     // recuperation des valeurs des champs textes du formulaire validé,  les autres champs sont mis en place individuellement
     $listeChamps = array('titre', 'source', 'sourcetxt', 'dateDebut', 'dateFin', 'nbEtages', 'description', 'ville', 'villetxt');
     foreach ($listeChamps as $indice => $fieldName) {
         if (isset($this->variablesPost[$fieldName]) && $this->variablesPost[$fieldName] != '') {
             $t->assign_vars(array($fieldName => $this->variablesPost[$fieldName]));
         }
     }
     // gestion du favori de la ville ou si on a une ville generale courante
     if ($ville == '0' && !isset($this->variablesGet['archiIdVilleGeneral'])) {
         $reqVilleTxt = "select nom from ville where idVille = '" . $this->session->getFromSession('idVilleFavoris') . "'";
         $resVilleTxt = $this->connexionBdd->requete($reqVilleTxt);
         $fetchVilleTxt = mysql_fetch_assoc($resVilleTxt);
         $t->assign_vars(array('ville' => $this->session->getFromSession('idVilleFavoris'), 'villetxt' => $fetchVilleTxt['nom']));
         $ville = $this->session->getFromSession('idVilleFavoris');
     } elseif (isset($this->variablesGet['archiIdVilleGeneral'])) {
         $reqVilleTxt = "select nom from ville where idVille = '" . $this->variablesGet['archiIdVilleGeneral'] . "'";
         $resVilleTxt = $this->connexionBdd->requete($reqVilleTxt);
         $fetchVilleTxt = mysql_fetch_assoc($resVilleTxt);
         $t->assign_vars(array('ville' => $this->variablesGet['archiIdVilleGeneral'], 'villetxt' => $fetchVilleTxt['nom']));
         $ville = $this->variablesGet['archiIdVilleGeneral'];
     }
     // ***********************************************************************************
     // si un idVille existe sur le formulaire ,  on affiche les quartiers correspondants
     if ($ville != 0) {
         $resQuartiers = $this->connexionBdd->requete("select idQuartier,  nom from quartier where idVille = '" . $ville . "' order by nom");
         while ($fetchQuartiers = mysql_fetch_assoc($resQuartiers)) {
             $selected = "";
             if (isset($this->variablesPost['quartiers']) && $this->variablesPost['quartiers'] != '0' && $fetchQuartiers['idQuartier'] == $this->variablesPost['quartiers']) {
                 $selected = " selected";
             }
             if ($fetchQuartiers['nom'] != 'autre') {
                 if ($type == "personne") {
                 } else {
                     $t->assign_block_vars("isNotAjoutSousEvenement.quartiers", array('id' => $fetchQuartiers['idQuartier'], 'nom' => $fetchQuartiers['nom'], 'selected' => $selected));
                 }
             }
         }
     }
     // ***********************************************************************************
     // si on a des personnes selectionnees ,  on les ajoute
     $d = new droitsObject();
     $u = new archiUtilisateur();
     if ($d->isAuthorized('personne_sur_evenement_ajouter', $u->getIdProfilFromUtilisateur($authentification->getIdUtilisateur()))) {
         $t->assign_vars(array("affichePersonnesBlock" => "table-row"));
     } else {
         $t->assign_vars(array("affichePersonnesBlock" => "none"));
     }
     if ($d->isAuthorized('affiche_selection_source', $u->getIdProfilFromUtilisateur($authentification->getIdUtilisateur()))) {
         $t->assign_block_vars('afficheAjoutEvenement.isDisplaySource', array());
     } else {
         $t->assign_block_vars('afficheAjoutEvenement.isNotDisplaySource', array());
     }
     if (count($personnes) > 0) {
         $listePersonnes = implode("', '", $personnes);
         $reqPersonnes = "select idPersonne,  nom,  prenom from personne where idPersonne in ('" . $listePersonnes . "')";
         $resPersonnes = $this->connexionBdd->requete($reqPersonnes);
         while ($fetchPersonnes = mysql_fetch_assoc($resPersonnes)) {
             $t->assign_block_vars('personnes', array('id' => $fetchPersonnes['idPersonne'], 'nom' => $fetchPersonnes['nom'] . ' ' . $fetchPersonnes['prenom'], 'selected' => " selected"));
         }
     }
     // ***********************************************************************************
     // si un idQuartier existe sur le formulaire on affiche les sous quartier correspondants
     if (isset($this->variablesPost['quartiers']) && $this->variablesPost['quartiers'] != '') {
         $resSousQuartiers = $this->connexionBdd->requete("select idSousQuartier,  nom from sousQuartier where idQuartier = '" . $this->variablesPost['quartiers'] . "' order by nom");
         while ($fetchSousQuartiers = mysql_fetch_assoc($resSousQuartiers)) {
             $selected = "";
             if (isset($this->variablesPost['sousQuartiers']) && $this->variablesPost['sousQuartiers'] != '0' && $fetchSousQuartiers['idSousQuartier'] == $this->variablesPost['sousQuartiers']) {
                 $selected = " selected";
             }
             if ($fetchSousQuartiers['nom'] != 'autre') {
                 if ($type == "personne") {
                 } else {
                     $t->assign_block_vars("isNotAjoutSousEvenement.sousQuartiers", array('id' => $fetchSousQuartiers['idSousQuartier'], 'nom' => $fetchSousQuartiers['nom'], 'selected' => $selected));
                 }
             }
         }
     }
     $numLigne = 0;
     if (isset($this->variablesPost['idUnique'])) {
         foreach ($this->variablesPost['idUnique'] as $indice => $valueIdUnique) {
             if (isset($this->variablesGet['supprAdresse']) && $this->variablesGet['supprAdresse'] == $valueIdUnique) {
                 //
             } else {
                 $arrayAdresse[$numLigne]['idAdresse'] = 0;
                 $arrayAdresse[$numLigne]['txt'] = $this->variablesPost['ruetxt'][$valueIdUnique];
                 $arrayAdresse[$numLigne]['id'] = $this->variablesPost['rue'][$valueIdUnique];
                 $arrayAdresse[$numLigne]['numero'] = $this->variablesPost['numero'][$valueIdUnique];
                 $arrayAdresse[$numLigne]['indicatif'] = $this->variablesPost['indicatif'][$valueIdUnique];
                 $numLigne++;
             }
         }
         if (isset($this->variablesPost['ajouterAdresse'])) {
             $arrayAdresse[$numLigne]['idAdresse'] = 0;
             $arrayAdresse[$numLigne]['txt'] = "";
             $arrayAdresse[$numLigne]['id'] = "";
             $arrayAdresse[$numLigne]['numero'] = "";
             $arrayAdresse[$numLigne]['indicatif'] = "";
             $numLigne++;
         }
         if (count($this->variablesPost['idUnique']) == 1 && isset($this->variablesPost['enleverAdresse'])) {
             $arrayAdresse[$numLigne]['idAdresse'] = 0;
             $arrayAdresse[$numLigne]['txt'] = "";
             $arrayAdresse[$numLigne]['id'] = "";
             $arrayAdresse[$numLigne]['numero'] = "";
             $arrayAdresse[$numLigne]['indicatif'] = "";
             $numLigne++;
         }
     } else {
         $arrayAdresse[$numLigne]['idAdresse'] = 0;
         $arrayAdresse[$numLigne]['txt'] = "";
         $arrayAdresse[$numLigne]['id'] = "";
         $arrayAdresse[$numLigne]['numero'] = "";
         $arrayAdresse[$numLigne]['indicatif'] = "";
         $numLigne++;
     }
     $configArrayRetrieveCoordonneesGoogleMap = array();
     for ($i = 0; $i < $numLigne; $i++) {
         // affichage des indicatifs pour chaque adresse
         if ($type == "personne") {
         } else {
             $t->assign_block_vars("isNotAjoutSousEvenement.adresses", array('idUnique' => $i, 'onClickBoutonChoixRue' => "document.getElementById('paramChampAppelantRue').value= 'rue" . $i . "';document.getElementById('iFrameRue').src='" . $this->creerUrl('', 'afficheChoixRue', array('noHeaderNoFooter' => 1)) . "&archiIdVille='+document.getElementById('ville').value+'&archiIdQuartier='+document.getElementById('quartiers').value+'&archiIdSousQuartier='+document.getElementById('sousQuartiers').value;document.getElementById('calqueRue').style.top=(getScrollHeight()+150)+'px';document.getElementById('calqueRue').style.display='block';", "nomRue" => $arrayAdresse[$i]["txt"], "rue" => $arrayAdresse[$i]["id"], "numero" => $arrayAdresse[$i]["numero"], "onClickBoutonSupprAdresse" => "document.getElementById('formAjoutDossier').action='" . $this->creerUrl('', 'ajoutNouveauDossier', array('supprAdresse' => $i)) . "'"));
         }
         // gestion des indicatifs de chaque adresse
         $reqIndicatif = "select idIndicatif,  nom from indicatif";
         $resIndicatif = $this->connexionBdd->requete($reqIndicatif);
         while ($fetchIndicatif = mysql_fetch_assoc($resIndicatif)) {
             $selected = "";
             if (isset($this->variablesPost['indicatif' . $i]) && $this->variablesPost['indicatif' . $i] != '' && $this->variablesPost['indicatif' . $i] == $fetchIndicatif['idIndicatif']) {
                 $selected = " selected";
             }
             if ($type == "personne") {
             } else {
                 $t->assign_block_vars("isNotAjoutSousEvenement.adresses.indicatifs", array("id" => $fetchIndicatif['idIndicatif'], "nom" => $fetchIndicatif['nom'], "selected" => $selected));
             }
         }
         $configArrayRetrieveCoordonneesGoogleMap[$i] = array('nomChampLatitudeRetour' => 'latitude_' . $i, 'nomChampLongitudeRetour' => 'longitude_' . $i, 'getAdresseFromElementById' => true, 'jsAdresseValue' => "document.getElementById('numero" . $i . "').value+' '+document.getElementById('rue" . $i . "txt').value+' '+document.getElementById('villetxt').value", 'jsToExecuteIfNoAddressFound' => "document.getElementById('latitude_" . $i . "').value='';document.getElementById('longitude_" . $i . "').value='';");
     }
     $jsToExecute = "document.getElementById('formAjoutDossier').action='" . $this->creerUrl('ajoutNouveauDossier', '') . "';testAdresseValideAndSubmit('formAjoutDossier');";
     $arrayJsCoordonneesFromGoogleMap = $googleMap->getJSMultipleRetriveCoordonnees(array('jsToExecuteIfOK' => $jsToExecute), $configArrayRetrieveCoordonneesGoogleMap);
     $html .= $arrayJsCoordonneesFromGoogleMap['jsFunctionToExecute'];
     // **************************************************************************************
     // ***********************************************************************************
     // liste des courants architecturaux
     $resCourants = $this->connexionBdd->requete("select idCourantArchitectural, nom from courantArchitectural order by nom");
     $tableauHtml = new tableau();
     while ($fetchCourants = mysql_fetch_assoc($resCourants)) {
         $checked = "";
         if (isset($this->variablesPost["courantArchitectural"]) && in_array($fetchCourants["idCourantArchitectural"], $this->variablesPost["courantArchitectural"])) {
             $checked = " checked";
         }
         $tableauHtml->addValue("<input type='checkbox' name='courantArchitectural[]' value='" . $fetchCourants["idCourantArchitectural"] . "' " . $checked . ">&nbsp;" . $fetchCourants['nom']);
     }
     $t->assign_vars(array('listeCourantsArchitecturaux' => $tableauHtml->createHtmlTableFromArray(3, 'white-space:nowrap;border:1px solid #000000;', 'listeCourantsArchitecturaux')));
     if ($type == "adresse") {
         $t->assign_block_vars("afficheAjoutEvenement.isAddress", array());
         // ***********************************************************************************
         // les des types de structures
         $resTypeStructure = $this->connexionBdd->requete("SELECT idTypeStructure,  nom FROM typeStructure order by nom");
         while ($fetchTypeStructure = mysql_fetch_assoc($resTypeStructure)) {
             $selected = "";
             if ($typeStructure != '' && $typeStructure == $fetchTypeStructure["idTypeStructure"] || $typeStructure == "" && $fetchTypeStructure["idTypeStructure"] == $this->getIdTypeStructureImmeuble()) {
                 $selected = " selected";
             }
             if ($fetchTypeStructure["idTypeStructure"] > 0) {
                 $t->assign_block_vars('afficheAjoutEvenement.isAddress.typesStructure', array('id' => $fetchTypeStructure["idTypeStructure"], 'nom' => $fetchTypeStructure["nom"], 'selected' => $selected));
             }
         }
     }
     // ***********************************************************************************
     // le type de groupe d'evenement
     // 1 - culturel
     // 2 - travaux
     if ($groupeTypeEvenement == '2') {
         $t->assign_vars(array('checkedTypeEvenement2' => " checked"));
         $t->assign_vars(array('styleChampsSupplementaireCulturel' => "display:none;", 'styleChampsSupplementaireTravaux' => "display:block;"));
     } elseif ($groupeTypeEvenement == '1') {
         $t->assign_vars(array('checkedTypeEvenement1' => " checked"));
         $t->assign_vars(array('styleChampsSupplementaireCulturel' => "display:table-row;", 'styleChampsSupplementaireTravaux' => "display:none;"));
     }
     $t->assign_vars(array('onClickTypeEvenement1' => "appelAjax('" . $this->creerUrl('', 'afficheSelectTypeEvenement', array('noHeaderNoFooter' => 1, 'archiTypeGroupeEvenement' => '1')) . "', 'typeEvenement');document.getElementById('afficheChampsSupplementairesCulturel').style.display='block';document.getElementById('afficheChampsSupplementairesTravaux').style.display='none';"));
     $t->assign_vars(array('onClickTypeEvenement2' => "appelAjax('" . $this->creerUrl('', 'afficheSelectTypeEvenement', array('noHeaderNoFooter' => 1, 'archiTypeGroupeEvenement' => '2')) . "', 'typeEvenement');document.getElementById('afficheChampsSupplementairesTravaux').style.display='block';document.getElementById('afficheChampsSupplementairesCulturel').style.display='none';"));
     if ($type == "adresse") {
         // ***********************************************************************************
         // les type d'evenements
         // par defaut on selectionne le typeEvenement=2 (travaux)
         $resTypeEvenement = $this->connexionBdd->requete("SELECT idTypeEvenement, nom FROM typeEvenement where groupe = '" . $groupeTypeEvenement . "'");
         while ($fetchTypeEvenement = mysql_fetch_assoc($resTypeEvenement)) {
             $selected = "";
             if ($typeEvenement != "" && $typeEvenement == $fetchTypeEvenement["idTypeEvenement"]) {
                 $selected = "selected";
             }
             $t->assign_block_vars('afficheAjoutEvenement.isAddress.typesEvenement', array('id' => $fetchTypeEvenement['idTypeEvenement'], 'nom' => $fetchTypeEvenement['nom'], 'selected' => $selected));
         }
     }
     // ***********************************************************************************
     // ISMH   (inscrit au s des monuments historiques)
     // MH (monument historique)
     if ($ISMH) {
         $t->assign_vars(array('ISMHchecked' => ' checked'));
     }
     if ($MH) {
         $t->assign_vars(array('MHchecked' => ' checked'));
     }
     // ***********************************************************************************
     // ***********************************************************************************
     // autre cas pour l'affichage du champ numeroArchive ,  il faut que l'utilisateur soit autorisé à l'afficher => table utilisateur
     $utilisateur = new archiUtilisateur();
     if ($utilisateur->canChangeNumeroArchiveField(array('idUtilisateur' => $authentification->getIdUtilisateur()))) {
         $t->assign_block_vars('afficheAjoutEvenement.canChangeNumeroArchive', array());
     } else {
         $t->assign_block_vars('afficheAjoutEvenement.noChangeNumeroArchive', array());
     }
     // ***********************************************************************************
     // idem champ dateFin
     if ($utilisateur->canChangeDateFinField(array('idUtilisateur' => $authentification->getIdUtilisateur()))) {
         $t->assign_block_vars('afficheAjoutEvenement.canChangeDateFin', array());
     } else {
         $t->assign_block_vars('afficheAjoutEvenement.noChangeDateFin', array());
     }
     $recherche = new archiRecherche();
     $source = new archiSource();
     $onClickBoutonValider = $type == "adresse" ? "affichePopupAttente();" . $arrayJsCoordonneesFromGoogleMap['jsFunctionCall'] : "";
     $typeBoutonValidation = $type == "adresse" ? "button" : "submit";
     $t->assign_vars(array('formAction' => $this->creerUrl($formAction), 'popupCalendrier' => $this->getPopupCalendrier(), 'popupVilles' => $this->getPopupChoixVille('nouveauDossier'), 'popupRues' => $this->getPopupChoixRue('nouveauDossier'), 'popupSources' => $recherche->getPopupChoixSource('nouveauDossier'), 'popupPersonnes' => $recherche->getPopupChoixPersonne('nouveauDossier'), 'onClickBoutonAjouterAdresse' => "document.getElementById('formAjoutDossier').action='" . $this->creerUrl('', 'ajoutNouveauDossier') . "'", 'onClickBoutonEnleverAdresse' => "document.getElementById('formAjoutDossier').action='" . $this->creerUrl('', 'ajoutNouveauDossier') . "'", 'onClickBoutonValider' => $onClickBoutonValider, 'typeBoutonValidation' => $typeBoutonValidation, 'onClickBoutonChoixVille' => "document.getElementById('paramChampAppelantVille').value='ville';document.getElementById('calqueVille').style.top=(getScrollHeight()+150)+'px';document.getElementById('calqueVille').style.display='block';", 'onChangeListeQuartier' => "appelAjax('" . $this->creerUrl('', 'afficheSelectSousQuartier', array('noHeaderNoFooter' => 1)) . "&archiIdQuartier='+document.getElementById('quartiers').value, 'listeSousQuartier')", 'onClickBoutonChoisirSource' => "document.getElementById('paramChampsAppelantSource').value='source';document.getElementById('calqueSource').style.top=(getScrollHeight()+150)+'px';document.getElementById('calqueSource').style.display='block';", 'onClickChoixPersonne' => "document.getElementById('paramChampsAppelantPersonne').value='personnes';document.getElementById('calquePersonne').style.top=(getScrollHeight()+150)+'px';document.getElementById('calquePersonne').style.display='block';", 'onClickDateDebut' => "document.getElementById('paramChampAppelantDate').value='dateDebut';document.getElementById('calqueDate').style.top=(getScrollHeight()+150)+'px';document.getElementById('calqueDate').style.display='block';", 'onClickDateFin' => "document.getElementById('paramChampAppelantDate').value='dateDebut';document.getElementById('calqueDate').style.top=(getScrollHeight()+150)+'px';document.getElementById('paramChampAppelantDate').value='dateFin';document.getElementById('calqueDate').style.display='block';", 'popupAttente' => $this->getPopupAttente()));
     //document.getElementById('formAjoutDossier').action='".$this->creerUrl('ajoutNouveauDossier', '')."';testAdresseValideAndSubmit('formAjoutDossier');
     // ******************************************************************************************************************************
     // on recupere les messages d'aide contextuelle et on les affiche :
     $helpMessages = $this->getHelpMessages("helpEvenement");
     foreach ($helpMessages as $fieldName => $helpMessage) {
         $t->assign_vars(array($fieldName => $helpMessage));
     }
     // ******************************************************************************************************************************
     ob_start();
     $t->pparse('nouveauDossier');
     $html .= ob_get_contents();
     ob_end_clean();
     return $html;
 }
    case "offresDescriptions":
        $req = "\n\t\t\tSELECT obd.idDescription, concat(obd.adresseOffre,' ',v.nomVille) as adresseOffre2\n\t\t\tFROM offresBiensDescriptions obd\n\t\t\tLEFT JOIN ville v ON v.idVille = obd.idVille\n\t\t\t{$paramReq}\n\t\t\tORDER BY obd.idDescription\n\t\t\tLIMIT 10\n\t\t ";
        break;
    case "historiqueAdresse":
        $req = "\n\t\t\tSELECT ha.idHistoriqueAdresse,ha.idAdresse\n\t\t\tFROM historiqueAdresse ha\n\t\t\t{$paramReq}\n\t\t\tORDER BY ha.idHistoriqueAdresse\n\t\t\tLIMIT 10\n\t\t";
        break;
    case "ville":
        $req = "\n\t\t\tSELECT v.idVille as idVille,v.nom as nomVille,p.nom as nomPays, concat(v.nom,' ',p.nom) as libelleAdresse\n\t\t\tFROM ville v\n\t\t\tLEFT JOIN pays p ON p.idPays = v.idPays\n\t\t\t{$paramReq}\n\t\t\tAND v.nom!='autre'\n\t\t\tORDER BY v.idVille\n\t\t\tLIMIT 10\n\t\t";
        break;
    default:
        break;
}
echo $req;
echo "<h1>Recuperation des coordonnées de latitudes et longitudes</h1>";
$paramsGoogleMap = array('googleMapKey' => $config->googleMapKey);
$googleMap = new googleMap($paramsGoogleMap);
echo $googleMap->getJsFunctions();
// recuperation des adresses des arrets
$res = $config->connexionBdd->requete($req);
$str = new stringObject();
echo "\n\t\t<script language='javascript'>\n\t\tgeocoder = new GClientGeocoder();\n\t\t</script>\n";
echo "\n<div id='debug' style='background-color:blue;color:white;'>\n</div>\n<form action='?ajout=1' name='formAdresses' id=formAdresses method='POST' enctype='multipart/form-data'>\n<input type='text' value='{$idSuivant}' name='idATraiter'>\n";
$a = new archiAdresse();
$i = 0;
while ($fetch = mysql_fetch_assoc($res)) {
    if ($typeTable != 'ville') {
        $adresse = $a->getIntituleAdresseFrom($fetch['idAdresse'], 'idAdresse', array("noQuartier" => true, "noSousQuartier" => true));
        if (!$str->isUTF8($adresse)) {
            $adresse = utf8_encode($adresse);
        }
    } else {
 /**
  *
  * @return string
  */
 private function displayOnMap($criterias, $idHistoriqueEvenementArray, $nbResult)
 {
     $adresses = new archiAdresse();
     $arrayIdEvenementsGA = array();
     foreach ($idHistoriqueEvenementArray as $idHE) {
         $arrayIdEvenementsGA[] = $idHE['idEvenementGroupeAdresse'];
     }
     $gm = new googleMap(array('googleMapKey' => $this->googleMapKey, 'width' => 700, 'height' => 500, 'zoom' => 13));
     $this->addToJsHeader($gm->getJsFunctions());
     // ajout des fonctions de google map dans le header
     // on affiche uniquement les 100 premieres coordonnées
     // preparation du tableau de liste de coordonnées a transmettre a la classe googlemap
     $listeCoordonnees = array();
     $arrayIdEvenementGroupeAdressesConfigGMap = array();
     for ($i = 0; $i < 100 && isset($arrayIdEvenementsGA[$i]); $i++) {
         $reqCoordonnees = "\n\t\t\t\t\tSELECT     IF(ae.latitudeGroupeAdresse<>'0',ae.latitudeGroupeAdresse,ha1.latitude) as latitude,\n\t\t\t\t\tIF(ae.longitudeGroupeAdresse<>'0', ae.longitudeGroupeAdresse,ha1.longitude) as longitude,\n\t\t\t\t\tae.idEvenement as idEvenementGroupeAdresse\n\t\t\t\t\tFROM historiqueAdresse ha2, historiqueAdresse ha1\n\t\t\t\t\tLEFT JOIN _adresseEvenement ae ON ae.idAdresse = ha1.idAdresse\n\t\t\t\t\tWHERE ha2.idAdresse = ha1.idAdresse\n\t\t\t\t\tAND ha1.longitude!=''\n\t\t\t\t\tAND ha1.latitude!=''\n\t\t\t\t\tAND ha1.longitude!='0'\n\t\t\t\t\tAND ha1.latitude!='0'\n\t\t\t\t\tAND ha1.longitude IS NOT NULL\n\t\t\t\t\tAND ha1.latitude IS NOT NULL\n\t\t\t\t\tAND ha1.idHistoriqueAdresse = '" . $arrayIdEvenementsGA[$i] . "'\n\t\t\t\t\t\tGROUP BY ha1.idAdresse,ha1.idHistoriqueAdresse\n\t\t\t\t\t\tHAVING ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)\n\n\t\t\t\t\t\t\t";
         $resCoordonnees = $this->connexionBdd->requete($reqCoordonnees);
         $arrayIdEvenementGroupeAdressesConfigGMap[$i]['idEvenementGroupeAdresse'] = $arrayIdEvenementsGA[$i];
         if (mysql_num_rows($resCoordonnees) > 0) {
             $fetchCoordonnees = mysql_fetch_assoc($resCoordonnees);
             $arrayIdEvenementGroupeAdressesConfigGMap[$i]['longitude'] = $fetchCoordonnees['longitude'];
             $arrayIdEvenementGroupeAdressesConfigGMap[$i]['latitude'] = $fetchCoordonnees['latitude'];
             $arrayIdEvenementGroupeAdressesConfigGMap[$i]['idEvenementGroupeAdresse'] = $fetchCoordonnees['idEvenementGroupeAdresse'];
         } else {
             $arrayIdEvenementGroupeAdressesConfigGMap[$i]['longitude'] = 0;
             $arrayIdEvenementGroupeAdressesConfigGMap[$i]['latitude'] = 0;
             $arrayIdEvenementGroupeAdressesConfigGMap[$i]['idEvenementGroupeAdresse'] = '0';
         }
     }
     $retourConfig = $adresses->getArrayGoogleMapConfigCoordonneesFromCenter(array('arrayIdEvenementsGroupeAdresse' => $arrayIdEvenementGroupeAdressesConfigGMap));
     $html = "<h1>" . _("Résultats de la recherche avancée :") . "</h1>";
     if ($nbResult == 0) {
         $html .= _("aucun résultat.") . "<br><br>";
     } else {
         $html .= "<br>" . $nbResult . " " . _("résultats.") . "<br>";
     }
     $html .= $gm->getMap(array('listeCoordonnees' => $retourConfig['arrayConfigCoordonnees'], 'urlImageIcon' => $this->urlImages . "pointGM.png", 'pathImageIcon' => $this->getCheminPhysique() . "images/pointGM.png", 'setAutomaticCentering' => true));
     return $html;
 }