Raid-Titel ändern bei Custom

master
Seph 2024-08-05 20:19:44 +02:00
parent 52bdd3c703
commit 7d0771be23
15 changed files with 308 additions and 183 deletions

View File

@ -70,7 +70,6 @@
body { body {
background-color: unset; background-color: unset;
--body-bg: url('https://sephger.de/nkbg.png');
position: relative; position: relative;
z-index: -10; z-index: -10;
@apply min-h-screen; @apply min-h-screen;

View File

@ -396,7 +396,8 @@ function wowpress_add_category_meta($taxonomy)
} }
//* Theme Options Page **/ //* Theme Options Page **/
require_once(get_stylesheet_directory() . '/options/api.php'); require_once(get_stylesheet_directory() . '/options/register.php');
/** Global Helper functions */ /** Global Helper functions */
function translate_string($string, $lang = "deu") function translate_string($string, $lang = "deu")

View File

@ -26,6 +26,8 @@ global $user;
<style> <style>
:root { :root {
--color-background: var(--color-deepblue); --color-background: var(--color-deepblue);
--body-bg: url('/wp-content/bg.jpg');
} }
</style> </style>
</head> </head>

View File

@ -1,33 +1,4 @@
<?php <?php
/* ------------------ */
/* theme options page */
/* ------------------ */
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
// Einstellungen registrieren (http://codex.wordpress.org/Function_Reference/register_setting)
function theme_options_init(){
register_setting( 'wowpress_options', 'wowpress_api', 'kb_validate_options' );
}
// Seite in der Dashboard-Navigation erstellen
function theme_options_add_page() {
add_menu_page(
'Theme-Einstellungen',
'Theme-Einstellungen',
'wowpress_edit_site',
'wowpress_options',
'wowpress_api_options_page',
'dashicons-universal-access',
25
);
#add_theme_page('API-Einstellungen', 'API-Einstellungen', 'edit_theme_options', 'api_options', 'wowpress_api_options_page' ); // Seitentitel, Titel in der Navi, Berechtigung zum Editieren (http://codex.wordpress.org/Roles_and_Capabilities) , Slug, Funktion
}
// Optionen-Seite erstellen // Optionen-Seite erstellen
function wowpress_api_options_page() { function wowpress_api_options_page() {
global $select_options, $radio_options; global $select_options, $radio_options;
@ -35,7 +6,7 @@ if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false; ?> $_REQUEST['settings-updated'] = false; ?>
<div class="wrap"> <div class="wrap">
<?php screen_icon(); ?><h2>API-Optionen für <?php bloginfo('name'); ?></h2> <h2>API-Optionen für <?php bloginfo('name'); ?></h2>
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?> <?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade"> <div class="updated fade">
@ -73,12 +44,3 @@ if ( ! isset( $_REQUEST['settings-updated'] ) )
</div> </div>
<?php } <?php }
// Strip HTML-Code:
// Hier kann definiert werden, ob HTML-Code in einem Eingabefeld
// automatisch entfernt werden soll. Soll beispielsweise im
// Copyright-Feld KEIN HTML-Code erlaubt werden, kommentiert die Zeile
// unten wieder ein. http://codex.wordpress.org/Function_Reference/wp_filter_nohtml_kses
function kb_validate_options( $input ) {
// $input['copyright'] = wp_filter_nohtml_kses( $input['copyright'] );
return $input;
}

View File

