public function load() { parent::load(); if (isset($_GET['l']) && !$this->data['active_plus_account']) { exit(0); } else { $this->largeMap = isset($_GET['l']) && $this->data['active_plus_account']; $this->viewFile = $this->largeMap ? "map2.phtml" : "map.phtml"; if ($this->largeMap) { $this->layoutViewFile = "layout" . DIRECTORY_SEPARATOR . "popup.phtml"; } $this->rad = $this->largeMap ? 6 : 3; $map_size = $this->setupMetadata['map_size']; $this->x = $this->data['rel_x']; $this->y = $this->data['rel_y']; $m = new MapModel(); $this->contractsAllianceId = array(); if (0 < intval($this->data['alliance_id'])) { $cont = trim($m->getContractsAllianceId($this->data['alliance_id'])); if ($cont != "") { $_arr = explode(",", $cont); foreach ($_arr as $contractAllianceId) { list($aid, $pendingStatus) = $contractAllianceId; $this->contractsAllianceId[$aid] = $pendingStatus; } } } $_x = $this->data['rel_x']; $_y = $this->data['rel_y']; if ($this->isPost()) { $_x = intval($_POST['mxp']); $_y = intval($_POST['myp']); } else { if (isset($_GET['id']) && is_numeric($_GET['id'])) { $m_vid = intval($_GET['id']); if ($m_vid < 1) { $m_vid = 1; } $_x = floor(($m_vid - 1) / $map_size); $_y = $m_vid - ($_x * $map_size + 1); } } $map_matrix = $this->__getVillageMatrix($map_size, $_x, $_y, $this->rad); $map_matrix_arr = explode("|", $map_matrix); $matrixStr = $map_matrix_arr[0]; $matrixStrArray = explode(",", $matrixStr); $this->directionsMatrix = explode(",", $map_matrix_arr[1]); $result = $m->getVillagesMatrix($matrixStr); while ($result->next()) { $this->matrixSet[$result->row['id']] = array("vid" => $result->row['id'], "x" => $result->row['rel_x'], "y" => $result->row['rel_y'], "image_num" => $result->row['image_num'], "player_id" => $result->row['player_id'], "tribe_id" => $result->row['tribe_id'], "alliance_id" => $result->row['alliance_id'], "player_name" => $result->row['player_name'], "village_name" => $result->row['village_name'], "alliance_name" => $result->row['alliance_name'], "people_count" => $result->row['people_count'], "is_oasis" => $result->row['is_oasis'], "field_maps_id" => $result->row['field_maps_id']); } $i = 0; $this->json = ""; $sjson = ""; $sortedArray = array(); foreach ($matrixStrArray as $vid) { $mapItem = $this->matrixSet[$vid]; $sortedArray[] = $mapItem; if ($sjson != "") { $sjson .= ","; } $sjson .= sprintf("[%s,%s,%s,\"%s\",\"%s\",%s,%s", $mapItem['vid'], $mapItem['x'], $mapItem['y'], $this->getCssClassNameByItem($mapItem), $this->getMapAreaTitle($mapItem), $mapItem['player_id'] != "" ? 1 : 0, $mapItem['is_oasis']); if ($mapItem['player_id'] != "") { $sjson .= sprintf(",%s,%s,\"%s\",\"%s\",\"%s\"", $mapItem['tribe_id'], $mapItem['people_count'], htmlspecialchars(str_replace("\\", "\\\\", $mapItem['player_name'])), htmlspecialchars(str_replace("\\", "\\\\", $mapItem['village_name'])), htmlspecialchars(str_replace("\\", "\\\\", $mapItem['alliance_name']))); } else { if (!$mapItem['is_oasis']) { $sjson .= "," . $mapItem['field_maps_id']; } } $sjson .= "]"; if (++$i % ($this->rad * 2 + 1) == 0) { if ($this->json != "") { $this->json .= ","; } $this->json .= "[" . $sjson . "]"; $sjson = ""; } } $this->json = "[" . $this->json . "]"; $this->matrixSet = $sortedArray; $centerIndex = 2 * ($this->rad + 1) * $this->rad; $this->x = $this->matrixSet[$centerIndex]['x']; $this->y = $this->matrixSet[$centerIndex]['y']; $this->stepDirectionsMatrix = array($this->matrixSet[$centerIndex - $this->rad * 2 - 1]['vid'], $this->matrixSet[$centerIndex + 1]['vid'], $this->matrixSet[$centerIndex + $this->rad * 2 + 1]['vid'], $this->matrixSet[$centerIndex - 1]['vid']); $m->dispose(); if ($this->isCallback()) { echo $this->getClientScript(); exit(0); } } }