<div id="lv-quests" class="listview"></div> <script type="text/javascript">//<![CDATA[ var _ = {}; <?php $quests = WoW_Quests::GetQuests(); if (isset($quests['items']) && is_array($quests['items'])) { foreach ($quests['items'] as $item) { echo sprintf('_[%d]={name_enus:\'%s\',quality:%d,icon:\'%s\'};', $item['entry'], addslashes(WoW_Locale::GetLocaleID() != LOCALE_EN && isset($item['name_loc']) && $item['name'] != null ? $item['name_loc'] : $item['name']), $item['quality'], $item['icon']); } } ?> $.extend(true, g_items, _); _ = g_items; new Listview({template: 'quest', id: 'quests', note: $WH.sprintf(LANG.lvnote_questsfound, <?php echo WoW_Quests::GetTotalQuestsCount(); ?> , <?php echo isset($quests['quests']) ? count($quests['quests']) : 0; ?> ) + LANG.dash + LANG.lvnote_tryfiltering, _truncated: 1, data: [ <?php if (isset($quests['quests']) && is_array($quests['quests'])) { $count = count($quests['quests']); $current = 1; foreach ($quests['quests'] as $quest) { echo sprintf('{"category":0,"category2":0,"id":%d,"name":"%s","reqlevel":%d', $quest['entry'], str_replace('"', '\\"', $quest['Title']), $quest['MinLevel']); $item_rewards = null; $item_choices = null; for ($i = 1; $i < 7; ++$i) { if ($i < 5) {
<?php $quest = null; $items = null; $achievements = null; $zone = null; $relations = null; $quest_data = WoW_Quests::GetQuest(); if (isset($quest_data['quest'])) { $quest = $quest_data['quest']; } if (isset($quest_data['items'])) { $items = $quest_data['items']; } if (isset($quest_data['achievements'])) { $achievements = $quest_data['achievements']; } if (isset($quest_data['zone'])) { $zone = $quest_data['zone']; } if (isset($quest_data['relations'])) { $relations = $quest_data['relations']; } ?> <script type="text/javascript">//<![CDATA[ var _ = g_users; var lv_comments0 = []; var _ = g_users; var lv_screenshots = []; var lv_videos = []; var lv_links = [];
private static function InitQuests() { self::AssignTemplatePageIndex(array('quests', 'quest')); WoW_Template::SetPageData('activeTab', 0); WoW_Quests::InitPage(WoW_Template::GetPageIndex(), self::GetPageAction()); }
private static function HandleQuest() { if (!self::$m_quest) { return false; } $fields_to_locale = array('Title', 'Details', 'Objectives', 'OfferRewardText', 'RequestItemsText', 'EndText', 'CompletedText', 'ObjectiveText1', 'ObjectiveText2', 'ObjectiveText3', 'ObjectiveText4'); // Try to set localized fields foreach ($fields_to_locale as $field) { if (WoW_Locale::GetLocaleID() != LOCALE_EN) { if (isset(self::$m_quest[$field . '_loc']) && self::$m_quest[$field . '_loc'] != null) { self::$m_quest[$field] = self::$m_quest[$field . '_loc']; } } WoW_Utils::GameStringToHTML(self::$m_quest[$field]); } // Zone? $zone_data = array(); if (self::$m_quest['ZoneOrSort'] > 0) { // Find zone $zone_data = DB::World()->selectRow("\n SELECT\n `a`.`id`,\n `a`.`mapID`,\n `a`.`zoneID`,\n `a`.`name_en` AS `name_original`,\n `a`.`name_%s` AS `name_loc`\n FROM `DBPREFIX_areas` AS `a`\n WHERE `a`.`id` = %d", WoW_Locale::GetLocale(), self::$m_quest['ZoneOrSort']); if ($zone_data) { $zone_data = array('id' => $zone_data['id'], 'name' => WoW_Locale::GetLocaleID() != LOCALE_EN ? $zone_data['name_loc'] : $zone_data['name_original']); } } // Find NPC relations (start/end) $quest_relation = array('start' => 'creature_questrelation', 'end' => 'creature_involvedrelation'); foreach ($quest_relation as &$relation) { $table = $relation; $relation = array('npc' => array(), 'zone' => array()); $relation['npc'] = DB::World()->selectRow("\n SELECT\n `a`.`id`,\n `b`.`guid`,\n `b`.`map`,\n `b`.`position_x`,\n `b`.`position_y`,\n `c`.`name`,\n `c`.`faction_A`,\n `c`.`faction_H`,\n %s\n FROM `%s` AS `a`\n LEFT JOIN `creature` AS `b` ON `b`.`id` = `a`.`id`\n LEFT JOIN `creature_template` AS `c` ON `c`.`entry` = `a`.`id`\n %s\n WHERE `a`.`quest` = %d", WoW_Locale::GetLocaleID() != LOCALE_EN ? '`d`.`name_loc' . WoW_Locale::GetLocaleID() . '` AS `name_loc`' : 'NULL', $table, WoW_Locale::GetLocaleID() != LOCALE_EN ? 'LEFT JOIN `locales_creature` AS `d` ON `d`.`entry` = `a`.`id`' : null, self::$m_quest['entry']); if (!$relation['npc']) { $relation = false; continue; } $relation['zone'] = WoW_Utils::GetNpcAreaInfo($relation['npc']['id'], $relation['npc'], true); if (WoW_Locale::GetLocaleID() != LOCALE_EN) { if (isset($relation['npc']['name_loc']) && $relation['npc']['name_loc'] != null) { $relation['npc']['name'] = $relation['npc']['name_loc']; unset($relation['npc']['name_loc']); } if (isset($relation['zone']['zoneName_loc']) && $relation['zone']['zoneName_loc'] != null) { $relation['zone']['zoneName'] = $relation['zone']['zoneName_loc']; unset($relation['zone']['zoneName_loc']); } } } if (!$quest_relation['start'] && !$quest_relation['end']) { $quest_relation = null; } // Objectives $items_to_add = array(); self::$m_quest['ObjectivesText'] = ''; self::$m_quest['ObjectivesTextScript'] = ''; $obj_item_icon = 1; // Kill %d players if (self::$m_quest['PlayersSlain'] > 0) { self::$m_quest['ObjectivesText'] .= '<tr><th><ul><li><var> </var></li></ul></th><td>' . sprintf(WoW_Locale::GetString('template_quest_obj_players_slain'), self::$m_quest['PlayersSlain']) . '</td></tr>'; } // Provided item if (self::$m_quest['SrcItemId'] > 0) { $src_item = WoW_Items::GetBasicItemInfo(self::$m_quest['SrcItemId']); if (is_array($src_item)) { $items_to_add = array_merge($items_to_add, array($src_item)); self::$m_quest['ObjectivesText'] .= sprintf('<tr><th align="right" id="iconlist-icon%d"></th><td><span class="q%d"><a href="%s/item=%d">%s</a></span> %s</td></tr>', $obj_item_icon, $src_item['quality'], WoW::GetWoWPath(), $src_item['entry'], $src_item['name'], WoW_Locale::GetString('template_quest_item_provided')); self::$m_quest['ObjectivesTextScript'] .= '$WH.ge(\'iconlist-icon' . $obj_item_icon . '\').appendChild(g_items.createIcon(' . $src_item['entry'] . ', 0, 1))'; ++$obj_item_icon; } } // Related items $items = array(); $rewardItems = array(); $choiceItems = array(); $rewItemData = array(); $choiceItemData = array(); // Find items for ($i = 1; $i < 7; ++$i) { if ($i < 5) { if (!in_array(self::$m_quest['RewItemId' . $i], $items)) { $items[self::$m_quest['RewItemId' . $i]] = self::$m_quest['RewItemId' . $i]; $rewardItems[] = array('itemId' => self::$m_quest['RewItemId' . $i], 'count' => self::$m_quest['RewItemCount' . $i]); } } if (!in_array(self::$m_quest['RewChoiceItemId' . $i], $items)) { $items[self::$m_quest['RewChoiceItemId' . $i]] = self::$m_quest['RewChoiceItemId' . $i]; $choiceItems[] = array('itemId' => self::$m_quest['RewChoiceItemId' . $i], 'count' => self::$m_quest['RewChoiceItemCount' . $i]); } } // Load basic items info for reward items if (is_array($rewardItems)) { $ids = array(); foreach ($rewardItems as $it) { if (!in_array($it['itemId'], $ids)) { $ids[] = $it['itemId']; } } $rewItemData = WoW_Items::GetBasicItemInfo($ids); } // Load basic items info for choice reward items if (is_array($choiceItems)) { $ids = array(); foreach ($choiceItems as $it) { if (!in_array($it['itemId'], $ids)) { $ids[] = $it['itemId']; } } $choiceItemData = WoW_Items::GetBasicItemInfo($ids); } self::$m_quest['ReceiveRewardText'] = array('text' => '', 'script' => ''); self::$m_quest['ChoiceRewardText'] = array('text' => '', 'script' => ''); $rewMoney = self::$m_quest['RewOrReqMoney'] > 0 ? self::$m_quest['RewOrReqMoney'] : 0; if ($rewMoney > 0) { $isRecieve = true; $money = WoW_Utils::GetMoneyFormat($rewMoney); self::$m_quest['ReceiveRewardText']['text'] .= sprintf('%s%s%s', $money['gold'] > 0 ? sprintf('<span class="moneygold">%d</span> ', $money['gold']) : null, $money['silver'] > 0 ? sprintf('<span class="moneysilver">%d</span> ', $money['silver']) : null, $money['copper'] > 0 ? sprintf('<span class="moneycopper">%d</span> ', $money['copper']) : null); } $item_to_add = array(array('field' => 'ReceiveRewardText', 'var' => $rewItemData), array('field' => 'ChoiceRewardText', 'var' => $choiceItemData)); // Generate rewards text foreach ($item_to_add as $item) { if (is_array($item['var']) && sizeof($item['var']) > 0) { self::$m_quest[$item['field']]['text'] .= '<table class="icontab icontab-box">'; $i = 0; $item_icon = 1; $tr_opened = false; $tr_closed = true; foreach ($item['var'] as $it) { if ($i == 2) { self::$m_quest[$item['field']]['text'] .= '</tr>'; $i = 0; $tr_closed = true; $tr_opened = false; } if ($i == 0) { self::$m_quest[$item['field']]['text'] .= '<tr>'; $tr_closed = false; $tr_opened = true; } self::$m_quest[$item['field']]['text'] .= sprintf('<th id="icontab-icon%d"></th><td><span class="q%d"><a href="%s/item=%d">%s</a></span></td>', $item_icon, $it['quality'], WoW::GetWoWPath(), $it['entry'], WoW_Locale::GetLocaleID() != LOCALE_EN && isset($it['name_loc']) && $it['name_loc'] != null ? $it['name_loc'] : $it['name']); self::$m_quest[$item['field']]['script'] .= sprintf('$WH.ge(\'icontab-icon%d\').appendChild(g_items.createIcon(%d, 1, 1));', $item_icon, $it['entry']); ++$i; ++$item_icon; } if ($tr_opened && !$tr_closed) { self::$m_quest[$item['field']]['text'] .= '</tr>'; } self::$m_quest[$item['field']]['text'] .= '</table>'; } } // Merge items arrays if (is_array($rewItemData) && is_array($choiceItemData)) { $items_info = array_merge($rewItemData, $choiceItemData); // If any item found } elseif (is_array($rewItemData)) { $items_info = $rewItemData; } elseif (is_array($choiceItemData)) { $items_info = $choiceItemData; } if (is_array($items_to_add)) { $items_info = array_merge($items_info, $items_to_add); } // Find quest in achievement criterias $achievements_cr = DB::World()->select("\n SELECT\n `a`.`referredAchievement`,\n `b`.`id`,\n `b`.`factionFlag` AS `side`,\n `b`.`name_en` AS `name_original`,\n `b`.`name_%s` AS `name_loc`,\n `b`.`desc_en` AS `desc_original`,\n `b`.`desc_%s` AS `desc_loc`,\n `b`.`categoryId`,\n `b`.`iconID`,\n `b`.`points`,\n `c`.`icon`,\n `d`.`parentCategory`,\n `d`.`name_en` AS `categoryName_original`,\n `d`.`name_%s` AS `categoryName_loc`\n FROM `DBPREFIX_achievement_criteria` AS `a`\n LEFT JOIN `DBPREFIX_achievement` AS `b` ON `b`.`id` = `a`.`referredAchievement`\n LEFT JOIN `DBPREFIX_spell_icon` AS `c` ON `c`.`id` = `b`.`iconID`\n LEFT JOIN `DBPREFIX_achievement_category` AS `d` ON `d`.`id` = `b`.`categoryId`\n WHERE `a`.`requiredType` = 27 AND `a`.`data` = %d\n ", WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), self::GetID()); $achievements = array(); if (is_array($achievements_cr)) { foreach ($achievements_cr as $ach) { $ach['name'] = WoW_Locale::GetLocaleID() != LOCALE_EN && isset($ach['name_loc']) && $ach['name_loc'] != null ? $ach['name_loc'] : $ach['name_original']; $ach['desc'] = WoW_Locale::GetLocaleID() != LOCALE_EN && isset($ach['desc_loc']) && $ach['desc_loc'] != null ? $ach['desc_loc'] : $ach['desc_original']; $ach['categoryName'] = WoW_Locale::GetLocaleID() != LOCALE_EN && isset($ach['categoryName_loc']) && $ach['categoryName_loc'] != null ? $ach['categoryName_loc'] : $ach['categoryName_original']; $achievements[] = array('id' => $ach['id'], 'name' => $ach['name'], 'desc' => $ach['desc'], 'categoryName' => $ach['categoryName'], 'categoryId' => $ach['categoryId'], 'icon' => $ach['icon'], 'points' => $ach['points'], 'side' => $ach['side'], 'parentCategory' => $ach['parentCategory']); } unset($achievements_cr, $ach); } // Set page title WoW_Template::SetPageData('quest_name', self::$m_quest['Title']); $quest = self::$m_quest; self::$m_quest = array('items' => $items_info, 'quest' => $quest, 'achievements' => $achievements, 'zone' => $zone_data, 'relations' => $quest_relation); //echo '<pre>'; //print_r(self::$m_quest); //die; unset($quest, $items, $items_info); }