@ -0,0 +1,59 @@
<?php
require_once('api.php');
require_once('style.php');
add_action('admin_init', 'theme_options_init');
add_action('admin_menu', 'theme_options_add_page');
/* ------------------ */
/* theme options page */
/* ------------------ */
add_action('admin_init', 'theme_options_init');
add_action('admin_menu', 'theme_options_add_page');
// Einstellungen registrieren (http://codex.wordpress.org/Function_Reference/register_setting)
function theme_options_init()
{
register_setting('wowpress_options', 'wowpress_api', 'kb_validate_options');
register_setting('wowpress_options', 'wowpress_style', 'kb_validate_options');
}
// Seite in der Dashboard-Navigation erstellen
function theme_options_add_page()
{
add_menu_page(
'API-Keys',
'API-Keys',
'wowpress_edit_site',
'wowpress_api_options',
'wowpress_api_options_page',
'dashicons-lock',
25
);
add_menu_page(
'Hintergrund',
'Hintergrund',
'wowpress_edit_site',
'wowpress_style_options',
'wowpress_style_options_page',
'dashicons-format-image',
26
);
}
// Strip HTML-Code:
// Hier kann definiert werden, ob HTML-Code in einem Eingabefeld
// automatisch entfernt werden soll. Soll beispielsweise im
// Copyright-Feld KEIN HTML-Code erlaubt werden, kommentiert die Zeile
// unten wieder ein. http://codex.wordpress.org/Function_Reference/wp_filter_nohtml_kses
function kb_validate_options($input)
{
// $input['copyright'] = wp_filter_nohtml_kses( $input['copyright'] );
return $input;
}

View File

@ -0,0 +1,42 @@
<?php
// Optionen-Seite erstellen
function wowpress_style_options_page() {
global $select_options, $radio_options;
if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false; ?>
<div class="wrap">
<h2>Style-Optionen für <?php bloginfo('name'); ?></h2>
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade">
<p><strong>Einstellungen gespeichert!</strong></p>
</div>
<?php endif; ?>
<form method="post" action="/request" enctype="multipart/form-data">
<input type="hidden" name="action" value="updatePageBG" >
<?php wp_nonce_field('updatePageBG', 'updatePageBG_nonce'); ?>
<h3>Hintergrund</h3>
<table class="form-table">
<tr valign="top">
<th scope="row">Hintergrund-Bild</th>
<td>
<input type="file" name="bg" id="wowpress_bg" accept="image/jpeg">
</td>
</tr>
<tr>
<td colspan="2">
<img src="/wp-content/bg.jpg" alt="" style="width: 42rem;">
</td>
</tr>
</table>
<!-- submit -->
<p class="submit"><input type="submit" class="button-primary" value="Hochladen" /></p>
</form>
</div>
<?php }

View File

