コード例 #1
0
ファイル: Format.php プロジェクト: ngangchill/templater
 public function toListLinks($collection, $key, $route, ...$route_params)
 {
     $list = new ItemList($collection, $key);
     $list->setRoute($route);
     $list->setRouteParams($route_params);
     return (string) $list->links();
 }
コード例 #2
0
ファイル: PageHome.php プロジェクト: aimxhaisse/kenavo
function PageHome(&$skeleton)
{
    $articles = Entities::retrieveGroupedEntities(ARTICLES);
    $itemlist = new ItemList($skeleton);
    $itemlist->setBorders(array('top' => '-', 'bottom' => '-', 'left' => '+', 'right' => '+'));
    $ascii_article = new Article($skeleton, current($articles));
    $skeleton->addWidget($ascii_article);
    $count = 0;
    while ($article = next($articles)) {
        ++$count;
        $text = "";
        $text .= "[url=";
        $text .= Common::urlFor('view_article', array('token' => $article->getToken())) . ']';
        $text .= "[b]" . $article->getCategory() . "[/b]";
        $text .= "/" . $article->getTitle() . '[/url]';
        $text .= " (" . $article->getDate() . ")";
        if ($count < count($articles) - 1) {
            $text .= "\n";
        }
        $itemlist->setText($text);
    }
    if ($count > 0) {
        $skeleton->addWidget($itemlist);
    }
}
コード例 #3
0
ファイル: donate.php プロジェクト: kayecandy/secudev
function test()
{
    global $apiContext;
    // IncludeConfig('paypal/bootstrap.php');
    $payer = new Payer();
    $payer->setPaymentMethod("paypal");
    $item1 = new Item();
    $item1->setName('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setPrice(7.5);
    $item2 = new Item();
    $item2->setName('Granola bars')->setCurrency('USD')->setQuantity(5)->setPrice(2);
    $itemList = new ItemList();
    $itemList->setItems(array($item1, $item2));
    $details = new Details();
    $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5);
    $amount = new Amount();
    $amount->setCurrency("USD")->setTotal(20)->setDetails($details);
    $transaction = new Transaction();
    $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid());
    $baseUrl = getBaseUrl();
    $redirectUrls = new RedirectUrls();
    $redirectUrls->setReturnUrl("{$baseUrl}/donate.php/execute_payment_test?success=true")->setCancelUrl("{$baseUrl}/donate.php/execute_payment_test?success=false");
    $payment = new Payment();
    $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction));
    $request = clone $payment;
    try {
        $payment->create($apiContext);
    } catch (Exception $ex) {
        ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
        exit(1);
    }
    $approvalUrl = $payment->getApprovalLink();
    ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='{$approvalUrl}' >{$approvalUrl}</a>", $request, $payment);
    return $payment;
}
コード例 #4
0
ファイル: PageStat.php プロジェクト: aimxhaisse/kenavo
function PageStat(&$skeleton)
{
    $itemlist = new ItemList($skeleton);
    $db = Stat::loadDb();
    $itemlist->setBorders(array('top' => '-', 'bottom' => '-', 'left' => '+', 'right' => '+'));
    $itemlist->setText("Number of page viewed: " . $db['total_pages']);
    $skeleton->addWidget($itemlist);
}
コード例 #5
0
 /**
  * @static
  *
  * @param array $items
  *
  * @return \Math\StatIndex\ItemList
  */
 public static function fromArray(array $items)
 {
     $list = new ItemList();
     foreach ($items as $name => $item) {
         $importance = isset($item['importance']) ? floatval($item['importance']) : 1.0;
         $list->addItem(new Item((string) $name, $item['value'], $item['quantity'], $importance));
     }
     return $list;
 }
コード例 #6
0
ファイル: PackedBoxTest.php プロジェクト: adallaway/BoxPacker
 function testVolumeUtilisation()
 {
     $box = new TestBox('Box', 10, 10, 10, 10, 10, 10, 10, 10);
     $item = new TestItem('Item', 5, 10, 10, 10);
     $boxItems = new ItemList();
     $boxItems->insert($item);
     $packedBox = new PackedBox($box, $boxItems, 1, 2, 3, 4);
     self::assertEquals(50, $packedBox->getVolumeUtilisation());
 }
コード例 #7
0
 function testWeightVariance()
 {
     $box = new TestBox('Box', 10, 10, 10, 10, 10, 10, 10, 10);
     $item = new TestItem('Item', 5, 10, 10, 10, true);
     $boxItems = new ItemList();
     $boxItems->insert($item);
     $packedBox = new PackedBox($box, $boxItems, 1, 2, 3, 4);
     $packedBoxList = new PackedBoxList();
     $packedBoxList->insert($packedBox);
     self::assertEquals(0, $packedBoxList->getWeightVariance());
 }
コード例 #8
0
 /**
  * @param \Math\StatIndex\ItemList $current
  * @param \Math\StatIndex\ItemList $reference
  *
  * @return bool
  * @throws \Math\StatIndex\StatIndexException
  */
 public function setCurrentAndReferenceData(ItemList $current, ItemList $reference)
 {
     // validate lists
     $sizeCheck = $current->size() === $reference->size();
     $diff = array_diff($current->getItemsNames(), $reference->getItemsNames());
     $namesCheck = empty($diff);
     $this->_validData = $sizeCheck && $namesCheck;
     $this->validData();
     // raise an exception if something is amiss
     $this->_indexes = array();
     $this->_currList = $current;
     $this->_itemNames = $current->getItemsNames();
     $this->_refList = $reference;
     return $this->_validData;
 }
コード例 #9
0
ファイル: PageSearch.php プロジェクト: aimxhaisse/kenavo
function SearchArticles($pattern, $skeleton)
{
    $matches = 0;
    $articles = Entities::retrieveGroupedEntities(ARTICLES);
    $itemlist = new ItemList($skeleton);
    foreach ($articles as $article) {
        if (stristr($article->getContent(), $pattern)) {
            ++$matches;
            $link = Common::urlFor('view_article', array('token' => $article->getToken()));
            $itemlist->setText('<a href="' . $link . '">' . $article->getTitle() . '</a>');
        }
    }
    $skeleton->addWidget($itemlist);
    return $matches;
}
コード例 #10
0
ファイル: ajax.php プロジェクト: nerdling/gregarius
function __exp__getFeedContent($cid)
{
    $cid = sanitize($cid, RSS_SANITIZER_NUMERIC);
    ob_start();
    rss_require('cls/items.php');
    $readItems = new ItemList();
    $readItems->populate(" not(i.unread & " . RSS_MODE_UNREAD_STATE . ") and i.cid= {$cid}", "", 0, 2, ITEM_SORT_HINT_READ);
    $readItems->setTitle(__('Recent items'));
    $readItems->setRenderOptions(IL_TITLE_NO_ESCAPE);
    foreach ($readItems->feeds[0]->items as $item) {
        $item->render();
    }
    $c = ob_get_contents();
    ob_end_clean();
    return "{$cid}|@|{$c}";
}
コード例 #11
0
 public function testWeightRedistribution()
 {
     $box = new TestBox('Box', 370, 375, 60, 140, 364, 374, 40, 3000);
     $boxList = new BoxList();
     $boxList->insert($box);
     $item1 = new TestItem('Item #1', 230, 330, 6, 320, true);
     $item2 = new TestItem('Item #2', 210, 297, 5, 187, true);
     $item3 = new TestItem('Item #3', 210, 297, 11, 674, true);
     $item4 = new TestItem('Item #4', 210, 297, 3, 82, true);
     $item5 = new TestItem('Item #5', 206, 295, 4, 217, true);
     $box1Items = new ItemList();
     $box1Items->insert(clone $item1);
     $box1Items->insert(clone $item1);
     $box1Items->insert(clone $item1);
     $box1Items->insert(clone $item1);
     $box1Items->insert(clone $item1);
     $box1Items->insert(clone $item1);
     $box1Items->insert(clone $item5);
     $box2Items = new ItemList();
     $box2Items->insert(clone $item3);
     $box2Items->insert(clone $item1);
     $box2Items->insert(clone $item1);
     $box2Items->insert(clone $item1);
     $box2Items->insert(clone $item1);
     $box2Items->insert(clone $item2);
     $box3Items = new ItemList();
     $box3Items->insert(clone $item5);
     $box3Items->insert(clone $item4);
     $packedBox1 = new PackedBox($box, $box1Items, 0, 0, 0, 0);
     $packedBox2 = new PackedBox($box, $box2Items, 0, 0, 0, 0);
     $packedBox3 = new PackedBox($box, $box3Items, 0, 0, 0, 0);
     $packedBoxList = new PackedBoxList();
     $packedBoxList->insert($packedBox1);
     $packedBoxList->insert($packedBox2);
     $packedBoxList->insert($packedBox3);
     $redistributor = new WeightRedistributor($boxList);
     $packedBoxes = $redistributor->redistributeWeight($packedBoxList);
     $packedItemCount = 0;
     foreach (clone $packedBoxes as $packedBox) {
         $packedItemCount += $packedBox->getItems()->count();
     }
     self::assertEquals(3070, (int) $packedBoxes->getWeightVariance());
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $field = DropdownField::create('ItemListID', 'Item list to display', ItemList::get()->map()->toArray())->setEmptyString('--choose list--');
     $fields->addFieldToTab('Root.Main', $field, 'Content');
     if ($this->hasField('TemplateID')) {
         $fields->addFieldToTab('Root.Main', $df = DropdownField::create('TemplateID', 'Template for rendering items', UserTemplate::get()->map()->toArray()), 'Content');
         $df->setEmptyString('--template--');
     }
     return $fields;
 }
コード例 #13
0
ファイル: item_stats.func.php プロジェクト: Carbenium/aowow
 public function __construct($start, $limit, array $ids)
 {
     $this->statCols = DB::Aowow()->selectCol('SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` LIKE "%item_stats"');
     $this->queryOpts['i']['o'] = 'i.id ASC';
     unset($this->queryOpts['is']);
     // do not reference the stats table we are going to write to
     $conditions = array(['i.id', $start, '>'], ['class', [ITEM_CLASS_WEAPON, ITEM_CLASS_GEM, ITEM_CLASS_ARMOR, ITEM_CLASS_CONSUMABLE]], $limit);
     if ($ids) {
         $conditions[] = ['id', $ids];
     }
     parent::__construct($conditions);
 }
コード例 #14
0
ファイル: compare.php プロジェクト: Carbenium/aowow
 protected function generateContent()
 {
     // add conditional js
     $this->addJS('?data=weight-presets.gems.enchants.itemsets&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     if (!$this->compareString) {
         return;
     }
     $sets = explode(';', $this->compareString);
     $items = $outSet = [];
     foreach ($sets as $set) {
         $itemSting = explode(':', $set);
         $outString = [];
         foreach ($itemSting as $substring) {
             $params = explode('.', $substring);
             $items[] = (int) $params[0];
             while (sizeof($params) < 7) {
                 $params[] = 0;
             }
             $outString[] = $params;
         }
         $outSet[] = $outString;
     }
     $this->summary = $outSet;
     $iList = new ItemList(array(['i.id', $items]));
     $data = $iList->getListviewData(ITEMINFO_SUBITEMS | ITEMINFO_JSON);
     foreach ($iList->iterate() as $itemId => $__) {
         if (empty($data[$itemId])) {
             continue;
         }
         $this->cmpItems[] = [$itemId, $iList->getField('name', true), $iList->getField('quality'), $iList->getField('iconString'), $data[$itemId]];
     }
 }
