private static function HandleSellingItems() { if (self::$selling_count <= 0 || !is_array(self::$myitems_storage)) { return false; } $item_ids = array(); $item_ids_guids = array(); $items_data = array(); foreach (self::$myitems_storage as $item) { $item_ids[] = $item['item_template']; $item_ids_guids[$item['itemguid']] = $item['item_template']; $items_data[$item['itemguid']] = $item; } $items = DB::World()->select("SELECT `entry`, `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry` IN (%s)", $item_ids); if (!$items) { return false; } $items_storage = array(); $displayids = array(); foreach ($items as $item) { $items_storage[$item['entry']] = $item; $displayids[] = $item['displayid']; } $icons = DB::WoW()->select("SELECT `displayid`, `icon` FROM `DBPREFIX_icons` WHERE `displayid` IN (%s)", $displayids); if (!$icons) { return false; } $icons_storage = array(); foreach ($icons as $icon) { $icons_storage[$icon['displayid']] = $icon['icon']; } unset($icons); self::$items_storage = array(); self::$buyout_price = 0; foreach ($item_ids_guids as $item_guid => $item_id) { if (isset($items_storage[$item_id])) { $item = new WoW_Item(WoWConfig::$Realms[WoW_Account::GetActiveCharacterInfo('realmId')]['type']); $item->LoadFromDBByEntry($item_guid, $item_id); $auc_time = $items_data[$item_guid]['time']; $now = time(); $auction_time = 0; if ($now - $auc_time <= 48 * IN_HOURS) { $auction_time = 3; } elseif ($now - $auc_time <= 24 * IN_HOURS) { $auction_time = 2; } elseif ($now - $auc_time <= 12 * IN_HOURS) { $auction_time = 1; } self::$items_storage[] = array('auction_id' => $items_data[$item_guid]['id'], 'guid' => $item_guid, 'id' => $items_storage[$item_id]['entry'], 'quality' => $items_storage[$item_id]['Quality'], 'name' => WoW_Locale::GetLocaleId() == LOCALE_EN ? $items_storage[$item_id]['name'] : WoW_Items::GetItemName($item_id), 'icon' => $icons_storage[$items_storage[$item_id]['displayid']], 'price_raw' => $items_data[$item_guid]['startbid'], 'price' => WoW_Utils::GetMoneyFormat($items_data[$item_guid]['startbid']), 'buyout_raw' => $items_data[$item_guid]['buyoutprice'], 'buyout' => WoW_Utils::GetMoneyFormat($items_data[$item_guid]['buyoutprice']), 'lastbid' => $items_data[$item_guid]['lastbid'], 'count' => $item->GetStackCount(), 'time' => $auction_time); self::$buyout_price += $items_data[$item_guid]['buyoutprice']; } } unset($items, $items_storage, $displayids); return true; }
private static function BuildCriteriasList($ach_id) { $data = DB::WoW()->select("SELECT `id`, `referredAchievement`, `requiredType`, `data`, `value`, `additional_type_1`, `additional_value_1`, `additional_type_2`, `additional_value_2`, `name_%s` AS `name`, `completionFlag`, `groupFlag` FROM `DBPREFIX_achievement_criteria` WHERE `referredAchievement` = %d ORDER BY `showOrder`", WoW_Locale::GetLocale(), $ach_id); if (!$data) { return false; } $i = 0; $achievement_criterias = array(); foreach ($data as $criteria) { if ($criteria['completionFlag'] & ACHIEVEMENT_CRITERIA_FLAG_HIDE_CRITERIA) { continue; } $cr_data = self::GetCompletedCriteriaData($criteria['id']); if (!$cr_data) { $cr_data = array('counter' => 0, 'date' => 0); } if (!isset($cr_data['counter'])) { $cr_data['counter'] = 0; } $achievement_criterias[$i] = array('id' => $criteria['id'], 'dateCompleted' => $cr_data['date'], 'name' => $criteria['name']); if ($criteria['requiredType'] == 8) { // ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT $achievement_criterias[$i]['achievementCriteria'] = DB::WoW()->selectRow("SELECT `id`, `categoryId`, `name_%s` AS `name`, `iconname` FROM `DBPREFIX_achievement` WHERE `id` = %d", WoW_Locale::GetLocale(), $criteria['data']); if ($achievement_criterias[$i]['achievementCriteria']) { if (self::IsAchievementCompleted($criteria['data'], $achievement_criterias[$i]['achievementCriteria']['categoryId'])) { $achievement_criterias[$i]['achievementCriteria']['completed'] = true; } else { $achievement_criterias[$i]['achievementCriteria']['completed'] = false; } } else { unset($achievement_criterias[$i]['achievementCriteria']); } } $achievement_criterias[$i]['progressBar'] = false; if ($criteria['completionFlag'] & ACHIEVEMENT_CRITERIA_FLAG_SHOW_PROGRESS_BAR || $criteria['completionFlag'] & ACHIEVEMENT_FLAG_COUNTER) { $achievement_criterias[$i]['progressBar'] = true; if ($criteria['completionFlag'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER) { $achievement_criterias[$i]['maxQuantityGold'] = $criteria['value']; $achievement_criterias[$i]['maxQuantity'] = $criteria['value']; $money = WoW_Utils::GetMoneyFormat($cr_data['counter']); $achievement_criterias[$i]['quantityGold'] = $money['gold']; $achievement_criterias[$i]['quantitySilver'] = $money['silver']; $achievement_criterias[$i]['quantityCopper'] = $money['copper']; $achievement_criterias[$i]['quantity'] = $cr_data['counter']; } else { $achievement_criterias[$i]['maxQuantity'] = $criteria['value']; $achievement_criterias[$i]['quantity'] = $cr_data['counter']; } } $i++; } return $achievement_criterias; }
</div> </div> </th> <th><span class="sort-tab"> </span></th> </tr> </thead> <tfoot> <tr> <th colspan="4" class="align-right"><strong><?php echo WoW_Locale::GetString('template_auction_buyout_total'); ?> </strong></th> <th class="price" id="buyout-total"> <?php $total_price = WoW_Auction::GetBuyOutTotalPrice(); $money_format = WoW_Utils::GetMoneyFormat($total_price); echo sprintf('<span class="hide">%d</span><span class="icon-gold">%d</span> <span class="icon-silver">%d</span> <span class="icon-copper">%d</span>', $total_price, $money_format['gold'], $money_format['silver'], $money_format['copper']); ?> </th> <th> </th> </tr> </tfoot> <tbody> <?php $auction_items = WoW_Auction::GetSellingItems(); if (is_array($auction_items)) { $toggleStyle = 2; foreach ($auction_items as $item) {
private static function GenerateItemTooltip() { $proto = self::GetItem(); if (!$proto || $proto->entry == 0) { return false; } $tooltip_buffer = ''; // Load SSD & SSV $ssd = DB::World()->selectRow("SELECT * FROM `DBPREFIX_ssd` WHERE `entry` = %d LIMIT 1", $proto->ScalingStatDistribution); $ssd_level = MAX_PLAYER_LEVEL; $ssv = DB::World()->selectRow("SELECT * FROM `DBPREFIX_ssv` WHERE `level` = %d LIMIT 1", $ssd_level); // Begin $tooltip_buffer .= '<table><tr><td>'; $tooltip_buffer .= sprintf('<b class="q%d">%s</b><br />', $proto->Quality, $proto->GetName()); // Heroic if ($proto->Flags & ITEM_FLAGS_HEROIC) { $tooltip_buffer .= sprintf('<span class="q2">%s</span><br />', WoW_Locale::GetString('template_item_heroic')); } // Bonding if ($proto->bonding > 0) { $tooltip_buffer .= sprintf('<!--bo-->%s<br />', WoW_Locale::GetString('template_item_bonding_' . $proto->bonding)); } if ($proto->maxcount == 1) { $tooltip_buffer .= sprintf('%s<br />', WoW_Locale::GetString('template_item_unique')); } // Subclass name & Inventory type if ($proto->IsCanBeEquipped()) { if (!in_array($proto->subclass, array(ITEM_SUBCLASS_ARMOR_MISC))) { $subclass_str = $proto->subclass_name; } else { $subclass_str = ''; } $tooltip_buffer .= sprintf('<table width="100%%"><tr><td>%s</td><th>%s</th></tr></table><!--rf-->', $proto->InventoryType_name, $subclass_str); } // Armor $armor = $proto->armor; if ($ssv && $proto->ScalingStatValue > 0) { if ($ssvarmor = self::GetArmorMod($ssv, $proto->ScalingStatValue)) { $armor = $ssvarmor; } } if ($armor > 0) { $tooltip_buffer .= sprintf('<span>%s</span><br />', sprintf(WoW_Locale::GetString('template_item_armor'), $armor)); } // Block if ($proto->block > 0) { $tooltip_buffer .= sprintf('<span>%s</span><br />', sprintf(WoW_Locale::GetString('template_item_block'), $proto->block)); } // Weapon damage info if ($proto->IsWeapon()) { $minDmg = $proto->Damage[0]['min']; $maxDmg = $proto->Damage[0]['max']; $dps = $proto->getDPS(); $tooltip_buffer .= sprintf('<!--rf--><table width="100%%"><tr><td><span>%s</span></td><th>%s</th></tr></table>%s<br />', sprintf(WoW_Locale::GetString('template_item_weapon_damage'), $minDmg, $maxDmg), sprintf(WoW_Locale::GetString('template_item_weapon_delay'), $proto->delay / 1000), sprintf(WoW_Locale::GetString('template_item_weapon_dps'), $dps)); } // Is projectile? if ($proto->class == ITEM_CLASS_PROJECTILE && $proto->Damage[0]['min'] > 0 && $proto->Damage[0]['max'] > $proto->Damage[0]['min']) { $tooltip_buffer .= sprintf('<span class="q1">%s</span><br/ >', sprintf(WoW_Locale::GetString('template_item_projectile_dps'), ($proto->Damage[0]['min'] + $proto->Damage[0]['max']) / 2)); } // Is gem? if ($proto->class == ITEM_CLASS_GEM && $proto->GemProperties > 0) { $gemText = DB::World()->selectRow("\n SELECT\n `a`.`spellitemenchantement`,\n `b`.`text_%s` AS `text`\n FROM `DBPREFIX_gemproperties` AS `a`\n LEFT JOIN `DBPREFIX_enchantment` AS `b` ON `b`.`id` = `a`.`spellitemenchantement`\n WHERE `a`.`id` = %d", WoW_Locale::GetLocale(), $proto->GemProperties); if ($gemText) { $tooltip_buffer .= sprintf('<span class="q1">%s</span><br />', $gemText['text']); } } // Base stats foreach ($proto->ItemStat as $stat) { if ($stat['type'] >= 3 && $stat['type'] <= 8) { $tooltip_buffer .= sprintf('<span><!--stat%d-->+%s</span><br />', $stat['type'], sprintf(WoW_Locale::GetString('template_item_stat_' . $stat['type']), $stat['value'])); } } // Sockets if ($proto->Socket) { foreach ($proto->Socket as $socket) { if ($socket['name'] != null) { $tooltip_buffer .= sprintf('<a href="%s/items=3&filter=cr=81;crs=3;crv=%d" class="socket-%s q0">%s</a><br />', WoW::GetWoWPath(), $socket['filter'], $socket['name'], WoW_Locale::GetString('template_item_socket_' . $socket['color'])); } } } // Socket bonus if ($proto->socketBonus > 0) { $tooltip_buffer .= sprintf('<!--sb--><span class="q0">%s</span><br />', sprintf(WoW_Locale::GetString('template_item_socket_match'), DB::World()->selectCell("SELECT `text_%s` FROM `DBPREFIX_enchantment` WHERE `id` = %d LIMIT 1", WoW_Locale::GetLocale(), $proto->socketBonus))); } // Durability if ($proto->MaxDurability > 0) { $tooltip_buffer .= sprintf('%s<br />', sprintf(WoW_Locale::GetString('template_item_durability'), $proto->MaxDurability, $proto->MaxDurability)); } // Classes mask if ($proto->AllowableClass > 0) { $classes_data = self::AllowableClasses($proto->AllowableClass); if (is_array($classes_data)) { $tooltip_buffer .= sprintf('%s ', WoW_Locale::GetString('template_item_allowable_classes')); $current = 1; foreach ($classes_data as $class_id => $class) { $tooltip_buffer .= sprintf('<a href="%s/class=%d" class="c%d">%s</a>%s', WoW::GetWoWPath(), $class_id, $class_id, WoW_Locale::GetString('character_class_' . $class_id), $current < sizeof($classes_data) ? ', ' : null); ++$current; } $tooltip_buffer .= '<br />'; } } // Races mask if ($proto->AllowableRace > 0) { $races_data = self::AllowableRaces($proto->AllowableRace); if (is_array($races_data)) { $tooltip_buffer .= sprintf('%s ', WoW_Locale::GetString('template_item_allowable_races')); $current = 1; foreach ($races_data as $race_id => $race) { $tooltip_buffer .= sprintf('<a href="%s/race=%d" class="q1">%s</a>%s', WoW::GetWoWPath(), $race_id, WoW_Locale::GetString('character_race_' . $race_id), $current < sizeof($races_data) ? ', ' : null); ++$current; } $tooltip_buffer .= '<br />'; } } // Required* fields if ($proto->RequiredLevel > 0) { $tooltip_buffer .= sprintf('%s<br />', sprintf(WoW_Locale::GetString('template_item_required_level'), $proto->RequiredLevel)); } if ($proto->ItemLevel > 0) { $tooltip_buffer .= sprintf('%s<br />', sprintf(WoW_Locale::GetString('template_item_itemlevel'), $proto->ItemLevel)); } if ($proto->RequiredSkill > 0) { $skillInfo = DB::World()->selectRow("SELECT `name_%s` AS `name` FROM `DBPREFIX_skills` WHERE `id`=%d", WoW_Locale::GetLocale(), $proto->RequiredSkill); if ($skillInfo) { $tooltip_buffer .= sprintf('%s<br />', sprintf(WoW_Locale::GetString('template_item_required_skill'), WoW::GetWoWPath(), $proto->RequiredSkill, $skillInfo['name'], $proto->RequiredSkillRank)); } } if ($proto->requiredspell > 0) { $spellInfo = DB::World()->selectRow("SELECT `SpellName_%s` AS `name` FROM `DBPREFIX_spell` WHERE `id` = %d", in_array(WoW_Locale::GetLocaleID(), array(LOCALE_EN, LOCALE_RU)) ? WoW_Locale::GetLocale() : 'en', $proto->requiredspell); if ($spellInfo) { $tooltip_buffer .= sprintf('%s<br />', sprintf(WoW_Locale::GetString('template_item_required_spell'), WoW::GetWoWPath(), $proto->requiredspell, $spellInfo['name'])); } } if ($proto->RequiredReputationFaction > 0) { $factionInfo = DB::World()->selectCell("SELECT `name_%s` FROM `DBPREFIX_faction` WHERE `id` = %d", WoW_Locale::GetLocale(), $proto->RequiredReputationFaction); if ($factionInfo) { $tooltip_buffer .= sprintf('%s<br />', sprintf(WoW_Locale::GetString('template_item_required_reputation'), WoW_Locale::GetString('reputation_rank_' . $proto->RequiredReputationRank), WoW::GetWoWPath(), $proto->RequiredReputationFaction, $factionInfo)); } } // Green bonuses $tooltip_buffer .= '</td></tr></table><table><tr><td><!--rr-->'; foreach ($proto->ItemStat as $stat) { if ($stat['type'] < 12) { // Skip white bonuses continue; } $tooltip_buffer .= sprintf('<span class="q2">%s %s<!--rtg%d--> %d <small>(<!--rtg%d-->0.00%% @ L<!--lvl-->%d)</small>.</span><br />', WoW_Locale::GetString('template_item_stats_green'), WoW_Locale::GetString('template_item_stat_' . $stat['type']), $stat['type'], $stat['value'], $stat['type'], MAX_PLAYER_LEVEL); } // Description if ($proto->description != null) { $tooltip_buffer .= sprintf('<span class="q">"%s"</span><br />', $proto->GetDesc()); } if ($proto->SellPrice > 0) { $money = WoW_Utils::GetMoneyFormat($proto->SellPrice); $tooltip_buffer .= sprintf('%s %s%s%s', WoW_Locale::GetString('template_item_sell_price'), $money['gold'] > 0 ? ' <span class="moneygold">' . $money['gold'] . '</span>' : null, $money['silver'] > 0 ? ' <span class="moneysilver">' . $money['silver'] . '</span>' : null, $money['copper'] > 0 ? '<span class="moneycopper">' . $money['copper'] . '</span>' : null); } $tooltip_buffer .= sprintf('</td></tr></table><!--?%d:1:%d:%d-->', $proto->entry, MAX_PLAYER_LEVEL, $proto->RequiredLevel); self::$m_item->tooltip = $tooltip_buffer; unset($proto); return true; }
echo sprintf('<div class="more-results"> <a href="?q=%s&f=wowcharacter" class="more"> Больше результатов по запросу «%s» </a> </div> </div>', WoW_Search::GetSearchQuery(), WoW_Search::GetSearchQuery()); } } if (WoW_Search::GetItemsSearchResultsCount() > 0) { echo sprintf('<div class="result-set"> <h3 class="results-title">%s</h3>', sprintf(WoW_Locale::GetString('template_search_results_wowitem'), WoW_Search::GetSearchQuery())); $items = WoW_Search::GetRightBoxResults('wowitem'); if (is_array($items)) { foreach ($items as $item) { $itemIcon = WoW_Items::GetItemIcon($item['entry'], $item['displayid']); $sellPrice = WoW_Utils::GetMoneyFormat($item['SellPrice']); $classSubClassString = null; switch ($item['class']) { case ITEM_CLASS_ARMOR: case ITEM_CLASS_WEAPON: $classSubClassName = DB::WoW()->selectRow("SELECT `class_name_%s` AS `className`, `subclass_name_%s` AS `subclassName` FROM `DBPREFIX_itemsubclass` WHERE `class` = %d AND `subclass` = %d LIMIT 1", WoW_Locale::GetLocale(), WoW_Locale::GetLocale(), $item['class'], $item['subclass']); if (is_array($classSubClassName)) { $classSubClassString = sprintf('%s (%s)', $classSubClassName['subclassName'], WoW_Locale::GetString('template_item_invtype_' . $item['InventoryType'])); } break; } echo sprintf('<div class="search-result"> <div class="multi-type"> <div class="result-title"> <div class="type-icon type-wowitem border-q%d" style="background-image:url(http://eu.battle.net/wow-assets/static/images/icons/36/%s.jpg)"> <a href="%s/wow/' . WoW_Locale::GetLocale() . '/item/%d" rel="item:%d">
$tmp_locale = WoW_Locale::GetLocale(); } else { $tmp_locale = 'en'; } $spellInfo = WoW_Items::SpellReplace($spell_tmp, WoW_Utils::ValidateSpellText($spell_tmp['Description_' . $tmp_locale])); if ($spellInfo) { echo sprintf('<li class="color-q2">%s</li>', sprintf(WoW_Locale::GetString('template_item_spell_trigger_' . $proto->Spells[$i]['trigger']), $spellInfo)); } } } // Descrition if ($proto->description) { echo sprintf('<li class="color-tooltip-yellow">%s</li>', $proto->description); } if ($proto->SellPrice > 0) { $sell_price = WoW_Utils::GetMoneyFormat($proto->SellPrice); echo sprintf('<li>%s', WoW_Locale::GetString('template_item_sell_price')); $sMoney = array('gold', 'silver', 'copper'); foreach ($sMoney as $money) { if ($sell_price[$money] > 0) { echo sprintf('<span class="icon-%s">%d</span>', $money, $sell_price[$money]); } } echo '</li>'; } if (WoW_Template::GetPageData('tooltip') == true) { $source = WoW_Items::GetItemSource($proto->entry); if ($source) { switch ($source['type']) { case 'sourceType.creatureDrop': break;
<span>0</span> </a> </li> </ul> </div> <span class="clear"><!-- --></span> <ul class="sidebar-list"> <li> <span class="float-right"> <?php $money_won = WoW_Auction::GetWonMoneyAmount(); $money = WoW_Utils::GetMoneyFormat($money_won); ?> <span class="icon-gold"><?php echo $money['gold'] > 0 ? $money['gold'] : '--'; ?> </span> <span class="icon-silver"><?php echo $money['gold'] > 0 ? $money['silver'] : '--'; ?> </span> <span class="icon-copper"><?php echo $money['gold'] > 0 ? $money['copper'] : '--'; ?> </span> </span> <?php
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); }