From 7d0771be2346fcb9ca5e93118b29b89a9c0e458b Mon Sep 17 00:00:00 2001 From: Seph Date: Mon, 5 Aug 2024 20:19:44 +0200 Subject: [PATCH] =?UTF-8?q?Raid-Titel=20=C3=A4ndern=20bei=20Custom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tailwind/tailwind.css | 1 - theme/functions.php | 3 +- theme/header.php | 2 + theme/options/api.php | 40 +--- theme/options/register.php | 59 ++++++ theme/options/style.php | 42 +++++ theme/pages/single_raid.php | 178 ++++++++++-------- theme/request.php | 23 ++- theme/template-parts/content/content-page.php | 17 +- .../template-parts/layout/header-content.php | 2 +- theme/template-parts/widgets/boss_kills.php | 11 +- theme/template-parts/widgets/char_search.php | 67 +++---- theme/wowpress/Frontend/NavWalker.php | 20 +- theme/wowpress/Frontend/Widgets/BossKills.php | 8 +- theme/wowpress/Models/Raid.php | 18 +- 15 files changed, 308 insertions(+), 183 deletions(-) create mode 100644 theme/options/register.php create mode 100644 theme/options/style.php diff --git a/tailwind/tailwind.css b/tailwind/tailwind.css index 2c42f30..da9588e 100644 --- a/tailwind/tailwind.css +++ b/tailwind/tailwind.css @@ -70,7 +70,6 @@ body { background-color: unset; - --body-bg: url('https://sephger.de/nkbg.png'); position: relative; z-index: -10; @apply min-h-screen; diff --git a/theme/functions.php b/theme/functions.php index 9e6b9ab..e120f54 100644 --- a/theme/functions.php +++ b/theme/functions.php @@ -396,7 +396,8 @@ function wowpress_add_category_meta($taxonomy) } //* Theme Options Page **/ - require_once(get_stylesheet_directory() . '/options/api.php'); + require_once(get_stylesheet_directory() . '/options/register.php'); + /** Global Helper functions */ function translate_string($string, $lang = "deu") diff --git a/theme/header.php b/theme/header.php index be72d9a..ae58529 100644 --- a/theme/header.php +++ b/theme/header.php @@ -26,6 +26,8 @@ global $user; diff --git a/theme/options/api.php b/theme/options/api.php index 95e4f11..28978e8 100644 --- a/theme/options/api.php +++ b/theme/options/api.php @@ -1,33 +1,4 @@
-

API-Optionen für

+

API-Optionen für

@@ -73,12 +44,3 @@ if ( ! isset( $_REQUEST['settings-updated'] ) )
+ +
+

Style-Optionen für

+ + +
+

Einstellungen gespeichert!

+
+ + +
+ + +

Hintergrund

+ + + + + + + + +
Hintergrund-Bild + +
+ +
+ + + + +

+
+
+id_wowaudit) { - if($raid->sync(true)){ + if ($raid->sync(true)) { $raid->save(); - }else{ + } else { $raid->status = "Cancelled"; $raid->save(); } - } @@ -34,107 +33,120 @@ get_header();
- title ?> + +
+ + + +
+ + +
+
+ + + title ?> +
next) : ?>
-status == "Cancelled"): ?> -
-
-
-

Raid abgesagt!

-
-
-
- -
-
-
-

Bosse

-
- encounters as $encounter) : ?> - - + status == "Cancelled") : ?> +
+
+
+

Raid abgesagt!

-
-
-
-
-
start, "EEEE") ?>
-
-
start, "dd. MMMM") ?>
-
-
Start: start, "HH:mm") ?>
-
Ende: end, "HH:mm") ?>
- difficulty) : ?> -
difficulty ?>
- -
-
-
+
+ +
+
+
+

Bosse

+
encounters as $encounter) : ?> -
-

Informationen für :

-
- -
-
+
- - -
- encounters as $encounter) : ?> -
- -
- groupBy('role') as $role => $signups) : - if ($role != "Unknown") : - ?> -
-

- - showForm(false, true, false, $encounter['id'] == 0,true) ?> - -
- +
+
+
+
+
start, "EEEE") ?>
+
+
start, "dd. MMMM") ?>
+
+
Start: start, "HH:mm") ?>
+
Ende: end, "HH:mm") ?>
+ difficulty) : ?> +
difficulty ?>
+
-
- +
+ encounters as $encounter) : ?> +
+

Informationen für :

+
+ +
+
+ +
+
+ +
+ encounters as $encounter) : ?> +
+ +
+ groupBy('role') as $role => $signups) : + if ($role != "Unknown") : + ?> +
+

+ + showForm(false, true, false, $encounter['id'] == 0, true) ?> + +
+ +
+ +
+ + +
-
-
-
-
-

Status

- showSignup($user->characters->first(), true, true, true) ?> +
+
+
+

Status

+ showSignup($user->characters->first(), true, true, true) ?> +
-
-
-

Keine Rückmeldung

-
- - showForm() ?> - +
+

Keine Rückmeldung

+
+ + showForm() ?> + +
-
-
+
ID && $note->user_id == get_current_user_id())){ + if (!empty($note->ID && $note->user_id == get_current_user_id())) { $note->delete(); } } } } 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']); diff --git a/theme/template-parts/content/content-page.php b/theme/template-parts/content/content-page.php index 559b0d5..7eeea56 100644 --- a/theme/template-parts/content/content-page.php +++ b/theme/template-parts/content/content-page.php @@ -7,6 +7,9 @@ * @package WowPress */ + if(!(get_post_meta(get_the_ID(),'loggedin',true) && !is_user_logged_in())){ + + ?> @@ -29,7 +32,7 @@ -
> +
> + + + +
+
+