@ -15,13 +15,12 @@ set_sidebar_status('right', false);
global $user; global $user;
if ($raid->id_wowaudit) { if ($raid->id_wowaudit) {
if($raid->sync(true)){ if ($raid->sync(true)) {
$raid->save(); $raid->save();
}else{ } else {
$raid->status = "Cancelled"; $raid->status = "Cancelled";
$raid->save(); $raid->save();
} }
} }
@ -34,107 +33,120 @@ get_header();
<a href="<?= $raid->previous->link ?>" class="btn btn-outline hidden lg:flex">Vorheriger</a> <a href="<?= $raid->previous->link ?>" class="btn btn-outline hidden lg:flex">Vorheriger</a>
<?php endif; ?> <?php endif; ?>
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full"> <div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
<?= $raid->title ?> <?php if (current_user_can('wowpress_edit_raids')) : ?>
<form action="/request" method="POST">
<?php wp_nonce_field('updateRaidTitle', 'updateRaidTitle_nonce'); ?>
<input type="hidden" name="action" value="updateRaidTitle">
<input type="hidden" name="raid_id" value="<?= $raid->ID ?>">
<div class="flex flex-row gap-1 justify-center">
<input type="text" name="name" class="bg-white bg-opacity-0 border-alliance" value="<?= $raid->title ?>">
<button class="btn btn-green">Titel ändern</button>
</div>
</form>
<?php else : ?>
<?= $raid->title ?>
<?php endif; ?>
</div> </div>
<?php if ($raid->next) : ?> <?php if ($raid->next) : ?>
<a href="<?= $raid->next->link ?>" class="btn btn-outline hidden lg:flex">Nächster</a> <a href="<?= $raid->next->link ?>" class="btn btn-outline hidden lg:flex">Nächster</a>
<?php endif; ?> <?php endif; ?>
</div> </div>
<section id="primary"> <section id="primary">
<?php if($raid->status == "Cancelled"): ?> <?php if ($raid->status == "Cancelled") : ?>
<main id="main"> <main id="main">
<div class="flex flex-col lg:flex-row gap-auto"> <div class="flex flex-col lg:flex-row gap-auto">
<div class="bg-glass shadow p-auto w-full text-center"> <div class="bg-glass shadow p-auto w-full text-center">
<h1 class="text-3xl font-bold text-red">Raid abgesagt!</h1> <h1 class="text-3xl font-bold text-red">Raid abgesagt!</h1>
</div>
</div>
</main>
<?php else: ?>
<main id="main">
<div class="flex flex-col lg:flex-row gap-auto" x-data="{encounter:<?= $raid->encounters[0]['id'] ?>}">
<div class="bg-glass shadow p-auto w-full lg:w-1/5 order-2 lg:order-1">
<h3 class="text-xl font-bold text-center">Bosse</h3>
<div class="grid gap-auto">
<?php foreach ($raid->encounters as $encounter) : ?>
<button <?= $encounter['enabled'] ? "" : "disabled" ?> x-on:click="encounter=<?= $encounter['id'] ?>" class="btn btn-outline <?= $encounter['enabled'] ? "btn-green" : "btn-slate" ?>" :class="{'current-menu-item' : encounter==<?= $encounter['id'] ?> }"><?= $encounter['name'] ?></button>
<?php endforeach; ?>
</div> </div>
</div> </div>
<div class="w-full flex flex-col gap-auto order-3 lg:order-2"> </main>
<div class="flex flex-col lg:flex-row gap-auto"> <?php else : ?>
<div class="bg-glass shadow p-auto w-full lg:w-1/5"> <main id="main">
<div class="grid text-center gap-1"> <div class="flex flex-col lg:flex-row gap-auto" x-data="{encounter:<?= $raid->encounters[0]['id'] ?>}">
<div class="bg-<?= $raid->color ?> text-black text-2xl "><?= format_date($raid->start, "EEEE") ?></div> <div class="bg-glass shadow p-auto w-full lg:w-1/5 order-2 lg:order-1">
<div class="border border-<?= $raid->color ?>"> <h3 class="text-xl font-bold text-center">Bosse</h3>
<div class="text-3xl p-auto "><?= format_date($raid->start, "dd. MMMM") ?></div> <div class="grid gap-auto">
</div>
<div class="border border-<?= $raid->color ?> p-2">Start: <?= format_date($raid->start, "HH:mm") ?></div>
<div class="border border-<?= $raid->color ?> p-2">Ende: <?= format_date($raid->end, "HH:mm") ?></div>
<?php if ($raid->difficulty) : ?>
<div class="border border-<?= $raid->color ?> p-2"><?= $raid->difficulty ?></div>
<?php endif; ?>
</div>
</div>
<div class="bg-glass shadow p-auto w-full">
<?php foreach ($raid->encounters as $encounter) : ?> <?php foreach ($raid->encounters as $encounter) : ?>
<div x-cloak x-show="encounter==<?= $encounter['id'] ?>"> <button <?= $encounter['enabled'] ? "" : "disabled" ?> x-on:click="encounter=<?= $encounter['id'] ?>" class="btn btn-outline <?= $encounter['enabled'] ? "btn-green" : "btn-slate" ?>" :class="{'current-menu-item' : encounter==<?= $encounter['id'] ?> }"><?= $encounter['name'] ?></button>
<h3 class="text-xl font-bold">Informationen für : <?= $encounter['name'] ?></h3>
<div>
<?= $encounter['notes'] ?>
</div>
</div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
<div class="w-full flex flex-col gap-auto order-3 lg:order-2">
<div class="flex flex-col lg:flex-row gap-auto">
<div class="flex flex-col lg:flex-row gap-auto"> <div class="bg-glass shadow p-auto w-full lg:w-1/5">
<?php foreach ($raid->encounters as $encounter) : ?> <div class="grid text-center gap-1">
<div x-cloak x-show="encounter==<?= $encounter['id'] ?>" class="w-full"> <div class="bg-<?= $raid->color ?> text-black text-2xl "><?= format_date($raid->start, "EEEE") ?></div>
<div class="border border-<?= $raid->color ?>">
<div class="w-full grid grid-cols-1 lg:grid-cols-4 gap-auto"> <div class="text-3xl p-auto "><?= format_date($raid->start, "dd. MMMM") ?></div>
<?php </div>
foreach ($encounter['selections']->groupBy('role') as $role => $signups) : <div class="border border-<?= $raid->color ?> p-2">Start: <?= format_date($raid->start, "HH:mm") ?></div>
if ($role != "Unknown") : <div class="border border-<?= $raid->color ?> p-2">Ende: <?= format_date($raid->end, "HH:mm") ?></div>
?> <?php if ($raid->difficulty) : ?>
<div class="bg-glass shadow p-auto flex flex-col gap-auto"> <div class="border border-<?= $raid->color ?> p-2"><?= $raid->difficulty ?></div>
<h3 class="text-xl font-bold text-center"><?= $role ?></h3> <?php endif; ?>
<?php foreach ($signups as $signup) : ?>
<?= $signup->showForm(false, true, false, $encounter['id'] == 0,true) ?>
<?php endforeach; ?>
</div>
<?php
else : if ($encounter['id'] == 0) : $unknowns = $signups;
endif;
endif;
endforeach;
?>
</div> </div>
</div> </div>
<?php endforeach; ?> <div class="bg-glass shadow p-auto w-full">
<?php foreach ($raid->encounters as $encounter) : ?>
<div x-cloak x-show="encounter==<?= $encounter['id'] ?>">
<h3 class="text-xl font-bold">Informationen für : <?= $encounter['name'] ?></h3>
<div>
<?= $encounter['notes'] ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<div class="flex flex-col lg:flex-row gap-auto">
<?php foreach ($raid->encounters as $encounter) : ?>
<div x-cloak x-show="encounter==<?= $encounter['id'] ?>" class="w-full">
<div class="w-full grid grid-cols-1 lg:grid-cols-4 gap-auto">
<?php
foreach ($encounter['selections']->groupBy('role') as $role => $signups) :
if ($role != "Unknown") :
?>
<div class="bg-glass shadow p-auto flex flex-col gap-auto">
<h3 class="text-xl font-bold text-center"><?= $role ?></h3>
<?php foreach ($signups as $signup) : ?>
<?= $signup->showForm(false, true, false, $encounter['id'] == 0, true) ?>
<?php endforeach; ?>
</div>
<?php
else : if ($encounter['id'] == 0) : $unknowns = $signups;
endif;
endif;
endforeach;
?>
</div>
</div>
<?php endforeach; ?>
</div>
</div> </div>
</div> <div class="flex flex-col gap-auto w-full lg:w-1/5 order-1 lg:order-3">
<div class="flex flex-col gap-auto w-full lg:w-1/5 order-1 lg:order-3"> <div class="bg-glass shadow p-auto">
<div class="bg-glass shadow p-auto"> <div class="flex flex-col gap-auto">
<div class="flex flex-col gap-auto"> <h3 class="text-xl font-bold text-center">Status</h3>
<h3 class="text-xl font-bold text-center">Status</h3> <?= $raid->showSignup($user->characters->first(), true, true, true) ?>
<?= $raid->showSignup($user->characters->first(), true, true, true) ?> </div>
</div> </div>
</div> </div>
</div> </div>
</div> <div class="w-full order-4 bg-glass shadow p-auto flex flex-col gap-auto">
<div class="w-full order-4 bg-glass shadow p-auto flex flex-col gap-auto"> <h3 class="text-xl font-bold text-center">Keine Rückmeldung</h3>
<h3 class="text-xl font-bold text-center">Keine Rückmeldung</h3> <div class="grid grid-cols-1 lg:grid-cols-5 flex-wrap gap-auto">
<div class="grid grid-cols-1 lg:grid-cols-5 flex-wrap gap-auto"> <?php foreach ($unknowns as $signup) : ?>
<?php foreach ($unknowns as $signup) : ?> <?= $signup->showForm() ?>
<?= $signup->showForm() ?> <?php endforeach; ?>
<?php endforeach; ?> </div>
</div> </div>
</div>
<?php endif; ?> <?php endif; ?>
</main> </main>
</section> </section>
<?php <?php
get_footer(); get_footer();

