Пример #1
0
 public function renderTooltip($interactive = false, $subOf = 0, $enhance = [])
 {
     if ($this->error) {
         return;
     }
     $_name = $this->getField('name', true);
     $_reqLvl = $this->curTpl['requiredLevel'];
     $_quality = $this->curTpl['quality'];
     $_flags = $this->curTpl['flags'];
     $_class = $this->curTpl['class'];
     $_subClass = $this->curTpl['subClass'];
     $_slot = $this->curTpl['slot'];
     $causesScaling = false;
     if (!empty($enhance['r'])) {
         if ($this->getRandEnchantForItem($enhance['r'])) {
             $_name .= ' ' . Util::localizedString($this->enhanceR, 'name');
             $randEnchant = '';
             for ($i = 1; $i < 6; $i++) {
                 if ($this->enhanceR['enchantId' . $i] <= 0) {
                     continue;
                 }
                 $enchant = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $this->enhanceR['enchantId' . $i]);
                 if ($this->enhanceR['allocationPct' . $i] > 0) {
                     $amount = intVal($this->enhanceR['allocationPct' . $i] * $this->generateEnchSuffixFactor());
                     $randEnchant .= '<span>' . str_replace('$i', $amount, Util::localizedString($enchant, 'name')) . '</span><br />';
                 } else {
                     $randEnchant .= '<span>' . Util::localizedString($enchant, 'name') . '</span><br />';
                 }
             }
         } else {
             unset($enhance['r']);
         }
     }
     if (isset($enhance['s']) && !in_array($_slot, [INVTYPE_WRISTS, INVTYPE_WAIST, INVTYPE_HANDS])) {
         unset($enhance['s']);
     }
     // IMPORTAT: DO NOT REMOVE THE HTML-COMMENTS! THEY ARE REQUIRED TO UPDATE THE TOOLTIP CLIENTSIDE
     $x = '';
     // upper table: stats
     if (!$subOf) {
         $x .= '<table><tr><td>';
     }
     // name; quality
     if ($subOf) {
         $x .= '<span class="q' . $_quality . '"><a href="?item=' . $this->id . '">' . $_name . '</a></span>';
     } else {
         $x .= '<b class="q' . $_quality . '">' . $_name . '</b>';
     }
     // heroic tag
     if ($_flags & ITEM_FLAG_HEROIC && $_quality == ITEM_QUALITY_EPIC) {
         $x .= '<br /><span class="q2">' . Lang::item('heroic') . '</span>';
     }
     // requires map (todo: reparse ?_zones for non-conflicting data; generate Link to zone)
     if ($_ = $this->curTpl['map']) {
         $map = DB::Aowow()->selectRow('SELECT * FROM ?_zones WHERE mapId = ?d LIMIT 1', $_);
         $x .= '<br /><a href="?zone=' . $_ . '" class="q1">' . Util::localizedString($map, 'name') . '</a>';
     }
     // requires area
     if ($this->curTpl['area']) {
         $area = DB::Aowow()->selectRow('SELECT * FROM ?_zones WHERE Id=?d LIMIT 1', $this->curTpl['area']);
         $x .= '<br />' . Util::localizedString($area, 'name');
     }
     // conjured
     if ($_flags & ITEM_FLAG_CONJURED) {
         $x .= '<br />' . Lang::item('conjured');
     }
     // bonding
     if ($_flags & ITEM_FLAG_ACCOUNTBOUND) {
         $x .= '<br /><!--bo-->' . Lang::item('bonding', 0);
     } else {
         if ($this->curTpl['bonding']) {
             $x .= '<br /><!--bo-->' . Lang::item('bonding', $this->curTpl['bonding']);
         }
     }
     // unique || unique-equipped || unique-limited
     if ($this->curTpl['maxCount'] > 0) {
         $x .= '<br />' . Lang::item('unique');
         if ($this->curTpl['maxCount'] > 1) {
             $x .= ' (' . $this->curTpl['maxCount'] . ')';
         }
     } else {
         if ($_flags & ITEM_FLAG_UNIQUEEQUIPPED) {
             $x .= '<br />' . Lang::item('uniqueEquipped');
         } else {
             if ($this->curTpl['itemLimitCategory']) {
                 $limit = DB::Aowow()->selectRow("SELECT * FROM ?_itemlimitcategory WHERE id = ?", $this->curTpl['itemLimitCategory']);
                 $x .= '<br />' . ($limit['isGem'] ? Lang::item('uniqueEquipped') : Lang::item('unique')) . Lang::main('colon') . Util::localizedString($limit, 'name') . ' (' . $limit['count'] . ')';
             }
         }
     }
     // max duration
     if ($dur = $this->curTpl['duration']) {
         $x .= "<br />" . Lang::game('duration') . Lang::main('colon') . Util::formatTime(abs($dur) * 1000) . ($this->curTpl['flagsCustom'] & 0x1 ? ' (' . Lang::item('realTime') . ')' : null);
     }
     // required holiday
     if ($eId = $this->curTpl['eventId']) {
         if ($hName = DB::Aowow()->selectRow('SELECT h.* FROM ?_holidays h JOIN ?_events e ON e.holidayId = h.id WHERE e.id = ?d', $eId)) {
             $x .= '<br />' . sprintf(Lang::game('requires'), '<a href="' . $eId . '" class="q1">' . Util::localizedString($hName, 'name') . '</a>');
         }
     }
     // item begins a quest
     if ($this->curTpl['startQuest']) {
         $x .= '<br /><a class="q1" href="?quest=' . $this->curTpl['startQuest'] . '">' . Lang::item('startQuest') . '</a>';
     }
     // containerType (slotCount)
     if ($this->curTpl['slots'] > 0) {
         $fam = $this->curTpl['bagFamily'] ? log($this->curTpl['bagFamily'], 2) + 1 : 0;
         // word order differs <_<
         if (in_array(User::$localeId, [LOCALE_FR, LOCALE_ES, LOCALE_RU])) {
             $x .= '<br />' . sprintf(Lang::item('bagSlotString'), Lang::item('bagFamily', $fam), $this->curTpl['slots']);
         } else {
             $x .= '<br />' . sprintf(Lang::item('bagSlotString'), $this->curTpl['slots'], Lang::item('bagFamily', $fam));
         }
     }
     if (in_array($_class, [ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, ITEM_CLASS_AMMUNITION])) {
         $x .= '<table width="100%"><tr>';
         // Class
         if ($_slot) {
             $x .= '<td>' . Lang::item('inventoryType', $_slot) . '</td>';
         }
         // Subclass
         if ($_class == ITEM_CLASS_ARMOR && $_subClass > 0) {
             $x .= '<th><!--asc' . $_subClass . '-->' . Lang::item('armorSubClass', $_subClass) . '</th>';
         } else {
             if ($_class == ITEM_CLASS_WEAPON) {
                 $x .= '<th>' . Lang::item('weaponSubClass', $_subClass) . '</th>';
             } else {
                 if ($_class == ITEM_CLASS_AMMUNITION) {
                     $x .= '<th>' . Lang::item('projectileSubClass', $_subClass) . '</th>';
                 }
             }
         }
         $x .= '</tr></table>';
     } else {
         if ($_slot && $_class != ITEM_CLASS_CONTAINER) {
             // yes, slot can occur on random items and is then also displayed <_< .. excluding Bags >_>
             $x .= '<br />' . Lang::item('inventoryType', $_slot) . '<br />';
         } else {
             $x .= '<br />';
         }
     }
     // Weapon/Ammunition Stats                          (not limited to weapons (see item:1700))
     $speed = $this->curTpl['delay'] / 1000;
     $dmgmin1 = $this->curTpl['dmgMin1'] + $this->curTpl['dmgMin2'];
     $dmgmax1 = $this->curTpl['dmgMax1'] + $this->curTpl['dmgMax2'];
     $dps = $speed ? ($dmgmin1 + $dmgmax1) / (2 * $speed) : 0;
     if ($_class == ITEM_CLASS_AMMUNITION && $dmgmin1 && $dmgmax1) {
         $x .= Lang::item('addsDps') . ' ' . number_format(($dmgmin1 + $dmgmax1) / 2, 1) . ' ' . Lang::item('dps2') . '<br />';
     } else {
         if ($dps) {
             if ($_class == ITEM_CLASS_WEAPON) {
                 $x .= '<table width="100%"><tr>';
                 $x .= '<td><!--dmg-->' . sprintf($this->curTpl['dmgType1'] ? Lang::item('damageMagic') : Lang::item('damagePhys'), $this->curTpl['dmgMin1'] . ' - ' . $this->curTpl['dmgMax1'], Lang::game('sc', $this->curTpl['dmgType1'])) . '</td>';
                 $x .= '<th>' . Lang::item('speed') . ' <!--spd-->' . number_format($speed, 2) . '</th>';
                 // do not use localized format here!
                 $x .= '</tr></table>';
             } else {
                 $x .= '<!--dmg-->' . sprintf($this->curTpl['dmgType1'] ? Lang::item('damageMagic') : Lang::item('damagePhys'), $this->curTpl['dmgMin1'] . ' - ' . $this->curTpl['dmgMax1'], Lang::game('sc', $this->curTpl['dmgType1'])) . '<br />';
             }
             // secondary damage is set
             if ($this->curTpl['dmgMin2']) {
                 $x .= '+' . sprintf($this->curTpl['dmgType2'] ? Lang::item('damageMagic') : Lang::item('damagePhys'), $this->curTpl['dmgMin2'] . ' - ' . $this->curTpl['dmgMax2'], Lang::game('sc', $this->curTpl['dmgType2'])) . '<br />';
             }
             if ($_class == ITEM_CLASS_WEAPON) {
                 $x .= '<!--dps-->(' . number_format($dps, 1) . ' ' . Lang::item('dps') . ')<br />';
             }
             // do not use localized format here!
             // display FeralAttackPower if set
             if ($fap = $this->getFeralAP()) {
                 $x .= '<span class="c11"><!--fap-->(' . $fap . ' ' . Lang::item('fap') . ')</span><br />';
             }
         }
     }
     // Armor
     if ($_class == ITEM_CLASS_ARMOR && $this->curTpl['armorDamageModifier'] > 0) {
         $spanI = 'class="q2"';
         if ($interactive) {
             $spanI = 'class="q2 tip" onmouseover="$WH.Tooltip.showAtCursor(event, $WH.sprintf(LANG.tooltip_armorbonus, ' . $this->curTpl['armorDamageModifier'] . '), 0, 0, \'q\')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"';
         }
         $x .= '<span ' . $spanI . '><!--addamr' . $this->curTpl['armorDamageModifier'] . '--><span>' . sprintf(Lang::item('armor'), intVal($this->curTpl['armor'] + $this->curTpl['armorDamageModifier'])) . '</span></span><br />';
     } else {
         if ($this->curTpl['armor'] + $this->curTpl['armorDamageModifier'] > 0) {
             $x .= '<span><!--amr-->' . sprintf(Lang::item('armor'), intVal($this->curTpl['armor'] + $this->curTpl['armorDamageModifier'])) . '</span><br />';
         }
     }
     // Block
     if ($this->curTpl['block']) {
         $x .= '<span>' . sprintf(Lang::item('block'), $this->curTpl['block']) . '</span><br />';
     }
     // Item is a gem (don't mix with sockets)
     if ($geId = $this->curTpl['gemEnchantmentId']) {
         $gemEnch = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE id = ?d', $geId);
         $x .= '<span class="q1"><a href="?enchantment=' . $geId . '">' . Util::localizedString($gemEnch, 'name') . '</a></span><br />';
         // activation conditions for meta gems
         if (!empty($gemEnch['conditionId'])) {
             if ($gemCnd = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantmentcondition WHERE id = ?d', $gemEnch['conditionId'])) {
                 for ($i = 1; $i < 6; $i++) {
                     if (!$gemCnd['color' . $i]) {
                         continue;
                     }
                     switch ($gemCnd['comparator' . $i]) {
                         case 2:
                             // requires less <color> than (<value> || <comparecolor>) gems
                         // requires less <color> than (<value> || <comparecolor>) gems
                         case 5:
                             // requires at least <color> than (<value> || <comparecolor>) gems
                             $sp = (int) $gemCnd['value' . $i] > 1;
                             $x .= '<span class="q0">' . Lang::achievement('reqNumCrt') . ' ' . sprintf(Lang::item('gemConditions', $gemCnd['comparator' . $i], $sp), $gemCnd['value' . $i], Lang::item('gemColors', $gemCnd['color' . $i] - 1)) . '</span><br />';
                             break;
                         case 3:
                             // requires more <color> than (<value> || <comparecolor>) gems
                             $x .= '<span class="q0">' . Lang::achievement('reqNumCrt') . ' ' . sprintf(Lang::item('gemConditions', 3), Lang::item('gemColors', $gemCnd['color' . $i] - 1), Lang::item('gemColors', $gemCnd['cmpColor' . $i] - 1)) . '</span><br />';
                             break;
                     }
                 }
             }
         }
     }
     // Random Enchantment - if random enchantment is set, prepend stats from it
     if ($this->curTpl['randomEnchant'] && !isset($enhance['r'])) {
         $x .= '<span class="q2">' . Lang::item('randEnchant') . '</span><br />';
     } else {
         if (isset($enhance['r'])) {
             $x .= $randEnchant;
         }
     }
     // itemMods (display stats and save ratings for later use)
     for ($j = 1; $j <= 10; $j++) {
         $type = $this->curTpl['statType' . $j];
         $qty = $this->curTpl['statValue' . $j];
         if (!$qty || $type <= 0) {
             continue;
         }
         // base stat
         if ($type >= ITEM_MOD_AGILITY && $type <= ITEM_MOD_STAMINA) {
             $x .= '<span><!--stat' . $type . '-->' . ($qty > 0 ? '+' : '-') . abs($qty) . ' ' . Lang::item('statType', $type) . '</span><br />';
         } else {
             // rating with % for reqLevel
             $green[] = $this->parseRating($type, $qty, $interactive, $causesScaling);
         }
     }
     // magic resistances
     foreach (Util::$resistanceFields as $j => $rowName) {
         if ($rowName && $this->curTpl[$rowName] != 0) {
             $x .= '+' . $this->curTpl[$rowName] . ' ' . Lang::game('resistances', $j) . '<br />';
         }
     }
     // Enchantment
     if (isset($enhance['e'])) {
         if ($enchText = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?', $enhance['e'])) {
             $x .= '<span class="q2"><!--e-->' . Util::localizedString($enchText, 'name') . '</span><br />';
         } else {
             unset($enhance['e']);
             $x .= '<!--e-->';
         }
     } else {
         // enchantment placeholder
         $x .= '<!--e-->';
     }
     // Sockets w/ Gems
     if (!empty($enhance['g'])) {
         $gems = DB::Aowow()->select('
             SELECT it.id AS ARRAY_KEY, ic.iconString, ae.*, it.gemColorMask AS colorMask
             FROM   ?_items it
             JOIN   ?_itemenchantment ae ON ae.id = it.gemEnchantmentId
             JOIN   ?_icons ic ON ic.id = -it.displayId
             WHERE  it.id IN (?a)', $enhance['g']);
         foreach ($enhance['g'] as $k => $v) {
             if ($v && !in_array($v, array_keys($gems))) {
                 // 0 is valid
                 unset($enhance['g'][$k]);
             }
         }
     } else {
         $enhance['g'] = [];
     }
     // zero fill empty sockets
     $sockCount = isset($enhance['s']) ? 1 : 0;
     if (!empty($this->json[$this->id]['nsockets'])) {
         $sockCount += $this->json[$this->id]['nsockets'];
     }
     while ($sockCount > count($enhance['g'])) {
         $enhance['g'][] = 0;
     }
     $enhance['g'] = array_reverse($enhance['g']);
     $hasMatch = 1;
     // fill native sockets
     for ($j = 1; $j <= 3; $j++) {
         if (!$this->curTpl['socketColor' . $j]) {
             continue;
         }
         for ($i = 0; $i < 4; $i++) {
             if ($this->curTpl['socketColor' . $j] & 1 << $i) {
                 $colorId = $i;
             }
         }
         $pop = array_pop($enhance['g']);
         $col = $pop ? 1 : 0;
         $hasMatch &= $pop ? $gems[$pop]['colorMask'] & 1 << $colorId ? 1 : 0 : 0;
         $icon = $pop ? sprintf(Util::$bgImagePath['tiny'], STATIC_URL, strtolower($gems[$pop]['iconString'])) : null;
         $text = $pop ? Util::localizedString($gems[$pop], 'name') : Lang::item('socket', $colorId);
         if ($interactive) {
             $x .= '<a href="?items=3&amp;filter=cr=81;crs=' . ($colorId + 1) . ';crv=0" class="socket-' . Util::$sockets[$colorId] . ' q' . $col . '" ' . $icon . '>' . $text . '</a><br />';
         } else {
             $x .= '<span class="socket-' . Util::$sockets[$colorId] . ' q' . $col . '" ' . $icon . '>' . $text . '</span><br />';
         }
     }
     // fill extra socket
     if (isset($enhance['s'])) {
         $pop = array_pop($enhance['g']);
         $col = $pop ? 1 : 0;
         $icon = $pop ? sprintf(Util::$bgImagePath['tiny'], STATIC_URL, strtolower($gems[$pop]['iconString'])) : null;
         $text = $pop ? Util::localizedString($gems[$pop], 'name') : Lang::item('socket', -1);
         if ($interactive) {
             $x .= '<a href="?items=3&amp;filter=cr=81;crs=5;crv=0" class="socket-prismatic q' . $col . '" ' . $icon . '>' . $text . '</a><br />';
         } else {
             $x .= '<span class="socket-prismatic q' . $col . '" ' . $icon . '>' . $text . '</span><br />';
         }
     } else {
         // prismatic socket placeholder
         $x .= '<!--ps-->';
     }
     if ($_ = $this->curTpl['socketBonus']) {
         $sbonus = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $_);
         $x .= '<span class="q' . ($hasMatch ? '2' : '0') . '">' . Lang::item('socketBonus') . Lang::main('colon') . '<a href="?enchantment=' . $_ . '">' . Util::localizedString($sbonus, 'name') . '</a></span><br />';
     }
     // durability
     if ($dur = $this->curTpl['durability']) {
         $x .= Lang::item('durability') . ' ' . $dur . ' / ' . $dur . '<br />';
     }
     // required classes
     if ($classes = Lang::getClassString($this->curTpl['requiredClass'], $jsg, $__)) {
         foreach ($jsg as $js) {
             if (empty($this->jsGlobals[TYPE_CLASS][$js])) {
                 $this->jsGlobals[TYPE_CLASS][$js] = $js;
             }
         }
         $x .= Lang::game('classes') . Lang::main('colon') . $classes . '<br />';
     }
     // required races
     if ($races = Lang::getRaceString($this->curTpl['requiredRace'], $__, $jsg, $__)) {
         foreach ($jsg as $js) {
             if (empty($this->jsGlobals[TYPE_RACE][$js])) {
                 $this->jsGlobals[TYPE_RACE][$js] = $js;
             }
         }
         if ($races != Lang::game('ra', 0)) {
             // not "both", but display combinations like: troll, dwarf
             $x .= Lang::game('races') . Lang::main('colon') . $races . '<br />';
         }
     }
     // required honorRank (not used anymore)
     if ($rhr = $this->curTpl['requiredHonorRank']) {
         $x .= sprintf(Lang::game('requires'), Lang::game('pvpRank', $rhr)) . '<br />';
     }
     // required CityRank..?
     // what the f..
     // required level
     if ($_flags & ITEM_FLAG_ACCOUNTBOUND && $_quality == ITEM_QUALITY_HEIRLOOM) {
         $x .= sprintf(Lang::game('reqLevelHlm'), ' 1' . Lang::game('valueDelim') . MAX_LEVEL . ' (' . ($interactive ? sprintf(Util::$changeLevelString, MAX_LEVEL) : '<!--lvl-->' . MAX_LEVEL) . ')') . '<br />';
     } else {
         if ($_reqLvl > 1) {
             $x .= sprintf(Lang::game('reqLevel'), $_reqLvl) . '<br />';
         }
     }
     // required arena team rating / personal rating / todo (low): sort out what kind of rating
     if (!empty($this->getExtendedCost([], $reqRating)[$this->id]) && $reqRating) {
         $x .= sprintf(Lang::item('reqRating', $reqRating[1]), $reqRating[0]) . '<br />';
     }
     // item level
     if (in_array($_class, [ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON])) {
         $x .= Lang::item('itemLevel') . ' ' . $this->curTpl['itemLevel'] . '<br />';
     }
     // required skill
     if ($reqSkill = $this->curTpl['requiredSkill']) {
         $_ = '<a class="q1" href="?skill=' . $reqSkill . '">' . SkillList::getName($reqSkill) . '</a>';
         if ($this->curTpl['requiredSkillRank'] > 0) {
             $_ .= ' (' . $this->curTpl['requiredSkillRank'] . ')';
         }
         $x .= sprintf(Lang::game('requires'), $_) . '<br />';
     }
     // required spell
     if ($reqSpell = $this->curTpl['requiredSpell']) {
         $x .= Lang::game('requires2') . ' <a class="q1" href="?spell=' . $reqSpell . '">' . SpellList::getName($reqSpell) . '</a><br />';
     }
     // required reputation w/ faction
     if ($reqFac = $this->curTpl['requiredFaction']) {
         $x .= sprintf(Lang::game('requires'), '<a class="q1" href=?faction="' . $reqFac . '">' . FactionList::getName($reqFac) . '</a> - ' . Lang::game('rep', $this->curTpl['requiredFactionRank'])) . '<br />';
     }
     // locked or openable
     if ($locks = Lang::getLocks($this->curTpl['lockId'], true)) {
         $x .= '<span class="q0">' . Lang::item('locked') . '<br />' . implode('<br />', $locks) . '</span><br />';
     } else {
         if ($this->curTpl['flags'] & ITEM_FLAG_OPENABLE) {
             $x .= '<span class="q2">' . Lang::item('openClick') . '</span><br />';
         }
     }
     // upper table: done
     if (!$subOf) {
         $x .= '</td></tr></table>';
     }
     // spells on item
     if (!$this->canTeachSpell()) {
         $itemSpellsAndTrigger = [];
         for ($j = 1; $j <= 5; $j++) {
             if ($this->curTpl['spellId' . $j] > 0) {
                 $cd = $this->curTpl['spellCooldown' . $j];
                 if ($cd < $this->curTpl['spellCategoryCooldown' . $j]) {
                     $cd = $this->curTpl['spellCategoryCooldown' . $j];
                 }
                 $cd = $cd < 5000 ? null : ' (' . sprintf(Lang::game('cooldown'), Util::formatTime($cd)) . ')';
                 $itemSpellsAndTrigger[$this->curTpl['spellId' . $j]] = [$this->curTpl['spellTrigger' . $j], $cd];
             }
         }
         if ($itemSpellsAndTrigger) {
             $cooldown = '';
             $itemSpells = new SpellList(array(['s.id', array_keys($itemSpellsAndTrigger)]));
             foreach ($itemSpells->iterate() as $__) {
                 if ($parsed = $itemSpells->parseText('description', $_reqLvl > 1 ? $_reqLvl : MAX_LEVEL, false, $causesScaling)[0]) {
                     if ($interactive) {
                         $link = '<a href="?spell=' . $itemSpells->id . '">%s</a>';
                         $parsed = preg_replace_callback('/([^;]*)(&nbsp;<small>.*?<\\/small>)([^&]*)/i', function ($m) use($link) {
                             $m[1] = $m[1] ? sprintf($link, $m[1]) : '';
                             $m[3] = $m[3] ? sprintf($link, $m[3]) : '';
                             return $m[1] . $m[2] . $m[3];
                         }, $parsed, -1, $nMatches);
                         if (!$nMatches) {
                             $parsed = sprintf($link, $parsed);
                         }
                     }
                     $green[] = Lang::item('trigger', $itemSpellsAndTrigger[$itemSpells->id][0]) . $parsed . $itemSpellsAndTrigger[$itemSpells->id][1];
                 }
             }
         }
     }
     // lower table (ratings, spells, ect)
     if (!$subOf) {
         $x .= '<table><tr><td>';
     }
     if (isset($green)) {
         foreach ($green as $j => $bonus) {
             if ($bonus) {
                 $x .= '<span class="q2">' . $bonus . '</span><br />';
             }
         }
     }
     // Item Set
     $pieces = [];
     if ($setId = $this->getField('itemset')) {
         // while Ids can technically be used multiple times the only difference in data are the items used. So it doesn't matter what we get
         $itemset = new ItemsetList(array(['id', $setId]));
         if (!$itemset->error && $itemset->pieceToSet) {
             $pieces = DB::Aowow()->select('
                 SELECT b.id AS ARRAY_KEY, b.name_loc0, b.name_loc2, b.name_loc3, b.name_loc6, b.name_loc8, GROUP_CONCAT(a.id SEPARATOR \':\') AS equiv
                 FROM   ?_items a, ?_items b
                 WHERE  a.slotBak = b.slotBak AND a.itemset = b.itemset AND b.id IN (?a)
                 GROUP BY b.id;', array_keys($itemset->pieceToSet));
             foreach ($pieces as $k => &$p) {
                 $p = '<span><!--si' . $p['equiv'] . '--><a href="?item=' . $k . '">' . Util::localizedString($p, 'name') . '</a></span>';
             }
             $xSet = '<br /><span class="q"><a href="?itemset=' . $itemset->id . '" class="q">' . $itemset->getField('name', true) . '</a> (0/' . count($pieces) . ')</span>';
             if ($skId = $itemset->getField('skillId')) {
                 $xSet .= '<br />' . sprintf(Lang::game('requires'), '<a href="?skills=' . $skId . '" class="q1">' . SkillList::getName($skId) . '</a>');
                 if ($_ = $itemset->getField('skillLevel')) {
                     $xSet .= ' (' . $_ . ')';
                 }
                 $xSet .= '<br />';
             }
             // list pieces
             $xSet .= '<div class="q0 indent">' . implode('<br />', $pieces) . '</div><br />';
             // get bonuses
             $setSpellsAndIdx = [];
             for ($j = 1; $j <= 8; $j++) {
                 if ($_ = $itemset->getField('spell' . $j)) {
                     $setSpellsAndIdx[$_] = $j;
                 }
             }
             $setSpells = [];
             if ($setSpellsAndIdx) {
                 $boni = new SpellList(array(['s.id', array_keys($setSpellsAndIdx)]));
                 foreach ($boni->iterate() as $__) {
                     $setSpells[] = array('tooltip' => $boni->parseText('description', $_reqLvl > 1 ? $_reqLvl : MAX_LEVEL, false, $causesScaling)[0], 'entry' => $itemset->getField('spell' . $setSpellsAndIdx[$boni->id]), 'bonus' => $itemset->getField('bonus' . $setSpellsAndIdx[$boni->id]));
                 }
             }
             // sort and list bonuses
             $xSet .= '<span class="q0">';
             for ($i = 0; $i < count($setSpells); $i++) {
                 for ($j = $i; $j < count($setSpells); $j++) {
                     if ($setSpells[$j]['bonus'] >= $setSpells[$i]['bonus']) {
                         continue;
                     }
                     $tmp = $setSpells[$i];
                     $setSpells[$i] = $setSpells[$j];
                     $setSpells[$j] = $tmp;
                 }
                 $xSet .= '<span>(' . $setSpells[$i]['bonus'] . ') ' . Lang::item('set') . ': <a href="?spell=' . $setSpells[$i]['entry'] . '">' . $setSpells[$i]['tooltip'] . '</a></span>';
                 if ($i < count($setSpells) - 1) {
                     $xSet .= '<br />';
                 }
             }
             $xSet .= '</span>';
         }
     }
     // recipes, vanity pets, mounts
     if ($this->canTeachSpell()) {
         $craftSpell = new SpellList(array(['s.id', intVal($this->curTpl['spellId2'])]));
         if (!$craftSpell->error) {
             $xCraft = '';
             if ($desc = $this->getField('description', true)) {
                 $x .= '<span class="q2">' . Lang::item('trigger', 0) . ' <a href="?spell=' . $this->curTpl['spellId2'] . '">' . $desc . '</a></span><br />';
             }
             // recipe handling (some stray Techniques have subclass == 0), place at bottom of tooltipp
             if ($_class == ITEM_CLASS_RECIPE || $this->curTpl['bagFamily'] == 16) {
                 $craftItem = new ItemList(array(['i.id', (int) $craftSpell->curTpl['effect1CreateItemId']]));
                 if (!$craftItem->error) {
                     if ($itemTT = $craftItem->renderTooltip($interactive, $this->id)) {
                         $xCraft .= '<div><br />' . $itemTT . '</div>';
                     }
                     $reagentItems = [];
                     for ($i = 1; $i <= 8; $i++) {
                         if ($rId = $craftSpell->getField('reagent' . $i)) {
                             $reagentItems[$rId] = $craftSpell->getField('reagentCount' . $i);
                         }
                     }
                     if (isset($xCraft) && $reagentItems) {
                         $reagents = new ItemList(array(['i.id', array_keys($reagentItems)]));
                         $reqReag = [];
                         foreach ($reagents->iterate() as $__) {
                             $reqReag[] = '<a href="?item=' . $reagents->id . '">' . $reagents->getField('name', true) . '</a> (' . $reagentItems[$reagents->id] . ')';
                         }
                         $xCraft .= '<div class="q1 whtt-reagents"><br />' . Lang::game('requires2') . ' ' . implode(', ', $reqReag) . '</div>';
                     }
                 }
             }
         }
     }
     // misc (no idea, how to organize the <br /> better)
     $xMisc = [];
     // itemset: pieces and boni
     if (isset($xSet)) {
         $xMisc[] = $xSet;
     }
     // funny, yellow text at the bottom, omit if we have a recipe
     if ($this->curTpl['description_loc0'] && !$this->canTeachSpell()) {
         $xMisc[] = '<span class="q">"' . $this->getField('description', true) . '"</span>';
     }
     // readable
     if ($this->curTpl['pageTextId']) {
         $xMisc[] = '<span class="q2">' . Lang::item('readClick') . '</span>';
     }
     // charges (i guess checking first spell is enough (single charges not shown))
     if ($this->curTpl['spellCharges1'] > 1 || $this->curTpl['spellCharges1'] < -1) {
         $xMisc[] = '<span class="q1">' . abs($this->curTpl['spellCharges1']) . ' ' . Lang::item('charges') . '</span>';
     }
     // list required reagents
     if (isset($xCraft)) {
         $xMisc[] = $xCraft;
     }
     if ($xMisc) {
         $x .= implode('<br />', $xMisc);
     }
     if ($sp = $this->curTpl['sellPrice']) {
         $x .= '<div class="q1 whtt-sellprice">' . Lang::item('sellPrice') . Lang::main('colon') . Util::formatMoney($sp) . '</div>';
     }
     if (!$subOf) {
         $x .= '</td></tr></table>';
     }
     // tooltip scaling
     if (!isset($xCraft)) {
         $link = [$subOf ? $subOf : $this->id, 1];
         // itemId, scaleMinLevel
         if (isset($this->ssd[$this->id])) {
             array_push($link, $this->ssd[$this->id]['maxLevel'], $this->ssd[$this->id]['maxLevel'], $this->curTpl['scalingStatDistribution'], $this->curTpl['scalingStatValue']);
         } else {
             array_push($link, $causesScaling ? MAX_LEVEL : 1, $_reqLvl > 1 ? $_reqLvl : MAX_LEVEL);
         }
         $x .= '<!--?' . implode(':', $link) . '-->';
     }
     return $x;
 }
Пример #2
0
 private function createMail(&$attachmentTab, $startEnd)
 {
     $mail = [];
     if ($_ = $this->subject->getField('rewardMailTemplateId')) {
         $delay = $this->subject->getField('rewardMailDelay');
         $letter = DB::Aowow()->selectRow('SELECT * FROM ?_mailtemplate WHERE id = ?d', $_);
         $mail = array('delay' => $delay ? sprintf(Lang::quest('mailIn'), Util::formatTime($delay * 1000)) : null, 'sender' => null, 'text' => $letter ? Util::parseHtmlText(Util::localizedString($letter, 'text')) : null, 'subject' => Util::parseHtmlText(Util::localizedString($letter, 'subject')));
         foreach ($startEnd as $se) {
             if (!($se['method'] & 0x2) || $se['type'] != TYPE_NPC) {
                 continue;
             }
             if ($_ = CreatureList::getName($se['typeId'])) {
                 $mail['sender'] = sprintf(Lang::quest('mailBy'), $se['typeId'], $_);
                 break;
             }
         }
         $extraCols = ['Listview.extraCols.percent'];
         $mailLoot = new Loot();
         if ($mailLoot->getByContainer(LOOT_MAIL, $_)) {
             $this->extendGlobalData($mailLoot->jsGlobals);
             $attachmentTab = array('file' => 'item', 'data' => $mailLoot->getResult(), 'params' => array('name' => '[Mail Attachments]', 'id' => 'mail-attachments', 'extraCols' => "\$[" . implode(', ', array_merge($extraCols, $mailLoot->extraCols)) . "]", 'hiddenCols' => "\$['side', 'slot', 'reqlevel']"));
         }
     }
     return $mail;
 }
Пример #3
0
 private function createEffects(&$infobox, &$redButtons)
 {
     // proc data .. maybe use more information..?
     $procData = DB::World()->selectRow('SELECT IF(ppmRate > 0, -ppmRate, customChance) AS chance, cooldown FROM spell_proc_event WHERE entry = ?d', $this->typeId);
     if (!isset($procData['cooldown'])) {
         $procData['cooldown'] = 0;
     }
     $effects = [];
     $spellIdx = array_unique(array_merge($this->subject->canTriggerSpell(), $this->subject->canTeachSpell()));
     $itemIdx = $this->subject->canCreateItem();
     // Iterate through all effects:
     for ($i = 1; $i < 4; $i++) {
         if ($this->subject->getField('effect' . $i . 'Id') <= 0) {
             continue;
         }
         $effId = (int) $this->subject->getField('effect' . $i . 'Id');
         $effMV = (int) $this->subject->getField('effect' . $i . 'MiscValue');
         $effBP = (int) $this->subject->getField('effect' . $i . 'BasePoints');
         $effDS = (int) $this->subject->getField('effect' . $i . 'DieSides');
         $effRPPL = $this->subject->getField('effect' . $i . 'RealPointsPerLevel');
         $effAura = (int) $this->subject->getField('effect' . $i . 'AuraId');
         $foo =& $effects[];
         // Icons:
         // .. from item
         if (in_array($i, $itemIdx)) {
             $_ = $this->subject->getField('effect' . $i . 'CreateItemId');
             foreach ($this->subject->relItems->iterate() as $itemId => $__) {
                 if ($itemId != $_) {
                     continue;
                 }
                 $foo['icon'] = array('id' => $this->subject->relItems->id, 'name' => $this->subject->relItems->getField('name', true), 'quality' => $this->subject->relItems->getField('quality'), 'count' => $effDS + $effBP, 'icon' => $this->subject->relItems->getField('iconString'));
                 break;
             }
             if ($effDS > 1) {
                 $foo['icon']['count'] = "'" . ($effBP + 1) . '-' . $foo['icon']['count'] . "'";
             }
         } else {
             if (in_array($i, $spellIdx) || $effId == 133) {
                 $_ = $this->subject->getField('effect' . $i . 'TriggerSpell');
                 if (!$_) {
                     $_ = $this->subject->getField('effect' . $i . 'MiscValue');
                 }
                 $trig = new SpellList(array(['s.id', (int) $_]));
                 $foo['icon'] = array('id' => $_, 'name' => $trig->error ? Util::ucFirst(Lang::game('spell')) . ' #' . $_ : $trig->getField('name', true), 'count' => 0);
                 $this->extendGlobalData($trig->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             }
         }
         // Effect Name
         $foo['name'] = (User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'EffectId: ' . $effId, Util::$spellEffectStrings[$effId]) : Util::$spellEffectStrings[$effId]) . Lang::main('colon');
         if ($this->subject->getField('effect' . $i . 'RadiusMax') > 0) {
             $foo['radius'] = $this->subject->getField('effect' . $i . 'RadiusMax');
         }
         if (!in_array($i, $itemIdx) && !in_array($i, $spellIdx) && !in_array($effAura, [225, 227])) {
             $foo['value'] = ($effDS && $effDS != 1 ? $effBP + 1 . Lang::game('valueDelim') : null) . ($effBP + $effDS);
         }
         if ($effRPPL != 0) {
             $foo['value'] = (isset($foo['value']) ? $foo['value'] : '0') . sprintf(Lang::spell('costPerLevel'), $effRPPL);
         }
         if ($this->subject->getField('effect' . $i . 'Periode') > 0) {
             $foo['interval'] = Util::formatTime($this->subject->getField('effect' . $i . 'Periode'));
         }
         if ($_ = $this->subject->getField('effect' . $i . 'Mechanic')) {
             $foo['mechanic'] = Lang::game('me', $_);
         }
         if (!empty($procData['chance'])) {
             $foo['procData'] = array($procData['chance'], $procData['cooldown'] ? Util::formatTime($procData['cooldown'] * 1000, true) : null);
         } else {
             if (in_array($i, $this->subject->canTriggerSpell()) && $this->subject->getField('procChance')) {
                 $foo['procData'] = array($this->subject->getField('procChance'), $procData['cooldown'] ? Util::formatTime($procData['cooldown'] * 1000, true) : null);
             }
         }
         // parse masks and indizes
         switch ($effId) {
             case 8:
                 // Power Drain
             // Power Drain
             case 30:
                 // Energize
             // Energize
             case 137:
                 // Energize Pct
                 $_ = Lang::spell('powerTypes', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 if ($effMV == POWER_RAGE || $effMV == POWER_RUNIC_POWER) {
                     $foo['value'] = ($effDS && $effDS != 1 ? ($effBP + 1) / 10 . Lang::game('valueDelim') : null) . ($effBP + $effDS) / 10;
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 16:
                 // QuestComplete
                 if ($_ = QuestList::getName($effMV)) {
                     $foo['name'] .= '(<a href="?quest=' . $effMV . '">' . $_ . '</a>)';
                 } else {
                     $foo['name'] .= Util::ucFirst(Lang::game('quest')) . ' #' . $effMV;
                 }
                 break;
             case 28:
                 // Summon
             // Summon
             case 90:
                 // Kill Credit
             // Kill Credit
             case 134:
                 // Kill Credit2
                 $_ = Lang::game('npc') . ' #' . $effMV;
                 if ($summon = $this->subject->getModelInfo($this->typeId, $i)) {
                     $_ = $summon['typeId'] ? ' (<a href="?npc=' . $summon['typeId'] . '">' . $summon['displayName'] . '</a>)' : ' (#0)';
                     $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $summon['displayId']];
                 }
                 $foo['name'] .= $_;
                 break;
             case 33:
                 // Open Lock
                 $_ = $effMV ? Lang::spell('lockType', $effMV) : $effMV;
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 53:
                 // Enchant Item Perm
             // Enchant Item Perm
             case 54:
                 // Enchant Item Temp
             // Enchant Item Temp
             case 92:
                 // Enchant Held Item
             // Enchant Held Item
             case 156:
                 // Enchant Item Prismatic
                 if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE id = ?d', $effMV)) {
                     $foo['name'] .= ' (<a href="?enchantment=' . $effMV . '" class="q2">' . Util::localizedString($_, 'name') . '</a>)';
                 } else {
                     $foo['name'] .= ' #' . $effMV;
                 }
                 break;
             case 38:
                 // Dispel [miscValue => Types]
             // Dispel [miscValue => Types]
             case 126:
                 // Steal Aura
                 $_ = Lang::game('dt', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 39:
                 // Learn Language
                 $_ = Lang::game('languages', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 50:
                 // Trans Door
             // Trans Door
             case 76:
                 // Summon Object (Wild)
                 // case 86:                                 // Activate Object
             // Summon Object (Wild)
             // case 86:                                 // Activate Object
             case 104:
                 // Summon Object (slot 1)
             // Summon Object (slot 1)
             case 105:
                 // Summon Object (slot 2)
             // Summon Object (slot 2)
             case 106:
                 // Summon Object (slot 3)
             // Summon Object (slot 3)
             case 107:
                 // Summon Object (slot 4)
                 $_ = Util::ucFirst(Lang::game('object')) . ' #' . $effMV;
                 if ($summon = $this->subject->getModelInfo($this->typeId, $i)) {
                     $_ = $summon['typeId'] ? ' (<a href="?object=' . $summon['typeId'] . '">' . $summon['displayName'] . '</a>)' : ' (#0)';
                     $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_OBJECT, 'displayId' => $summon['displayId']];
                 }
                 $foo['name'] .= $_;
                 break;
             case 74:
                 // Apply Glyph
                 if ($_ = DB::Aowow()->selectCell('SELECT spellId FROM ?_glyphproperties WHERE id = ?d', $effMV)) {
                     if ($n = SpellList::getName($_)) {
                         $foo['name'] .= '(<a href="?spell=' . $_ . '">' . $n . '</a>)';
                     } else {
                         $foo['name'] .= Util::ucFirst(Lang::game('spell')) . ' #' . $effMV;
                     }
                 } else {
                     $foo['name'] .= ' #' . $effMV;
                 }
                 break;
             case 95:
                 // Skinning
                 switch ($effMV) {
                     case 0:
                         $_ = Lang::game('ct', 1) . ', ' . Lang::game('ct', 2);
                         break;
                         // Beast, Dragonkin
                     // Beast, Dragonkin
                     case 1:
                     case 2:
                         $_ = Lang::game('ct', 4);
                         break;
                         // Elemental (nature based, earth based)
                     // Elemental (nature based, earth based)
                     case 3:
                         $_ = Lang::game('ct', 9);
                         break;
                         // Mechanic
                     // Mechanic
                     default:
                         $_ = '';
                 }
                 if (User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     $_ = $effMV;
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 108:
                 // Dispel Mechanic
                 $_ = Lang::game('me', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 118:
                 // Require Skill
                 if ($_ = SkillList::getName($effMV)) {
                     $foo['name'] .= '(<a href="?skill=' . $effMV . '">' . $_ . '</a>)';
                 } else {
                     $foo['name'] .= Util::ucFirst(Lang::game('skill')) . ' #' . $effMV;
                 }
                 break;
             case 146:
                 // Activate Rune
                 $_ = Lang::spell('powerRunes', $effMV);
                 if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) {
                     $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_);
                 } else {
                     if (!$_) {
                         $_ = $effMV;
                     }
                 }
                 $foo['name'] .= ' (' . $_ . ')';
                 break;
             case 123:
                 // Send Taxi - effMV is taxiPathId. We only use paths for flightmasters for now, so spell-triggered paths are not in the table
             // Send Taxi - effMV is taxiPathId. We only use paths for flightmasters for now, so spell-triggered paths are not in the table
             default:
                 if (($effMV || $effId == 97) && $effId != 155) {
                     $foo['name'] .= ' (' . $effMV . ')';
                 }
                 // Aura
             // Aura
             case 6:
                 // Simple
             // Simple
             case 27:
                 // AA Persistent
             // AA Persistent
             case 35:
                 // AA Party
             // AA Party
             case 65:
                 // AA Raid
             // AA Raid
             case 119:
                 // AA Pet
             // AA Pet
             case 128:
                 // AA Friend
             // AA Friend
             case 129:
                 // AA Enemy
             // AA Enemy
             case 143:
                 if ($effAura > 0 && isset(Util::$spellAuraStrings[$effAura])) {
                     $foo['name'] .= User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'AuraId: ' . $effAura, Util::$spellAuraStrings[$effAura]) : Util::$spellAuraStrings[$effAura];
                     $bar = $effMV;
                     switch ($effAura) {
                         case 17:
                             // Mod Stealth Detection
                             if ($_ = Lang::spell('stealthType', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 19:
                             // Mod Invisibility Detection
                             if ($_ = Lang::spell('invisibilityType', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 24:
                             // Periodic Energize
                         // Periodic Energize
                         case 21:
                             // Obsolete Mod Power
                         // Obsolete Mod Power
                         case 35:
                             // Mod Increase Power
                         // Mod Increase Power
                         case 85:
                             // Mod Power Regeneration
                         // Mod Power Regeneration
                         case 110:
                             // Mod Power Regeneration Pct
                             if ($_ = Lang::spell('powerTypes', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 29:
                             // Mod Stat
                         // Mod Stat
                         case 80:
                             // Mod Stat %
                         // Mod Stat %
                         case 137:
                             // Mod Total Stat %
                         // Mod Total Stat %
                         case 175:
                             // Mod Spell Healing Of Stat Percent
                         // Mod Spell Healing Of Stat Percent
                         case 212:
                             // Mod Ranged Attack Power Of Stat Percent
                         // Mod Ranged Attack Power Of Stat Percent
                         case 219:
                             // Mod Mana Regeneration from Stat
                         // Mod Mana Regeneration from Stat
                         case 268:
                             // Mod Attack Power Of Stat Percent
                             $mask = $effMV == -1 ? 0x1f : 1 << $effMV;
                             $_ = [];
                             for ($j = 0; $j < 5; $j++) {
                                 if ($mask & 1 << $j) {
                                     $_[] = Lang::game('stats', $j);
                                 }
                             }
                             if ($_ = implode(', ', $_)) {
                             }
                             $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             break;
                         case 36:
                             // Shapeshift
                             if ($st = $this->subject->getModelInfo($this->typeId, $i)) {
                                 $redButtons[BUTTON_VIEW3D] = array('type' => TYPE_NPC, 'displayId' => $st['displayId']);
                                 if ($st['creatureType'] > 0) {
                                     $infobox[] = Lang::game('type') . Lang::main('colon') . Lang::game('ct', $st['creatureType']);
                                 }
                                 if ($_ = $st['displayName']) {
                                     $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                                 }
                             }
                             break;
                         case 37:
                             // Effect immunity
                             if (isset(Util::$spellEffectStrings[$effMV])) {
                                 $_ = Util::$spellEffectStrings[$effMV];
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 38:
                             // Aura immunity
                             if (isset(Util::$spellAuraStrings[$effMV])) {
                                 $_ = Util::$spellAuraStrings[$effMV];
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 41:
                             // Dispel Immunity
                         // Dispel Immunity
                         case 178:
                             // Mod Debuff Resistance
                         // Mod Debuff Resistance
                         case 245:
                             // Mod Aura Duration By Dispel
                             if ($_ = Lang::game('dt', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 44:
                             // Track Creature
                             if ($_ = Lang::game('ct', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 45:
                             // Track Resource
                             if ($_ = Lang::spell('lockType', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 75:
                             // Language
                             if ($_ = Lang::game('languages', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 77:
                             // Mechanic Immunity
                         // Mechanic Immunity
                         case 117:
                             // Mod Mechanic Resistance
                         // Mod Mechanic Resistance
                         case 232:
                             // Mod Mechanic Duration
                         // Mod Mechanic Duration
                         case 234:
                             // Mod Mechanic Duration (no stack)
                         // Mod Mechanic Duration (no stack)
                         case 255:
                             // Mod Mechanic Damage Taken Pct
                         // Mod Mechanic Damage Taken Pct
                         case 276:
                             // Mod Mechanic Damage Done Percent
                             if ($_ = Lang::game('me', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 147:
                             // Mechanic Immunity Mask
                             $_ = [];
                             foreach (Lang::game('me') as $k => $str) {
                                 if ($effMV & 1 << $k - 1) {
                                     $_[] = $str;
                                 }
                             }
                             if ($_ = implode(', ', $_)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 10:
                             // Mod Threat
                         // Mod Threat
                         case 13:
                             // Mod Damage Done
                         // Mod Damage Done
                         case 14:
                             // Mod Damage Taken
                         // Mod Damage Taken
                         case 22:
                             // Mod Resistance
                         // Mod Resistance
                         case 39:
                             // School Immunity
                         // School Immunity
                         case 40:
                             // Damage Immunity
                         // Damage Immunity
                         case 50:
                             // Mod Critical Healing Amount
                         // Mod Critical Healing Amount
                         case 57:
                             // Mod Spell Crit Chance
                         // Mod Spell Crit Chance
                         case 69:
                             // School Absorb
                         // School Absorb
                         case 71:
                             // Mod Spell Crit Chance School
                         // Mod Spell Crit Chance School
                         case 72:
                             // Mod Power Cost School Percent
                         // Mod Power Cost School Percent
                         case 73:
                             // Mod Power Cost School Flat
                         // Mod Power Cost School Flat
                         case 74:
                             // Reflect Spell School
                         // Reflect Spell School
                         case 79:
                             // Mod Damage Done Pct
                         // Mod Damage Done Pct
                         case 81:
                             // Split Damage Pct
                         // Split Damage Pct
                         case 83:
                             // Mod Base Resistance
                         // Mod Base Resistance
                         case 87:
                             // Mod Damage Taken Pct
                         // Mod Damage Taken Pct
                         case 97:
                             // Mana Shield
                         // Mana Shield
                         case 101:
                             // Mod Resistance Pct
                         // Mod Resistance Pct
                         case 115:
                             // Mod Healing Taken
                         // Mod Healing Taken
                         case 118:
                             // Mod Healing Taken Pct
                         // Mod Healing Taken Pct
                         case 123:
                             // Mod Target Resistance
                         // Mod Target Resistance
                         case 135:
                             // Mod Healing Done
                         // Mod Healing Done
                         case 136:
                             // Mod Healing Done Pct
                         // Mod Healing Done Pct
                         case 142:
                             // Mod Base Resistance Pct
                         // Mod Base Resistance Pct
                         case 143:
                             // Mod Resistance Exclusive
                         // Mod Resistance Exclusive
                         case 149:
                             // Reduce Pushback
                         // Reduce Pushback
                         case 163:
                             // Mod Crit Damage Bonus
                         // Mod Crit Damage Bonus
                         case 174:
                             // Mod Spell Damage Of Stat Percent
                         // Mod Spell Damage Of Stat Percent
                         case 182:
                             // Mod Resistance Of Stat Percent
                         // Mod Resistance Of Stat Percent
                         case 186:
                             // Mod Attacker Spell Hit Chance
                         // Mod Attacker Spell Hit Chance
                         case 194:
                             // Mod Target Absorb School
                         // Mod Target Absorb School
                         case 195:
                             // Mod Target Ability Absorb School
                         // Mod Target Ability Absorb School
                         case 199:
                             // Mod Increases Spell Percent to Hit
                         // Mod Increases Spell Percent to Hit
                         case 229:
                             // Mod AoE Damage Avoidance
                         // Mod AoE Damage Avoidance
                         case 271:
                             // Mod Damage Percent Taken Form Caster
                         // Mod Damage Percent Taken Form Caster
                         case 310:
                             // Mod Creature AoE Damage Avoidance
                             if ($_ = Lang::getMagicSchools($effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 30:
                             // Mod Skill
                         // Mod Skill
                         case 98:
                             // Mod Skill Value
                             if ($_ = SkillList::getName($effMV)) {
                                 $bar = ' (<a href="?skill=' . $effMV . '">' . SkillList::getName($effMV) . '</a>)';
                             } else {
                                 $bar = Lang::main('colon') . Util::ucFirst(Lang::game('skill')) . ' #' . $effMV;
                             }
                             break;
                         case 107:
                             // Flat Modifier
                         // Flat Modifier
                         case 108:
                             // Pct Modifier
                             if ($_ = Lang::spell('spellModOp', $effMV)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_;
                             }
                             break;
                         case 189:
                             // Mod Rating
                         // Mod Rating
                         case 220:
                             // Combat Rating From Stat
                             $_ = [];
                             foreach (Lang::spell('combatRating') as $k => $str) {
                                 if (1 << $k & $effMV) {
                                     $_[] = $str;
                                 }
                             }
                             if ($_ = implode(', ', $_)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 168:
                             // Mod Damage Done Versus
                         // Mod Damage Done Versus
                         case 59:
                             // Mod Damage Done Versus Creature
                         // Mod Damage Done Versus Creature
                         case 102:
                             // Mod Melee Attack Power Versus
                         // Mod Melee Attack Power Versus
                         case 131:
                             // Mod Ranged Attack Power Versus
                         // Mod Ranged Attack Power Versus
                         case 180:
                             // Mod Spell Damage Versus
                             $_ = [];
                             foreach (Lang::game('ct') as $k => $str) {
                                 if ($effMV & 1 << $k - 1) {
                                     $_[] = $str;
                                 }
                             }
                             if ($_ = implode(', ', $_)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_;
                             }
                             break;
                         case 249:
                             // Convert Rune
                             $x = $this->subject->getField('effect' . $i . 'MiscValueB');
                             if ($_ = Lang::spell('powerRunes', $x)) {
                                 $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $x, $_) : $_;
                             }
                             break;
                         case 78:
                             // Mounted
                         // Mounted
                         case 56:
                             // Transform
                             if ($transform = $this->subject->getModelInfo($this->typeId, $i)) {
                                 $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $transform['displayId']];
                                 $bar = $transform['typeId'] ? ' (<a href="?npc=' . $transform['typeId'] . '">' . $transform['displayName'] . '</a>)' : ' (#0)';
                             } else {
                                 $bar = Lang::main('colon') . Lang::game('npc') . ' #' . $effMV;
                             }
                             break;
                         case 139:
                             // Force Reaction
                             $foo['value'] = sprintf(Util::$dfnString, $foo['value'], Lang::game('rep', $foo['value']));
                             // DO NOT BREAK
                         // DO NOT BREAK
                         case 190:
                             // Mod Faction Reputation Gain
                             $bar = ' (<a href="?faction=' . $effMV . '">' . FactionList::getName($effMV) . '</a>)';
                             break;
                             // also breaks for 139
                     }
                     $foo['name'] .= strstr($bar, 'href') || strstr($bar, '#') ? $bar : ($bar ? ' (' . $bar . ')' : null);
                     if (in_array($effAura, [174, 220, 182])) {
                         $foo['name'] .= ' [' . sprintf(Util::$dfnString, Lang::game('stats', $this->subject->getField('effect' . $i . 'MiscValueB')), $this->subject->getField('effect' . $i . 'MiscValueB')) . ']';
                     } else {
                         if ($this->subject->getField('effect' . $i . 'MiscValueB') > 0) {
                             $foo['name'] .= ' [' . $this->subject->getField('effect' . $i . 'MiscValueB') . ']';
                         }
                     }
                 } else {
                     if ($effAura > 0) {
                         $foo['name'] .= Lang::main('colon') . 'Unknown Aura (' . $effAura . ')';
                     }
                 }
                 break;
         }
         // cases where we dont want 'Value' to be displayed
         if (in_array($effAura, [11, 12, 36, 77]) || in_array($effId, []) || empty($foo['value'])) {
             unset($foo['value']);
         }
     }
     unset($foo);
     // clear reference
     return $effects;
 }
Пример #4
0
 public function renderBuff($level = MAX_LEVEL, $interactive = false)
 {
     if (!$this->curTpl) {
         return ['', []];
     }
     // doesn't have a buff
     if (!$this->getField('buff', true)) {
         return ['', []];
     }
     $this->interactive = $interactive;
     $x = '<table><tr>';
     // spellName
     $x .= '<td><b class="q">' . $this->getField('name', true) . '</b></td>';
     // dispelType (if applicable)
     if ($this->curTpl['dispelType']) {
         if ($dispel = Lang::game('dt', $this->curTpl['dispelType'])) {
             $x .= '<th><b class="q">' . $dispel . '</b></th>';
         }
     }
     $x .= '</tr></table>';
     $x .= '<table><tr><td>';
     // parse Buff-Text
     $btt = $this->parseText('buff', $level, $this->interactive, $scaling);
     $x .= $btt[0] . '<br>';
     // duration
     if ($this->curTpl['duration'] > 0) {
         $x .= '<span class="q">' . sprintf(Lang::spell('remaining'), Util::formatTime($this->curTpl['duration'])) . '<span>';
     }
     $x .= '</td></tr></table>';
     // scaling information - spellId:min:max:curr
     $x .= '<!--?' . $this->id . ':1:' . ($scaling ? MAX_LEVEL : 1) . ':' . $level . '-->';
     return [$x, $btt[1]];
 }
Пример #5
0
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // Event (ignore events, where the object only gets removed)
     if ($_ = DB::World()->selectCol('SELECT DISTINCT IF(ge.holiday, ge.holiday, -ge.eventEntry) FROM game_event ge, game_event_gameobject geg, gameobject g WHERE ge.eventEntry = geg.eventEntry AND g.guid = geg.guid AND g.id = ?d', $this->typeId)) {
         $this->extendGlobalIds(TYPE_WORLDEVENT, $_);
         $ev = [];
         foreach ($_ as $i => $e) {
             $ev[] = ($i % 2 ? '[br]' : ' ') . '[event=' . $e . ']';
         }
         $infobox[] = Util::ucFirst(Lang::game('eventShort')) . Lang::main('colon') . implode(',', $ev);
     }
     // Reaction
     $_ = function ($r) {
         if ($r == 1) {
             return 2;
         }
         if ($r == -1) {
             return 10;
         }
         return;
     };
     $infobox[] = Lang::npc('react') . Lang::main('colon') . '[color=q' . $_($this->subject->getField('A')) . ']A[/color] [color=q' . $_($this->subject->getField('H')) . ']H[/color]';
     // reqSkill
     switch ($this->subject->getField('typeCat')) {
         case -3:
             // Herbalism
             $infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 2) . ' (' . $this->subject->getField('reqSkill') . ')');
             break;
         case -4:
             // Mining
             $infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 3) . ' (' . $this->subject->getField('reqSkill') . ')');
             break;
         case -5:
             // Lockpicking
             $infobox[] = sprintf(Lang::game('requires'), Lang::spell('lockType', 1) . ' (' . $this->subject->getField('reqSkill') . ')');
             break;
         default:
             $locks = Lang::getLocks($this->subject->getField('lockId'));
             $l = '';
             foreach ($locks as $idx => $_) {
                 if ($idx < 0) {
                     continue;
                 }
                 $this->extendGlobalIds(TYPE_ITEM, $idx);
                 $l = Lang::gameObject('key') . Lang::main('colon') . '[item=' . $idx . ']';
             }
             // if no propper item is found use a skill
             if ($locks) {
                 $infobox[] = $l ? $l : array_pop($locks);
             }
     }
     // linked trap
     if ($_ = $this->subject->getField('linkedTrap')) {
         $this->extendGlobalIds(TYPE_OBJECT, $_);
         $infobox[] = Lang::gameObject('trap') . Lang::main('colon') . '[object=' . $_ . ']';
     }
     // trap for
     $trigger = new GameObjectList(array(['linkedTrap', $this->typeId]));
     if (!$trigger->error) {
         $this->extendGlobalData($trigger->getJSGlobals());
         $infobox[] = Lang::gameObject('triggeredBy') . Lang::main('colon') . '[object=' . $trigger->id . ']';
     }
     // SpellFocus
     if ($_ = $this->subject->getField('spellFocusId')) {
         if ($sfo = DB::Aowow()->selectRow('SELECT * FROM ?_spellfocusobject WHERE id = ?d', $_)) {
             $infobox[] = '[tooltip name=focus]' . Lang::gameObject('focusDesc') . '[/tooltip][span class=tip tooltip=focus]' . Lang::gameObject('focus') . Lang::main('colon') . Util::localizedString($sfo, 'name') . '[/span]';
         }
     }
     // lootinfo: [min, max, restock]
     if (($_ = $this->subject->getField('lootStack')) && $_[0]) {
         $buff = Lang::item('charges') . Lang::main('colon') . $_[0];
         if ($_[0] < $_[1]) {
             $buff .= Lang::game('valueDelim') . $_[1];
         }
         // since Veins don't have charges anymore, the timer is questionable
         $infobox[] = $_[2] > 1 ? '[tooltip name=restock]' . sprintf(Lang::gameObject('restock'), Util::formatTime($_[2] * 1000)) . '[/tooltip][span class=tip tooltip=restock]' . $buff . '[/span]' : $buff;
     }
     // meeting stone [minLevel, maxLevel, zone]
     if ($this->subject->getField('type') == OBJECT_MEETINGSTONE) {
         if ($_ = $this->subject->getField('mStone')) {
             $this->extendGlobalIds(TYPE_ZONE, $_[2]);
             $m = Lang::game('meetingStone') . Lang::main('colon') . '[zone=' . $_[2] . ']';
             $l = $_[0];
             if ($_[0] > 1 && $_[1] > $_[0]) {
                 $l .= Lang::game('valueDelim') . min($_[1], MAX_LEVEL);
             }
             $infobox[] = $l ? '[tooltip name=meetingstone]' . sprintf(Lang::game('reqLevel'), $l) . '[/tooltip][span class=tip tooltip=meetingstone]' . $m . '[/span]' : $m;
         }
     }
     // capture area [minPlayer, maxPlayer, minTime, maxTime, radius]
     if ($this->subject->getField('type') == OBJECT_CAPTURE_POINT) {
         if ($_ = $this->subject->getField('capture')) {
             $buff = Lang::gameObject('capturePoint');
             if ($_[2] > 1 || $_[0]) {
                 $buff .= Lang::main('colon') . '[ul]';
             }
             if ($_[2] > 1) {
                 $buff .= '[li]' . Lang::game('duration') . Lang::main('colon') . ($_[3] > $_[2] ? Util::FormatTime($_[3] * 1000, true) . ' - ' : null) . Util::FormatTime($_[2] * 1000, true) . '[/li]';
             }
             if ($_[1]) {
                 $buff .= '[li]' . Lang::main('players') . Lang::main('colon') . $_[0] . ($_[1] > $_[0] ? ' - ' . $_[1] : null) . '[/li]';
             }
             if ($_[4]) {
                 $buff .= '[li]' . sprintf(Lang::spell('range'), $_[4]) . '[/li]';
             }
             if ($_[2] > 1 || $_[0]) {
                 $buff .= '[/ul]';
             }
         }
         $infobox[] = $buff;
     }
     // AI
     if (User::isInGroup(U_GROUP_EMPLOYEE)) {
         if ($_ = $this->subject->getField('ScriptName')) {
             $infobox[] = 'Script' . Lang::main('colon') . $_;
         } else {
             if ($_ = $this->subject->getField('AIName')) {
                 $infobox[] = 'AI' . Lang::main('colon') . $_;
             }
         }
     }
     /****************/
     /* Main Content */
     /****************/
     // pageText
     $pageText = [];
     if ($next = $this->subject->getField('pageTextId')) {
         while ($next) {
             $row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next);
             $next = $row['next_page'];
             $pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
         }
     }
     // add conditional js & css
     if ($pageText) {
         $this->addCSS(['path' => 'Book.css']);
         $this->addJS('Book.js');
     }
     // get spawns and path
     $map = null;
     if ($spawns = $this->subject->getSpawns(SPAWNINFO_FULL)) {
         $map = ['data' => ['parent' => 'mapper-generic'], 'mapperData' => &$spawns];
         foreach ($spawns as $areaId => &$areaData) {
             $map['extra'][$areaId] = ZoneList::getName($areaId);
         }
     }
     // consider pooled spawns
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->pageText = $pageText;
     $this->map = $map;
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true, BUTTON_VIEW3D => ['displayId' => $this->subject->getField('displayId'), 'type' => TYPE_OBJECT, 'typeId' => $this->typeId]);
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: summoned by
     $conditions = array('OR', ['AND', ['effect1Id', [50, 76, 104, 105, 106, 107]], ['effect1MiscValue', $this->typeId]], ['AND', ['effect2Id', [50, 76, 104, 105, 106, 107]], ['effect2MiscValue', $this->typeId]], ['AND', ['effect3Id', [50, 76, 104, 105, 106, 107]], ['effect3MiscValue', $this->typeId]]);
     $summons = new SpellList($conditions);
     if (!$summons->error) {
         $this->extendGlobalData($summons->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         $this->lvTabs[] = array('file' => 'spell', 'data' => $summons->getListviewData(), 'params' => array('id' => 'summoned-by', 'name' => '$LANG.tab_summonedby'));
     }
     // tab: related spells
     if ($_ = $this->subject->getField('spells')) {
         $relSpells = new SpellList(array(['id', $_]));
         if (!$relSpells->error) {
             $this->extendGlobalData($relSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $data = $relSpells->getListviewData();
             foreach ($data as $relId => $d) {
                 $data[$relId]['trigger'] = array_search($relId, $_);
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'spells', 'name' => '$LANG.tab_spells', 'hiddenCols' => "\$['skill']", 'extraCols' => "\$[Listview.funcBox.createSimpleCol('trigger', 'Condition', '10%', 'trigger')]"));
         }
     }
     // tab: criteria of
     $acvs = new AchievementList(array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT]], ['ac.value1', $this->typeId]));
     if (!$acvs->error) {
         $this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         $this->lvTabs[] = array('file' => 'achievement', 'data' => $acvs->getListviewData(), 'params' => array('id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof'));
     }
     // tab: starts quest
     // tab: ends quest
     $startEnd = new QuestList(array(['qse.type', TYPE_OBJECT], ['qse.typeId', $this->typeId]));
     if (!$startEnd->error) {
         $this->extendGlobalData($startEnd->getJSGlobals());
         $lvData = $startEnd->getListviewData();
         $_ = [[], []];
         foreach ($startEnd->iterate() as $id => $__) {
             $m = $startEnd->getField('method');
             if ($m & 0x1) {
                 $_[0][] = $lvData[$id];
             }
             if ($m & 0x2) {
                 $_[1][] = $lvData[$id];
             }
         }
         if ($_[0]) {
             $this->lvTabs[] = array('file' => 'quest', 'data' => $_[0], 'params' => array('name' => '$LANG.tab_starts', 'id' => 'starts'));
         }
         if ($_[1]) {
             $this->lvTabs[] = array('file' => 'quest', 'data' => $_[1], 'params' => array('name' => '$LANG.tab_ends', 'id' => 'ends'));
         }
     }
     // tab: related quests
     if ($_ = $this->subject->getField('reqQuest')) {
         $relQuest = new QuestList(array(['id', $_]));
         if (!$relQuest->error) {
             $this->extendGlobalData($relQuest->getJSGlobals());
             $this->lvTabs[] = array('file' => 'quest', 'data' => $relQuest->getListviewData(), 'params' => array('name' => '$LANG.tab_quests', 'id' => 'quests'));
         }
     }
     // tab: contains
     $reqQuest = [];
     if ($_ = $this->subject->getField('lootId')) {
         $goLoot = new Loot();
         if ($goLoot->getByContainer(LOOT_GAMEOBJECT, $_)) {
             $extraCols = $goLoot->extraCols;
             $hiddenCols = ['source', 'side', 'slot', 'reqlevel'];
             $this->extendGlobalData($goLoot->jsGlobals);
             foreach ($goLoot->iterate() as &$lv) {
                 if (!empty($hiddenCols)) {
                     foreach ($hiddenCols as $k => $str) {
                         if (!empty($lv[$str])) {
                             unset($hiddenCols[$k]);
                         }
                     }
                 }
                 if (!$lv['quest']) {
                     continue;
                 }
                 $extraCols[] = 'Listview.extraCols.condition';
                 $reqQuest[$lv['id']] = 0;
                 $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
             }
             $extraCols[] = 'Listview.extraCols.percent';
             $this->lvTabs[] = array('file' => 'item', 'data' => $goLoot->getResult(), 'params' => array('name' => '$LANG.tab_contains', 'id' => 'contains', 'extraCols' => "\$[" . implode(', ', array_unique($extraCols)) . "]", 'hiddenCols' => $hiddenCols ? '$' . Util::toJSON(array_values($hiddenCols)) : null));
         }
     }
     if ($reqIds = array_keys($reqQuest)) {
         $conditions = array('OR', ['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds], ['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds], ['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds], ['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]);
         $reqQuests = new QuestList($conditions);
         $this->extendGlobalData($reqQuests->getJSGlobals());
         foreach ($reqQuests->iterate() as $qId => $__) {
             if (empty($reqQuests->requires[$qId][TYPE_ITEM])) {
                 continue;
             }
             foreach ($reqIds as $rId) {
                 if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM])) {
                     $reqQuest[$rId] = $reqQuests->id;
                 }
             }
         }
     }
     // tab: Same model as .. whats the f*****g point..?
     $sameModel = new GameObjectList(array(['displayId', $this->subject->getField('displayId')], ['id', $this->typeId, '!']));
     if (!$sameModel->error) {
         $this->extendGlobalData($sameModel->getJSGlobals());
         $this->lvTabs[] = array('file' => 'object', 'data' => $sameModel->getListviewData(), 'params' => array('name' => '$LANG.tab_samemodelas', 'id' => 'same-model-as'));
     }
 }
Пример #6
0
 /**
  * This method registers a couple of commands which can be used by the
  * bot owner to control one another from IRC, like adding, removing and
  * renaming, changing properties of commands, (un)loading modules, etc.
  * Just have a skim through this method and you'll figure it out.
  */
 private function registerInternalCommands()
 {
     $this->registerCommand(new Command('cmdadd', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) < 2) {
             echo '!cmdadd CommandName Code';
             return Command::OUTPUT_USAGE;
         } else {
             Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->addCommand(array_shift($aParams), implode(' ', $aParams));
             echo 'The command has been added.';
             return Command::OUTPUT_SUCCESS;
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('cmdremove', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 1) {
             echo '!cmdremove CommandName';
             return Command::OUTPUT_USAGE;
         } else {
             if (Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->deleteCommand($aParams[0])) {
                 echo 'The command has been deleted successfully.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'The command has not been found.';
                 return Command::OUTPUT_ERROR;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('cmdrename', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 2) {
             echo '!cmdrename OldName NewName';
             return Command::OUTPUT_USAGE;
         } else {
             if (Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->renameCommand($aParams[0], $aParams[1])) {
                 echo 'The command has been renamed successfully.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'The command has not been found.';
                 return Command::OUTPUT_ERROR;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('cmdchannel', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) < 2) {
             echo '!cmdchannel CommandName [- / Channel1 14ChannelN]';
             return Command::OUTPUT_USAGE;
         } else {
             $c = Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->offsetGet($aParams[0]);
             if ($c) {
                 $c->setChannels(array_slice($aParams, 1));
                 echo 'The channels have been updated successfully.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'The command has not been found.';
                 return Command::OUTPUT_ERROR;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('cmdnetwork', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) < 2) {
             echo '!cmdnetwork CommandName [- / Network1 14NetworkN]';
             return Command::OUTPUT_USAGE;
         } else {
             $c = Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->offsetGet($aParams[0]);
             if ($c) {
                 $c->setNetworks(array_slice($aParams, 1));
                 echo 'The networks have been updated successfully.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'The command has not been found.';
                 return Command::OUTPUT_ERROR;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('cmdcode', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 1) {
             echo '!cmdcode CommandName';
             return Command::OUTPUT_USAGE;
         } else {
             $c = Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->offsetGet($aParams[0]);
             if ($c) {
                 if (is_string($c->getCode())) {
                     echo $c->getCode();
                     return Command::OUTPUT_NORMAL;
                 } else {
                     echo 'The command is a function call, no code can be displayed.';
                     return Command::OUTPUT_ERROR;
                 }
             } else {
                 echo 'The command has not been found.';
                 return Command::OUTPUT_ERROR;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('cmdlist', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         $aCmd = array();
         $iAmountOfCommands = 0;
         foreach (Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->getIterator() as $sName => $pCommand) {
             if ($sName[0] == '.') {
                 continue;
             }
             $aCmd[] = $sName;
             $iAmountOfCommands++;
         }
         echo wordwrap('10* Commands (' . $iAmountOfCommands . '): !' . implode(', !', $aCmd), 400);
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('moduleload', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 1) {
             echo '!moduleload ModuleName';
             return Command::OUTPUT_USAGE;
         } else {
             if (Nuwani\ModuleManager::getInstance()->loadModule($aParams[0])) {
                 echo 'The module has been loaded.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'The module could not be loaded.';
                 return Command::OUTPUT_ERROR;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('moduleunload', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 1) {
             echo '!moduleunload ModuleName';
             return Command::OUTPUT_USAGE;
         } else {
             if (Nuwani\ModuleManager::getInstance()->unloadModule($aParams[0])) {
                 echo 'The module has been unloaded.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'The module could not be unloaded.';
                 return Command::OUTPUT_ERROR;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('modulereload', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 1) {
             echo '!modulereload ModuleName';
             return Command::OUTPUT_USAGE;
         } else {
             if (Nuwani\ModuleManager::getInstance()->reloadModule($aParams[0])) {
                 echo 'The module has been reloaded.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'The module could not be reloaded.';
                 return Command::OUTPUT_ERROR;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('modulelist', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         $c = Nuwani\ModuleManager::getInstance();
         $aModules = array();
         foreach ($c as $sName => $pModule) {
             $aModules[] = $sName;
         }
         echo '10* Modules (' . count($c) . '): ' . implode(', ', $aModules);
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('botlist', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         $c = Nuwani\BotManager::getInstance()->getBotList();
         $aBots = array();
         foreach ($c as $sName => $Bot) {
             $aBots[] = $sName . ' (' . $Bot['Network'] . ')';
         }
         echo '10* Bots (' . count($c) . '): ' . implode(', ', $aBots);
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('meminfo', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         $aGarbage = Nuwani\Memory::getStatistics();
         echo '10* Current usage: ', sprintf('%.2f MB', memory_get_usage() / 1024 / 1024), ' | 10Top usage: ', sprintf('%.2f MB', memory_get_peak_usage() / 1024 / 1024), ' | 10Garbage: ', sprintf('%.2f kB', $aGarbage['Memory']);
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('restart', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         Nuwani\BotManager::getInstance()->getBotList()->send('QUIT :Restart requested by ' . $sNickname);
         usleep(150000);
         die(exec('php ' . $_SERVER['argv'][0] . ' restart'));
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('cmdpermission', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 2) {
             echo '!cmdpermission command level';
             return Command::OUTPUT_USAGE;
         } else {
             if (!Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->setCommandPermission($aParams[0], $aParams[1])) {
                 echo 'The command has not been found.';
                 return Command::OUTPUT_ERROR;
             } else {
                 echo 'The required permission has been updated successfully.';
                 return Command::OUTPUT_SUCCESS;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('useradd', function (Bot $pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 1) {
             echo '!useradd usermask';
             return Command::OUTPUT_USAGE;
         } else {
             if ($pBot->getSecurityManager()->isUserKnown($aParams[0])) {
                 echo 'Given user mask is already known.';
                 return Command::OUTPUT_ERROR;
             }
             $pBot->getSecurityManager()->addUser($aParams[0]);
             echo 'User ' . $aParams[0] . ' has been added.';
             return Command::OUTPUT_SUCCESS;
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('permissiongrant', function (Bot $pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 2) {
             echo '!permissiongrant usermask permission';
             return Command::OUTPUT_USAGE;
         } else {
             if (!$pBot->getSecurityManager()->isUserKnown($aParams[0])) {
                 echo 'Given user mask does not match any known users.';
                 return Command::OUTPUT_ERROR;
             }
             $user = new Nuwani\User($pBot['Network'], $aParams[0]);
             if ($pBot->getSecurityManager()->grantPermission($user, $aParams[1])) {
                 echo 'User ' . (string) $user . ' has been granted the "' . $aParams[1] . '" permission.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'User ' . (string) $user . ' already has the "' . $aParams[1] . '" permission.';
                 return Command::OUTPUT_NOTICE;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('permissionrevoke', function (Bot $pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 2) {
             echo '!permissionrevoke usermask permission';
             return Command::OUTPUT_USAGE;
         } else {
             if (!$pBot->getSecurityManager()->isUserKnown($aParams[0])) {
                 echo 'Given user mask does not match any known users.';
                 return Command::OUTPUT_ERROR;
             }
             $user = new Nuwani\User($pBot['Network'], $aParams[0]);
             if ($pBot->getSecurityManager()->revokePermission($user, $aParams[1])) {
                 echo 'The "' . $aParams[1] . '" permission has been revoked from user ' . (string) $user . '.';
                 return Command::OUTPUT_SUCCESS;
             } else {
                 echo 'User ' . (string) $user . ' doesn\'t have the "' . $aParams[1] . '" permission.';
                 return Command::OUTPUT_NOTICE;
             }
         }
     }, SecurityManager::PERMISSION_BOT_OWNER))->registerCommand(new Command('permissionshow', function (Bot $pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (count($aParams) != 1) {
             echo '!permissionshow usermask';
             return Command::OUTPUT_USAGE;
         } else {
             $user = null;
             if ($aParams[0] == 'me' || $aParams[0] == 'self') {
                 $user = $pBot->In->User;
             } else {
                 $user = new Nuwani\User($pBot['Network'], $aParams[0]);
             }
             $permissions = $pBot->getSecurityManager()->getPermissionList($user);
             if (empty($permissions)) {
                 echo 'User ' . (string) $user . ' doesn\'t have any permissions.';
                 return Command::OUTPUT_INFO;
             } else {
                 echo 'User ' . (string) $user . ' has the following permissions: ' . implode(', ', $permissions);
                 return Command::OUTPUT_INFO;
             }
         }
     }, null))->registerCommand(new Command('runningtimers', function ($pBot, $sDestination, $sChannel, $sNickname, $sParams, $sMessage) {
         echo '10* Running timers: ';
         $message = '';
         foreach (Nuwani\Timer::getActiveTimers() as $timerInfo) {
             $message .= $timerInfo['name'];
             $message .= ' 14(ID: ' . $timerInfo['id'];
             $message .= ', in ' . Util::formatTime($timerInfo['next_run'] - microtime(true), true);
             $message .= $timerInfo['type'] == Nuwani\Timer::TIMEOUT ? ', once' : '';
             $message .= '), ';
         }
         echo wordwrap(substr($message, 0, -2), 400);
     }, SecurityManager::PERMISSION_BOT_OWNER));
 }
Пример #7
0
        <div class="footer">
<?php 
if (User::isInGroup(U_GROUP_EMPLOYEE) && ($this->time || isset($this->mysql) || $this->isCached)) {
    echo "            <table style=\"margin:auto;\">\n";
    if (isset($this->mysql)) {
        echo '                <tr><td style="text-align:left;">' . Lang::main('numSQL') . '</td><td>' . $this->mysql['count'] . "</td></tr>\n";
        echo '                <tr><td style="text-align:left;">' . Lang::main('timeSQL') . '</td><td>' . Util::formatTime($this->mysql['time'] * 1000, true) . "</td></tr>\n";
    }
    if ($this->time) {
        echo '                <tr><td style="text-align:left;">Page generated in</td><td>' . Util::formatTime($this->time * 1000, true) . "</td></tr>\n";
    }
    if ($this->cacheLoaded && $this->cacheLoaded[0] == CACHE_MODE_FILECACHE) {
        echo "                <tr><td style=\"text-align:left;\">reloaded from filecache</td><td>created" . Lang::main('colon') . date(Lang::main('dateFmtLong'), $this->cacheLoaded[1]) . "</td></tr>\n";
    } elseif ($this->cacheLoaded && $this->cacheLoaded[0] == CACHE_MODE_MEMCACHED) {
        echo "                <tr><td style=\"text-align:left;\">reloaded from memcached</td><td>created" . Lang::main('colon') . date(Lang::main('dateFmtLong'), $this->cacheLoaded[1]) . "</td></tr>\n";
    }
    echo "            </table>\n";
}
?>
        </div>
    </div><!-- #wrapper .nosidebar -->
    </div><!-- #layout-inner -->
</div><!-- #layout .nosidebar -->

<noscript>
    <div id="noscript-bg"></div>
    <div id="noscript-text"><?php 
echo Lang::main('noJScript');
?>
</div>
</noscript>
Пример #8
0
 protected function postCache()
 {
     // update dates to now()
     $updated = WorldEventList::updateDates($this->dates);
     if ($this->mode == CACHE_TYPE_TOOLTIP) {
         return array(date(Lang::main('dateFmtLong'), $updated['start']), date(Lang::main('dateFmtLong'), $updated['end']));
     } else {
         if ($this->hId) {
             Util::$wowheadLink = 'http://' . Util::$subDomains[User::$localeId] . '.wowhead.com/event=' . $this->hId;
         }
         /********************/
         /* finalize infobox */
         /********************/
         // start
         if ($updated['start']) {
             array_push($this->infobox, Lang::event('start') . Lang::main('colon') . date(Lang::main('dateFmtLong'), $updated['start']));
         }
         // end
         if ($updated['end']) {
             array_push($this->infobox, Lang::event('end') . Lang::main('colon') . date(Lang::main('dateFmtLong'), $updated['end']));
         }
         // occurence
         if ($updated['rec'] > 0) {
             array_push($this->infobox, Lang::event('interval') . Lang::main('colon') . Util::formatTime($updated['rec'] * 1000));
         }
         // in progress
         if ($updated['start'] < time() && $updated['end'] > time()) {
             array_push($this->infobox, '[span class=q2]' . Lang::event('inProgress') . '[/span]');
         }
         $this->infobox = '[ul][li]' . implode('[/li][li]', $this->infobox) . '[/li][/ul]';
         /***************************/
         /* finalize related events */
         /***************************/
         foreach ($this->lvTabs as &$view) {
             if ($view[0] != WorldEventList::$brickFile) {
                 continue;
             }
             foreach ($view[1]['data'] as &$data) {
                 $updated = WorldEventList::updateDates($data['_date']);
                 unset($data['_date']);
                 $data['startDate'] = $updated['start'] ? date(Util::$dateFormatInternal, $updated['start']) : false;
                 $data['endDate'] = $updated['end'] ? date(Util::$dateFormatInternal, $updated['end']) : false;
                 $data['rec'] = $updated['rec'];
             }
         }
     }
 }
Пример #9
0
 private function createFullSpawns()
 {
     $data = [];
     $wpSum = [];
     $wpIdx = 0;
     $spawns = DB::Aowow()->select("SELECT * FROM ?_spawns WHERE type = ?d AND typeId = ?d", self::$type, $this->id);
     if (!$spawns) {
         return;
     }
     foreach ($spawns as $s) {
         // check, if we can attach waypoints to creature
         // we will get a nice clusterfuck of dots if we do this for more GUIDs, than we have colors though
         if (count($spawns) < 6 && self::$type == TYPE_NPC) {
             if ($wPoints = DB::Aowow()->select('SELECT * FROM ?_creature_waypoints WHERE creatureOrPath = ?d AND floor = ?d', $s['pathId'] ? -$s['pathId'] : $this->id, $s['floor'])) {
                 foreach ($wPoints as $i => $p) {
                     $label = [Lang::npc('waypoint') . Lang::main('colon') . $p['point']];
                     if ($p['wait']) {
                         $label[] = Lang::npc('wait') . Lang::main('colon') . Util::formatTime($p['wait'], false);
                     }
                     $set = ['label' => '$<br><span class="q0">' . implode('<br>', $label) . '</span>', 'type' => $wpIdx];
                     // connective line
                     if ($i > 0) {
                         $set['lines'] = [[$wPoints[$i - 1]['posX'], $wPoints[$i - 1]['posY']]];
                     }
                     $data[$s['areaId']][$s['floor']]['coords'][] = [$p['posX'], $p['posY'], $set];
                     if (empty($wpSum[$s['areaId']][$s['floor']])) {
                         $wpSum[$s['areaId']][$s['floor']] = 1;
                     } else {
                         $wpSum[$s['areaId']][$s['floor']]++;
                     }
                 }
                 $wpIdx++;
             }
         }
         $label = [];
         if (User::isInGroup(U_GROUP_STAFF)) {
             $label[] = $s['guid'] < 0 ? 'Vehicle Accessory' : 'GUID' . Lang::main('colon') . $s['guid'];
         }
         if ($s['respawn']) {
             $label[] = Lang::npc('respawnIn') . Lang::main('colon') . Util::formatTime($s['respawn'] * 1000, false);
         }
         if (User::isInGroup(U_GROUP_STAFF)) {
             if ($s['phaseMask'] > 1 && ($s['phaseMask'] & 0xffff) != 0xffff) {
                 $label[] = Lang::game('phases') . Lang::main('colon') . Util::asHex($s['phaseMask']);
             }
             if ($s['spawnMask'] == 15) {
                 $label[] = Lang::game('mode') . Lang::main('colon') . Lang::game('modes', -1);
             } else {
                 if ($s['spawnMask']) {
                     $_ = [];
                     for ($i = 0; $i < 4; $i++) {
                         if ($s['spawnMask'] & 1 << $i) {
                             $_[] = Lang::game('modes', $i);
                         }
                     }
                     $label[] = Lang::game('mode') . Lang::main('colon') . implode(', ', $_);
                 }
             }
         }
         $data[$s['areaId']][$s['floor']]['coords'][] = [$s['posX'], $s['posY'], ['label' => '$<br><span class="q0">' . implode('<br>', $label) . '</span>']];
     }
     foreach ($data as $a => &$areas) {
         foreach ($areas as $f => &$floor) {
             $floor['count'] = count($floor['coords']) - (!empty($wpSum[$a][$f]) ? $wpSum[$a][$f] : 0);
         }
     }
     $this->spawnResult[SPAWNINFO_FULL] = $data;
 }
Пример #10
0
                            <!--                        <div class="kanban-item-title">
                            <?php 
            //                            echo CHtml::link($credito->fecha_credito, "");
            //                            echo CHtml::link($cliente->nombre_formato, "", array("id" => $cliente->id, "onClick" => "viewModal('incidencias/incidencia/view/id/" . $cliente->id . "')"));
            ?>
                                                    </div>-->
                            <div><label>Emisor: </label> <?php 
            echo Empleado::model()->find('userid=:idUser', array(':idUser' => $tarea->usuario_creacion_id))->nombre_completo;
            ?>
</div>
                            <!--<div><label>Responsable: </label> <?php 
            // echo Empleado::model()->find('id=:idUser', array(':idUser' => $tarea->responsable_id))->nombre_completo;
            ?>
</div>-->
                            <div><label>fecha y hora fin: </label> <?php 
            echo Util::FormatDate($tarea->fecha_fin, 'd/m/Y') . " a las " . Util::formatTime($tarea->hora_fin);
            ?>
</div>
                            <div><label>descripcion: </label> <?php 
            echo Util::Truncate($tarea->descripcion, 20);
            ?>
</div>
                            <div >
                                <?php 
            //                            $this->widget(
            //                                    'ext.bootstrap.widgets.TbToggleButton', array(
            //                                'name' => 'testToggleButtonB',
            //                                'enabledLabel' => 'Aprobado',
            //                                'disabledLabel' => 'En espera...',
            //                                'value' => $cliente->aprobado,
            //                                'onChange' => 'js:function($el, status, e){ actualizarAprobado($cliente_id,status);}',
Пример #11
0
 private function sendMail($subj, $msg, $delay = 300)
 {
     // send recovery mail
     $subj = CFG_NAME_SHORT . Lang::main('colon') . $subj;
     $msg .= "\r\n\r\n" . sprintf(Lang::mail('tokenExpires'), Util::formatTime($delay * 1000)) . "\r\n";
     $header = 'From: ' . CFG_CONTACT_EMAIL . "\r\n" . 'Reply-To: ' . CFG_CONTACT_EMAIL . "\r\n" . 'X-Mailer: PHP/' . phpversion();
     if (!mail($this->_post['email'], $subj, $msg, $header)) {
         return sprintf(Lang::main('intError2'), 'send mail');
     }
 }
Пример #12
0
 protected function postCache()
 {
     /********************/
     /* finalize infobox */
     /********************/
     // update dates to now()
     $updated = WorldEventList::updateDates($this->dates);
     // start
     if ($updated['start']) {
         array_push($this->infobox, Lang::event('start') . Lang::main('colon') . date(Lang::main('dateFmtLong'), $updated['start']));
     }
     // end
     if ($updated['end']) {
         array_push($this->infobox, Lang::event('end') . Lang::main('colon') . date(Lang::main('dateFmtLong'), $updated['end']));
     }
     // occurence
     if ($updated['rec'] > 0) {
         array_push($this->infobox, Lang::event('interval') . Lang::main('colon') . Util::formatTime($updated['rec'] * 1000));
     }
     // in progress
     if ($updated['start'] < time() && $updated['end'] > time()) {
         array_push($this->infobox, '[span class=q2]' . Lang::event('inProgress') . '[/span]');
     }
     $this->infobox = '[ul][li]' . implode('[/li][li]', $this->infobox) . '[/li][/ul]';
     /***************************/
     /* finalize related events */
     /***************************/
     foreach ($this->lvTabs as &$view) {
         if ($view['file'] != WorldEventList::$brickFile) {
             continue;
         }
         foreach ($view['data'] as &$data) {
             $updated = WorldEventList::updateDates($data['_date']);
             unset($data['_date']);
             $data['startDate'] = $updated['start'] ? date(Util::$dateFormatInternal, $updated['start']) : false;
             $data['endDate'] = $updated['end'] ? date(Util::$dateFormatInternal, $updated['end']) : false;
             $data['rec'] = $updated['rec'];
         }
     }
 }
Пример #13
0
 /**
  * This function adds the .seen-command internally since the code is too long.
  */
 private function addSeenCommand()
 {
     Nuwani\ModuleManager::getInstance()->offsetGet('Commands')->registerCommand(new Command('.seen', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         $oLastSeenPerson = new Nuwani\Model('lvp_person_last_seen', 'lvp_person_last_seen_id', $aParams[0]);
         if ($aParams[0] == '') {
             echo '!msg * Usage: .seen <username>';
         } else {
             if (!is_null($oLastSeenPerson->lvp_person_last_seen_id)) {
                 if ($oLastSeenPerson->sReason == 'online') {
                     echo '!msg ' . $oLastSeenPerson->lvp_person_last_seen_id . ' is already online for ' . Util::formatTime(time() - $oLastSeenPerson->iTime, true) . '.';
                 } else {
                     echo '!msg ' . $oLastSeenPerson->lvp_person_last_seen_id . ' was last seen online ' . date('H:i:s @ d-m-Y', $oLastSeenPerson->iTime) . ' ' . $oLastSeenPerson->sReason;
                 }
             } else {
                 echo '!msg * Error: Sorry, this username has not (yet) been found.';
             }
         }
     }));
 }
Пример #14
0
 protected function generateRSS()
 {
     $this->generateContent();
     $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<rss version=\"2.0\">\n<channel>\n" . "<title>" . CFG_NAME_SHORT . ' - ' . $this->name . "</title>\n" . "<link>" . HOST_URL . '?' . $this->page . ($this->category ? '=' . $this->category[0] : null) . "</link>\n" . "<description>" . CFG_NAME . "</description>\n" . "<language>" . implode('-', str_split(User::$localeString, 2)) . "</language>\n" . "<ttl>" . CFG_TTL_RSS . "</ttl>\n" . "<lastBuildDate>" . date(DATE_RSS) . "</lastBuildDate>\n";
     foreach ($this->lvTabs[0]['data'] as $row) {
         $xml .= "<item>\n" . "<title><![CDATA[" . htmlentities($row['subject']) . "]]></title>\n" . "<link>" . HOST_URL . '?go-to-comment&amp;id=' . $row['id'] . "</link>\n" . "<description><![CDATA[" . htmlentities($row['preview']) . " " . sprintf(Lang::timeUnits('ago'), Util::formatTime($row['elapsed'] * 100, true)) . "]]></description>\n" . "<pubDate>" . date(DATE_RSS, time() - $row['elapsed']) . "</pubDate>\n" . "<guid>" . HOST_URL . '?go-to-comment&amp;id=' . $row['id'] . "</guid>\n" . "<domain />\n" . "</item>\n";
     }
     $xml .= "</channel>\n</rss>";
     return $xml;
 }
Пример #15
0
 public static function CLTimeParser($time, $l = "load")
 {
     if ($l == "load") {
         return Util::formatTime($_SESSION["S"]->getUserLanguage(), $time);
     }
     if ($l == "store") {
         return Util::parseTime($_SESSION["S"]->getUserLanguage(), $time);
     }
 }
Пример #16
0
 public static function formatTime($timestamp)
 {
     return str_replace(":", "", Util::formatTime("de_DE", $timestamp));
 }
Пример #17
0
 protected function generateContent()
 {
     /****************/
     /* Main Content */
     /****************/
     if (in_array(array_search($this->page, $this->validPages), [0, 1, 2, 3, 11, 12])) {
         $this->h1Links = '<small><a href="?' . $this->page . ($this->category ? '=' . $this->category[0] : null) . '&rss" class="icon-rss">' . Lang::main('subscribe') . '</a></small>';
     }
     switch ($this->page) {
         case 'random':
             $type = array_rand(array_filter(Util::$typeClasses));
             $typeId = (new Util::$typeClasses[$type](null))->getRandomId();
             header('Location: ?' . Util::$typeStrings[$type] . '=' . $typeId, true, 302);
             die;
         case 'latest-comments':
             // rss
             $data = CommunityContent::getCommentPreviews();
             if ($this->rss) {
                 foreach ($data as $d) {
                     // todo (low): preview should be html-formated
                     $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($d['subject'])], 'link' => [false, [], HOST_URL . '/?go-to-comment&amp;id=' . $d['id']], 'description' => [true, [], htmlentities($d['preview']) . "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true))], 'pubDate' => [false, [], date(DATE_RSS, time() - $d['elapsed'])], 'guid' => [false, [], HOST_URL . '/?go-to-comment&amp;id=' . $d['id']]);
                 }
             } else {
                 $this->lvTabs[] = ['commentpreview', ['data' => $data]];
             }
             break;
         case 'latest-screenshots':
             // rss
             $data = CommunityContent::getScreenshots();
             if ($this->rss) {
                 foreach ($data as $d) {
                     $desc = '<a href="' . HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id'] . '"><img src="' . STATIC_URL . '/uploads/screenshots/thumb/' . $d['id'] . '.jpg" alt="" /></a>';
                     if ($d['caption']) {
                         $desc .= '<br />' . $d['caption'];
                     }
                     $desc .= "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true));
                     // enclosure/length => filesize('static/uploads/screenshots/thumb/'.$d['id'].'.jpg') .. always set to this placeholder value though
                     $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($d['subject'])], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, time() - $d['elapsed'])], 'enclosure' => [false, ['url' => STATIC_URL . '/uploads/screenshots/thumb/' . $d['id'] . '.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], 'guid' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id']]);
                 }
             } else {
                 $this->lvTabs[] = ['screenshot', ['data' => $data]];
             }
             break;
         case 'latest-videos':
             // rss
             $data = CommunityContent::getVideos();
             if ($this->rss) {
                 foreach ($data as $d) {
                     $desc = '<a href="' . HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id'] . '"><img src="//i3.ytimg.com/vi/' . $d['videoId'] . '/default.jpg" alt="" /></a>';
                     if ($d['caption']) {
                         $desc .= '<br />' . $d['caption'];
                     }
                     $desc .= "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true));
                     // is enclosure/length .. is this even relevant..?
                     $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($row['subject'])], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, time() - $row['elapsed'])], 'enclosure' => [false, ['url' => '//i3.ytimg.com/vi/' . $d['videoId'] . '/default.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], 'guid' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id']]);
                 }
             } else {
                 $this->lvTabs[] = ['video', ['data' => $data]];
             }
             break;
         case 'latest-articles':
             // rss
             $this->lvTabs = [];
             break;
         case 'latest-additions':
             // rss
             $extraText = '';
             break;
         case 'unrated-comments':
             $this->lvTabs[] = ['commentpreview', ['data' => []]];
             break;
         case 'missing-screenshots':
             // limit to 200 entries each (it generates faster, consumes less memory and should be enough options)
             $cnd = [[['cuFlags', CUSTOM_HAS_SCREENSHOT, '&'], 0], 200];
             if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
                 $cnd[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
             }
             foreach (Util::$typeClasses as $classStr) {
                 if (!$classStr) {
                     continue;
                 }
                 $typeObj = new $classStr($cnd);
                 if (!$typeObj->error) {
                     $this->extendGlobalData($typeObj->getJSGlobals(GLOBALINFO_ANY));
                     $this->lvTabs[] = [$typeObj::$brickFile, ['data' => array_values($typeObj->getListviewData())]];
                 }
             }
             break;
         case 'most-comments':
             // rss
             if ($this->category && !in_array($this->category[0], [1, 7, 30])) {
                 header('Location: ?most-comments=1' . ($this->rss ? '&rss' : null), true, 302);
             }
             $tabBase = array('extraCols' => ["\$Listview.funcBox.createSimpleCol('ncomments', 'tab_comments', '10%', 'ncomments')"], 'sort' => ['-ncomments']);
             foreach (Util::$typeClasses as $type => $classStr) {
                 if (!$classStr) {
                     continue;
                 }
                 $comments = DB::Aowow()->selectCol('
                     SELECT   `typeId` AS ARRAY_KEY, count(1) FROM ?_comments
                     WHERE    `replyTo` = 0 AND (`flags` & ?d) = 0 AND `type`= ?d AND `date` > (UNIX_TIMESTAMP() - ?d)
                     GROUP BY `type`, `typeId`
                     LIMIT    100', CC_FLAG_DELETED, $type, (isset($this->category[0]) ? $this->category[0] : 1) * DAY);
                 if (!$comments) {
                     continue;
                 }
                 $typeClass = new $classStr(array(['id', array_keys($comments)]));
                 if (!$typeClass->error) {
                     $data = $typeClass->getListviewData();
                     if ($this->rss) {
                         foreach ($data as $typeId => &$d) {
                             $this->feedData[] = array('title' => [true, [], htmlentities(Util::$typeStrings[$type] == 'item' ? mb_substr($d['name'], 1) : $d['name'])], 'type' => [false, [], Util::$typeStrings[$type]], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$type] . '=' . $d['id']], 'ncomments' => [false, [], $comments[$typeId]]);
                         }
                     } else {
                         foreach ($data as $typeId => &$d) {
                             $d['ncomments'] = $comments[$typeId];
                         }
                         $this->extendGlobalData($typeClass->getJSGlobals(GLOBALINFO_ANY));
                         $this->lvTabs[] = [$typeClass::$brickFile, array_merge($tabBase, ['data' => array_values($data)])];
                     }
                 }
             }
             break;
     }
     // found nothing => set empty content
     // tpl: commentpreview - anything, doesn't matter what
     if (!$this->lvTabs && !$this->rss) {
         $this->lvTabs[] = ['commentpreview', ['data' => []]];
     }
 }
Пример #18
0
 /**
  * Registers the .seen-command in the commands-module for use in-game
  *
  * @param Commands $moduleManager Object so the command can be registered in the commands-module
  */
 public static function addSeenCommand(Commands $moduleManager)
 {
     $moduleManager->registerCommand(new \Command('.seen', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (stringH::IsNullOrWhiteSpace($aParams[0]) || count($aParams) != 1) {
             echo '!msg * Usage: .seen <username>';
         } else {
             $oLastSeenPerson = self::getPersonSeenData('lvp_person_last_seen_id', $aParams[0]);
             if (!stringH::IsNullOrWhiteSpace($oLastSeenPerson->lvp_person_last_seen_id)) {
                 if ($oLastSeenPerson->sReason != 'online') {
                     echo stringH::Format('!msg {0} was last seen online {1}{2}.', $oLastSeenPerson->lvp_person_last_seen_id, date('H:i:s @ d-m-Y', $oLastSeenPerson->iTime), $oLastSeenPerson->sReason);
                 } else {
                     echo stringH::Format('!msg {0} is already online for {1}.', $oLastSeenPerson->lvp_person_last_seen_id, \Util::formatTime(time() - $oLastSeenPerson->iTime));
                 }
             } else {
                 echo '!msg * Error: Sorry, this username has not (yet) been found.';
             }
         }
     }));
 }