From 537ee2e6562d66007063a20c8dc52302dd76b9b8 Mon Sep 17 00:00:00 2001
From: Grischa Brockhaus <github@brockha.us>
Date: Fri, 25 Nov 2022 02:05:38 +0100
Subject: [PATCH] Code style

---
 fancybox/fancybox.php | 65 +++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 37 deletions(-)

diff --git a/fancybox/fancybox.php b/fancybox/fancybox.php
index b572b7f8..a0279914 100644
--- a/fancybox/fancybox.php
+++ b/fancybox/fancybox.php
@@ -12,50 +12,41 @@ use Friendica\DI;
 
 function fancybox_install()
 {
-    Hook::register('head', __FILE__, 'fancybox_head');
-    Hook::register('footer', __FILE__, 'fancybox_footer');
-    Hook::register('prepare_body_final', __FILE__, 'fancybox_render');
+	Hook::register('head', __FILE__, 'fancybox_head');
+	Hook::register('footer', __FILE__, 'fancybox_footer');
+	Hook::register('prepare_body_final', __FILE__, 'fancybox_render');
 }
 
 function fancybox_head(App $a, string &$b)
 {
-    DI::page()->registerStylesheet(__DIR__ . '/asset/fancybox/jquery.fancybox.min.css');
+	DI::page()->registerStylesheet(__DIR__ . '/asset/fancybox/jquery.fancybox.min.css');
 }
+
 function fancybox_footer(App $a, string &$str)
 {
-    DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/jquery.fancybox.min.js');
-    DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js');
+	DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/jquery.fancybox.min.js');
+	DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js');
 }
 
-/*
-
-prepare_body_final
-
-Called at the end of prepare_body(). Hook data:
-
-    item: item array (input)
-    html: converted item body (input/output)
-
-*/
-
-function fancybox_render(App $a, array &$b) {
-    $matches = [];
-    $pattern='#<div class="body-attach">.*?</div>#s';
-    $gallery = 'gallery';
-    if (array_key_exists('item', $b)) {
-        $item = $b['item'];
-        if (array_key_exists('uri-id', $item)) {
-            $gallery = $gallery . '-' . $item['uri-id'];
-        }
-    }
-    $html = $b['html'];
-    while (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
-        if (is_array($matches)) $matches=$matches[0];
-        $part = $matches[0];
-        $replaced = str_replace('<a href', '<a data-fancybox="' . $gallery . '" href', $part);
-        $replaced = str_replace('<div class="body-attach"', '<div class="body-attach done"', $replaced);
-        $html =str_replace($part, $replaced, $html);
-    }
-    $html = str_replace('class="body-attach done"', 'class="body-attach"', $html);
-    $b['html'] = $html;
+function fancybox_render(App $a, array &$b)
+{
+	$matches = [];
+	$pattern = '#<div class="body-attach">.*?</div>#s';
+	$gallery = 'gallery';
+	if (array_key_exists('item', $b)) {
+		$item = $b['item'];
+		if (array_key_exists('uri-id', $item)) {
+			$gallery = $gallery . '-' . $item['uri-id'];
+		}
+	}
+	$html = $b['html'];
+	while (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
+		if (is_array($matches)) $matches = $matches[0];
+		$part = $matches[0];
+		$replaced = str_replace('<a href', '<a data-fancybox="' . $gallery . '" href', $part);
+		$replaced = str_replace('<div class="body-attach"', '<div class="body-attach done"', $replaced);
+		$html = str_replace($part, $replaced, $html);
+	}
+	$html = str_replace('class="body-attach done"', 'class="body-attach"', $html);
+	$b['html'] = $html;
 }
\ No newline at end of file
-- 
2.39.5