Itemset/Summary (#351)

* disable compare button for empty item sets
 * do not display summary for empty item sets
This commit is contained in:
Sarjuuk
2023-04-07 18:56:04 +02:00
parent 2e82bf84d2
commit beb32da3b4
2 changed files with 17 additions and 8 deletions

View File

@@ -18,6 +18,8 @@ class ItemsetPage extends GenericPage
protected $mode = CACHE_TYPE_PAGE;
protected $js = [[JS_FILE, 'swfobject.js'], [JS_FILE, 'Summary.js']];
protected $summary = [];
protected $_get = ['domain' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkDomain']];
private $powerTpl = '$WowheadPower.registerItemSet(%d, %d, %s);';
@@ -167,15 +169,16 @@ class ItemsetPage extends GenericPage
BUTTON_WOWHEAD => $this->typeId > 0, // bool only
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId],
BUTTON_VIEW3D => ['type' => Type::ITEMSET, 'typeId' => $this->typeId, 'equipList' => $eqList],
BUTTON_COMPARE => ['eqList' => implode(':', $compare), 'qty' => $_cnt]
);
$this->summary = array(
'id' => 'itemset',
'template' => 'itemset',
'parent' => 'summary-generic',
'groups' => array_map(function ($v) { return [[$v]]; }, $compare),
'level' => $this->subject->getField('reqLevel'),
BUTTON_COMPARE => $compare ? ['eqList' => implode(':', $compare), 'qty' => $_cnt] : false
);
if ($compare)
$this->summary = array(
'id' => 'itemset',
'template' => 'itemset',
'parent' => 'summary-generic',
'groups' => array_map(function ($v) { return [[$v]]; }, $compare),
'level' => $this->subject->getField('reqLevel'),
);
/**************/
/* Extra Tabs */

View File

@@ -68,6 +68,9 @@ foreach ($this->spells as $i => $s):
endforeach;
?>
</ul>
<?php
if ($this->summary):
?>
<h2 class="clear"><?=Lang::itemset('summary'); ?></h2>
@@ -75,6 +78,9 @@ endforeach;
<script type="text/javascript">//<![CDATA[
new Summary(<?=Util::toJSON($this->summary); ?>);
//]]></script>
<?php
endif;
?>
<h2 class="clear"><?=Lang::main('related'); ?></h2>
</div>