kenken999/php
0
1<?php2class MapPage_Dashboard extends ListPage_Dashboard3{4 /**5 * @type Boolean6 */7 protected $gridBased = false;8 9 /**10 * Constructor, set initial params11 * @param array $params12 */13 function __construct(&$params)14 {15 parent::__construct( $params );16 17 $this->gridBased = !$this->dashElementData["updateMoved"] && $this->hasTableDashGridElement();18 }19 20 public function getSubsetDataCommand( $ignoreFilterField = "" ) {21 $dc = parent::getSubsetDataCommand();22 23 if( $this->mapRefresh ) {24 $dc->filter = DataCondition::_And( array(25 $dc->filter,26 $this->getLatLngCondition( $this->dashElementData['latF'], $this->dashElementData['lonF'] )27 ));28 }29 30 return $dc;31 }32 33 /**34 *35 */36 public function setGoogleMapsParams( $params )37 {38 $this->googleMapCfg['tName'] = $this->tName;39 $this->googleMapCfg['isUseMainMaps'] = true;40 $this->googleMapCfg['isUseGoogleMap'] = true;41 $this->googleMapCfg['isUseFieldsMaps'] = false;42 43 $mapId = GoodFieldName($this->dashTName).'_'.$this->dashElementName.'_dashMap';44 $this->googleMapCfg['mainMapIds'][] = $mapId;45 46 $this->googleMapCfg['mapsData'][ $mapId ]['type'] = 'DASH_MAP';47 $this->googleMapCfg['mapsData'][ $mapId ]['latField'] = $this->dashElementData['latF'];48 $this->googleMapCfg['mapsData'][ $mapId ]['lngField'] = $this->dashElementData['lonF'];49 $this->googleMapCfg['mapsData'][ $mapId ]['descField'] = $this->dashElementData['descF'];50 $this->googleMapCfg['mapsData'][ $mapId ]['addressField'] = $this->dashElementData['addressF'];51 52 $this->googleMapCfg['mapsData'][ $mapId ]['dashMap'] = true;53 54 $this->googleMapCfg['mapsData'][ $mapId ]['heatMap'] = $this->dashElementData['heatMap'];55 $this->googleMapCfg['mapsData'][ $mapId ]['clustering'] = $this->dashElementData['clustering'];56 $this->googleMapCfg['mapsData'][ $mapId ]['showAllMarkers'] = ( $this->dashElementData['heatMap'] || $this->dashElementData['clustering'] );57 58 $this->googleMapCfg['mapsData'][ $mapId ]['showCurrentLocation'] = !!$this->dashElementData['showCurrentLocation'];59 $this->googleMapCfg['mapsData'][ $mapId ]['currentLocationIcon'] = $this->dashSet->getDashMapLocationIcon( $this->dashElementName );60 61 if( !$this->gridBased )62 $this->googleMapCfg['mapsData'][ $mapId ]['zoom'] = "auto";63 else if( isset($this->dashElementData['zoom']) )64 $this->googleMapCfg['mapsData'][ $mapId ]['zoom'] = $this->dashElementData['zoom'];65 66 if( isset($this->dashElementData['APIkey']) )67 $this->googleMapCfg['APIcode'] = $this->dashElementData['APIkey'];68 69 if( $this->dashElementData['clustering'] )70 $this->AddJSFile("include/markerclusterer.js");71 }72 73 /**74 *75 */76 function fillGridData()77 {78 if( $this->gridBased )79 return;80 81 $data = $this->beforeProccessRow();82 $tKeys = $this->pSet->getTableKeys();83 84 $recNum = $this->hasTableDashGridElement() || strlen($this->masterTable) ? $this->pageSize : GetGlobalData( "mapMarkerCount" );85 86 if( !$this->mapRefresh && ( $this->dashElementData['clustering'] || $this->dashElementData['heatMap'] ) )87 {88 // fetch as much records as we can89 $recNum = 10000;90 }91 92 while($data && ($this->recNo <= $recNum || $recNum == -1))93 {94 // update $this->recId value95 $this->genId();96 97 $keys = array();98 $params = array();99 foreach( $tKeys as $i => $fKey )100 {101 $keys[ 0 ] = $data[ $fKey ];102 $params[] = "editid".($i + 1)."=".runner_htmlspecialchars(rawurlencode( $data[ $fKey ] ));103 }104 $editlink = implode("&", $params);105 106 $this->addBigGoogleMapMarkers($data, $keys, $editlink);107 108 $data = $this->beforeProccessRow();109 $this->recNo ++;110 }111 }112 113 /**114 *115 */116 function fillControlsHTMLMap()117 {118 $this->controlsHTMLMap[ $this->tName ] = array();119 $this->controlsHTMLMap[ $this->tName ][ PAGE_DASHMAP ] = array();120 $this->controlsHTMLMap[ $this->tName ][ PAGE_DASHMAP ][ $this->id ] = array();121 $this->controlsHTMLMap[ $this->tName ][ PAGE_DASHMAP ][ $this->id ]["gMaps"] = $this->googleMapCfg;122 }123 124 /**125 * @return String126 */127 protected function getMapDiv()128 {129 $mapId = GoodFieldName($this->dashTName).'_'.$this->dashElementName.'_dashMap';130// $width = $this->dashElementData['width'] ? $this->dashElementData['width'] : 600;131// $height = $this->dashElementData['height'] ? $this->dashElementData['height'] : 400;132 $width = "100%";133 $height = "100%";134 $style = "@media print, (min-width: 768px) { #".$mapId." { width: ".$width."; } }";135 return '<style>'.$style.'</style><div id="'.$mapId.'" style="height: '.$height.';"></div>';136 }137 138 /**139 * Show the page.140 * It's supposed to be displayed in resonce on an ajax-like request141 */142 public function showPage()143 {144 $this->fillSetCntrlMaps();145 146 $response = array();147 global $pagesData;148 $response["pagesData"] = $pagesData;149 $response['settings'] = $this->jsSettings;150 $response['controlsMap'] = $this->controlsHTMLMap;151 152 $response['html'] = $this->getMapDiv();153 $response['success'] = true;154 $response['id'] = $this->id;155 156 $response["additionalJS"] = $this->grabAllJsFiles();157 $response['headerCont'] = '<span class="rnr-dbebrick">' . $this->getPageTitle($this->pageName, GoodFieldName($this->tName)) . "</span>";158 $icon = getIconHTML( $this->dashElementData["item"]["icon"] );159 if( $icon )160 $response["iconHtml"] = $icon;161 162 echo printJSON($response);163 }164 165 /**166 * A stub167 * @return Boolean168 */169 protected function checkIfSearchPanelActivated() {170 return false;171 }172 173 function deleteAvailable() {174 return ListPage_Embed::deleteAvailable() && $this->dashElementData["details"][$this->tName]["delete"];175 }176 177 function editAvailable() {178 return ListPage_Embed::editAvailable() && $this->dashElementData["details"][$this->tName]["edit"];179 }180 181 function addAvailable() {182 return ListPage_Embed::addAvailable() && $this->dashElementData["details"][$this->tName]["add"];183 }184 185 function viewAvailable() {186 return ListPage_Embed::viewAvailable() && $this->dashElementData["details"][$this->tName]["view"];187 }188 189 function inlineEditAvailable() {190 return false;191 }192 function inlineAddAvailable() {193 return false;194 }195 196 function addCommonJs()197 {198 $this->initGmaps();199 }200 201 /**202 * A stub203 */204 function addCommonHtml() {}205 206 /**207 * A stub208 */209 function commonAssign() {}210 211 /**212 * A stub213 */214 function addCustomCss() {}215 216 /**217 * A stub218 */219 function buildPagination() {}220 221 function fetchMapMarkersInSeparateQuery( $mapId )222 {223 return false;224 }225 226 protected function hasBigMap()227 {228 return true;229 }230 231 public function fillAdvancedMapData()232 {233 }234 235}236?>237 