public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $cache = new wowhead_cache(); $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); // if the wowhead arg exists then format it into something the script can read if (array_key_exists('wowhead', $args)) { $args['pins'] = $this->wowhead_map($args['wowhead']); unset($args['wowhead']); } if (!($result = $cache->getZone($name, $this->lang))) { // method depends if the id or name is given $result = is_numeric($name) ? $this->getZoneByID($name) : $this->getZoneByName($name); if (!$result) { // not found $cache->close(); return $this->_notFound($this->language->words['zone'], $name); } else { // transfer the zone map if (WHP_TRANSFER_MAP == true) { $this->transferImage($result['map']); } $cache->saveZone($result); $cache->close(); return $this->toHTML($result, $args); } } else { // found in cache $cache->close(); return $this->toHTML($result, $args); } }
include_once dirname(__FILE__) . '/../config.php'; include_once dirname(__FILE__) . '/../includes/wowhead_cache.php'; $cache = new wowhead_cache(); $id = isset($_GET['id']) ? (int) $_GET['id'] : null; $lang = isset($_GET['lang']) ? $_GET['lang'] : WHP_LANG; $pins = isset($_GET['pins']) && $_GET['pins'] != '{pins}' ? $_GET['pins'] : null; // images path and urls $wowhead_zone_maps = 'http://static.wowhead.com/images/maps/enus/normal/'; $maps_url = $armory_image_url . 'images/zones/'; $maps_dir = dirname(__FILE__) . '/../images/zones/'; if ($id == null) { echo 'ID not given.'; $cache->close; exit; } if (!($result = $cache->getZone($id, $lang, true))) { echo 'Zone not found in the cache.'; $cache->close(); exit; } else { // parse the pins to make them easier to deal with $coords = array(); if ($pins != null) { $each = explode('|', $pins); foreach ($each as $val) { $xy = explode(',', $val); $coords[] = array('x' => $xy[0], 'y' => $xy[1]); } } // get the image based on whether or not the file exists locally $image = file_exists($maps_dir . $result['map']) ? $maps_url . $result['map'] : $wowhead_zone_maps . $result['map'];
public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); $cache = new wowhead_cache(); if (!($result = $cache->getNPC($name, $this->lang))) { // not found in cache $result = $this->getNPCInfo($name); if (!$result) { // not found $cache->close(); return $this->_notFound($this->language->words['npc'], $name); } else { // see if they want to display a map as well if (array_key_exists('map', $args)) { if (!($sql_map = $cache->getZone($args['map']['name'], $this->lang))) { $mapinfo = $this->getZoneMap($args['map']['name']); if (!$mapinfo) { $cache->close(); return $this->_notFound($this->language->words['zone'], $name); } else { if (!file_exists($this->images_path . $mapinfo['map']) && WHP_TRANSFER_MAP == true) { // file doesn't exist, so transfer it locally $this->transferImage($mapinfo['map']); } $cache->saveZone($mapinfo); $mapinfo['x'] = $args['map']['x']; $mapinfo['y'] = $args['map']['y']; $cache->saveNPC($result); $cache->close(); return $this->mapHTML($result, $mapinfo); } } else { if (!file_exists($this->images_path . $sql_map['map']) && WHP_TRANSFER_MAP == true) { // file doesn't exist, so transfer it locally $this->transferImage($sql_map['map']); } $sql_map['x'] = $args['map']['x']; $sql_map['y'] = $args['map']['y']; $cache->saveNPC($result); $cache->close(); return $this->mapHTML($result, $sql_map); } } else { // found, save it and display $cache->saveNPC($result); $cache->close(); return $this->generateHTML($result, 'npc'); } } } else { if (array_key_exists('map', $args)) { $mapinfo = $cache->getZone($args['map']['name'], $this->lang); if (!file_exists($this->images_path . $mapinfo['map']) && WHP_TRANSFER_MAP == true) { // file doesn't exist, so transfer it locally $this->transferImage($mapinfo['map']); } $mapinfo['x'] = $args['map']['x']; $mapinfo['y'] = $args['map']['y']; $cache->close(); return $this->mapHTML($result, $mapinfo); } else { $cache->close(); return $this->generateHTML($result, 'npc'); } } }