View File

@ -324,13 +324,34 @@ switch ($_POST['action']) {
if (isset($_POST['notificationSeen_nonce']) && wp_verify_nonce($_POST['notificationSeen_nonce'], 'notificationSeen')) { if (isset($_POST['notificationSeen_nonce']) && wp_verify_nonce($_POST['notificationSeen_nonce'], 'notificationSeen')) {
if (isset($_POST['notification_id'])) { if (isset($_POST['notification_id'])) {
$note = Notification::find($_POST['notification_id']); $note = Notification::find($_POST['notification_id']);
if(!empty($note->ID && $note->user_id == get_current_user_id())){ if (!empty($note->ID && $note->user_id == get_current_user_id())) {
$note->delete(); $note->delete();
} }
} }
} }
} }
break; break;
case 'updatePageBG':
isAllowed('wowpress_edit_site');
if (isset($_POST['updatePageBG_nonce']) && wp_verify_nonce($_POST['updatePageBG_nonce'], 'updatePageBG')) {
if (isset($_FILES['bg']) && $_FILES['bg']['type'] == "image/jpeg" ) {
$bg_path = ABSPATH."/wp-content/bg.jpg";
rename($_FILES['bg']['tmp_name'],$bg_path);
chmod(ABSPATH."/wp-content/bg.jpg",0644);
}
}
break;
case 'updateRaidTitle':
isAllowed('wowpress_edit_raids');
if (isset($_POST['updateRaidTitle_nonce']) && wp_verify_nonce($_POST['updateRaidTitle_nonce'], 'updateRaidTitle')) {
if(isset($_POST['raid_id']) && isset($_POST['name'])){
$raid = Raid::find($_POST['raid_id']);
if($raid){
$raid->setTitle($_POST['name']);
}
}
}
} }
header('Location: ' . $_SERVER['HTTP_REFERER']); header('Location: ' . $_SERVER['HTTP_REFERER']);

