diff --git a/boot.php b/boot.php index 8491538..af43068 100644 --- a/boot.php +++ b/boot.php @@ -19,6 +19,7 @@ use FriendsOfRedaxo\QuickNavigation\Button\FavoriteButton; use FriendsOfRedaxo\QuickNavigation\Button\WatsonButton; use FriendsOfRedaxo\QuickNavigation\Button\YformButton; +use FriendsOfRedaxo\QuickNavigation\Media\QuickNavigationMedia; use FriendsOfRedaxo\QuickNavigation\Minibar\ArticleHistoryElement; use rex; use rex_addon; @@ -75,7 +76,7 @@ return '
' . $ep->getSubject(); }); rex_extension::register('PAGE_TITLE_SHOWN', QuickNavigation::LinkMapQuickNavigation(...)); - rex_extension::register('MEDIA_LIST_TOOLBAR', QuickNavigation::MediaHistory(...)); + rex_extension::register('MEDIA_LIST_TOOLBAR', QuickNavigationMedia::MediaHistory(...)); } } diff --git a/lib/QuickNavigation/Button/CategoryButton.php b/lib/QuickNavigation/Button/CategoryButton.php index 7308fdb..a4c4f92 100644 --- a/lib/QuickNavigation/Button/CategoryButton.php +++ b/lib/QuickNavigation/Button/CategoryButton.php @@ -17,7 +17,7 @@ class CategoryButton implements ButtonInterface { - public function renderCategoriesAsList(array $categoriesArray, int $depth = 0): array + public function RenderCategoriesAsList(array $categoriesArray, int $depth = 0): array { $listItems = []; foreach ($categoriesArray as $item) { @@ -39,7 +39,7 @@ public function renderCategoriesAsList(array $categoriesArray, int $depth = 0): if (!empty($item['children'])) { $fragment = new rex_fragment([ - 'listItems' => $this->renderCategoriesAsList($item['children'], $depth + 1), + 'listItems' => $this->RenderCategoriesAsList($item['children'], $depth + 1), ]); $listItem .= $fragment->parse('QuickNavigation/List.php'); } @@ -59,9 +59,9 @@ public function get(): string } $currentClangId = rex_clang::getCurrentId(); - $categoriesArray = BuildNavigationArray::generateBackendNavArray($currentClangId, $ignoreOffline, null); + $categoriesArray = BuildNavigationArray::GenerateBackendNavArray($currentClangId, $ignoreOffline, null); - $listItems = $this->renderCategoriesAsList($categoriesArray); + $listItems = $this->RenderCategoriesAsList($categoriesArray); $placeholder = rex_i18n::msg('quick_navigation_placeholder'); $fragment = new rex_fragment(); $fragment->setVar('id', 'quick-navigation-search'); diff --git a/lib/QuickNavigation/Media/QuickNavigationMedia.php b/lib/QuickNavigation/Media/QuickNavigationMedia.php new file mode 100644 index 0000000..1349f40 --- /dev/null +++ b/lib/QuickNavigation/Media/QuickNavigationMedia.php @@ -0,0 +1,120 @@ + $ep + */ + public static function MediaHistory(rex_extension_point $ep): ?string + { + if (rex_be_controller::getCurrentPagePart(1) == 'mediapool') { + $subject = $ep->getSubject(); + $drophistory = self::GenerateMediaHistoryList(); + $custom_media_buttons = rex_extension::registerPoint(new rex_extension_point('QUICK_NAVI_CUSTOM_MEDIA', '')); + $button = $custom_media_buttons . '
' . $drophistory . '
hasPerm('quick_navigation[history]')) { - $file_id = rex_request('file_id', 'int'); - - // Verwendung der neuen Funktion zur Generierung der quick_file_nav - $quick_file_nav = self::GenerateFileNavigation($file_id, $opener); - - $where = ''; - if (!rex::getUser()->hasPerm('quick_navigation[all_changes]')) { - $where = 'WHERE updateuser="' . rex::getUser()->getValue('login') . '"'; - } - - $qry = 'SELECT category_id, id, title, filename, updateuser, updatedate FROM ' . rex::getTable('media') . ' ' . $where . ' ORDER BY updatedate DESC LIMIT ' . $limit; - $datas = rex_sql::factory()->getArray($qry); - $listItems = []; - if (count($datas) === 0) { - $fragment = new rex_fragment(); - $listItems[] = $fragment->parse('QuickNavigation/NoResult.php'); - } - - foreach ($datas as $data) { - $attributes = [ - 'title' => $data['filename'], - 'href' => rex_url::backendPage('mediapool/media', ['opener_input_field' => $opener, 'rex_file_category' => $data['category_id'], 'file_id' => $data['id']]), - ]; - - $date = rex_formatter::intlDateTime(strtotime($data['updatedate'])); - - $listItems[] = ' -
- - ' . ('' !== $data['title'] ? rex_escape($data['title']) : rex_escape($data['filename'])) . ' - -
-
-
- - - ' . rex_escape($data['updateuser']) . ' - ' . $date . ' - -
-
'; - } - - $fragment = new rex_fragment([ - 'label' => rex_i18n::msg('quick_navigation_media_history'), - 'icon' => 'fa-regular fa-clock', - 'listItems' => $listItems, - ]); - return $quick_file_nav . $fragment->parse('QuickNavigation/Dropdown.php'); - } - - return null; - } - - protected static function GenerateFileNavigation(int $file_id, string $opener): string - { - $quick_file_nav = ''; - if ($file_id !== 0) { - $quick_file = rex_sql::factory(); - $quick_file->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'media WHERE id = ?', [$file_id]); - - $quick_file_before = rex_sql::factory(); - $quick_file_before->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'media WHERE category_id = ? AND updatedate > ? ORDER BY updatedate LIMIT 1', [$quick_file->getValue('category_id'), $quick_file->getValue('updatedate')]); - - $quick_file_after = rex_sql::factory(); - $quick_file_after->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'media WHERE category_id = ? AND updatedate < ? ORDER BY updatedate DESC LIMIT 1', [$quick_file->getValue('category_id'), $quick_file->getValue('updatedate')]); - - // Link für "Zurück" Button, aktiv oder deaktiviert - $backButton = $quick_file_before->getRows() == 1 - ? '' - : ''; - - // Link für "Vorwärts" Button, aktiv oder deaktiviert - $forwardButton = $quick_file_after->getRows() == 1 - ? '' - : ''; - - // Kombinieren der Buttons mit einem Trennzeichen - $quick_file_nav = '
' . $backButton . $forwardButton . '
'; - } - - return $quick_file_nav; - } public static function get(): string { diff --git a/lib/QuickNavigation/Utiliy/BuildNavigationArray.php b/lib/QuickNavigation/Utiliy/BuildNavigationArray.php index 214aa3e..63fb78e 100644 --- a/lib/QuickNavigation/Utiliy/BuildNavigationArray.php +++ b/lib/QuickNavigation/Utiliy/BuildNavigationArray.php @@ -17,7 +17,7 @@ class BuildNavigationArray /** * @return array */ - public static function generateBackendNavArray(int $clangId = null, bool $ignoreOffline = true, int $parentId = null, bool $includeHome = true): array + public static function GenerateBackendNavArray(int $clangId = null, bool $ignoreOffline = true, int $parentId = null, bool $includeHome = true): array { $user = rex::getUser(); if ($clangId === null) {