public function parse($name, $args = array()) { if (trim($name) == '') { return false; } // set the language for this parse, and then load the language pack $this->lang = array_key_exists('lang', $args) ? $args['lang'] : WHP_LANG; $this->language->loadLanguage($this->lang); $cache = new wowhead_cache(); if (!($result = $cache->getFaction($name, $this->lang))) { $result = is_numeric($name) ? $this->getFactionByID($name) : $this->getFactionByName($name); if (!$result) { $cache->close(); return $this->_notFound($this->language->words['faction'], $name); } else { $cache->saveFaction($result); $cache->close(); return $this->generateHTML($result, 'faction'); } } else { $cache->close(); return $this->generateHTML($result, 'faction'); } }
return $found; } // we'll need this later $standings = array('hated', 'hostile', 'unfriendly', 'neutral', 'friendly', 'honored', 'revered', 'exalted'); // first, we need to get the necessary data from $_GET $id = array_key_exists('id', $_GET) ? (int) $_GET['id'] : null; $lang = array_key_exists('lang', $_GET) ? $_GET['lang'] : WHP_LANG; $mode = array_key_exists('mode', $_GET) ? $_GET['mode'] : 'tooltip'; // connect to sql $cache = new wowhead_cache(); if ($id == null) { echo 'Faction ID not given.'; exit; } if ($mode == 'tooltip') { if (!($result = $cache->getFaction($id, $lang, true))) { $cache->close(); echo 'Faction "' . $id . '" not found in cache.'; exit; } else { echo stripslashes($result['tooltip']); } } elseif ($mode == 'rewards') { if (!($result = $cache->getFactionRewards($id, $lang))) { // gotta build the html $data = readURL(getDomain($lang) . '?faction=' . $id, false); $rLine = getRewardLine($data); if (!$rLine) { return false; } else { $items = array('hated' => array(), 'hostile' => array(), 'unfriendly' => array(), 'neutral' => array(), 'friendly' => array(), 'honored' => array(), 'revered' => array(), 'exalted' => array());