From a310d23b35883b14f3941da84c3308fc40bca4c8 Mon Sep 17 00:00:00 2001 From: Matthieu Leproux Date: Tue, 7 Jun 2022 16:00:32 +0200 Subject: [PATCH] related to #1666 badge is changed, still needs to have the proper icon --- admin/albums.php | 33 ++++++++++++++++++++++++ admin/themes/default/js/albums.js | 9 +++++++ admin/themes/default/template/albums.tpl | 8 ++++++ 3 files changed, 50 insertions(+) diff --git a/admin/albums.php b/admin/albums.php index cd872d455..c5911d660 100644 --- a/admin/albums.php +++ b/admin/albums.php @@ -186,6 +186,38 @@ SELECT ;'; $nb_photos_in = query2array($query, 'category_id', 'nb_photos'); + + $query = ' +SELECT + id, + uppercats + FROM '.CATEGORIES_TABLE.' +;'; + $all_categories = query2array($query, 'id', 'uppercats'); + $subcats_of = array(); + + foreach ($all_categories as $id => $uppercats) + { + foreach (array_slice(explode(',', $uppercats), 0, -1) as $uppercat_id) + { + @$subcats_of[$uppercat_id][] = $id; + } + } + + $nb_sub_photos = array(); + foreach ($subcats_of as $cat_id => $subcat_ids) + { + $nb_photos = 0; + foreach ($subcat_ids as $id) + { + if (isset($nb_photos_in[$id])) + { + $nb_photos+= $nb_photos_in[$id]; + } + } + + $nb_sub_photos[$cat_id] = $nb_photos; + } foreach($assocT as $cat) { @@ -197,6 +229,7 @@ SELECT $orderedCat['nb_images'] = isset($nb_photos_in[$cat['cat']['id']]) ? $nb_photos_in[$cat['cat']['id']] : 0; $orderedCat['last_updates'] = $cat['cat']['lastmodified']; $orderedCat['has_not_access'] = !cat_admin_access($cat['cat']['id']); + $orderedCat['nb_sub_photos'] = isset($nb_sub_photos[$cat['cat']['id']]) ? $nb_sub_photos[$cat['cat']['id']] : 0; if (isset($cat['children'])) { //Does not update when moving a node diff --git a/admin/themes/default/js/albums.js b/admin/themes/default/js/albums.js index a72d72189..54237b012 100644 --- a/admin/themes/default/js/albums.js +++ b/admin/themes/default/js/albums.js @@ -4,6 +4,8 @@ $(document).ready(() => { $("h1").append(``+nb_albums+``); + console.log(formatedData); + $('.tree').tree({ data: formatedData, autoOpen : false, @@ -98,6 +100,7 @@ $(document).ready(() => { "
" +"" +"" + +"" +""+ node.last_updates +"" +"
" ) @@ -120,6 +123,12 @@ $(document).ready(() => { cont.find(".last-update").hide(); } + if (node.nb_sub_photos) { + cont.find(".nb-sub-photos").text(node.nb_sub_photos); + } else { + cont.find(".nb-sub-photos").hide(); + } + if (node.has_not_access) { cont.find(".move-cat-see").addClass("notClickable"); cont.find('#catOptionsSmall .icon-eye').hide(); diff --git a/admin/themes/default/template/albums.tpl b/admin/themes/default/template/albums.tpl index 06dfa06a5..0c50786f6 100644 --- a/admin/themes/default/template/albums.tpl +++ b/admin/themes/default/template/albums.tpl @@ -549,10 +549,18 @@ input[name="position"] { margin: 0 6px 0 -2px; } +.last-update { + display: none; +} + @media (max-width: 1415px) { .badge-container .last-update { display: none; } + + .badge-container .nb-sub-photos { + display: none; + } } @media (max-width: 1300px) {