コード例 #15
0
ファイル: PluginController.php プロジェクト: elvyrra/hawk
 /**
  * Display the list of available plugins on the file system
  */
 public function availablePlugins()
 {
     $plugins = Plugin::getAll(false, true);
     $api = new HawkApi();
     try {
         $updates = $api->getPluginsAvailableUpdates(array_map(function ($plugin) {
             return $plugin->getDefinition('version');
         }, $plugins));
     } catch (\Hawk\HawkApiException $e) {
         $updates = array();
     }
     $list = new ItemList(array('id' => 'available-plugins-list', 'reference' => 'name', 'action' => App::router()->getUri('plugins-list'), 'data' => $plugins, 'controls' => array(array('icon' => 'plus', 'class' => 'btn-success', 'label' => Lang::get($this->_plugin . '.new-plugin-btn'), 'href' => App::router()->getUri('create-plugin'), 'target' => 'dialog')), 'fields' => array('controls' => array('display' => function ($value, $field, $plugin) use($updates) {
         $buttons = array();
         $installer = $plugin->getInstallerInstance();
         if (!$plugin->isInstalled()) {
             // the plugin is not installed
             $buttons = array(ButtonInput::create(array('title' => Lang::get($this->_plugin . '.install-plugin-button'), 'icon' => 'upload', 'class' => 'install-plugin', 'href' => App::router()->getUri('install-plugin', array('plugin' => $plugin->getName())))), !$plugin->isMandatoryDependency() ? ButtonInput::create(array('title' => Lang::get($this->_plugin . '.delete-plugin-button'), 'icon' => 'trash', 'class' => 'btn-danger delete-plugin', 'href' => App::router()->getUri('delete-plugin', array('plugin' => $plugin->getName())))) : '');
             $status = Lang::get($this->_plugin . '.plugin-uninstalled-status');
         } else {
             if (!$plugin->isActive()) {
                 // The plugin is installed but not activated
                 $buttons = array(ButtonInput::create(array('title' => Lang::get($this->_plugin . '.activate-plugin-button'), 'class' => 'btn-success activate-plugin', 'icon' => 'check', 'href' => App::router()->getUri('activate-plugin', array('plugin' => $plugin->getName())))), method_exists($installer, 'settings') ? ButtonInput::create(array('icon' => 'cogs', 'title' => Lang::get($this->_plugin . '.plugin-settings-button'), 'href' => App::router()->getUri('plugin-settings', array('plugin' => $plugin->getName())), 'target' => 'dialog', 'class' => 'btn-info')) : '', !$plugin->isMandatoryDependency() ? ButtonInput::create(array('title' => Lang::get($this->_plugin . '.uninstall-plugin-button'), 'class' => 'btn-danger uninstall-plugin', 'icon' => 'chain-broken', 'href' => App::router()->getUri('uninstall-plugin', array('plugin' => $plugin->getName())))) : '');
                 $status = Lang::get($this->_plugin . '.plugin-inactive-status');
             } else {
                 // The plugin is installed and active
                 $buttons = array(method_exists($installer, 'settings') ? ButtonInput::create(array('icon' => 'cogs', 'title' => Lang::get($this->_plugin . '.plugin-settings-button'), 'href' => App::router()->getUri('plugin-settings', array('plugin' => $plugin->getName())), 'target' => 'dialog', 'class' => 'btn-info')) : '', ButtonInput::create(array('title' => Lang::get($this->_plugin . '.deactivate-plugin-button'), 'class' => 'btn-warning deactivate-plugin', 'icon' => 'ban', 'href' => App::router()->getUri('deactivate-plugin', array('plugin' => $plugin->getName())))));
                 $status = Lang::get($this->_plugin . '.plugin-active-status');
             }
         }
         if (isset($updates[$plugin->getName()])) {
             array_unshift($buttons, ButtonInput::create(array('icon' => 'refresh', 'class' => 'btn-info update-plugin', 'title' => Lang::get($this->_plugin . '.update-plugin-button'), 'href' => App::router()->getUri('update-plugin', array('plugin' => $plugin->getName())))));
         }
         return View::make(Plugin::current()->getView('plugin-list-controls.tpl'), array('plugin' => $plugin, 'status' => $status, 'buttons' => $buttons));
     }, 'label' => Lang::get($this->_plugin . '.plugins-list-controls-label'), 'search' => false, 'sort' => false), 'description' => array('search' => false, 'sort' => false, 'label' => Lang::get($this->_plugin . '.plugins-list-description-label'), 'display' => function ($value, $field, $plugin) {
         return View::make(Plugin::current()->getView("plugin-list-description.tpl"), $plugin->getDefinition());
     }))));
     return $list->display();
 }
