WowPress-Tailwind/theme/template-parts/widgets/char_search.php

51 lines
1.9 KiB
PHP

<?php
use WoWPress\Models\Character;
function hasSearch($specs)
{
foreach ($specs as $spec) {
foreach ($spec as $search) {
if ($search) {
return true;
}
}
}
return false;
}
?>
<div class="bg-glass shadow p-auto order-last flex flex-col gap-1">
<h1 class="text-xl font-bold text-center">Klassensuche</h1>
<div class="grid grid-cols-5 gap-2">
<?php if($instance['text']): ?>
<div class="p-auto col-span-5 text-center">
<?=$instance['text']?>
</div>
<?php endif; ?>
<?php foreach ($instance['classes'] as $class => $specs) : ?>
<?php if($this->hasSpec($specs)): ?>
<div class="col-span-1"><img src="<?=Character::classIconLink($class)?>" title="<?=translate_string($class)?>" alt="" class="h-8"></div>
<div class="col-span-4 grid grid-cols-subgrid">
<?php foreach ($specs as $spec => $search) : ?>
<div><img src="<?=Character::specIconLink($class,$spec)?>" alt=""
<?php
switch($search){
case 3: ?>class="h-8 border border-red-500" title="<?=translate_string($spec)?>: Hoch"<?php
break;
case 2: ?>class="h-8 opacity-70 border border-yellow-500" title="<?=translate_string($spec)?>: Mittel"<?php
break;
case 1: ?>class="h-8 opacity-50 border border-green-500" title="<?=translate_string($spec)?>: Niedrig"<?php
break;
case 0:
default: ?>class="h-8 opacity-10" title="<?=translate_string($spec)?>: Suche geschlossen"<?php
break;
}
?>
></div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>