* All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is * free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** * PLUGIN 'Google-Map' for the 'rggooglemap' extension. * * @author Georg Ringer */ require_once(PATH_tslib.'class.tslib_pibase.php'); /** * Plugin 'Google Map (rggooglemap)' for the 'rggooglemap' extension. * * @author Georg Ringer */ class tx_rggooglemap_pi1 extends tslib_pibase { var $prefixId = 'tx_rggooglemap_pi1'; // Same as class name var $scriptRelPath = 'pi1/class.tx_rggooglemap_pi1.php'; // Path to this script relative to the extension dir. var $extKey = 'rggooglemap'; // The extension key. /** * Just some intialization, mainly reading the settings in the flexforms * * @param array $conf: The PlugIn configuration */ function init($conf) { require_once (PATH_tslib.'/class.tslib_content.php'); $this->cObj2 = t3lib_div::makeInstance('tslib_cObj'); // Local cObj. $this->conf = $conf; // Storing configuration as a member var $this->pi_loadLL(); // Loading language-labels $this->pi_setPiVarDefaults(); // Set default piVars from TS $this->pi_initPIflexForm(); // Init FlexForm configuration for plugin $this->confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rggooglemap']); // Template code $this->templateCode = $this->cObj2->fileResource('EXT:rggooglemap/template.html'); $this->templateCode = $this->cObj2->fileResource($this->conf['templateFile']); /* * 1st sheet: Map settings */ /* // Getting the pid list via the flexform $pid_list = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'startingpoint', 'sDEF') ? implode(t3lib_div::intExplode(',', $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'startingpoint', 'sDEF')), ',') : $this->conf['pidList']; # if ($pid_list == '') $pid_list = $GLOBALS["TSFE"]->id; // Checking for recursive level $recursive = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'recursive', 'sDEF') ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'recursive', 'sDEF') : $this->conf['recursive']; if (is_numeric($recursive) && $recursive > 0) { $this->config['pid_list'] = $this->pi_getPidList($pid_list,$recursive); } else { $this->config['pid_list'] = $pid_list; } */ $this->config['pid_list'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'startingpoint', 'sDEF') ? implode(t3lib_div::intExplode(',', $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'startingpoint', 'sDEF')), ',') : $this->conf['pidList']; // Show $this->config['show'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'show', 'sDEF'); // active POI categories $this->config['categories'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categories', 'sDEF') ? $this->config['categories'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categories', 'sDEF') : $this->conf['mapActiveCats']; // loaded POI categories $this->config['categoriesselected'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categoriesselected', 'sDEF') ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categoriesselected', 'sDEF') : $this->conf['mapAvailableCats']; // map div id $this->config['mapDiv'] = $this->conf['mapDiv']; // width $width = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'width', 'sDEF'); $this->config['mapWidth'] = intval(($width) ? intval($width) : $this->conf['mapWidth']) ; // height $height = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'height', 'sDEF'); $this->config['mapHeight'] = intval(($height) ? $height : $this->conf['mapHeight']) ; // lng $confLng = $this->conf['mapLng'] ? $this->conf['mapLng'] : $this->confArr['startLong']; $lng = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'lng', 'sDEF'); $this->config['mapLng'] = $lng ? $lng : $confLng ; // lat $confLat = $this->conf['mapLat'] ? $this->conf['mapLat'] : $this->confArr['startLat']; $lat = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'lat', 'sDEF'); $this->config['mapLat'] = $lat ? $lat : $confLat; // zoom $confZoom = $this->conf['mapZoom'] ? $this->conf['mapZoom'] : $this->confArr['startZoom']; $zoom = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'zoom', 'sDEF'); $this->config['mapZoom'] = $zoom ? $zoom : $confZoom ; // google map key $confKey = $this->conf['mapKey'] ? $this->conf['mapKey'] : $this->confArr['googleKey']; $key = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'key', 'sDEF'); $this->config['mapKey'] = $key ? $key : $confKey; // map control $this->config['mapType'] = ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'type', 'sDEF')) ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'type', 'sDEF') : $this->conf['mapType'] ; $this->config['mapTypeControl'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'type_controls', 'sDEF') ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'type_controls', 'sDEF') : $this->conf['mapControl']; $this->config['mapNavControl'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'nav_controls', 'sDEF') ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'nav_controls', 'sDEF') : $this->conf['mapNavigation']; $this->config['mapControlOnMouseOver'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'controlonmouseouver', 'sDEF') ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'controlonmouseouver', 'sDEF') : $this->conf['mapNavigationOnMouseOver']; $this->config['mapOverview'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'mapoverview', 'sDEF') ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'mapoverview', 'sDEF') : $this->conf['mapOverview']; // default POI to show on begin $this->config['mapShowOnDefault'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showondefault', 'sDEF'); /* * 3rd sheet: Config for Menu-output */ // Starting point of the menu $this->config['menu-start'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'startingpoint', 'menu'); // Included categories $this->config['menu-cat'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categories', 'menu'); // Checkbox to include header + description $this->config['menu-include'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'include', 'menu'); // ID of the map page $this->config['menu-map'] =$this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'map', 'menu'); // orderBy of categories and records $this->config['menu-catSort'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'menucatsortorder', 'menu'); $this->config['menu-recordSort'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'menurecordsortorder', 'menu'); // Use category-tree in menu view $this->config['menu-categorytree'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'usecategorytree', 'menu'); // Use searchbbox in menu view $this->config['menu-searchbox'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'usesearchbox', 'menu'); // which tables should be uses $tmp_confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rggooglemap']); $this->config['tables'] = ($this->confArr['tables']!='') ? $this->confArr['tables'] : $tmp_confArr['tables']; require_once( t3lib_extMgm::siteRelpath('rggooglemap').'res/class.tx_rggooglemap_table.php'); $this->generic = t3lib_div::makeInstance('tx_rggooglemap_table'); $this->config['test'] = $conf['whereUid'].'xx'.$this->conf['whereUid']; } /** * The main method of the PlugIn * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * @return The content that is displayed on the website */ function main($content,$conf) { $this->conf=$conf; $this->init($conf); $this->pi_setPiVarDefaults(); $this->pi_loadLL(); $this->pi_USER_INT_obj=1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object! $this->pi_initPIflexForm(); // Init FlexForm configuration for plugin // emulate dynamic filtering $this->loadOnDefault = '14'; #$this->config['recordsPerPage'] =10 ; if ($this->config['show'] == 'MAP') { $content .= $this->pi_wrapInBaseClass($this->showMap($content,$conf)); } if ($this->config['show'] == 'SEARCHBOX') { $content .= $this->pi_wrapInBaseClass($this->showSearchBox($content,$conf)); } if ($this->config['show'] == 'RECORDSONMAP') { $content .= $this->pi_wrapInBaseClass($this->recordsOnMap($content,$conf)); } if ($this->config['show'] == 'MENU') { $content .= $this->pi_wrapInBaseClass($this->showMenu($content,$conf)); } if ($this->config['show'] == 'SEARCH') { $content .= $this->pi_wrapInBaseClass($this->showSearch($content,$conf)); } return $content; } /** * View "MENU": Show all records of the selected categories and starting point, linking to the map on a different page * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * $param array $additional: Function can be called by processCatTree to change used categories dynamically * @return The plugin content */ function showMenu ($content, $conf, $additionalCat='', $additionalWhere='') { $template["total"] = $this->cObj->getSubpart($this->templateCode,"###TEMPLATE_MENU###"); $template["item"] = $this->cObj->getSubpart($template["total"],"###ITEM_SINGLE###"); $template["item2"] = $this->cObj->getSubpart($template["total"],"###ITEM_SINGLE2###"); $this->conf=$conf; $this->init($conf); // query for the categories $table = 'tx_rggooglemap_cat'; // if the tree is used in menu view, take the IDs from there, otherwise out of the plugin if ($additionalCat!='') { $menuCatList.= ' AND uid IN ('.implode(',',$additionalCat).') '; } else { $menuCatList = (($this->config['menu-cat']!='') ? ' AND uid IN ('.$this->config['menu-cat'].') ' : ''); } $where = 'deleted = 0 AND hidden=0' .$menuCatList; $orderBy = $conf['menu.']['orderByCat'].' '.$this->config['menu-catSort']; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',$table,$where,$groupBy='',$orderBy,$limit=''); $i = 0; // List of the Categories while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $markerArray['###TEXT###'] = ($this->config['menu-include'] == 1 || $this->config['menu-include'] == 3) ? $this->cObj->stdWrap($row['title'], $conf['menu.']['header.']) : ''; $markerArray['###DESCRIPTION###'] = ($this->config['menu-include'] == 2 || $this->config['menu-include'] == 3) ? $this->cObj->stdWrap($row['descr'], $conf['menu.']['description.']) : ''; $markerArray['###TEST###'] = $row['uid']; // query for single records in category $firstCategory = explode(',',$row['uid']); // display not yet $where2 = 'deleted = 0 AND hidden = 0 AND pid IN('.$this->config['menu-start'].') AND rggmcat = '.$firstCategory{0}.' AND tx_rggooglemap_display = 1 AND lng != \'\' AND lat != \'\' '; $where2 = 'deleted = 0 AND hidden = 0 AND pid IN('.$this->config['menu-start'].') AND rggmcat = '.$firstCategory{0}.' AND lng != \'\' AND lat != \'\' '; // search mode if ($additionalWhere!= '') { $where2 .= $additionalWhere; } $table = $this->config['tables']; $orderBy2 = $conf['menu.']['orderByRecord'].' '.$this->config['menu-recordSort']; //x $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',$table,$where2,$groupBy='',$orderBy2,$limit=''); $res2 = $this->generic->exec_SELECTquery('*',$table,$where2,$groupBy='',$orderBy2,$limit=''); // List of single records $content_item2 = ''; //x while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2)) { while($row2=array_shift($res2)) { $i++; foreach ($row2 as $key=>$value) { $this->cObj->data[$key]=$value; // thanks to tobi $markerArray['###'.strtoupper($key).'###'] = $this->cObj->stdWrap($value,$this->conf['menu.'][$key.'.']); } // odd/even $markerArray['###ZEBRA###'] = ($i%2==0) ? 'odd' : 'even'; // Linkfields $allFields = explode(',',$this->conf['linkFields']); foreach ($allFields as $key=>$field) { $vars = explode('|',$row2[$field]); // static link text > TS: link.www.value = xxx if ($this->conf['link.'][$field.'.']['value']) $vars[1] = $this->conf['link.'][$field.'.']['value']; // dynamic link text from other field if ($this->conf['link.'][$field.'.']['field']) $vars[1] = $row2[ $this->conf['link.'][$field.'.']['field'] ]; $param = array('parameter'=>$vars[0].' '.$this->$conf['marker.'][$key.'Link']); $link = $this->cObj->typoLink($this->cObj->stdWrap($vars[1],$this->conf['marker.'][$field.'.']),$param); $markerArray['###'.strtoupper($field).'###'] = $this->cObj->stdWrap($link,$this->conf['menu.'][$field.'.']); } // no page ID for map > suggesting plugin is on the same page => javascript links if ($this->config['menu-map']!='') { $wrappedSubpartArray['###LINK###'] = explode('|', $this->pi_linkTP_keepPIvars('|', Array('poi'=>$row2["uid"]), 1,1,$this->config['menu-map'])); } else { $wrappedSubpartArray['###LINK###'] = explode('|', '|'); } $content_item2 .=$this->cObj->substituteMarkerArrayCached($template["item2"],$markerArray, $subpartArray,$wrappedSubpartArray ); } # end while $subpartArray["###CONTENT2###"] = $content_item2 ; $content_item .=($i>0) ? $this->cObj->substituteMarkerArrayCached($template["item"],$markerArray, $subpartArray,$wrappedSubpartArray ) :''; } # end while $subpartArray["###CONTENT###"] =($i>0) ? $content_item : ''; $content.= $this->cObj->substituteMarkerArrayCached($template["total"],$markerArray, $subpartArray,$wrappedSubpartArray); return $content; } // function showSearchBox($content, $conf) /** * Plugin mode SEARCH: Presents a form to search for records * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * @return The plugin content */ function showSearch ($content, $conf) { $this->conf=$conf; $this->init($conf); $template["list"] = $this->cObj->getSubpart($this->templateCode,"###TEMPLATE_SEARCH###"); $content.= $this->cObj->substituteMarkerArrayCached($template["list"],$markerArray, $subpartArray,$wrappedSubpartArray); return $content; } /** * Function for the ajax search * * @param string $searchFields: The search fiels (search word & search on map only) * @return Records found with search value */ function search($searchForm) { $template['list'] = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE_SEARCH_RESULTS###'); $template["item"] = $this->cObj->getSubpart( $template["list"],"###SINGLE###"); $searchExpression = $searchForm['rggmsearchValue']; // minimum characters needed, default = 3 if (strlen($searchExpression) >= $this->conf['search.']['minChars']) { // escaping the search-value $delete = array("'", "\"", "\\", "/", ""); $searchExpression = str_replace($delete, "", $searchExpression); // query for the search $table = 'tt_address'; $field = '*'; $searchField = explode(',',$this->conf['search.']['tt_address']); foreach ($searchField as $key=>$value) { $where2.= " $value LIKE '%$searchExpression%' OR"; } $where = 'hidden = 0 AND deleted = 0 AND pid IN('.$this->config['pid_list'].') AND ( '.substr($where2,0,-3).' ) '; // search only within the map area if ($searchForm['rggmOnMap']=='on') { $areaArr=split("%2C%20",$searchForm['rggmBound']); $where.= 'AND tx_rggooglemap_lng between '.$areaArr[1].' AND '.$areaArr[3].' AND tx_rggooglemap_lat between '.$areaArr[0].' AND '.$areaArr[2]; } $i = 0; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($field,$table,$where,$groupBy='',$orderBy,$limit); while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $i++; foreach ($row as $key=>$value) { $markerArray['###'.strtoupper($key).'###'] = $this->cObj->stdWrap($value,$this->conf['search.'][$key.'.']); } $markerArray['###POPUP###'] = ' onClick=\' show("infobox"); ' . $this->prefixId . 'infomsg('.$row['uid'].', "'.$table.'"); \' '; $content_item .= $this->cObj->substituteMarkerArrayCached($template["item"],$markerArray, array(), array()); } $subpartArray["###CONTENT###"] = $content_item; // Nothing found if ($i ==0) { $subpartArray["###CONTENT###"] = $this->pi_getLL('searchNoResult'); } // minimum character length not reached } else { $subpartArray["###CONTENT###"] = sprintf($this->pi_getLL('searchMinChars'), $this->conf['search.']['minChars']); } $content.= $this->cObj->substituteMarkerArrayCached($template['list'],$markerArray, $subpartArray,$wrappedSubpartArray); $objResponse = new tx_xajax_response($GLOBALS['TSFE']->metaCharset); $objResponse->addAssign('searchFormResult', 'innerHTML', $content); return $objResponse->getXML(); } /** * Plugin mode RECORDSONMAP: Presents a list of on the map visible records * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * @return The plugin content */ function recordsOnMap ($content, $conf) { $this->conf=$conf; $this->init($conf); $template["list"] = $this->cObj->getSubpart($this->templateCode,"###TEMPLATE_RECORDSONMAP###"); $content.= $this->cObj->substituteMarkerArrayCached($template["list"],$markerArray, $subpartArray,$wrappedSubpartArray); return $content; } // function showSearchBox($content, $conf) /** * Plugin mode SEARCHBOX: Presents a form to search for a location, working with geocoding * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * @return The plugin content */ function showSearchBox ($content, $conf) { $this->init($conf); $template["list"] = $this->cObj2->getSubpart($this->templateCode,"###TEMPLATE_SEARCHBOX###"); $content.= $this->cObj2->substituteMarkerArrayCached($template["list"],$markerArray, $subpartArray,$wrappedSubpartArray); #echo '
'; print_r($GLOBALS['TSFE']).'
'; #var_dump($GLOBALS['TSFE']); return $content; } // function showSearchBox($content, $conf) /* Main mapview **/ function showMap ($content, $conf) { $this->init($conf); $this->pi_setPiVarDefaults(); $this->pi_loadLL(); /** * Instantiate the xajax object and configure it */ require_once (t3lib_extMgm::extPath('xajax') . 'class.tx_xajax.php'); $this->xajax = t3lib_div::makeInstance('tx_xajax'); // Make the instance if ($GLOBALS['TSFE']->metaCharset == 'utf-8') {$this->xajax->decodeUTF8InputOn(); } // Decode form vars from utf8 $this->xajax->setCharEncoding($GLOBALS['TSFE']->metaCharset); // Encode of the response to utf-8 ??? $this->xajax->setWrapperPrefix($this->prefixId); // To prevent conflicts, prepend the extension prefix $this->xajax->statusMessagesOn(); // Do you wnat messages in the status bar? #$this->xajax->debugOn(); $this->xajax->registerFunction(array('infomsg', &$this, 'infomsg')); $this->xajax->registerFunction(array('activeRecords', &$this, 'activeRecords')); $this->xajax->registerFunction(array('processCat', &$this, 'processCat')); $this->xajax->registerFunction(array('processFormData', &$this, 'processFormData')); $this->xajax->registerFunction(array('getPoiList', &$this, 'getPoiList')); $this->xajax->registerFunction(array('resultSet', &$this, 'resultSet')); $this->xajax->registerFunction(array('tab', &$this, 'tab')); $this->xajax->registerFunction(array('search', &$this, 'search')); $this->xajax->registerFunction(array('processCatTree', &$this, 'processCatTree')); $this->xajax->registerFunction(array('processSearchInMenu', &$this, 'processSearchInMenu')); $this->xajax->processRequests(); // Else create javascript and add it to the header output $path = t3lib_extMgm::siteRelpath('rggooglemap'); $GLOBALS['TSFE']->additionalHeaderData['b121000'] = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('xajax')); #$GLOBALS['TSFE']->additionalHeaderData['121212'] = ''; $GLOBALS['TSFE']->additionalHeaderData['b121212'] = ' '; $GLOBALS['TSFE']->additionalHeaderData['b121211'] = ''; $GLOBALS['TSFE']->additionalHeaderData['b121216'] = ''; $GLOBALS['TSFE']->additionalHeaderData['b121217'] = ''; $GLOBALS['TSFE']->additionalHeaderData['b121223'] = ''; $GLOBALS["TSFE"]->additionalHeaderData["b221213"] = ''; $GLOBALS['TSFE']->additionalHeaderData['b121214'] = ''; $GLOBALS['TSFE']->additionalHeaderData['c121214'] = ''; # $GLOBALS['TSFE']->additionalHeaderData['121299'] = ''; /* $GLOBALS['TSFE']->additionalHeaderData['124444'] = ' '; */ $template["list"] = $this->cObj2->getSubpart($this->templateCode,"###MAP###"); if ($this->config['menu-categorytree'] == 1 ) { $template["list"] = $this->cObj2->getSubpart($this->templateCode,"###TEMPLATE_CATMENU_MENU###"); } // title, text - markers $markerArray['###CAT_MENU###'] = $this->displayCatMenu(0); $markerArray['###MAP_WIDTH###'] = $this->config['mapWidth']; $markerArray['###MAP_HEIGHT###'] = $this->config['mapHeight']; $content.= $this->cObj2->substituteMarkerArrayCached($template["list"],$markerArray, $subpartArray,$wrappedSubpartArray); return $content; } // function main($content, $conf) /** * Load the info message popup window * * @param string $uid: id of reocord * @param string $table: table of record * @param int $prefix: Prefix for tabs in info window * @return The content of the info window */ function infomsg($uid, $table,$tmplPrefix=1) { $template["infobox"] = $this->cObj->getSubpart($this->templateCode,"###TEMPLATE_INFOBOX_$tmplPrefix###"); // query for single record $field = '*'; $where = 'uid = '.intval($uid); //x $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($field,$table,$where,$groupBy='',$orderBy,$limit=''); $res = $this->generic->exec_SELECTquery($field,$table,$where,$groupBy='',$orderBy,$limit=''); $row=array_shift($res); $markerArray = $this->getMarker($row,'popup.'); // query for categories of a single record $template["item"] = $this->cObj->getSubpart( $template["infobox"],"###SINGLE###"); $field = '*'; $where = 'uid IN ('.$row['rggmcat'].')'; $table = 'tx_rggooglemap_cat'; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($field,$table,$where,$groupBy='',$orderBy='',$limit=''); if ($res) { while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { foreach ($row2 as $key=>$value) { $markerArray['###CAT_'.strtoupper($key).'###'] = $row2[$key]; } $content_item .= $this->cObj->substituteMarkerArrayCached($template["item"],$markerArray, array(), array()); } } $subpartArray["###CONTENT###"] = $content_item; $content.= $this->cObj->substituteMarkerArrayCached($template["infobox"],$markerArray, $subpartArray,$wrappedSubpartArray); $objResponse = new tx_xajax_response($GLOBALS['TSFE']->metaCharset); $objResponse->addAssign('infobox', 'innerHTML', $content); return $objResponse->getXML(); } /** * Creates the "Show record 1 to 9 of 9" * * @param string $offset: offset value * @param string $table: table of query * @param string $field: $field of query * @param string $where: $where of query * @return Array with information for the page browser */ function pageBrowserStatistic($offset=0, $table, $field, $where) { $records=$this->generic->exec_COUNTquery($table,$where); $pages=ceil($records/$this->conf['recordsPerPage']); $max = ($this->conf['recordsPerPage']>= $records) ? $records : ($offset*$this->conf['recordsPerPage']+$this->conf['recordsPerPage']); $content['text'] = sprintf( $this->pi_getLL('pagebrowser'), $offset*$this->conf['recordsPerPage']+1, $max, $records ); $content['pages'] = $pages; $content['offset'] = $offset; return $content; } /** * Creates the result records for the first page * * @param array $data: selected checboxes * @return Result records including the pagebrowser for the 1st result page */ function processCat($data) { #$content .= t3lib_div::view_array($data); // debug // save selected categories into session $GLOBALS["TSFE"]->fe_user->setKey('ses', 'data2', $data['cb']); $GLOBALS['TSFE']->fe_user->storeSessionData(); // if at least one checkbox is activated if (count($data['cb']) > 0) { $test = implode(',',$data['cb']); foreach ($data['cb'] as $key=>$value) { $where2.= ' FIND_IN_SET('.$key.',rggmcat) OR'; } $where2 = ' AND ( '.substr($where2,0,-3).' ) '; #$where2 = "AND rggmcat REGEXP '(,|^)<$test>(,|$)' "; // template $template["resultSet"] = $this->cObj2->getSubpart($this->templateCode,"###TEMPLATE_RECORDLIST_FIRST###"); $template["item"] = $this->cObj2->getSubpart( $template["resultSet"],"###SINGLE###"); // db query $i = 0; $table = $this->config['tables']; $field = '*'; $where = 'pid IN('.$this->config['pid_list'].') AND hidden= 0 AND deleted = 0 ' ; $where.=' AND lng!=0 AND lat !=0 AND rggmcat != 0 '.$where2; $GLOBALS["TSFE"]->fe_user->setKey('ses', 'where', $where); $GLOBALS['TSFE']->fe_user->storeSessionData(); $res = $this->generic->exec_SELECTquery($field,$table,$where,$groupBy,$orderBy,'0,'.$this->conf['recordsPerPage']); while($row=array_shift($res)) { #x $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($field,$table,$where,$groupBy='',$orderBy,'0,'.$this->conf['recordsPerPage']); #x while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { foreach ($row as $key=>$value) { $markerArray['###'.strtoupper($key).'###'] = $this->cObj2->stdWrap($value,$this->conf['recordlist.'][$key.'.']); } $markerArray['###POPUP###'] = ' onClick=\' show("infobox"); ' . $this->prefixId . 'infomsg('.$row['uid'].', "'.$table.'"); \' '; $content_item .= $this->cObj2->substituteMarkerArrayCached($template["item"],$markerArray, array(), array()); } $subpartArray["###CONTENT###"] = $content_item; // initalize pagebrowser $pagebrowser = $this->pageBrowserStatistic($offset, $table, $field, $where); $text = $pagebrowser['text']; $pages = $pagebrowser['pages']; $offset = $pagebrowser['offset']; // Pagebrower statistic $markerArray['###PB_STATISTIC###'] = $pagebrowser['text']; // next link if ($offset +1 < $pages) { $new = $offset+1; $pb = ' onClick="'.$this->prefixId.'resultSet('.$new.')" '; $markerArray['###PB_NEXT###'] = sprintf( $this->pi_getLL('pagebrowser_next'), $pb, 2 ); } else { $markerArray['###PB_NEXT###'] = ''; } $content.=$this->cObj2->substituteMarkerArrayCached($template["resultSet"],$markerArray, $subpartArray,$wrappedSubpartArray); } // checkboxes selected $objResponse = new tx_xajax_response($GLOBALS['TSFE']->metaCharset); $objResponse->addAssign('formResult', 'innerHTML',$content); return $objResponse->getXML(); } /** * Modifies the menu output with including the cateory selection * * @param array $data: selected checboxes * @return Result records */ function processCatTree($data) { $content.= $this->showMenu('', $this->conf, $data['cb']); $objResponse = new tx_xajax_response($GLOBALS['TSFE']->metaCharset); $objResponse->addAssign('rggm-menu', 'innerHTML',$content); return $objResponse->getXML(); } /** * Modifies the menu output with including the search box * * @param array $data: selected uids * @return where clause for search */ function processSearchInMenu ($data) { $searchExpression = $data['rggmsearchValue']; // minimum characters needed, default = 3 if (strlen($searchExpression) >= $this->conf['search.']['minChars']) { // escaping the search-value $delete = array("'", "\"", "\\", "/", ""); $searchExpression = trim(str_replace($delete, "", $searchExpression)); // query for the search $searchField = explode(',',$this->conf['search.']['tt_address']); foreach ($searchField as $key=>$value) { $where2.= " $value LIKE '%$searchExpression%' OR"; } $where = ' AND ( '.substr($where2,0,-3).' ) '; // search only within the map area if ($data['rggmOnMap']=='on') { $areaArr=split("%2C%20",$searchForm['rggmBound']); $where.= 'AND tx_rggooglemap_lng between '.$areaArr[1].' AND '.$areaArr[3].' AND tx_rggooglemap_lat between '.$areaArr[0].' AND '.$areaArr[2]; } } // Adds hook for processing of extra search expressions if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rggooglemap']['extraSearchHook'])) { foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rggooglemap']['extraSearchHook'] as $_classRef) { $_procObj = & t3lib_div::getUserObj($_classRef); $where = $_procObj->extraSearchProcessor($where, $data, $this->config, $this); } } # $where.=t3lib_div::view_array($data); $content.= $this->showMenu('', $this->conf, '', $where); $objResponse = new tx_xajax_response($GLOBALS['TSFE']->metaCharset); $objResponse->addAssign('rggm-menu', 'innerHTML',$content); return $objResponse->getXML(); } /** * Creates the result records from 2nd page to last page * * @param string $offset: offset value * @return Result records including the pagebrowser */ function resultSet($var) { $offset = intval($var); // template $template["resultSet"] = $this->cObj->getSubpart($this->templateCode,"###TEMPLATE_RECORDLIST###"); $template["item"] = $this->cObj->getSubpart( $template["resultSet"],"###SINGLE###"); // pagebrowser (prev <> next) $table = $this->config['tables']; $field = '*'; $where = $GLOBALS["TSFE"]->fe_user->getKey('ses','where'); $pagebrowser = $this->pageBrowserStatistic($offset, $table, $field, $where); $offset = $pagebrowser['offset']; $pages = $pagebrowser['pages']; $begin = intval($var)*$this->conf['recordsPerPage']; // Pagebrower statistic $markerArray['###PB_STATISTIC###'] = $pagebrowser['text']; // actual page $markerArray['###PB_ACT###'] = sprintf( $this->pi_getLL('pagebrowser_act'), $offset+1 ); // previous link if ($offset > 0) { $pb = ' onClick="'.$this->prefixId.'resultSet('.($offset-1).')" '; $markerArray['###PB_PREV###'] = sprintf( $this->pi_getLL('pagebrowser_prev'), $pb, $offset ); } else { $markerArray['###PB_PREV###'] = ''; } // next link if ($offset +1 < $pages) { $new = $offset+1; $pb = ' onClick="'.$this->prefixId.'resultSet('.$new.')" '; $markerArray['###PB_NEXT###'] = sprintf( $this->pi_getLL('pagebrowser_next'), $pb, $offset+2 ); } else { $markerArray['###PB_NEXT###'] = ''; } // query for the results $limit= $begin.','.$this->conf['recordsPerPage']; $res = $this->generic->exec_SELECTquery($field,$table,$where,$groupBy,$orderBy,$limit); while($row=array_shift($res)) { foreach ($row as $key=>$value) { $markerArray['###'.strtoupper($key).'###'] = $this->cObj->stdWrap($value,$this->conf['recordlist.'][$key.'.']); } $markerArray['###POPUP###'] = ' onClick=\' show("infobox"); ' . $this->prefixId . 'infomsg('.$row['uid'].', "'.$table.'"); \' '; $content_item .= $this->cObj->substituteMarkerArrayCached($template["item"],$markerArray, array(), array()); } $subpartArray["###CONTENT###"] = $content_item; $content.= $this->cObj->substituteMarkerArrayCached($template["resultSet"],$markerArray, $subpartArray,$wrappedSubpartArray); $objResponse = new tx_xajax_response($GLOBALS['TSFE']->metaCharset); $objResponse->addAssign('resultdiv', 'innerHTML', $content); return $objResponse->getXML(); } /** * Creates the categorymenu * * @param int $id: parent_id for the recursive function * @return categorymenu with parent_id = $id */ function displayCatMenu($id=0) { // template if ($this->config['menu-categorytree'] == 0) { $template["total"] = $this->cObj2->getSubpart($this->templateCode,"###TEMPLATE_CATMENU###"); } else { $template["total"] = $this->cObj2->getSubpart($this->templateCode,"###TEMPLATE_CATMENU_TREE###"); } $table = 'tx_rggooglemap_cat'; $field = '*'; $where = 'hidden= 0 AND deleted = 0 AND parent_uid = '.$id; $where.= ($this->config['categoriesselected']!='') ? ' AND uid IN('.$this->config['categoriesselected'].')' : ''; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($field,$table,$where,$groupBy='',$orderBy,$limit=''); // actived checkbox for selected category $checkedBox = explode(',',$this->config['categories']); if ($res) { $i = 0; $first = ($id == 0) ? '