View File

@ -7,6 +7,9 @@
* @package WowPress * @package WowPress
*/ */
if(!(get_post_meta(get_the_ID(),'loggedin',true) && !is_user_logged_in())){
?> ?>
@ -29,7 +32,7 @@
<?php wowpress_post_thumbnail(); ?> <?php wowpress_post_thumbnail(); ?>
<div class="" <?php wowpress_content_class( 'entry-content' ); ?>> <div class="prose text-white" <?php wowpress_content_class( 'entry-content' ); ?>>
<?php <?php
the_content(); the_content();
@ -45,3 +48,15 @@
</article><!-- #post-<?php the_ID(); ?> --> </article><!-- #post-<?php the_ID(); ?> -->
<?php }else{
?>
<div class="bg-glass shadow p-auto text-center">
<header class="entry-header">
<h1>Keine Berechtigung die Seite anzuzeigen</h1>
</header>
</div>
<?php } ?>

View File

@ -15,7 +15,7 @@ use WoWPress\Models\Notification;
if (is_user_logged_in()) { if (is_user_logged_in()) {
$notifications = Notification::getAll(); $notifications = Notification::getAll();
} else { } else {
$notifications = []; $notifications = collect([]);
} }
?> ?>

View File

@ -1,10 +1,19 @@
<?php <?php
if(!empty($instance['raid_name'])){
$raid_name = $instance['raid_name'];
}else{
$raid_name = "";
}
?> ?>
<div class="bg-glass shadow p-auto order-last flex flex-col gap-2"> <div class="bg-glass shadow p-auto order-last flex flex-col gap-2">
<h3 class="text-xl font-bold text-center"><?= $this->title ?></h3> <h3 class="text-xl font-bold text-center"><?= $this->title ?></h3>
<h4 class="text-lg font-bold text-center"><?= $instance['raid_name'] ?></h4> <h4 class="text-lg font-bold text-center"><?= $raid_name ?></h4>
<div class="relative pt-1"> <div class="relative pt-1">
<div class="overflow-hidden h-2 mb-4 text-xs flex bg-slate-200"> <div class="overflow-hidden h-2 mb-4 text-xs flex bg-slate-200">
<div style="width:<?=$this->getCompletePercent($instance)?>%" class="shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-alliance"></div> <div style="width:<?=$this->getCompletePercent($instance)?>%" class="shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-alliance"></div>

