2024-04-23 22:43:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace WoWPress\Frontend\Widgets;
|
|
|
|
|
2024-04-26 17:47:19 +02:00
|
|
|
use Peast\Syntax\Node\Class_;
|
|
|
|
use WoWPress\Frontend\ToggleButton;
|
|
|
|
use WoWPress\Models\Character;
|
|
|
|
|
2024-04-23 22:43:54 +02:00
|
|
|
class CharacterSearch extends Widget
|
|
|
|
{
|
|
|
|
|
|
|
|
protected $template_path = "char_search.php";
|
|
|
|
protected $title = "Charaktersuche";
|
|
|
|
protected $base_id = "wowpress_char_search";
|
|
|
|
public $name = "Charaktersuche";
|
|
|
|
protected $restricted = false;
|
|
|
|
|
|
|
|
protected $classes = [
|
2024-04-26 17:47:19 +02:00
|
|
|
'Druid' => [
|
|
|
|
'Feral',
|
|
|
|
'Balance',
|
|
|
|
'Guardian',
|
|
|
|
'Restoration',
|
|
|
|
],
|
2024-04-23 22:43:54 +02:00
|
|
|
'Death Knight' => [
|
|
|
|
'Frost',
|
|
|
|
'Unholy',
|
|
|
|
'Blood'
|
|
|
|
],
|
2024-04-26 17:47:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
'Evoker' => [
|
|
|
|
'Augmentation',
|
|
|
|
'Devastation',
|
|
|
|
'Preservation',
|
|
|
|
],
|
|
|
|
'Warrior' => [
|
|
|
|
'Arms',
|
|
|
|
'Fury',
|
|
|
|
'Protection',
|
|
|
|
],
|
|
|
|
'Paladin' => [
|
|
|
|
'Holy',
|
|
|
|
'Protection',
|
|
|
|
'Retribution',
|
|
|
|
],
|
|
|
|
'Hunter' => [
|
|
|
|
'Beast Mastery',
|
|
|
|
'Marksmanship',
|
|
|
|
'Survival',
|
|
|
|
],
|
|
|
|
'Rogue' => [
|
|
|
|
'Assassination',
|
|
|
|
'Outlaw',
|
|
|
|
'Subtlety',
|
|
|
|
],
|
|
|
|
'Priest' => [
|
|
|
|
'Discipline',
|
|
|
|
'Shadow',
|
|
|
|
'Holy',
|
|
|
|
],
|
|
|
|
'Shaman' => [
|
|
|
|
'Elemental',
|
|
|
|
'Enhancement',
|
|
|
|
'Restoration',
|
|
|
|
],
|
|
|
|
'Mage' => [
|
|
|
|
'Arcane',
|
|
|
|
'Fire',
|
|
|
|
'Frost',
|
|
|
|
],
|
|
|
|
'Warlock' => [
|
|
|
|
'Affliction',
|
|
|
|
'Demonology',
|
|
|
|
'Destruction',
|
|
|
|
],
|
|
|
|
|
|
|
|
'Monk' => [
|
|
|
|
'Brewmaster',
|
|
|
|
'Mistweaver',
|
|
|
|
'Windwalker',
|
|
|
|
],
|
2024-04-23 22:43:54 +02:00
|
|
|
'Demon Hunter' => [
|
|
|
|
'Havoc',
|
|
|
|
'Vengeance',
|
|
|
|
],
|
2024-04-26 17:47:19 +02:00
|
|
|
|
2024-04-23 22:43:54 +02:00
|
|
|
];
|
|
|
|
|
2024-04-26 17:47:19 +02:00
|
|
|
public function hasSpec($specs)
|
|
|
|
{
|
|
|
|
foreach ($specs as $search) {
|
|
|
|
if ($search) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-04-23 22:43:54 +02:00
|
|
|
|
|
|
|
public function form($instance)
|
|
|
|
{
|
|
|
|
|
|
|
|
?>
|
2024-04-26 17:47:19 +02:00
|
|
|
<link rel="stylesheet" type="text/css" href="<?= get_template_directory_uri() ?>/style.css">
|
|
|
|
<style>
|
|
|
|
input[type=radio] {
|
|
|
|
display: none !important;
|
2024-04-23 22:43:54 +02:00
|
|
|
}
|
2024-04-26 17:47:19 +02:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<div class="p-auto">
|
|
|
|
<label for="<?php echo esc_attr($this->get_field_id("text")); ?>"><?php echo esc_html__('Freitext', 'wowpress'); ?></label>
|
|
|
|
<textarea class="w-full" name="<?php echo esc_attr($this->get_field_name("text")); ?>" id="<?php echo esc_attr($this->get_field_id("text")); ?>" rows="10"><?=$instance['text']?></textarea>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex flex-col gap-2 p-auto">
|
|
|
|
<?php
|
|
|
|
foreach ($this->classes as $class => $specs) {
|
|
|
|
$classname = sanitize($class);
|
|
|
|
|
|
|
|
?>
|
|
|
|
<div class="bg-<?= $classname ?> bg-opacity-25 p-auto flex flex-col gap-2">
|
|
|
|
<div class="text-center flex flex-col justify-center items-center p-auto">
|
|
|
|
|
|
|
|
<img src="<?= Character::classIconLink($class) ?>" alt="" class="h-8">
|
|
|
|
<h2 class="text-xl font-bold text-<?= $classname ?>"><?= translate_string($class) ?></h2>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
foreach ($specs as $spec) {
|
|
|
|
$specname = sanitize($spec);
|
|
|
|
?>
|
|
|
|
<div class="grid grid-cols-5 gap-2 p-auto border border-<?= $classname ?>">
|
|
|
|
|
|
|
|
<div class="col-span-5">
|
|
|
|
<h3 class="text-lg font-bold text-<?= $classname ?>"><?= translate_string($spec) ?></h3>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<img src="<?= Character::specIconLink($class, $spec) ?>" alt="" class="">
|
|
|
|
|
|
|
|
<?php
|
|
|
|
(new ToggleButton([
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => esc_attr($this->get_field_name("classes[$class][$spec]]")),
|
|
|
|
'id' => esc_attr($this->get_field_id("classes[$class][$spec]]")) . "_0",
|
|
|
|
'value' => 0,
|
|
|
|
'text' => "Kein Bedarf",
|
|
|
|
'color' => $classname,
|
|
|
|
'icon_yes' => 'o-check',
|
|
|
|
'checked' => empty($instance['classes'][$class][$spec]),
|
|
|
|
'row' => false,
|
|
|
|
'fullHeight' => true,
|
|
|
|
]))->render();
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
(new ToggleButton([
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => esc_attr($this->get_field_name("classes[$class][$spec]]")),
|
|
|
|
'id' => esc_attr($this->get_field_id("classes[$class][$spec]]")) . "_1",
|
|
|
|
'value' => 1,
|
|
|
|
'text' => "Niedrig",
|
|
|
|
'color' => $classname,
|
|
|
|
'icon_yes' => 'o-check',
|
|
|
|
'checked' => $instance['classes'][$class][$spec] == 1,
|
|
|
|
'row' => false,
|
|
|
|
'fullHeight' => true,
|
|
|
|
]))->render();
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
(new ToggleButton([
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => esc_attr($this->get_field_name("classes[$class][$spec]]")),
|
|
|
|
'id' => esc_attr($this->get_field_id("classes[$class][$spec]]")) . "_2",
|
|
|
|
'value' => 2,
|
|
|
|
'text' => "Mittel",
|
|
|
|
'color' => $classname,
|
|
|
|
'icon_yes' => 'o-check',
|
|
|
|
'checked' => $instance['classes'][$class][$spec] == 2,
|
|
|
|
'row' => false,
|
|
|
|
'fullHeight' => true,
|
|
|
|
]))->render();
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
(new ToggleButton([
|
|
|
|
'type' => 'radio',
|
|
|
|
'name' => esc_attr($this->get_field_name("classes[$class][$spec]]")),
|
|
|
|
'id' => esc_attr($this->get_field_id("classes[$class][$spec]]")) . "_3",
|
|
|
|
'value' => 3,
|
|
|
|
'text' => "Hoch",
|
|
|
|
'color' => $classname,
|
|
|
|
'icon_yes' => 'o-check',
|
|
|
|
'checked' => $instance['classes'][$class][$spec] == 3,
|
|
|
|
'row' => false,
|
|
|
|
'fullHeight' => true,
|
|
|
|
]))->render();
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
2024-04-23 22:43:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function update($new_instance, $old_instance)
|
|
|
|
{
|
|
|
|
$instance = array();
|
2024-04-26 17:47:19 +02:00
|
|
|
$instance['text'] = (!empty($new_instance['text'])) ? strip_tags($new_instance['text']) : '';
|
2024-04-23 22:43:54 +02:00
|
|
|
foreach ($this->classes as $class => $specs) {
|
|
|
|
foreach ($specs as $spec) {
|
2024-04-26 17:47:19 +02:00
|
|
|
$instance['classes'][$class][$spec] = (!empty($new_instance['classes'][$class][$spec])) ? strip_tags($new_instance['classes'][$class][$spec]) : '';
|
2024-04-23 22:43:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
}
|