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); } }
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'); } } }