View File

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

View File

@ -17,13 +17,12 @@ class NavWalker extends \Walker_Nav_Menu
} }
function end_lvl(&$output, $depth = 0, $args = null) function end_lvl(&$output, $depth = 0, $args = null)
{ {
$output .= '</div></div>'; $output .= '</div></div>';
} }
function end_el(&$output, $item, $depth = 0, $args = \null) function end_el(&$output, $item, $depth = 0, $args = \null)
{ {
$classes = collect($item->classes);
if (0 === $depth) { if (0 === $depth) {
$output .= '</div>'; $output .= '</div>';
} }
@ -31,17 +30,16 @@ class NavWalker extends \Walker_Nav_Menu
function start_el(&$output, $item, $depth = 0, $args = [], $id = 0) function start_el(&$output, $item, $depth = 0, $args = [], $id = 0)
{ {
$classes = collect($item->classes);
$needs_login = $classes->contains('loggedin')&&!is_user_logged_in();
if ($args->walker->has_children) { if ($args->walker->has_children) {
$output .= '<div x-cloak @click.away="open = false" class="relative" x-data="{ open: false }">'; $output .= '<div x-cloak @click.away="open = false" class="relative '.($needs_login?"hidden":"").'" x-data="{ open: false }">';
$output .= '<button @click="open = !open" class="w-full nav-btn ' . implode(" ", $item->classes) . '">'; $output .= '<button @click="open = !open" class="w-full nav-btn ' . implode(" ", $item->classes) . '">';
} elseif ($item->url && $item->url != '#' && $item->url != "#LOGIN") { } elseif ($item->url && $item->url != '#' && $item->url != "#LOGIN") {
if (0 === $depth) { if (0 === $depth) {
$output .= '<div>'; $output .= '<div class="'.($needs_login?"hidden":"").'">';
} }
$output .= '<a class="nav-btn ' . implode(" ", $item->classes) . '" href="' . $item->url . '">'; $output .= '<a class="nav-btn ' . implode(" ", $item->classes) . ' '.($needs_login?"hidden":"").'" href="' . $item->url . '">';
} elseif ($item->url && $item->url == "#LOGIN") { } elseif ($item->url && $item->url == "#LOGIN") {
if (!is_user_logged_in()) { if (!is_user_logged_in()) {
if (0 === $depth) { if (0 === $depth) {
@ -54,8 +52,6 @@ class NavWalker extends \Walker_Nav_Menu
$output .= '<div>'; $output .= '<div>';
} }
$item->classes[] = "btn-alliance btn-outline"; $item->classes[] = "btn-alliance btn-outline";
$output .= '<a class="nav-btn ' . implode(" ", $item->classes) . '" href="/wp-admin/profile.php">'; $output .= '<a class="nav-btn ' . implode(" ", $item->classes) . '" href="/wp-admin/profile.php">';
} }
} else { } else {
@ -64,14 +60,12 @@ class NavWalker extends \Walker_Nav_Menu
} }
$output .= '<span class="nav-btn ' . implode(" ", $item->classes) . '">'; $output .= '<span class="nav-btn ' . implode(" ", $item->classes) . '">';
} }
foreach ($item->classes as $class) { foreach ($item->classes as $class) {
if (str_contains($class, "icon-")) { if (str_contains($class, "icon-")) {
$icon_name = substr($class, 5); $icon_name = substr($class, 5);
$output .= Icon::get($icon_name, "24px"); $output .= Icon::get($icon_name, "24px");
} }
} }
if ($item->url && $item->url == "#LOGIN") { if ($item->url && $item->url == "#LOGIN") {
if (is_user_logged_in()) { if (is_user_logged_in()) {
@ -82,13 +76,11 @@ class NavWalker extends \Walker_Nav_Menu
} else { } else {
$output .= $item->title; $output .= $item->title;
} }
if ($args->walker->has_children) { if ($args->walker->has_children) {
$output .= " $output .= "
<svg fill= \"currentColor\" viewBox=\"0 0 20 20\" :class=\"{'rotate-180': open, 'rotate-0': !open}\" class=\"inline w-4 h-4 mt-1 ml-1 transition-transform duration-200 transform md:-mt-1\"><path fill-rule=\"evenodd\" d=\"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z\" clip-rule=\"evenodd\"></path></svg> <svg fill= \"currentColor\" viewBox=\"0 0 20 20\" :class=\"{'rotate-180': open, 'rotate-0': !open}\" class=\"inline w-4 h-4 mt-1 ml-1 transition-transform duration-200 transform md:-mt-1\"><path fill-rule=\"evenodd\" d=\"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z\" clip-rule=\"evenodd\"></path></svg>
"; ";
} }
if ($args->walker->has_children) { if ($args->walker->has_children) {
$output .= "</button>"; $output .= "</button>";
} elseif ($item->url && $item->url != '#') { } elseif ($item->url && $item->url != '#') {

View File

@ -14,6 +14,9 @@ class BossKills extends Widget
public function getBossList($instance){ public function getBossList($instance){
$out = []; $out = [];
if(empty($instance['bosses'])){
$instance['bosses'] = [];
}
foreach($instance['bosses'] as $boss){ foreach($instance['bosses'] as $boss){
if(!empty($boss['name'])){ if(!empty($boss['name'])){
$out[] = $boss; $out[] = $boss;
@ -24,7 +27,10 @@ class BossKills extends Widget
} }
public function getCompletePercent($instance){ public function getCompletePercent($instance){
$bosses = $this->getBossList($instance); $bosses = $this->getBossList($instance)?:[];
if(empty($bosses)){
return 0;
}
$done = 0; $done = 0;
foreach($bosses as $boss){ foreach($bosses as $boss){
if(!empty($boss['date'])){ if(!empty($boss['date'])){

View File

@ -81,7 +81,11 @@ class Raid extends Model
if (!empty($this->id_wowaudit)) { if (!empty($this->id_wowaudit)) {
$raid = (object)$this->api->getRaid($this->id_wowaudit, $force); $raid = (object)$this->api->getRaid($this->id_wowaudit, $force);
if (!empty($raid->id)) { if (!empty($raid->id)) {
$this->title = $raid->instance; if($this->title && $raid->instance == "Custom"){
//Titel nur sezten wenn kein Custom Raid
}else{
$this->title = $raid->instance;
}
$this->start = $raid->date . " " . $raid->start_time; $this->start = $raid->date . " " . $raid->start_time;
$this->end = $raid->date . " " . $raid->end_time; $this->end = $raid->date . " " . $raid->end_time;
$this->difficulty = $raid->difficulty; $this->difficulty = $raid->difficulty;
@ -188,6 +192,11 @@ class Raid extends Model
return $this; return $this;
} }
public function setTitle($title){
$this->title = $title;
$this->save();
}
public function getColorAttribute($type = "") public function getColorAttribute($type = "")
{ {
switch ($this->difficulty) { switch ($this->difficulty) {
@ -222,8 +231,11 @@ class Raid extends Model
$clean_name = str_replace([" ","'"],"-",$this->title); $clean_name = str_replace([" ","'"],"-",$this->title);
$clean_name = preg_replace('/[^a-zA-Z0-9_-]/', '', $clean_name); $clean_name = preg_replace('/[^a-zA-Z0-9_-]/', '', $clean_name);
$clean_name = strtolower($clean_name); $clean_name = strtolower($clean_name);
$url = "https://data.wowaudit.com/img/$clean_name-small.jpeg";
return "https://data.wowaudit.com/img/$clean_name-small.jpeg"; if(file_exists($url)){
return $url;
}
return "https://data.wowaudit.com/img/custom-small.jpeg";
} }