コード例 #16
0
ファイル: LinksList.php プロジェクト: ponticlaro/bebop-ui
 /**
  * Applies module defaults
  * 
  * @return void
  */
 protected function __init()
 {
     parent::__init();
     $this->setVars(['config.labels.add_button' => 'Add Link', 'before' => '<div class="bebop-ui-mod bebop-ui-mod-list bebop-ui-mod-list-linkslist">', 'item_views' => ['browse' => [['ui' => 'rawHtml', 'html' => '
           {{#link}}
             <a href="{{link}}" target="_blank">
               {{#title}}{{title}}{{/title}}
               {{^title}}
                 {{#link}}{{link}}{{/link}}
                 {{^link}}<em>No link or title to display</em>{{/link}}
               {{/title}}
             </a>
           {{/link}}
           {{^link}}
             <em>No link to display</em>
           {{/link}}']], 'edit' => [['ui' => 'input', 'label' => 'Title'], ['ui' => 'input', 'label' => 'Link'], ['ui' => 'checkbox', 'name' => 'open_in_new_window', 'options' => [['label' => 'Open in new window', 'value' => '1']]]]]]);
 }
コード例 #17
0
ファイル: ItemListTest.php プロジェクト: dvdoug/boxpacker
 function testCompare()
 {
     $box1 = new TestItem('Small', 20, 20, 2, 100, true);
     $box2 = new TestItem('Large', 200, 200, 20, 1000, true);
     $box3 = new TestItem('Medium', 100, 100, 10, 500, true);
     $list = new ItemList();
     $list->insert($box1);
     $list->insert($box2);
     $list->insert($box3);
     $sorted = [];
     while (!$list->isEmpty()) {
         $sorted[] = $list->extract();
     }
     self::assertEquals(array($box2, $box3, $box1), $sorted);
 }
コード例 #18
0
ファイル: spell.php プロジェクト: Niknox/aowow
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     $_cat = $this->subject->getField('typeCat');
     $redButtons = array(BUTTON_LINKS => ['color' => 'ff71d5ff', 'linkId' => Util::$typeStrings[TYPE_SPELL] . ':' . $this->typeId], BUTTON_VIEW3D => false, BUTTON_WOWHEAD => true);
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // level
     if (!in_array($_cat, [-5, -6])) {
         if ($_ = $this->subject->getField('talentLevel')) {
             $infobox[] = in_array($_cat, [-2, 7, -13]) ? sprintf(Lang::game('reqLevel'), $_) : Lang::game('level') . Lang::main('colon') . $_;
         } else {
             if ($_ = $this->subject->getField('spellLevel')) {
                 $infobox[] = in_array($_cat, [-2, 7, -13]) ? sprintf(Lang::game('reqLevel'), $_) : Lang::game('level') . Lang::main('colon') . $_;
             }
         }
     }
     // races
     if ($_ = Lang::getRaceString($this->subject->getField('reqRaceMask'), $__, $jsg, $n, false)) {
         if ($_ != Lang::game('ra', 0)) {
             $this->extendGlobalIds(TYPE_RACE, $jsg);
             $t = $n == 1 ? Lang::game('race') : Lang::game('races');
             $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $_;
         }
     }
     // classes
     if ($_ = Lang::getClassString($this->subject->getField('reqClassMask'), $jsg, $n, false)) {
         $this->extendGlobalIds(TYPE_CLASS, $jsg);
         $t = $n == 1 ? Lang::game('class') : Lang::game('classes');
         $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $_;
     }
     // spell focus
     if ($_ = $this->subject->getField('spellFocusObject')) {
         $bar = DB::Aowow()->selectRow('SELECT * FROM ?_spellfocusobject WHERE id = ?d', $_);
         $focus = new GameObjectList(array(['spellFocusId', $_], 1));
         $infobox[] = Lang::game('requires2') . ' ' . ($focus->error ? Util::localizedString($bar, 'name') : '[url=?object=' . $focus->id . ']' . Util::localizedString($bar, 'name') . '[/url]');
     }
     // primary & secondary trades
     if (in_array($_cat, [9, 11])) {
         // skill
         if ($_ = $this->subject->getField('skillLines')[0]) {
             $rSkill = new SkillList(array(['id', $_]));
             if (!$rSkill->error) {
                 $this->extendGlobalData($rSkill->getJSGlobals());
                 $bar = sprintf(Lang::game('requires'), '&nbsp;[skill=' . $rSkill->id . ']');
                 if ($_ = $this->subject->getField('learnedAt')) {
                     $bar .= ' (' . $_ . ')';
                 }
                 $infobox[] = $bar;
             }
         }
         // specialization
         if ($_ = $this->subject->getField('reqSpellId')) {
             $rSpell = new SpellList(array(['id', $_]));
             if (!$rSpell->error) {
                 $this->extendGlobalData($rSpell->getJSGlobals());
                 $infobox[] = Lang::game('requires2') . ' [spell=' . $rSpell->id . '][/li]';
             }
         }
         // difficulty
         if ($_ = $this->subject->getColorsForCurrent()) {
             $bar = [];
             for ($i = 0; $i < 4; $i++) {
                 if ($_[$i]) {
                     $bar[] = '[color=r' . ($i + 1) . ']' . $_[$i] . '[/color]';
                 }
             }
             $infobox[] = Lang::game('difficulty') . Lang::main('colon') . implode(' ', $bar);
         }
     }
     // accquisition..   10: starter spell; 7: discovery
     if (isset($this->subject->sources[$this->subject->id][10])) {
         $infobox[] = Lang::spell('starter');
     } else {
         if (isset($this->subject->sources[$this->subject->id][7])) {
             $infobox[] = Lang::spell('discovered');
         }
     }
     // training cost
     if ($cost = $this->subject->getField('trainingCost')) {
         $infobox[] = Lang::spell('trainingCost') . Lang::main('colon') . '[money=' . $cost . '][/li]';
     }
     // used in mode
     foreach ($this->difficulties as $n => $id) {
         if ($id == $this->typeId) {
             // "Mode" seems to be multilingual acceptable
             $infobox[] = 'Mode' . Lang::main('colon') . Lang::game('modes', $n);
         }
     }
     $effects = $this->createEffects($infobox, $redButtons);
     // spell script
     if (User::isInGroup(U_GROUP_STAFF)) {
         if ($_ = DB::World()->selectCell('SELECT ScriptName FROM spell_script_names WHERE ABS(spell_id) = ?d', $this->firstRank)) {
             $infobox[] = 'Script' . Lang::main('colon') . $_;
         }
     }
     $infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : '';
     // append glyph symbol if available
     $glyphId = 0;
     for ($i = 1; $i < 4; $i++) {
         if ($this->subject->getField('effect' . $i . 'Id') == 74) {
             $glyphId = $this->subject->getField('effect' . $i . 'MiscValue');
         }
     }
     if ($_ = DB::Aowow()->selectCell('SELECT si.iconString FROM ?_glyphproperties gp JOIN ?_icons si ON gp.iconId = si.id WHERE gp.spellId = ?d { OR gp.id = ?d }', $this->typeId, $glyphId ?: DBSIMPLE_SKIP)) {
         if (file_exists('static/images/wow/Interface/Spellbook/' . $_ . '.png')) {
             $infobox .= '[img src=' . STATIC_URL . '/images/wow/Interface/Spellbook/' . $_ . '.png border=0 float=center margin=15]';
         }
     }
     /****************/
     /* Main Content */
     /****************/
     $this->reagents = $this->createReagentList();
     $this->scaling = $this->createScalingData();
     $this->items = $this->createRequiredItems();
     $this->tools = $this->createTools();
     $this->effects = $effects;
     $this->infobox = $infobox;
     $this->powerCost = $this->subject->createPowerCostForCurrent();
     $this->castTime = $this->subject->createCastTimeForCurrent(false, false);
     $this->name = $this->subject->getField('name', true);
     $this->headIcons = [$this->subject->getField('iconString'), $this->subject->getField('stackAmount')];
     $this->level = $this->subject->getField('spellLevel');
     $this->rangeName = $this->subject->getField('rangeText', true);
     $this->range = $this->subject->getField('rangeMaxHostile');
     $this->gcd = Util::formatTime($this->subject->getField('startRecoveryTime'));
     $this->gcdCat = null;
     // todo (low): nyi; find out how this works [n/a; normal; ..]
     $this->school = [Util::asHex($this->subject->getField('schoolMask')), Lang::getMagicSchools($this->subject->getField('schoolMask'))];
     $this->dispel = $this->subject->getField('dispelType') ? Lang::game('dt', $this->subject->getField('dispelType')) : null;
     $this->mechanic = $this->subject->getField('mechanic') ? Lang::game('me', $this->subject->getField('mechanic')) : null;
     $this->unavailable = $this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE;
     $this->redButtons = $redButtons;
     // minRange exists..  prepend
     if ($_ = $this->subject->getField('rangeMinHostile')) {
         $this->range = $_ . ' - ' . $this->range;
     }
     if ($this->subject->getField('attributes2') & 0x80000) {
         $this->stances = Lang::getStances($this->subject->getField('stanceMask'));
     }
     if (($_ = $this->subject->getField('recoveryTime')) && $_ > 0) {
         $this->cooldown = Util::formatTime($_);
     }
     if (($_ = $this->subject->getField('duration')) && $_ > 0) {
         $this->duration = Util::formatTime($_);
     }
     // factionchange-equivalent
     if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_spells WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) {
         $altSpell = new SpellList(array(['id', abs($pendant)]));
         if (!$altSpell->error) {
             $this->transfer = sprintf(Lang::spell('_transfer'), $altSpell->id, 1, $altSpell->getField('iconString'), $altSpell->getField('name', true), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2));
         }
     }
     /**************/
     /* Extra Tabs */
     /**************/
     $j = [null, 'A', 'B', 'C'];
     // tab: abilities [of shapeshift form]
     for ($i = 1; $i < 4; $i++) {
         if ($this->subject->getField('effect' . $i . 'AuraId') != 36) {
             continue;
         }
         $formSpells = DB::Aowow()->selectRow('SELECT spellId1, spellId2, spellId3, spellId4, spellId5, spellId6, spellId7, spellId8 FROM ?_shapeshiftforms WHERE id = ?d', $this->subject->getField('effect' . $i . 'MiscValue'));
         if (!$formSpells) {
             continue;
         }
         $abilities = new SpellList(array(['id', $formSpells]));
         if (!$abilities->error) {
             if (!$abilities->hasSetFields(['skillLines'])) {
                 $abH = "\$['skill']";
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $abilities->getListviewData(), 'params' => array('id' => 'controlledabilities', 'name' => '$LANG.tab_controlledabilities', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($abH) ? $abH : null));
             $this->extendGlobalData($abilities->getJSGlobals(GLOBALINFO_SELF));
         }
     }
     // tab: modifies $this
     $sub = ['OR'];
     $conditions = [['s.typeCat', [0, -9, -8], '!'], ['s.spellFamilyId', $this->subject->getField('spellFamilyId')], &$sub];
     for ($i = 1; $i < 4; $i++) {
         // Flat Mods (107), Pct Mods (108), No Reagent Use (256) .. include dummy..? (4)
         if (!in_array($this->subject->getField('effect' . $i . 'AuraId'), [107, 108, 256, 286])) {
             continue;
         }
         $m1 = $this->subject->getField('effect1SpellClassMask' . $j[$i]);
         $m2 = $this->subject->getField('effect2SpellClassMask' . $j[$i]);
         $m3 = $this->subject->getField('effect3SpellClassMask' . $j[$i]);
         if (!$m1 && !$m2 && !$m3) {
             continue;
         }
         $sub[] = ['s.spellFamilyFlags1', $m1, '&'];
         $sub[] = ['s.spellFamilyFlags2', $m2, '&'];
         $sub[] = ['s.spellFamilyFlags3', $m3, '&'];
     }
     if (count($sub) > 1) {
         $modSpells = new SpellList($conditions);
         if (!$modSpells->error) {
             if (!$modSpells->hasSetFields(['skillLines'])) {
                 $msH = "\$['skill']";
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $modSpells->getListviewData(), 'params' => array('id' => 'modifies', 'name' => '$LANG.tab_modifies', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($msH) ? $msH : null));
             $this->extendGlobalData($modSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         }
     }
     // tab: modified by $this
     $sub = ['OR'];
     $conditions = [['s.spellFamilyId', $this->subject->getField('spellFamilyId')], &$sub];
     for ($i = 1; $i < 4; $i++) {
         $m1 = $this->subject->getField('spellFamilyFlags1');
         $m2 = $this->subject->getField('spellFamilyFlags2');
         $m3 = $this->subject->getField('spellFamilyFlags3');
         if (!$m1 && !$m2 && !$m3) {
             continue;
         }
         $sub[] = array('AND', ['s.effect' . $i . 'AuraId', [107, 108, 256, 286]], ['OR', ['s.effect1SpellClassMask' . $j[$i], $m1, '&'], ['s.effect2SpellClassMask' . $j[$i], $m2, '&'], ['s.effect3SpellClassMask' . $j[$i], $m3, '&']]);
     }
     if (count($sub) > 1) {
         $modsSpell = new SpellList($conditions);
         if (!$modsSpell->error) {
             if (!$modsSpell->hasSetFields(['skillLines'])) {
                 $mbH = "\$['skill']";
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $modsSpell->getListviewData(), 'params' => array('id' => 'modified-by', 'name' => '$LANG.tab_modifiedby', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($mbH) ? $mbH : null));
             $this->extendGlobalData($modsSpell->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         }
     }
     // tab: see also
     $conditions = array(['s.schoolMask', $this->subject->getField('schoolMask')], ['s.effect1Id', $this->subject->getField('effect1Id')], ['s.effect2Id', $this->subject->getField('effect2Id')], ['s.effect3Id', $this->subject->getField('effect3Id')], ['s.id', $this->subject->id, '!'], ['s.name_loc' . User::$localeId, $this->subject->getField('name', true)]);
     $saSpells = new SpellList($conditions);
     if (!$saSpells->error) {
         $data = $saSpells->getListviewData();
         if ($this->difficulties) {
             $saE = '$[Listview.extraCols.mode]';
             foreach ($data as $id => &$d) {
                 $d['modes'] = ['mode' => 0];
                 if ($this->difficulties[0] == $id) {
                     if (!$this->difficulties[2] && !$this->difficulties[3]) {
                         $d['modes']['mode'] |= 0x2;
                     } else {
                         $d['modes']['mode'] |= 0x8;
                     }
                 }
                 if ($this->difficulties[1] == $id) {
                     if (!$this->difficulties[2] && !$this->difficulties[3]) {
                         $d['modes']['mode'] |= 0x1;
                     } else {
                         $d['modes']['mode'] |= 0x10;
                     }
                 }
                 if ($this->difficulties[2] == $id) {
                     // b0100000
                     $d['modes']['mode'] |= 0x20;
                 }
                 if ($this->difficulties[3] == $id) {
                     // b1000000
                     $d['modes']['mode'] |= 0x40;
                 }
             }
         }
         if (!$saSpells->hasSetFields(['skillLines'])) {
             $saH = "\$['skill']";
         }
         $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso', 'visibleCols' => "\$['level']", 'extraCols' => isset($saE) ? $saE : null, 'hiddenCols' => isset($saH) ? $saH : null));
         $this->extendGlobalData($saSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     }
     // tab: used by - itemset
     $conditions = array('OR', ['spell1', $this->subject->id], ['spell2', $this->subject->id], ['spell3', $this->subject->id], ['spell4', $this->subject->id], ['spell5', $this->subject->id], ['spell6', $this->subject->id], ['spell7', $this->subject->id], ['spell8', $this->subject->id]);
     $ubSets = new ItemsetList($conditions);
     if (!$ubSets->error) {
         $this->lvTabs[] = array('file' => 'itemset', 'data' => $ubSets->getListviewData(), 'params' => array('id' => 'used-by-itemset', 'name' => '$LANG.tab_usedby'));
         $this->extendGlobalData($ubSets->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     }
     // tab: used by - item
     $conditions = array('OR', ['AND', ['spellTrigger1', 6, '!'], ['spellId1', $this->subject->id]], ['AND', ['spellTrigger2', 6, '!'], ['spellId2', $this->subject->id]], ['AND', ['spellTrigger3', 6, '!'], ['spellId3', $this->subject->id]], ['AND', ['spellTrigger4', 6, '!'], ['spellId4', $this->subject->id]], ['AND', ['spellTrigger5', 6, '!'], ['spellId5', $this->subject->id]]);
     $ubItems = new ItemList($conditions);
     if (!$ubItems->error) {
         $this->lvTabs[] = array('file' => 'item', 'data' => $ubItems->getListviewData(), 'params' => array('id' => 'used-by-item', 'name' => '$LANG.tab_usedby'));
         $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: used by - object
     $conditions = array('OR', ['onUseSpell', $this->subject->id], ['onSuccessSpell', $this->subject->id], ['auraSpell', $this->subject->id], ['triggeredSpell', $this->subject->id]);
     $ubObjects = new GameObjectList($conditions);
     if (!$ubObjects->error) {
         $this->lvTabs[] = array('file' => 'object', 'data' => $ubObjects->getListviewData(), 'params' => array('id' => 'used-by-object', 'name' => '$LANG.tab_usedby'));
         $this->extendGlobalData($ubObjects->getJSGlobals());
     }
     // tab: criteria of
     $conditions = array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL]], ['ac.value1', $this->typeId]);
     $coAchievemnts = new AchievementList($conditions);
     if (!$coAchievemnts->error) {
         $this->lvTabs[] = array('file' => 'achievement', 'data' => $coAchievemnts->getListviewData(), 'params' => array('id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof'));
         $this->extendGlobalData($coAchievemnts->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     }
     // tab: contains
     // spell_loot_template & skill_extra_item_template
     $extraItem = DB::World()->selectRow('SELECT * FROM skill_extra_item_template WHERE spellid = ?d', $this->subject->id);
     $spellLoot = new Loot();
     if ($spellLoot->getByContainer(LOOT_SPELL, $this->subject->id) || $extraItem) {
         $this->extendGlobalData($spellLoot->jsGlobals);
         $lv = $spellLoot->getResult();
         $extraCols = $spellLoot->extraCols;
         $extraCols[] = 'Listview.extraCols.percent';
         if ($extraItem && $this->subject->canCreateItem()) {
             $foo = $this->subject->relItems->getListviewData();
             for ($i = 1; $i < 4; $i++) {
                 if (($bar = $this->subject->getField('effect' . $i . 'CreateItemId')) && isset($foo[$bar])) {
                     $lv[$bar] = $foo[$bar];
                     $lv[$bar]['percent'] = $extraItem['additionalCreateChance'];
                     $lv[$bar]['condition'][0][$this->typeId][] = [[CND_SPELL, $extraItem['requiredSpecialization']]];
                     $this->extendGlobalIds(TYPE_SPELL, $extraItem['requiredSpecialization']);
                     $extraCols[] = 'Listview.extraCols.condition';
                     if ($max = $extraItem['additionalMaxNum']) {
                         $lv[$bar]['mincount'] = 1;
                         $lv[$bar]['maxcount'] = $max;
                     }
                     break;
                     // skill_extra_item_template can only contain 1 item
                 }
             }
         }
         $this->lvTabs[] = array('file' => 'item', 'data' => $lv, 'params' => array('name' => '$LANG.tab_contains', 'id' => 'contains', 'hiddenCols' => "\$['side', 'slot', 'source', 'reqlevel']", 'extraCols' => '$[' . implode(', ', $extraCols) . ']'));
     }
     // tab: exclusive with
     if ($this->firstRank) {
         $linkedSpells = DB::World()->selectCol('SELECT      IF(sg2.spell_id < 0, sg2.id, sg2.spell_id) AS ARRAY_KEY, IF(sg2.spell_id < 0, sg2.spell_id, sr.stack_rule)
             FROM        spell_group sg1
             JOIN        spell_group sg2
                 ON      (sg1.id = sg2.id OR sg1.id = -sg2.spell_id) AND sg1.spell_id != sg2.spell_id
             LEFT JOIN   spell_group_stack_rules sr
                 ON      sg1.id = sr.group_id
             WHERE       sg1.spell_id = ?d', $this->firstRank);
         if ($linkedSpells) {
             $extraSpells = [];
             foreach ($linkedSpells as $k => $v) {
                 if ($v > 0) {
                     continue;
                 }
                 $extraSpells += DB::World()->selectCol('SELECT      sg2.spell_id AS ARRAY_KEY, sr.stack_rule
                     FROM        spell_group sg1
                     JOIN        spell_group sg2
                         ON      sg2.id = -sg1.spell_id AND sg2.spell_id != ?d
                     LEFT JOIN   spell_group_stack_rules sr
                         ON      sg1.id = sr.group_id
                     WHERE       sg1.id = ?d', $this->firstRank, $k);
                 unset($linkedSpells[$k]);
             }
             $groups = $linkedSpells + $extraSpells;
             $stacks = new SpellList(array(['s.id', array_keys($groups)]));
             if (!$stacks->error) {
                 $data = $stacks->getListviewData();
                 foreach ($data as $k => $d) {
                     $data[$k]['stackRule'] = $groups[$k];
                 }
                 if (!$stacks->hasSetFields(['skillLines'])) {
                     $sH = "\$['skill']";
                 }
                 $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'spell-group-stack', 'name' => 'Stack Group', 'visibleCols' => "\$['stackRules']", 'hiddenCols' => isset($sH) ? $sH : null));
                 $this->extendGlobalData($stacks->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             }
         }
     }
     // tab: linked with
     $rows = DB::World()->select('
         SELECT  spell_trigger AS `trigger`,
                 spell_effect AS effect,
                 type,
                 IF(ABS(spell_effect) = ?d, ABS(spell_trigger), ABS(spell_effect)) AS related
         FROM    spell_linked_spell
         WHERE   ABS(spell_effect) = ?d OR ABS(spell_trigger) = ?d', $this->typeId, $this->typeId, $this->typeId);
     $related = [];
     foreach ($rows as $row) {
         $related[] = $row['related'];
     }
     if ($related) {
         $linked = new SpellList(array(['s.id', $related]));
     }
     if (isset($linked) && !$linked->error) {
         $lv = $linked->getListviewData();
         $data = [];
         foreach ($rows as $r) {
             foreach ($lv as $dk => $d) {
                 if ($r['related'] != $dk) {
                     continue;
                 }
                 $lv[$dk]['linked'] = [$r['trigger'], $r['effect'], $r['type']];
                 $data[] = $lv[$dk];
                 break;
             }
         }
         $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'spell-link', 'name' => 'Linked with', 'hiddenCols' => "\$['skill', 'name']", 'visibleCols' => "\$['linkedTrigger', 'linkedEffect']"));
         $this->extendGlobalData($linked->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
     }
     // tab: triggered by
     $conditions = array('OR', ['AND', ['OR', ['effect1Id', SpellList::$effects['trigger']], ['effect1AuraId', SpellList::$auras['trigger']]], ['effect1TriggerSpell', $this->subject->id]], ['AND', ['OR', ['effect2Id', SpellList::$effects['trigger']], ['effect2AuraId', SpellList::$auras['trigger']]], ['effect2TriggerSpell', $this->subject->id]], ['AND', ['OR', ['effect3Id', SpellList::$effects['trigger']], ['effect3AuraId', SpellList::$auras['trigger']]], ['effect3TriggerSpell', $this->subject->id]]);
     $trigger = new SpellList($conditions);
     if (!$trigger->error) {
         $this->lvTabs[] = array('file' => 'spell', 'data' => $trigger->getListviewData(), 'params' => array('id' => 'triggered-by', 'name' => '$LANG.tab_triggeredby'));
         $this->extendGlobalData($trigger->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: used by - creature
     // SMART_SCRIPT_TYPE_CREATURE = 0; SMART_ACTION_CAST = 11; SMART_ACTION_ADD_AURA = 75; SMART_ACTION_INVOKER_CAST = 85; SMART_ACTION_CROSS_CAST = 86
     $conditions = array('OR', ['spell1', $this->typeId], ['spell2', $this->typeId], ['spell3', $this->typeId], ['spell4', $this->typeId], ['spell5', $this->typeId], ['spell6', $this->typeId], ['spell7', $this->typeId], ['spell8', $this->typeId]);
     if ($_ = DB::World()->selectCol('SELECT entryOrGUID FROM smart_scripts WHERE entryorguid > 0 AND source_type = 0 AND action_type IN (11, 75, 85, 86) AND action_param1 = ?d', $this->typeId)) {
         $conditions[] = ['id', $_];
     }
     $ubCreature = new CreatureList($conditions);
     if (!$ubCreature->error) {
         $this->lvTabs[] = array('file' => 'creature', 'data' => $ubCreature->getListviewData(), 'params' => array('id' => 'used-by-npc', 'name' => '$LANG.tab_usedby'));
         $this->extendGlobalData($ubCreature->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: zone
     if ($areas = DB::World()->select('SELECT * FROM spell_area WHERE spell = ?d', $this->typeId)) {
         $zones = new ZoneList(array(['id', array_column($areas, 'area')]));
         if (!$zones->error) {
             $lvZones = $zones->getListviewData();
             $this->extendGlobalData($zones->getJSGlobals());
             $lv = [];
             $parents = [];
             $extra = false;
             foreach ($areas as $a) {
                 if (empty($lvZones[$a['area']])) {
                     continue;
                 }
                 $condition = [];
                 if ($a['aura_spell']) {
                     $this->extendGlobalIds(TYPE_SPELL, abs($a['aura_spell']));
                     $condition[0][$this->typeId][] = [[$a['aura_spell'] > 0 ? CND_AURA : -CND_AURA, abs($a['aura_spell'])]];
                 }
                 if ($a['quest_start']) {
                     $this->extendGlobalIds(TYPE_QUEST, $a['quest_start']);
                     $group = [];
                     for ($i = 0; $i < 7; $i++) {
                         if (!($a['quest_start_status'] & 1 << $i)) {
                             continue;
                         }
                         if ($i == 0) {
                             $group[] = [CND_QUEST_NONE, $a['quest_start']];
                         } else {
                             if ($i == 1) {
                                 $group[] = [CND_QUEST_COMPLETE, $a['quest_start']];
                             } else {
                                 if ($i == 3) {
                                     $group[] = [CND_QUESTTAKEN, $a['quest_start']];
                                 } else {
                                     if ($i == 6) {
                                         $group[] = [CND_QUESTREWARDED, $a['quest_start']];
                                     }
                                 }
                             }
                         }
                     }
                     if ($group) {
                         $condition[0][$this->typeId][] = $group;
                     }
                 }
                 if ($a['quest_end'] && $a['quest_end'] != $a['quest_start']) {
                     $this->extendGlobalIds(TYPE_QUEST, $a['quest_end']);
                     $group = [];
                     for ($i = 0; $i < 7; $i++) {
                         if (!($a['quest_end_status'] & 1 << $i)) {
                             continue;
                         }
                         if ($i == 0) {
                             $group[] = [-CND_QUEST_NONE, $a['quest_end']];
                         } else {
                             if ($i == 1) {
                                 $group[] = [-CND_QUEST_COMPLETE, $a['quest_end']];
                             } else {
                                 if ($i == 3) {
                                     $group[] = [-CND_QUESTTAKEN, $a['quest_end']];
                                 } else {
                                     if ($i == 6) {
                                         $group[] = [-CND_QUESTREWARDED, $a['quest_end']];
                                     }
                                 }
                             }
                         }
                     }
                     if ($group) {
                         $condition[0][$this->typeId][] = $group;
                     }
                 }
                 if ($a['racemask']) {
                     $foo = [];
                     for ($i = 0; $i < 11; $i++) {
                         if ($a['racemask'] & 1 << $i) {
                             $foo[] = $i + 1;
                         }
                     }
                     $this->extendGlobalIds(TYPE_RACE, $foo);
                     $condition[0][$this->typeId][] = [[CND_RACE, $a['racemask']]];
                 }
                 if ($a['gender'] != 2) {
                     // 2: both
                     $condition[0][$this->typeId][] = [[CND_GENDER, $a['gender'] + 1]];
                 }
                 $row = $lvZones[$a['area']];
                 if ($condition) {
                     $extra = true;
                     $row = array_merge($row, ['condition' => $condition]);
                 }
                 // merge subzones, into one row, if: conditions match && parentZone is shared
                 if ($p = $zones->getEntry($a['area'])['parentArea']) {
                     $parents[] = $p;
                     $row['parentArea'] = $p;
                     $row['subzones'] = [$a['area']];
                 } else {
                     $row['parentArea'] = 0;
                 }
                 $set = false;
                 foreach ($lv as &$v) {
                     if ($v['parentArea'] != $row['parentArea'] && $v['id'] != $row['parentArea']) {
                         continue;
                     }
                     if (empty($v['condition']) xor empty($row['condition'])) {
                         continue;
                     }
                     if (!empty($row['condition']) && !empty($v['condition']) && $v['condition'] != $row['condition']) {
                         continue;
                     }
                     if (!$row['parentArea'] && $v['id'] != $row['parentArea']) {
                         continue;
                     }
                     $set = true;
                     $v['subzones'][] = $row['id'];
                     break;
                 }
                 // add self as potential subzone; IF we are a parentZone without added children, we get filtered in JScript
                 if (!$set) {
                     $row['subzones'] = [$row['id']];
                     $lv[] = $row;
                 }
             }
             // overwrite lvData with parent-lvData (condition and subzones are kept)
             if ($parents) {
                 $parents = (new ZoneList(array(['id', $parents])))->getListviewData();
                 foreach ($lv as &$_) {
                     if (isset($parents[$_['parentArea']])) {
                         $_ = array_merge($_, $parents[$_['parentArea']]);
                     }
                 }
             }
             $this->lvTabs[] = array('file' => 'zone', 'data' => $lv, 'params' => array('extraCols' => $extra ? '$[Listview.extraCols.condition]' : null, 'hiddenCols' => $extra ? "\$['instancetype']" : null));
         }
     }
     // tab: teaches
     if ($ids = Util::getTaughtSpells($this->subject)) {
         $teaches = new SpellList(array(['id', $ids]));
         if (!$teaches->error) {
             $this->extendGlobalData($teaches->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $vis = ['level', 'schools'];
             $hid = [];
             if (!$teaches->hasSetFields(['skillLines'])) {
                 $hid[] = 'skill';
             }
             foreach ($teaches->iterate() as $__) {
                 if (!$teaches->canCreateItem()) {
                     continue;
                 }
                 $vis[] = 'reagents';
                 break;
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $teaches->getListviewData(), 'params' => array('id' => 'teaches-spell', 'name' => '$LANG.tab_teaches', 'visibleCols' => '$' . Util::toJSON($vis), 'hiddenCols' => $hid ? '$' . Util::toJSON($hid) : null));
         }
     }
     // tab: taught by npc (source:6 => trainer)
     if (!empty($this->subject->sources[$this->typeId][6])) {
         $src = $this->subject->sources[$this->typeId][6];
         $list = [];
         if (count($src) == 1 && $src[0] == 1) {
             $tt = null;
             // Professions
             if (in_array($_cat, [9, 11]) && isset(Util::$trainerTemplates[TYPE_SKILL][$this->subject->getField('skillLines')[0]])) {
                 $tt = Util::$trainerTemplates[TYPE_SKILL][$this->subject->getField('skillLines')[0]];
             } else {
                 if ($_cat == 7 && $this->subject->getField('reqClassMask')) {
                     $clId = log($this->subject->getField('reqClassMask'), 2) + 1;
                     if (intVal($clId) == $clId) {
                         // only one class was set, so float == int
                         if (isset(Util::$trainerTemplates[TYPE_CLASS][$clId])) {
                             $tt = Util::$trainerTemplates[TYPE_CLASS][$clId];
                         }
                     }
                 }
             }
             if ($tt) {
                 $list = DB::World()->selectCol('SELECT DISTINCT ID FROM npc_trainer WHERE SpellID IN (?a) AND ID < 200000', $tt);
             } else {
                 $mask = 0;
                 foreach (Util::$skillLineMask[-3] as $idx => $pair) {
                     if ($pair[1] == $this->typeId) {
                         $mask |= 1 << $idx;
                     }
                 }
                 $list = DB::World()->selectCol('
                     SELECT    IF(t1.ID > 200000, t2.ID, t1.ID)
                     FROM      npc_trainer t1
                     LEFT JOIN npc_trainer t2 ON t2.SpellID = -t1.ID
                     WHERE     t1.SpellID = ?d', $this->typeId);
             }
         } else {
             if ($src) {
                 $list = array_values($src);
             }
         }
         if ($list) {
             $tbTrainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&']));
             if (!$tbTrainer->error) {
                 $this->extendGlobalData($tbTrainer->getJSGlobals());
                 $this->lvTabs[] = array('file' => 'creature', 'data' => $tbTrainer->getListviewData(), 'params' => array('id' => 'taught-by-npc', 'name' => '$LANG.tab_taughtby'));
             }
         }
     }
     // tab: taught by spell
     $conditions = array('OR', ['AND', ['effect1Id', SpellList::$effects['teach']], ['effect1TriggerSpell', $this->subject->id]], ['AND', ['effect2Id', SpellList::$effects['teach']], ['effect2TriggerSpell', $this->subject->id]], ['AND', ['effect3Id', SpellList::$effects['teach']], ['effect3TriggerSpell', $this->subject->id]]);
     $tbSpell = new SpellList($conditions);
     $tbsData = [];
     if (!$tbSpell->error) {
         $tbsData = $tbSpell->getListviewData();
         $this->lvTabs[] = array('file' => 'spell', 'data' => $tbsData, 'params' => array('id' => 'taught-by-spell', 'name' => '$LANG.tab_taughtby'));
         $this->extendGlobalData($tbSpell->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: taught by quest
     $conditions = ['OR', ['sourceSpellId', $this->typeId], ['rewardSpell', $this->typeId]];
     if ($tbsData) {
         $conditions[] = ['rewardSpell', array_keys($tbsData)];
         if (User::isInGroup(U_GROUP_EMPLOYEE)) {
             $conditions[] = ['rewardSpellCast', array_keys($tbsData)];
         }
     }
     if (User::isInGroup(U_GROUP_EMPLOYEE)) {
         $conditions[] = ['rewardSpellCast', $this->typeId];
     }
     $tbQuest = new QuestList($conditions);
     if (!$tbQuest->error) {
         $this->lvTabs[] = array('file' => 'quest', 'data' => $tbQuest->getListviewData(), 'params' => array('id' => 'reward-from-quest', 'name' => '$LANG.tab_rewardfrom'));
         $this->extendGlobalData($tbQuest->getJSGlobals());
     }
     // tab: taught by item (i'd like to precheck $this->subject->sources, but there is no source:item only complicated crap like "drop" and "vendor")
     $conditions = array('OR', ['AND', ['spellTrigger1', 6], ['spellId1', $this->subject->id]], ['AND', ['spellTrigger2', 6], ['spellId2', $this->subject->id]], ['AND', ['spellTrigger3', 6], ['spellId3', $this->subject->id]], ['AND', ['spellTrigger4', 6], ['spellId4', $this->subject->id]], ['AND', ['spellTrigger5', 6], ['spellId5', $this->subject->id]]);
     $tbItem = new ItemList($conditions);
     if (!$tbItem->error) {
         $this->lvTabs[] = array('file' => 'item', 'data' => $tbItem->getListviewData(), 'params' => array('id' => 'taught-by-item', 'name' => '$LANG.tab_taughtby'));
         $this->extendGlobalData($tbItem->getJSGlobals(GLOBALINFO_SELF));
     }
     // tab: enchantments
     $conditions = array('OR', ['AND', ['type1', [1, 3, 7]], ['object1', $this->typeId]], ['AND', ['type2', [1, 3, 7]], ['object2', $this->typeId]], ['AND', ['type3', [1, 3, 7]], ['object3', $this->typeId]]);
     $enchList = new EnchantmentList($conditions);
     if (!$enchList->error) {
         $this->lvTabs[] = array('file' => 'enchantment', 'data' => $enchList->getListviewData(), 'params' => []);
         $this->extendGlobalData($enchList->getJSGlobals());
     }
     // find associated NPC, Item and merge results
     // taughtbypets (unused..?)
     // taughtbyquest (usually the spell casted as quest reward teaches something; exclude those seplls from taughtBySpell)
     // taughtbytrainers
     // taughtbyitem
     // tab: conditions
     $sc = Util::getServerConditions([CND_SRC_SPELL_LOOT_TEMPLATE, CND_SRC_SPELL_IMPLICIT_TARGET, CND_SRC_SPELL, CND_SRC_SPELL_CLICK_EVENT, CND_SRC_VEHICLE_SPELL, CND_SRC_SPELL_PROC], null, $this->typeId);
     if (!empty($sc[0])) {
         $this->extendGlobalData($sc[1]);
         $tab = "<script type=\"text/javascript\">\n" . "var markup = ConditionList.createTab(" . Util::toJSON($sc[0]) . ");\n" . "Markup.printHtml(markup, 'tab-conditions', { allow: Markup.CLASS_STAFF })" . "</script>";
         $this->lvTabs[] = array('file' => null, 'data' => $tab, 'params' => array('id' => 'conditions', 'name' => '$LANG.requires'));
     }
 }
コード例 #19
0
ファイル: lang.class.php プロジェクト: saqar/aowow
 public static function getLocks($lockId, $interactive = false)
 {
     $locks = [];
     $lock = DB::Aowow()->selectRow('SELECT * FROM ?_lock WHERE id = ?d', $lockId);
     if (!$lock) {
         return $locks;
     }
     for ($i = 1; $i <= 5; $i++) {
         $prop = $lock['properties' . $i];
         $rank = $lock['reqSkill' . $i];
         $name = '';
         if ($lock['type' . $i] == 1) {
             $name = ItemList::getName($prop);
             if (!$name) {
                 continue;
             }
             if ($interactive) {
                 $name = '<a class="q1" href="?item=' . $prop . '">' . $name . '</a>';
             }
         } else {
             if ($lock['type' . $i] == 2) {
                 // exclude unusual stuff
                 if (!in_array($prop, [1, 2, 3, 4, 9, 16, 20])) {
                     continue;
                 }
                 $name = self::spell('lockType', $prop);
                 if (!$name) {
                     continue;
                 }
                 if ($interactive) {
                     $skill = 0;
                     switch ($prop) {
                         case 1:
                             $skill = 633;
                             break;
                             // Lockpicking
                         // Lockpicking
                         case 2:
                             $skill = 182;
                             break;
                             // Herbing
                         // Herbing
                         case 3:
                             $skill = 186;
                             break;
                             // Mining
                         // Mining
                         case 20:
                             $skill = 773;
                             break;
                             // Scribing
                     }
                     if ($skill) {
                         $name = '<a href="?skill=' . $skill . '">' . $name . '</a>';
                     }
                 }
                 if ($rank > 0) {
                     $name .= ' (' . $rank . ')';
                 }
             } else {
                 continue;
             }
         }
         $locks[$lock['type' . $i] == 1 ? $prop : -$prop] = sprintf(self::game('requires'), $name);
     }
     return $locks;
 }
コード例 #20
0
ファイル: author.php プロジェクト: jphpsf/gregarius
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  or visit
# http://www.gnu.org/licenses/gpl.html
#
###############################################################################
# E-mail:	   mbonetti at gmail dot com
# Web page:	   http://gregarius.net/
#
###############################################################################
require_once 'init.php';
$a = trim(sanitize($_REQUEST['author'], RSS_SANITIZER_WORDS));
$sql = "select distinct(author) from " . getTable('item') . " where author  like '%{$a}'";
list($ra) = rss_fetch_row(rss_query($sql));
if (!$ra) {
    rss_404();
    exit;
}
$t = ucfirst(__('items')) . " " . __(' by ') . " " . $ra;
$GLOBALS['rss']->header = new Header($t);
$GLOBALS['rss']->feedList = new FeedList(false);
$authorItems = new ItemList();
$sqlWhere = " i.author like '%{$a}' ";
$numItems = getConfig('rss.output.frontpage.numitems');
$authorItems->populate($sqlWhere, "", 0, $numItems);
$authorItems->setTitle($t);
$authorItems->setRenderOptions(IL_NO_COLLAPSE | IL_TITLE_NO_ESCAPE);
$GLOBALS['rss']->appendContentObject($authorItems);
$GLOBALS['rss']->renderWithTemplate('index.php', 'items');
コード例 #21
0
ファイル: skill.php プロジェクト: Carbenium/aowow
 protected function generateContent()
 {
     /****************/
     /* Main Content */
     /****************/
     $this->headIcons = [$this->subject->getField('iconString')];
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true);
     if ($_ = $this->subject->getField('description', true)) {
         $this->extraText = $_;
     }
     /**************/
     /* Extra Tabs */
     /**************/
     if (in_array($this->cat, [-5, 9, 11])) {
         // tab: recipes [spells] (crafted)
         $condition = array(['OR', ['s.reagent1', 0, '>'], ['s.reagent2', 0, '>'], ['s.reagent3', 0, '>'], ['s.reagent4', 0, '>'], ['s.reagent5', 0, '>'], ['s.reagent6', 0, '>'], ['s.reagent7', 0, '>'], ['s.reagent8', 0, '>']], ['OR', ['s.skillLine1', $this->typeId], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->typeId]]], CFG_SQL_LIMIT_NONE);
         $recipes = new SpellList($condition);
         // also relevant for 3
         if (!$recipes->error) {
             $this->extendGlobalData($recipes->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $this->lvTabs[] = array('file' => 'spell', 'data' => $recipes->getListviewData(), 'params' => array('id' => 'recipes', 'name' => '$LANG.tab_recipes', 'visibleCols' => "\$['reagents', 'source']", 'note' => sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . $this->typeId . '&filter=cr=20;crs=1;crv=0')));
         }
         // tab: recipe Items [items] (Books)
         $filterRecipe = [null, 165, 197, 202, 164, 185, 171, 129, 333, 356, 755, 773, 186, 182];
         $conditions = array(['requiredSkill', $this->typeId], ['class', ITEM_CLASS_RECIPE], CFG_SQL_LIMIT_NONE);
         $recipeItems = new ItemList($conditions);
         if (!$recipeItems->error) {
             $this->extendGlobalData($recipeItems->getJSGlobals(GLOBALINFO_SELF));
             if ($_ = array_search($this->typeId, $filterRecipe)) {
                 $_ = sprintf(Util::$filterResultString, "?items=9." . $_);
             }
             $this->lvTabs[] = array('file' => 'item', 'data' => $recipeItems->getListviewData(), 'params' => array('id' => 'recipe-items', 'name' => '$LANG.tab_recipeitems', 'note' => $_));
         }
         // tab: crafted items [items]
         $filterItem = [null, 171, 164, 185, 333, 202, 129, 755, 165, 186, 197, null, null, 356, 182, 773];
         $created = [];
         foreach ($recipes->iterate() as $__) {
             if ($idx = $recipes->canCreateItem()) {
                 foreach ($idx as $i) {
                     $created[] = $recipes->getField('effect' . $i . 'CreateItemId');
                 }
             }
         }
         if ($created) {
             $created = new ItemList(array(['i.id', $created], CFG_SQL_LIMIT_NONE));
             if (!$created->error) {
                 $this->extendGlobalData($created->getJSGlobals(GLOBALINFO_SELF));
                 if ($_ = array_search($this->typeId, $filterItem)) {
                     $_ = sprintf(Util::$filterResultString, "?items&filter=cr=86;crs=" . $_ . ";crv=0");
                 }
                 $this->lvTabs[] = array('file' => 'item', 'data' => $created->getListviewData(), 'params' => array('id' => 'crafted-items', 'name' => '$LANG.tab_crafteditems', 'note' => $_));
             }
         }
         // tab: required by [item]
         $conditions = array(['requiredSkill', $this->typeId], ['class', ITEM_CLASS_RECIPE, '!'], CFG_SQL_LIMIT_NONE);
         $reqBy = new ItemList($conditions);
         if (!$reqBy->error) {
             $this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF));
             if ($_ = array_search($this->typeId, $filterItem)) {
                 $_ = sprintf(Util::$filterResultString, "?items&filter=cr=99:168;crs=" . $_ . ":2;crv=0:0");
             }
             $this->lvTabs[] = array('file' => 'item', 'data' => $reqBy->getListviewData(), 'params' => array('id' => 'required-by', 'name' => '$LANG.tab_requiredby', 'note' => $_));
         }
         // tab: required by [itemset]
         $conditions = array(['skillId', $this->typeId], CFG_SQL_LIMIT_NONE);
         $reqBy = new ItemsetList($conditions);
         if (!$reqBy->error) {
             $this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF));
             $this->lvTabs[] = array('file' => 'itemset', 'data' => $reqBy->getListviewData(), 'params' => array('id' => 'required-by-set', 'name' => '$LANG.tab_requiredby'));
         }
     }
     // tab: spells [spells] (exclude first tab)
     $reqClass = 0x0;
     $reqRace = 0x0;
     $condition = array(['AND', ['s.reagent1', 0], ['s.reagent2', 0], ['s.reagent3', 0], ['s.reagent4', 0], ['s.reagent5', 0], ['s.reagent6', 0], ['s.reagent7', 0], ['s.reagent8', 0]], ['OR', ['s.skillLine1', $this->typeId], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->typeId]]], CFG_SQL_LIMIT_NONE);
     foreach (Util::$skillLineMask as $line1 => $sets) {
         foreach ($sets as $idx => $set) {
             if ($set[1] == $this->typeId) {
                 $condition[1][] = array('AND', ['s.skillLine1', $line1], ['s.skillLine2OrMask', 1 << $idx, '&']);
                 break 2;
             }
         }
     }
     $spells = new SpellList($condition);
     if (!$spells->error) {
         foreach ($spells->iterate() as $__) {
             $reqClass |= $spells->getField('reqClassMask');
             $reqRace |= $spells->getField('reqRaceMask');
         }
         $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF));
         $lv = array('file' => 'spell', 'data' => $spells->getListviewData(), 'params' => ['visibleCols' => "\$['source']"]);
         switch ($this->cat) {
             case -4:
                 $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=-4');
                 break;
             case 7:
                 if ($this->typeId != 769) {
                     // Internal
                     $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . (log($reqClass, 2) + 1) . '.' . $this->typeId);
                 }
                 // doesn't matter what spell; reqClass should be identical for all Class Spells
                 break;
             case 9:
             case 11:
                 $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . $this->typeId);
                 break;
         }
         $this->lvTabs[] = $lv;
     }
     // tab: trainers [npcs]
     if (in_array($this->cat, [-5, 6, 7, 8, 9, 11])) {
         $list = [];
         if (!empty(Util::$trainerTemplates[TYPE_SKILL][$this->typeId])) {
             $list = DB::World()->selectCol('SELECT DISTINCT entry FROM npc_trainer WHERE spell IN (?a) AND entry < 200000', Util::$trainerTemplates[TYPE_SKILL][$this->typeId]);
         } else {
             $mask = 0;
             foreach (Util::$skillLineMask[-3] as $idx => $pair) {
                 if ($pair[1] == $this->typeId) {
                     $mask |= 1 << $idx;
                 }
             }
             $spellIds = DB::Aowow()->selectCol('SELECT id FROM ?_spell WHERE typeCat IN (-11, 9) AND (skillLine1 = ?d OR (skillLine1 > 0 AND skillLine2OrMask = ?d) {OR (skillLine1 = -3 AND skillLine2OrMask = ?d)})', $this->typeId, $this->typeId, $mask ?: DBSIMPLE_SKIP);
             $list = $spellIds ? DB::World()->selectCol('
                 SELECT    IF(t1.entry > 200000, t2.entry, t1.entry)
                 FROM      npc_trainer t1
                 LEFT JOIN npc_trainer t2 ON t2.spell = -t1.entry
                 WHERE     t1.spell IN (?a)', $spellIds) : [];
         }
         if ($list) {
             $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
             $trainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&']));
             if (!$trainer->error) {
                 $this->extendGlobalData($trainer->getJSGlobals());
                 $this->lvTabs[] = array('file' => 'creature', 'data' => $trainer->getListviewData(), 'params' => array('id' => 'trainer', 'name' => '$LANG.tab_trainers'));
             }
         }
     }
     // tab: quests [quests]
     if (in_array($this->cat, [9, 11])) {
         $sort = 0;
         switch ($this->typeId) {
             case 182:
                 $sort = 24;
                 break;
                 // Herbalism
             // Herbalism
             case 356:
                 $sort = 101;
                 break;
                 // Fishing
             // Fishing
             case 164:
                 $sort = 121;
                 break;
                 // Blacksmithing
             // Blacksmithing
             case 171:
                 $sort = 181;
                 break;
                 // Alchemy
             // Alchemy
             case 165:
                 $sort = 182;
                 break;
                 // Leatherworking
             // Leatherworking
             case 202:
                 $sort = 201;
                 break;
                 // Engineering
             // Engineering
             case 197:
                 $sort = 264;
                 break;
                 // Tailoring
             // Tailoring
             case 185:
                 $sort = 304;
                 break;
                 // Cooking
             // Cooking
             case 129:
                 $sort = 324;
                 break;
                 // First Aid
             // First Aid
             case 773:
                 $sort = 371;
                 break;
                 // Inscription
             // Inscription
             case 755:
                 $sort = 373;
                 break;
                 // Jewelcrafting
         }
         if ($sort) {
             $quests = new QuestList(array(['zoneOrSort', -$sort], CFG_SQL_LIMIT_NONE));
             if (!$quests->error) {
                 $this->extendGlobalData($quests->getJSGlobals());
                 $this->lvTabs[] = array('file' => 'quest', 'data' => $quests->getListviewData(), 'params' => []);
             }
         }
     }
     // tab: related classes (apply classes from [spells])
     $class = [];
     for ($i = 0; $i < 11; $i++) {
         if ($reqClass & 1 << $i) {
             $class[] = $i + 1;
         }
     }
     if ($class) {
         $classes = new CharClassList(array(['id', $class]));
         if (!$classes->error) {
             $this->lvTabs[] = array('file' => 'class', 'data' => $classes->getListviewData(), 'params' => []);
         }
     }
     // tab: related races (apply races from [spells])
     $race = [];
     for ($i = 0; $i < 12; $i++) {
         if ($reqRace & 1 << $i) {
             $race[] = $i + 1;
         }
     }
     if ($race) {
         $races = new CharRaceList(array(['id', $race]));
         if (!$races->error) {
             $this->lvTabs[] = array('file' => 'race', 'data' => $races->getListviewData(), 'params' => []);
         }
     }
 }
コード例 #22
0
ファイル: ThemeController.php プロジェクト: elvyrra/hawk
 /**
  * Search themes on the remote platform
  */
 public function search()
 {
     $api = new HawkApi();
     $search = App::request()->getParams('search');
     // Search themes on the API
     try {
         $themes = $api->searchThemes($search);
     } catch (\Hawk\HawkApiException $e) {
         $themes = array();
     }
     // Remove the plugins already downloaded on the application
     foreach ($themes as &$theme) {
         $installed = Theme::get($theme['name']);
         $theme['installed'] = $installed !== null;
         if ($installed) {
             $theme['currentVersion'] = $installed->getDefinition('version');
         }
     }
     $list = new ItemList(array('id' => 'search-themes-list', 'data' => $themes, 'resultTpl' => Plugin::current()->getView('theme-search-list.tpl'), 'fields' => array()));
     if ($list->isRefreshing()) {
         return $list->display();
     } else {
         $this->addCss(Plugin::current()->getCssUrl('themes.less'));
         $this->addJavaScript(Plugin::current()->getJsUrl('themes.js'));
         return LeftSidebarTab::make(array('page' => array('content' => $list->display()), 'sidebar' => array('widgets' => array(new SearchThemeWidget())), 'icon' => 'picture-o', 'title' => Lang::get($this->_plugin . '.search-theme-result-title', array('search' => $search))));
     }
 }
コード例 #23
0
ファイル: quest.php プロジェクト: Niknox/aowow
 private function createRewards()
 {
     $rewards = [];
     // moneyReward / maxLevelCompensation
     $comp = $this->subject->getField('rewardMoneyMaxLevel');
     $questMoney = $this->subject->getField('rewardOrReqMoney');
     if ($questMoney > 0) {
         $rewards['money'] = Util::formatMoney($questMoney);
         if ($comp > 0) {
             $rewards['money'] .= '&nbsp;' . sprintf(Lang::quest('expConvert'), Util::formatMoney($questMoney + $comp), MAX_LEVEL);
         }
     } else {
         if ($questMoney <= 0 && $questMoney + $comp > 0) {
             $rewards['money'] = sprintf(Lang::quest('expConvert2'), Util::formatMoney($questMoney + $comp), MAX_LEVEL);
         }
     }
     // itemChoices
     if (!empty($this->subject->choices[$this->typeId][TYPE_ITEM])) {
         $c = $this->subject->choices[$this->typeId][TYPE_ITEM];
         $choiceItems = new ItemList(array(['id', array_keys($c)]));
         if (!$choiceItems->error) {
             $this->extendGlobalData($choiceItems->getJSGlobals());
             foreach ($choiceItems->Iterate() as $id => $__) {
                 $rewards['choice'][] = array('typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'name' => $choiceItems->getField('name', true), 'quality' => $choiceItems->getField('quality'), 'qty' => $c[$id], 'globalStr' => 'g_items');
             }
         }
     }
     // itemRewards
     if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM])) {
         $ri = $this->subject->rewards[$this->typeId][TYPE_ITEM];
         $rewItems = new ItemList(array(['id', array_keys($ri)]));
         if (!$rewItems->error) {
             $this->extendGlobalData($rewItems->getJSGlobals());
             foreach ($rewItems->Iterate() as $id => $__) {
                 $rewards['items'][] = array('typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'name' => $rewItems->getField('name', true), 'quality' => $rewItems->getField('quality'), 'qty' => $ri[$id], 'globalStr' => 'g_items');
             }
         }
     }
     if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM][TYPE_CURRENCY])) {
         $rc = $this->subject->rewards[$this->typeId][TYPE_ITEM][TYPE_CURRENCY];
         $rewCurr = new CurrencyList(array(['id', array_keys($rc)]));
         if (!$rewCurr->error) {
             $this->extendGlobalData($rewCurr->getJSGlobals());
             foreach ($rewCurr->Iterate() as $id => $__) {
                 $rewards['items'][] = array('typeStr' => Util::$typeStrings[TYPE_CURRENCY], 'id' => $id, 'name' => $rewCurr->getField('name', true), 'quality' => 1, 'qty' => $rc[$id] * ($_side == 2 ? -1 : 1), 'globalStr' => 'g_gatheredcurrencies');
             }
         }
     }
     // spellRewards
     $displ = $this->subject->getField('rewardSpell');
     $cast = $this->subject->getField('rewardSpellCast');
     if (!$cast && $displ) {
         $cast = $displ;
         $displ = 0;
     }
     if ($cast || $displ) {
         $rewSpells = new SpellList(array(['id', [$displ, $cast]]));
         $this->extendGlobalData($rewSpells->getJSGlobals());
         if (User::isInGroup(U_GROUP_EMPLOYEE)) {
             $extra = null;
             if ($_ = $rewSpells->getEntry($displ)) {
                 $extra = sprintf(Lang::quest('spellDisplayed'), $displ, Util::localizedString($_, 'name'));
             }
             if ($_ = $rewSpells->getEntry($cast)) {
                 $rewards['spells']['extra'] = $extra;
                 $rewards['spells']['cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $cast, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells');
             }
         } else {
             $teach = [];
             foreach ($rewSpells->iterate() as $id => $__) {
                 if ($_ = $rewSpells->canTeachSpell()) {
                     foreach ($_ as $idx) {
                         $teach[$rewSpells->getField('effect' . $idx . 'TriggerSpell')] = $id;
                     }
                 }
             }
             if ($_ = $rewSpells->getEntry($displ)) {
                 $rewards['spells']['extra'] = null;
                 $rewards['spells'][$teach ? 'learn' : 'cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $displ, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells');
             } else {
                 if (($_ = $rewSpells->getEntry($cast)) && !$teach) {
                     $rewards['spells']['extra'] = null;
                     $rewards['spells']['cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $cast, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells');
                 } else {
                     $taught = new SpellList(array(['id', array_keys($teach)]));
                     if (!$taught->error) {
                         $this->extendGlobalData($taught->getJSGlobals());
                         $rewards['spells']['extra'] = null;
                         foreach ($taught->iterate() as $id => $__) {
                             $rewards['spells']['learn'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $id, 'name' => $taught->getField('name', true), 'globalStr' => 'g_spells');
                         }
                     }
                 }
             }
         }
     }
     return $rewards;
 }
コード例 #24
0
ファイル: currency.php プロジェクト: Carbenium/aowow
 protected function generateContent()
 {
     $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']);
     $_itemId = $this->subject->getField('itemId');
     /***********/
     /* Infobox */
     /**********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     if ($this->typeId == 103) {
         // Arena Points
         $infobox[] = Lang::currency('cap') . Lang::main('colon') . '10\'000';
     } else {
         if ($this->typeId == 104) {
             // Honor
             $infobox[] = Lang::currency('cap') . Lang::main('colon') . '75\'000';
         }
     }
     /****************/
     /* Main Content */
     /****************/
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->name = $this->subject->getField('name', true);
     $this->headIcons = $this->typeId == 104 ? ['inv_bannerpvp_02', 'inv_bannerpvp_01'] : [$this->subject->getField('iconString')];
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true);
     /**************/
     /* Extra Tabs */
     /**************/
     if ($this->typeId != 103 && $this->typeId != 104) {
         // tabs: this currency is contained in..
         $lootTabs = new Loot();
         if ($lootTabs->getByItem($_itemId)) {
             $this->extendGlobalData($lootTabs->jsGlobals);
             foreach ($lootTabs->iterate() as $tab) {
                 $this->lvTabs[] = array('file' => $tab[0], 'data' => $tab[1], 'params' => ['name' => $tab[2], 'id' => $tab[3], 'extraCols' => $tab[4] ? '$[' . implode(', ', array_unique($tab[4])) . ']' : null, 'hiddenCols' => $tab[5] ? '$[' . implode(', ', array_unique($tab[5])) . ']' : null, 'visibleCols' => $tab[6] ? '$' . Util::toJSON(array_unique($tab[6])) : null]);
             }
         }
         // tab: sold by
         $itemObj = new ItemList(array(['id', $_itemId]));
         if (!empty($itemObj->getExtendedCost()[$_itemId])) {
             $vendors = $itemObj->getExtendedCost()[$_itemId];
             $this->extendGlobalData($itemObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             $soldBy = new CreatureList(array(['id', array_keys($vendors)]));
             if (!$soldBy->error) {
                 $sbData = $soldBy->getListviewData();
                 $extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost'];
                 $holidays = [];
                 foreach ($sbData as $k => &$row) {
                     $items = [];
                     $tokens = [];
                     foreach ($vendors[$k] as $id => $qty) {
                         if (is_string($id)) {
                             continue;
                         }
                         if ($id > 0) {
                             $tokens[] = [$id, $qty];
                         } else {
                             if ($id < 0) {
                                 $items[] = [-$id, $qty];
                             }
                         }
                     }
                     if ($vendors[$k]['event']) {
                         if (count($extraCols) == 3) {
                             // not already pushed
                             $extraCols[] = 'Listview.extraCols.condition';
                         }
                         $this->extendGlobalIds(TYPE_WORLDEVENT, $vendors[$k]['event']);
                         $row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $vendors[$k]['event']]];
                     }
                     $row['stock'] = $vendors[$k]['stock'];
                     $row['stack'] = $itemObj->getField('buyCount');
                     $row['cost'] = array($itemObj->getField('buyPrice'), $items ? $items : null, $tokens ? $tokens : null);
                 }
                 $this->lvTabs[] = array('file' => 'creature', 'data' => $sbData, 'params' => ['name' => '$LANG.tab_soldby', 'id' => 'sold-by-npc', 'extraCols' => '$[' . implode(', ', $extraCols) . ']', 'hiddenCols' => "\$['level', 'type']"]);
             }
         }
     }
     // tab: created by (spell) [for items its handled in Loot::getByContainer()]
     if ($this->typeId == 104) {
         $createdBy = new SpellList(array(['effect1Id', 45], ['effect2Id', 45], ['effect3Id', 45], 'OR'));
         if (!$createdBy->error) {
             $this->extendGlobalData($createdBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
             if ($createdBy->hasSetFields(['reagent1'])) {
                 $visCols = ['reagents'];
             }
             $this->lvTabs[] = array('file' => 'spell', 'data' => $createdBy->getListviewData(), 'params' => ['name' => '$LANG.tab_createdby', 'id' => 'created-by', 'visibleCols' => isset($visCols) ? '$' . Util::toJSON($visCols) : null]);
         }
     }
     // tab: currency for
     if ($this->typeId == 103) {
         $n = '?items&filter=cr=145;crs=1;crv=0';
         $w = 'reqArenaPoints > 0';
     } else {
         if ($this->typeId == 104) {
             $n = '?items&filter=cr=144;crs=1;crv=0';
             $w = 'reqHonorPoints > 0';
         } else {
             $n = in_array($this->typeId, [42, 61, 81, 241, 121, 122, 123, 125, 126, 161, 201, 101, 102, 221, 301, 341]) ? '?items&filter=cr=158;crs=' . $_itemId . ';crv=0' : null;
             $w = 'reqItemId1 = ' . $_itemId . ' OR reqItemId2 = ' . $_itemId . ' OR reqItemId3 = ' . $_itemId . ' OR reqItemId4 = ' . $_itemId . ' OR reqItemId5 = ' . $_itemId;
         }
     }
     $xCosts = DB::Aowow()->selectCol('SELECT id FROM ?_itemextendedcost WHERE ' . $w);
     $boughtBy = $xCosts ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE extendedCost IN (?a) UNION SELECT item FROM game_event_npc_vendor WHERE extendedCost IN (?a)', $xCosts, $xCosts) : [];
     if ($boughtBy) {
         $boughtBy = new ItemList(array(['id', $boughtBy]));
         if (!$boughtBy->error) {
             if ($boughtBy->getMatches() <= CFG_SQL_LIMIT_DEFAULT) {
                 $n = null;
             }
             $this->lvTabs[] = array('file' => 'item', 'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, [TYPE_CURRENCY => $this->typeId]), 'params' => ['name' => '$LANG.tab_currencyfor', 'id' => 'currency-for', 'extraCols' => "\$[Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')]", 'note' => $n ? sprintf(Util::$filterResultString, $n) : null]);
             $this->extendGlobalData($boughtBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
         }
     }
 }
コード例 #25
0
ファイル: itemset.php プロジェクト: saqar/aowow
 protected function generateContent()
 {
     $_ta = $this->subject->getField('contentGroup');
     $_ty = $this->subject->getField('type');
     $_cnt = count($this->subject->getField('pieces'));
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // unavailable (todo (low): set data)
     if ($this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE) {
         $infobox[] = Lang::main('unavailable');
     }
     // worldevent
     if ($e = $this->subject->getField('eventId')) {
         $infobox[] = Lang::game('eventShort') . Lang::main('colon') . '[event=' . $e . ']';
         $this->extendGlobalIds(TYPE_WORLDEVENT, $e);
     }
     // itemLevel
     if ($min = $this->subject->getField('minLevel')) {
         $foo = Lang::game('level') . Lang::main('colon') . $min;
         $max = $this->subject->getField('maxLevel');
         if ($min < $max) {
             $foo .= ' - ' . $max;
         }
         $infobox[] = $foo;
     }
     // class
     if ($cl = Lang::getClassString($this->subject->getField('classMask'), $jsg, $qty, false)) {
         $this->extendGlobalIds(TYPE_CLASS, $jsg);
         $t = $qty == 1 ? Lang::game('class') : Lang::game('classes');
         $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $cl;
     }
     // required level
     if ($lvl = $this->subject->getField('reqLevel')) {
         $infobox[] = sprintf(Lang::game('reqLevel'), $lvl);
     }
     // type
     if ($_ty) {
         $infobox[] = Lang::game('type') . Lang::main('colon') . Lang::itemset('types', $_ty);
     }
     // tag
     if ($_ta) {
         $infobox[] = Lang::itemset('_tag') . Lang::main('colon') . '[url=?itemsets&filter=ta=' . $_ta . ']' . Lang::itemset('notes', $_ta) . '[/url]';
     }
     /****************/
     /* Main Content */
     /****************/
     // pieces + Summary
     $pieces = [];
     $eqList = [];
     $compare = [];
     if (!$this->subject->pieceToSet) {
         $cnd = [0];
     } else {
         $cnd = ['i.id', array_keys($this->subject->pieceToSet)];
     }
     $iList = new ItemList(array($cnd));
     $data = $iList->getListviewData(ITEMINFO_SUBITEMS | ITEMINFO_JSON);
     foreach ($iList->iterate() as $itemId => $__) {
         if (empty($data[$itemId])) {
             continue;
         }
         $slot = $iList->getField('slot');
         $disp = $iList->getField('displayId');
         if ($slot && $disp) {
             $eqList[] = [$slot, $disp];
         }
         $compare[] = $itemId;
         $pieces[] = array('id' => $itemId, 'name' => $iList->getField('name', true), 'quality' => $iList->getField('quality'), 'icon' => $iList->getField('iconString'), 'json' => $data[$itemId]);
     }
     $skill = '';
     if ($_sk = $this->subject->getField('skillId')) {
         $spellLink = sprintf('<a href="?spells=11.%s">%s</a> (%s)', $_sk, Lang::spell('cat', 11, $_sk, 0), $this->subject->getField('skillLevel'));
         $skill = ' &ndash; <small><b>' . sprintf(Lang::game('requires'), $spellLink) . '</b></small>';
     }
     $this->bonusExt = $skill;
     $this->description = $_ta ? sprintf(Lang::itemset('_desc'), $this->name, Lang::itemset('notes', $_ta), $_cnt) : sprintf(Lang::itemset('_descTagless'), $this->name, $_cnt);
     $this->unavailable = $this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE;
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->pieces = $pieces;
     $this->spells = $this->subject->getBonuses();
     $this->expansion = 0;
     $this->redButtons = array(BUTTON_WOWHEAD => $this->typeId > 0, BUTTON_LINKS => ['color' => '', 'linkId' => ''], BUTTON_VIEW3D => ['type' => TYPE_ITEMSET, 'typeId' => $this->typeId, 'equipList' => $eqList], BUTTON_COMPARE => ['eqList' => implode(':', $compare), 'qty' => $_cnt]);
     $this->compare = array('level' => $this->subject->getField('reqLevel'), 'items' => array_map(function ($v) {
         return [[$v]];
     }, $compare));
     /**************/
     /* Extra Tabs */
     /**************/
     // related sets (priority: 1: similar tag + class; 2: has event; 3: no tag + similar type, 4: similar type + profession)
     $rel = [];
     if ($_ta && count($this->path) == 3) {
         $rel[] = ['id', $this->typeId, '!'];
         $rel[] = ['classMask', 1 << end($this->path) - 1, '&'];
         $rel[] = ['contentGroup', (int) $_ta];
     } else {
         if ($this->subject->getField('eventId')) {
             $rel[] = ['id', $this->typeId, '!'];
             $rel[] = ['eventId', 0, '!'];
         } else {
             if ($this->subject->getField('skillId')) {
                 $rel[] = ['id', $this->typeId, '!'];
                 $rel[] = ['contentGroup', 0];
                 $rel[] = ['skillId', 0, '!'];
                 $rel[] = ['type', $_ty];
             } else {
                 if (!$_ta && $_ty) {
                     $rel[] = ['id', $this->typeId, '!'];
                     $rel[] = ['contentGroup', 0];
                     $rel[] = ['type', $_ty];
                     $rel[] = ['skillId', 0];
                 }
             }
         }
     }
     if ($rel) {
         $relSets = new ItemsetList($rel);
         if (!$relSets->error) {
             $lv = array('file' => 'itemset', 'data' => $relSets->getListviewData(), 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso'));
             if (!$relSets->hasDiffFields(['classMask'])) {
                 $lv['params']['hiddenCols'] = "\$['classes']";
             }
             $this->lvTabs[] = $lv;
             $this->extendGlobalData($relSets->getJSGlobals());
         }
     }
 }
コード例 #26
0
ファイル: item.class.php プロジェクト: saqar/aowow
 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;
 }
コード例 #27
0
ファイル: item_list.php プロジェクト: VonUniGE/concrete5-1
 public function getSortByURL($column, $dir = 'asc', $baseURL = false, $additionalVars = array())
 {
     if ($column instanceof AttributeKey) {
         $column = 'ak_' . $column->getAttributeKeyHandle();
     }
     return parent::getSortByURL($column, $dir, $baseURL, $additionalVars);
 }
コード例 #28
0
ファイル: achievement.php プロジェクト: Carbenium/aowow
 protected function generateContent()
 {
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // points
     if ($_ = $this->subject->getField('points')) {
         $infobox[] = Lang::achievement('points') . Lang::main('colon') . '[achievementpoints=' . $_ . ']';
     }
     // location
     // todo (low)
     // faction
     switch ($this->subject->getField('faction')) {
         case 1:
             $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-alliance]' . Lang::game('si', SIDE_ALLIANCE) . '[/span]';
             break;
         case 2:
             $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-horde]' . Lang::game('si', SIDE_HORDE) . '[/span]';
             break;
         default:
             // case 3
             $infobox[] = Lang::main('side') . Lang::main('colon') . Lang::game('si', SIDE_BOTH);
     }
     // realm first available?
     if ($this->subject->getField('flags') & 0x100 && DB::isConnectable(DB_AUTH)) {
         $avlb = [];
         foreach (DB::Auth()->selectCol('SELECT id AS ARRAY_KEY, name FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', WOW_VERSION) as $rId => $name) {
             if (!DB::isConnectable(DB_CHARACTERS . $rId)) {
                 continue;
             }
             if (!DB::Characters($rId)->selectCell('SELECT 1 FROM character_achievement WHERE achievement = ?d LIMIT 1', $this->typeId)) {
                 $avlb[] = $name;
             }
         }
         if ($avlb) {
             $infobox[] = Lang::achievement('rfAvailable') . implode(', ', $avlb);
         }
     }
     /**********/
     /* Series */
     /**********/
     $series = [];
     if ($c = $this->subject->getField('chainId')) {
         $chainAcv = new AchievementList(array(['chainId', $c]));
         foreach ($chainAcv->iterate() as $aId => $__) {
             $pos = $chainAcv->getField('chainPos');
             if (!isset($series[$pos])) {
                 $series[$pos] = [];
             }
             $series[$pos][] = array('side' => $chainAcv->getField('faction'), 'typeStr' => Util::$typeStrings[TYPE_ACHIEVEMENT], 'typeId' => $aId, 'name' => $chainAcv->getField('name', true));
         }
     }
     /****************/
     /* Main Content */
     /****************/
     $this->mail = $this->createMail($reqBook);
     $this->headIcons = [$this->subject->getField('iconString')];
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->series = $series ? [[$series, null]] : null;
     $this->description = $this->subject->getField('description', true);
     $this->redButtons = array(BUTTON_LINKS => ['color' => 'ffffff00', 'linkId' => Util::$typeStrings[TYPE_ACHIEVEMENT] . ':' . $this->typeId . ':&quot;..UnitGUID(&quot;player&quot;)..&quot;:0:0:0:0:0:0:0:0'], BUTTON_WOWHEAD => !($this->subject->getField('cuFlags') & CUSTOM_SERVERSIDE));
     $this->criteria = array('reqQty' => $this->subject->getField('reqCriteriaCount'), 'icons' => [], 'data' => []);
     if ($reqBook) {
         $this->addCss(['path' => 'Book.css']);
     }
     // create rewards
     if ($foo = $this->subject->getField('rewards')) {
         array_walk($foo, function (&$item) {
             $item = $item[0] != TYPE_ITEM ? null : $item[1];
         });
         $bar = new ItemList(array(['i.id', $foo]));
         foreach ($bar->iterate() as $id => $__) {
             $this->rewards['item'][] = array('name' => $bar->getField('name', true), 'quality' => $bar->getField('quality'), 'typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'globalStr' => 'g_items');
         }
     }
     if ($foo = $this->subject->getField('rewards')) {
         array_walk($foo, function (&$item) {
             $item = $item[0] != TYPE_TITLE ? null : $item[1];
         });
         $bar = new TitleList(array(['id', $foo]));
         foreach ($bar->iterate() as $__) {
             $this->rewards['title'][] = sprintf(Lang::achievement('titleReward'), $bar->id, trim(str_replace('%s', '', $bar->getField('male', true))));
         }
     }
     $this->rewards['text'] = $this->subject->getField('reward', true);
     // factionchange-equivalent
     if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_achievement WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) {
         $altAcv = new AchievementList(array(['id', abs($pendant)]));
         if (!$altAcv->error) {
             $this->transfer = sprintf(Lang::achievement('_transfer'), $altAcv->id, 1, $altAcv->getField('iconString'), $altAcv->getField('name', true), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2));
         }
     }
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: see also
     $conditions = array(['name_loc' . User::$localeId, $this->subject->getField('name', true)], ['id', $this->typeId, '!']);
     $saList = new AchievementList($conditions);
     $this->lvTabs[] = array('file' => 'achievement', 'data' => $saList->getListviewData(), 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso', 'visibleCols' => "\$['category']"));
     $this->extendGlobalData($saList->getJSGlobals());
     // tab: criteria of
     $refs = DB::Aowow()->SelectCol('SELECT refAchievementId FROM ?_achievementcriteria WHERE Type = ?d AND value1 = ?d', ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, $this->typeId);
     if (!empty($refs)) {
         $coList = new AchievementList(array(['id', $refs]));
         $this->lvTabs[] = array('file' => 'achievement', 'data' => $coList->getListviewData(), 'params' => array('id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof', 'visibleCols' => "\$['category']"));
         $this->extendGlobalData($coList->getJSGlobals());
     }
     /*****************/
     /* Criteria List */
     /*****************/
     $iconId = 1;
     $rightCol = [];
     foreach ($this->subject->getCriteria() as $i => $crt) {
         // hide hidden criteria for regular users (really do..?)
         // if (($crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_HIDDEN) && User::$perms > 0)
         // continue;
         // alternative display option
         $displayMoney = $crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER;
         $crtName = Util::localizedString($crt, 'name');
         $tmp = array('id' => $crt['id'], 'name' => $crtName, 'type' => $crt['type']);
         $obj = (int) $crt['value1'];
         $qty = (int) $crt['value2'];
         switch ($crt['type']) {
             // link to npc
             case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
             case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE:
                 $tmp['link'] = array('href' => '?npc=' . $obj, 'text' => $crtName);
                 $tmp['extraText'] = Lang::achievement('slain');
                 break;
                 // link to area (by map)
             // link to area (by map)
             case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
             case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA:
             case ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA:
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND:
             case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP:
                 if ($zoneId = DB::Aowow()->selectCell('SELECT id FROM ?_zones WHERE mapId = ? LIMIT 1', $obj)) {
                     $tmp['link'] = array('href' => '?zone=' . $zoneId, 'text' => $crtName);
                 } else {
                     $tmp['extraText'] = $crtName;
                 }
                 break;
                 // link to area
             // link to area
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE:
             case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA:
                 $tmp['link'] = array('href' => '?zone=' . $obj, 'text' => $crtName);
                 break;
                 // link to skills
             // link to skills
             case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
                 $tmp['link'] = array('href' => '?skill=' . $obj, 'text' => $crtName);
                 break;
                 // link to class
             // link to class
             case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
                 $tmp['link'] = array('href' => '?class=' . $obj, 'text' => $crtName);
                 break;
                 // link to race
             // link to race
             case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
                 $tmp['link'] = array('href' => '?race=' . $obj, 'text' => $crtName);
                 break;
                 // link to title - todo (low): crosslink
             // link to title - todo (low): crosslink
             case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE:
                 $tmp['extraText'] = Util::ucFirst(Lang::game('title')) . Lang::main('colon') . $crtName;
                 break;
                 // link to achivement (/w icon)
             // link to achivement (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT:
                 $tmp['link'] = array('href' => '?achievement=' . $obj, 'text' => $crtName);
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_achievements', 'id' => $obj);
                 $this->extendGlobalIds(TYPE_ACHIEVEMENT, $obj);
                 break;
                 // link to quest
             // link to quest
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
                 // $crtName = ;
                 $tmp['link'] = array('href' => '?quest=' . $obj, 'text' => $crtName ?: QuestList::getName($obj));
                 break;
                 // link to spell (/w icon)
             // link to spell (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
             case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
             case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
             case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
                 $tmp['link'] = array('href' => '?spell=' . $obj, 'text' => $crtName ?: SpellList::getName($obj));
                 $this->extendGlobalIds(TYPE_SPELL, $obj);
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_spells', 'id' => $obj);
                 break;
                 // link to item (/w icon)
             // link to item (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
                 $crtItm = new ItemList(array(['i.id', $obj]));
                 $tmp['link'] = array('href' => '?item=' . $obj, 'text' => $crtName ?: $crtItm->getField('name', true), 'quality' => $crtItm->getField('quality'), 'count' => $qty);
                 $this->extendGlobalData($crtItm->getJSGlobals());
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_items', 'id' => $obj, 'count' => $qty);
                 break;
                 // link to faction (/w target reputation)
             // link to faction (/w target reputation)
             case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
                 $tmp['link'] = array('href' => '?faction=' . $obj, 'text' => $crtName ?: FactionList::getName($obj));
                 $tmp['extraText'] = ' (' . Lang::getReputationLevelForPoints($qty) . ')';
                 break;
                 // link to GObject
             // link to GObject
             case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT:
             case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT:
                 $tmp['link'] = array('href' => '?object=' . $obj, 'text' => $crtName);
                 break;
             default:
                 // Add a gold coin icon if required
                 $tmp['extraText'] = $displayMoney ? Util::formatMoney($qty) : $crtName;
                 break;
         }
         // If the right column
         if ($i % 2) {
             $this->criteria['data'][] = $tmp;
         } else {
             $rightCol[] = $tmp;
         }
     }
     // If you found the second column - merge data from it to the end of the main body
     if ($rightCol) {
         $this->criteria['data'] = array_merge($this->criteria['data'], $rightCol);
     }
 }
コード例 #29
0
ファイル: search.php プロジェクト: Niknox/aowow
 private function _searchItem($cndBase, &$shared)
 {
     $result = [];
     $miscData = [];
     $cndAdd = empty($this->query) ? [] : (is_int($this->query) ? ['id', $this->query] : $this->createLookup());
     if ($this->searchMask & SEARCH_TYPE_JSON && $this->searchMask & 0x20 && !empty($shared['pcsToSet'])) {
         $cnd = [['i.id', array_keys($shared['pcsToSet'])], CFG_SQL_LIMIT_NONE];
         $miscData = ['pcsToSet' => $shared['pcsToSet']];
     } else {
         if ($this->searchMask & SEARCH_TYPE_JSON && $this->searchMask & 0x40) {
             $cnd = $cndBase;
             $cnd[] = ['i.class', [ITEM_CLASS_WEAPON, ITEM_CLASS_GEM, ITEM_CLASS_ARMOR]];
             $cnd[] = $cndAdd;
             $slots = isset($_GET['slots']) ? explode(':', $_GET['slots']) : [];
             array_walk($slots, function (&$v, $k) {
                 $v = intVal($v);
             });
             if ($_ = array_filter($slots)) {
                 $cnd[] = ['slot', $_];
             }
             $itemFilter = new ItemListFilter();
             if ($_ = $itemFilter->createConditionsForWeights($this->statWeight)) {
                 $miscData['extraOpts'] = $itemFilter->extraOpts;
                 $cnd = array_merge($cnd, [$_]);
             }
         } else {
             $cnd = array_merge($cndBase, [$cndAdd]);
         }
     }
     $items = new ItemList($cnd, $miscData);
     if ($data = $items->getListviewData($this->searchMask & SEARCH_TYPE_JSON ? ITEMINFO_SUBITEMS | ITEMINFO_JSON : 0)) {
         if ($this->searchMask & SEARCH_TYPE_REGULAR) {
             $this->extendGlobalData($items->getJSGlobals());
         }
         if ($this->searchMask & SEARCH_TYPE_OPEN) {
             foreach ($items->iterate() as $__) {
                 $data[$items->id]['param1'] = $items->getField('iconString');
                 $data[$items->id]['param2'] = $items->getField('quality');
             }
         }
         $result = array('type' => TYPE_ITEM, 'appendix' => ' (Item)', 'matches' => $items->getMatches(), 'file' => ItemList::$brickFile, 'data' => $data, 'params' => []);
         if ($items->getMatches() > $this->maxResults) {
             $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_itemsfound', $items->getMatches(), $this->maxResults);
             $result['params']['_truncated'] = 1;
         }
         if (isset($result['params']['note'])) {
             $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?items&filter=na=' . urlencode($this->search) . '\')';
         } else {
             $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?items&filter=na=' . urlencode($this->search) . '\')';
         }
     }
     return $result;
 }
コード例 #30
-1
ファイル: UserController.php プロジェクト: elvyrra/hawk
 /**
  * Display the list of the users
  */
 public function listUsers()
 {
     $example = array('id' => array('$ne' => User::GUEST_USER_ID));
     $filters = UserFilterWidget::getInstance()->getFilters();
     if (isset($filters['status']) && $filters['status'] != -1) {
         $example['active'] = $filters['status'];
     }
     $param = array('id' => 'admin-users-list', 'model' => 'User', 'action' => App::router()->getUri('list-users'), 'reference' => 'id', 'filter' => new DBExample($example), 'controls' => array(array('icon' => 'plus', 'label' => Lang::get($this->_plugin . '.new-user-btn'), 'class' => 'btn-success', 'href' => App::router()->getUri("edit-user", array('username' => '_new')), 'target' => 'dialog')), 'fields' => array('actions' => array('independant' => true, 'display' => function ($value, $field, $user) {
         $return = Icon::make(array('icon' => 'pencil', 'class' => 'text-primary', 'href' => App::router()->getUri('edit-user', array('username' => $user->username)), 'target' => 'dialog'));
         if ($user->isRemovable()) {
             $return .= Icon::make(array('icon' => 'close', 'class' => 'text-danger delete-user', 'data-user' => $user->username));
             $return .= $user->active ? Icon::make(array('icon' => 'lock', 'class' => 'text-warning lock-user', 'data-user' => $user->username)) : Icon::make(array('icon' => 'unlock', 'class' => 'text-success unlock-user', 'data-user' => $user->username));
         }
         return $return;
     }, 'search' => false, 'sort' => false), 'username' => array('label' => Lang::get($this->_plugin . '.users-list-username-label')), 'email' => array('label' => Lang::get($this->_plugin . '.users-list-email-label')), 'roleId' => array('label' => Lang::get($this->_plugin . '.users-list-roleId-label'), 'sort' => false, 'search' => array('type' => 'select', 'options' => call_user_func(function () {
         $options = array();
         foreach (Role::getAll('id', array('id')) as $id => $role) {
             $options[$id] = Lang::get('roles.role-' . $id . '-label');
         }
         return $options;
     }), 'invitation' => Lang::get($this->_plugin . '.user-filter-status-all')), 'display' => function ($value) {
         return Lang::get('roles.role-' . $value . '-label');
     }), 'active' => array('label' => Lang::get($this->_plugin . '.users-list-active-label'), 'search' => false, 'sort' => false, 'class' => function ($value) {
         return 'bold ' . ($value ? 'text-success' : 'text-danger');
     }, 'display' => function ($value) {
         return $value ? Lang::get($this->_plugin . '.users-list-active') : Lang::get($this->_plugin . '.users-list-inactive');
     }), 'createTime' => array('label' => Lang::get($this->_plugin . '.users-list-createTime-label'), 'search' => false, 'display' => function ($value) {
         return date(Lang::get('main.date-format'), $value);
     })));
     $list = new ItemList($param);
     if (App::request()->getParams('refresh')) {
         return $list->display();
     } else {
         $this->addKeysToJavaScript("admin.user-delete-confirmation");
         return View::make(Plugin::current()->getView("users-list.tpl"), array('list' => $list));
     }
 }