Keine Berechtigung die Seite anzuzeigen

+
+
+ + + \ No newline at end of file diff --git a/theme/template-parts/layout/header-content.php b/theme/template-parts/layout/header-content.php index a978d73..32afed9 100644 --- a/theme/template-parts/layout/header-content.php +++ b/theme/template-parts/layout/header-content.php @@ -15,7 +15,7 @@ use WoWPress\Models\Notification; if (is_user_logged_in()) { $notifications = Notification::getAll(); } else { - $notifications = []; + $notifications = collect([]); } ?> diff --git a/theme/template-parts/widgets/boss_kills.php b/theme/template-parts/widgets/boss_kills.php index f46eedb..c17afe7 100644 --- a/theme/template-parts/widgets/boss_kills.php +++ b/theme/template-parts/widgets/boss_kills.php @@ -1,10 +1,19 @@

title ?>

-

+

diff --git a/theme/template-parts/widgets/char_search.php b/theme/template-parts/widgets/char_search.php index 803b6d5..31d1b85 100644 --- a/theme/template-parts/widgets/char_search.php +++ b/theme/template-parts/widgets/char_search.php @@ -2,50 +2,43 @@ use WoWPress\Models\Character; -function hasSearch($specs) - { - foreach ($specs as $spec) { - foreach ($spec as $search) { - if ($search) { - return true; - } - } - } - return false; - } - ?>

Klassensuche

- +
- +
- + $specs) : ?> - hasSpec($specs)): ?> -
-
- $search) : ?> -
class="h-8 border border-red-500" title=": Hoch"class="h-8 opacity-70 border border-yellow-500" title=": Mittel"class="h-8 opacity-50 border border-green-500" title=": Niedrig"class="h-8 opacity-10" title=": Suche geschlossen" - >
- - -
+ hasSpec($specs)) : ?> +
+
+ $search) : + switch ($search) { + case 3: + $classes = "border border-red-500"; + $text = "Hoch"; + break; + case 2: + $classes = "border border-yellow-500 opacity-70"; + $text = "Mittel"; + break; + case 1: + $classes = "border border-green-500 opacity-50"; + $text = "Niedrig"; + break; + case 0: + default: + $classes = "opacity-10"; + $text = "Suche geschlossen"; + break; + } ?> +
+ +
+
\ No newline at end of file diff --git a/theme/wowpress/Frontend/NavWalker.php b/theme/wowpress/Frontend/NavWalker.php index 8cc7d8a..7fd8d9f 100644 --- a/theme/wowpress/Frontend/NavWalker.php +++ b/theme/wowpress/Frontend/NavWalker.php @@ -17,13 +17,12 @@ class NavWalker extends \Walker_Nav_Menu } function end_lvl(&$output, $depth = 0, $args = null) { - - $output .= '
'; } function end_el(&$output, $item, $depth = 0, $args = \null) { + $classes = collect($item->classes); if (0 === $depth) { $output .= '
'; } @@ -31,17 +30,16 @@ class NavWalker extends \Walker_Nav_Menu 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) { - $output .= '
'; + $output .= '
'; $output .= '"; } elseif ($item->url && $item->url != '#') { diff --git a/theme/wowpress/Frontend/Widgets/BossKills.php b/theme/wowpress/Frontend/Widgets/BossKills.php index 599ffba..9f1c197 100644 --- a/theme/wowpress/Frontend/Widgets/BossKills.php +++ b/theme/wowpress/Frontend/Widgets/BossKills.php @@ -14,6 +14,9 @@ class BossKills extends Widget public function getBossList($instance){ $out = []; + if(empty($instance['bosses'])){ + $instance['bosses'] = []; + } foreach($instance['bosses'] as $boss){ if(!empty($boss['name'])){ $out[] = $boss; @@ -24,7 +27,10 @@ class BossKills extends Widget } public function getCompletePercent($instance){ - $bosses = $this->getBossList($instance); + $bosses = $this->getBossList($instance)?:[]; + if(empty($bosses)){ + return 0; + } $done = 0; foreach($bosses as $boss){ if(!empty($boss['date'])){ diff --git a/theme/wowpress/Models/Raid.php b/theme/wowpress/Models/Raid.php index 5068c1a..358f6a5 100644 --- a/theme/wowpress/Models/Raid.php +++ b/theme/wowpress/Models/Raid.php @@ -81,7 +81,11 @@ class Raid extends Model if (!empty($this->id_wowaudit)) { $raid = (object)$this->api->getRaid($this->id_wowaudit, $force); 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->end = $raid->date . " " . $raid->end_time; $this->difficulty = $raid->difficulty; @@ -188,6 +192,11 @@ class Raid extends Model return $this; } + public function setTitle($title){ + $this->title = $title; + $this->save(); + } + public function getColorAttribute($type = "") { switch ($this->difficulty) { @@ -222,8 +231,11 @@ class Raid extends Model $clean_name = str_replace([" ","'"],"-",$this->title); $clean_name = preg_replace('/[^a-zA-Z0-9_-]/', '', $clean_name); $clean_name = strtolower($clean_name); - - return "https://data.wowaudit.com/img/$clean_name-small.jpeg"; + $url = "https://data.wowaudit.com/img/$clean_name-small.jpeg"; + if(file_exists($url)){ + return $url; + } + return "https://data.wowaudit.com/img/custom-small.jpeg"; }