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 ? '&cid=' . $this->intCatId : null; $strLevelLink = $this->intLevelId != 0 ? '&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 . '&cmd=' . $strDetailCmd . $strLevelLink . $strCategoryLink . '&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 . '&cmd=edit&eid=' . $arrEntry['entryId'], $this->moduleLangVar . '_ENTRY_DELETE_URL' => 'index.php?section=' . $this->moduleName . '&cmd=delete&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 ? '&cid=' . $this->intCatId : null; $strLevelLink = $this->intLevelId != 0 ? '&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 . '&cmd=' . $strDetailCmd . $strLevelLink . $strCategoryLink . '&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 . '&cmd=edit&eid=' . $arrEntry['entryId'], $this->moduleLangVar . '_ENTRY_DELETE_URL' => 'index.php?section=' . $this->moduleName . '&cmd=delete&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 . '&cmd=' . $strDetailCmd . '&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; } }
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; }
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; }
/** * * @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; }