diff --git a/admin.php b/admin.php index 469acb469..ef03c89f9 100644 --- a/admin.php +++ b/admin.php @@ -230,6 +230,7 @@ $template->assign( 'U_CHANGE_THEME' => $change_theme_url, 'U_UPDATES' => $link_start.'updates', 'ADMIN_PAGE_TITLE' => 'Piwigo Administration Page', + 'ADMIN_PAGE_OBJECT_ID' => '', 'U_SHOW_TEMPLATE_TAB' => $conf['show_template_in_side_menu'], 'SHOW_RATING' => $conf['rate'], ) diff --git a/admin/album.php b/admin/album.php index faa28c8c7..3fc91701a 100644 --- a/admin/album.php +++ b/admin/album.php @@ -56,7 +56,8 @@ $tabsheet->assign(); // +-----------------------------------------------------------------------+ $template->assign(array( - 'ADMIN_PAGE_TITLE' => l10n('Edit album'), + 'ADMIN_PAGE_TITLE' => l10n('Edit album').' '.$category['name'].'', + 'ADMIN_PAGE_OBJECT_ID' => '#'.$category['id'], )); if ('properties' == $page['tab']) diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 8a7f3bfc4..cf2181042 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -97,69 +97,6 @@ if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) ) } //--------------------------------------------------------- form criteria check -if (isset($_POST['submit'])) -{ - $data = array( - 'id' => $_GET['cat_id'], - 'name' => @$_POST['name'], - 'comment' => - $conf['allow_html_descriptions'] ? - @$_POST['comment'] : strip_tags(@$_POST['comment']), - ); - - if ($conf['activate_comments']) - { - $data['commentable'] = isset($_POST['commentable'])? 'true':'false'; - } - - single_update( - CATEGORIES_TABLE, - $data, - array('id' => $data['id']) - ); - if (isset($_POST['apply_commentable_on_sub'])) - { - $subcats = get_subcat_ids(array('id' => $data['id'])); - $query = ' -UPDATE '.CATEGORIES_TABLE.' - SET commentable = \''.$data['commentable'].'\' - WHERE id IN ('.implode(',', $subcats).') -;'; - pwg_query($query); - } - - // retrieve cat infos before continuing (following updates are expensive) - $cat_info = get_cat_info($_GET['cat_id']); - - $visible = false; - if (!isset($_POST['locked'])) - { - $visible = true; - } - - if ($visible !== $cat_info['visible']) - { - set_cat_visible(array($_GET['cat_id']), $visible); - } - - // in case the use moves his album to the gallery root, we force - // $_POST['parent'] from 0 to null to be compared with - // $cat_info['id_uppercat'] - if (empty($_POST['parent'])) - { - $_POST['parent'] = null; - } - - // only move virtual albums - if (empty($cat_info['dir']) and $cat_info['id_uppercat'] != $_POST['parent']) - { - move_categories( array($_GET['cat_id']), $_POST['parent'] ); - } - - $_SESSION['page_infos'][] = l10n('Album updated successfully'); - pwg_activity('album', $_GET['cat_id'], 'edit'); - $redirect = true; -} if (isset($redirect)) { @@ -193,9 +130,22 @@ $category['nb_subcats'] = count($subcat_ids) - 1; $navigation = get_cat_display_name_cache( $category['uppercats'], get_root_url().'admin.php?page=album-' - ); +); -$form_action = $admin_album_base_url.'-properties'; +// Parent navigation path +$uppercats_array = explode(',', $category['uppercats']); +if (count($uppercats_array) > 1) +{ + array_pop($uppercats_array); + $parent_navigation = get_cat_display_name_cache( + implode(',', $uppercats_array), + get_root_url().'admin.php?page=album-' + ); +} +else +{ + $parent_navigation = l10n('Root'); +} //----------------------------------------------------- template initialization $template->set_filename( 'album_properties', 'cat_modify.tpl'); @@ -212,10 +162,14 @@ if (!empty($category['id_uppercat'])) $template->assign( array( 'CATEGORIES_NAV' => preg_replace("# {2,}#"," ",preg_replace("#(\r\n|\n\r|\n|\r)#"," ",$navigation)), + 'CATEGORIES_PARENT_NAV' => preg_replace("# {2,}#"," ",preg_replace("#(\r\n|\n\r|\n|\r)#"," ",$parent_navigation)), + 'PARENT_CAT_ID' => !empty($category['id_uppercat']) ? $category['id_uppercat'] : 0, 'CAT_ID' => $category['id'], 'CAT_NAME' => @htmlspecialchars($category['name']), 'CAT_COMMENT' => @htmlspecialchars($category['comment']), - 'IS_LOCKED' => !get_boolean($category['visible']), + 'IS_LOCKED' => $category['status'] == "private", + + 'U_DELETE' => $base_url.'albums', 'U_JUMPTO' => make_index_url( array( @@ -225,10 +179,7 @@ $template->assign( 'U_ADD_PHOTOS_ALBUM' => $base_url.'photos_add&album='.$category['id'], 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], - 'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_modify', 'U_MOVE' => $base_url.'albums&parent_id='.$category['id'].'#cat-'.$category['id'], - - 'F_ACTION' => $form_action, ) ); @@ -238,6 +189,8 @@ if ($conf['activate_comments']) } // manage album elements link +$image_count = 0; +$info_title = ""; if ($category['has_images']) { $template->assign( @@ -273,16 +226,29 @@ SELECT format_date($max_date) ); } - $info_photos = l10n('%d photos', $image_count); - - $template->assign( - array( - 'INFO_PHOTO' => $info_photos, - 'INFO_TITLE' => $info_title - ) - ); - + } +$info_photos = l10n('%d photos', $image_count); + +$template->assign( + array( + 'INFO_PHOTO' => $info_photos, + 'INFO_TITLE' => $info_title + ) + ); + +// total number of images under this category (including sub-categories) + $query = ' +SELECT DISTINCT + (image_id) + FROM + '.IMAGE_CATEGORY_TABLE.' + WHERE + category_id IN ('.implode(',', $subcat_ids).') + ;'; + $image_ids_recursive = query2array($query, null, 'image_id'); + + $category['nb_images_recursive'] = count($image_ids_recursive); // date creation $query = ' @@ -297,7 +263,8 @@ $result = query2array($query); if (count($result) > 0) { $template->assign( array( - 'INFO_CREATION' => l10n('Created on %s',format_date($result[0]['occured_on'], array('day', 'month','year'))) + 'INFO_CREATION_SINCE' => time_since($result[0]['occured_on'], 'day', $format=null, $with_text=true, $with_week=true, $only_last_unit=true), + 'INFO_CREATION' => format_date($result[0]['occured_on'], array('day', 'month','year')) ) ); } @@ -310,45 +277,39 @@ SELECT COUNT(*) '; $result = query2array($query); -if ($result[0]['COUNT(*)'] > 0) { - $template->assign( - array( - 'INFO_DIRECT_SUB' => l10n('%d sub-albums',$result[0]['COUNT(*)']) - ) - ); -} + +$template->assign( + array( + 'INFO_DIRECT_SUB' => l10n( + '%d sub-albums', + $result[0]['COUNT(*)'] + ), + ) + ); $template->assign(array( 'INFO_ID' => l10n('Numeric identifier : %d',$category['id']), - 'INFO_LAST_MODIFIED'=> l10n('Edited on %s',format_date($category['lastmodified'], array('day', 'month','year'))) - ) - ); + 'INFO_LAST_MODIFIED_SINCE' => time_since($category['lastmodified'], 'minute', $format=null, $with_text=true, $with_week=true, $only_last_unit=true), + 'INFO_LAST_MODIFIED'=> format_date($category['lastmodified'], array('day', 'month','year')), + 'INFO_IMAGES_RECURSIVE' => l10n( + '%d including sub-albums', + $category['nb_images_recursive'] + ), + 'INFO_SUBCATS' => l10n( + '%d in whole branch', + $category['nb_subcats'] + ), -// info for deletion -$template->assign( - array( - 'CATEGORY_FULLNAME' => trim(strip_tags($navigation)), - 'NB_SUBCATS' => $category['nb_subcats'], - // 'NB_IMAGES_RECURSIVE' => $category['nb_images_recursive'], - // 'NB_IMAGES_BECOMING_ORPHAN' => $category['nb_images_becoming_orphan'], - // 'NB_IMAGES_ASSOCIATED_OUTSIDE' => $category['nb_images_associated_outside'], - ) - ); + 'NB_SUBCATS' => $category['nb_subcats'], + ), +); $template->assign(array( 'U_MANAGE_RANKS' => $base_url.'element_set_ranks&cat_id='.$category['id'], 'CACHE_KEYS' => get_admin_client_cache_keys(array('categories')), )); -if ($category['is_virtual']) -{ - $template->assign( - array( - 'U_DELETE' => $self_url.'&delete='.$category['id'].'&pwg_token='.get_pwg_token(), - ) - ); -} -else +if (!$category['is_virtual']) { $category['cat_full_dir'] = get_complete_dir($_GET['cat_id']); $template->assign( @@ -400,6 +361,8 @@ if ($category['is_virtual']) $template->assign('parent_category', empty($category['id_uppercat']) ? array() : array($category['id_uppercat'])); } +$template->assign('PWG_TOKEN', get_pwg_token()); + trigger_notify('loc_end_cat_modify'); //----------------------------------------------------------- sending html code diff --git a/admin/themes/default/css/components/general.css b/admin/themes/default/css/components/general.css index e5aa693fb..60bc10389 100644 --- a/admin/themes/default/css/components/general.css +++ b/admin/themes/default/css/components/general.css @@ -255,4 +255,73 @@ a.info-framed:hover { .info-framed-title { color: #3c3c3c; font-weight: bold; -} \ No newline at end of file +} + +/* ------------- +Info +------------- + +.info-message.icon-*, .info-warning.icon-*, .info-error.icon-* + p + (a) + +*/ + +.info-message, .info-warning, .info-error { + height: 35px; + overflow: hidden; + border-radius: 20px; + display: flex; + padding: 0px 10px 0px 0px; + font-weight: bold; + margin-left: 10px; +} + +.info.hide { + display: none; +} + +.info-message p, .info-warning p, .info-error p { + margin: auto; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + text-align: initial; +} + +.info-message::before, .info-warning::before, .info-error::before { + line-height: 35px; + margin: 0px 10px; + font-size: 16px; +} + +.info-warning { + color: #ee8800; + background-color:#ffdd99; +} + +.info-message { + color: #0a0; + background-color:#c2f5c2; + display: none; +} + +.info-error { + color: #f22; + background-color: #ffd5dc; + display: none; + animation-name: info-error-appear ; + animation-duration: 0.4s; + animation-timing-function: ease; +} + +.info-message a:hover, .info-warning a:hover, .info-error a:hover { + color: white; +} + +@keyframes info-error-appear { + 25% { transform: translateX(-10px)} + 50% { transform: translateX(10px)} + 75% { transform: translateX(-10px)} + 100% { transform: translateX(0px)} + } \ No newline at end of file diff --git a/admin/themes/default/js/cat_modify.js b/admin/themes/default/js/cat_modify.js new file mode 100644 index 000000000..c56cd898b --- /dev/null +++ b/admin/themes/default/js/cat_modify.js @@ -0,0 +1,527 @@ +jQuery(document).ready(function() { + + activateCommentDropdown() + + jQuery('.tiptip').tipTip({ + 'delay' : 0, + 'fadeIn' : 200, + 'fadeOut' : 200 + }); + + + $('#cat-properties-save').click(() => { + save_button_set_loading(true) + $('.info-error,.info-message').hide() + + jQuery.ajax({ + url: "ws.php?format=json&method=pwg.categories.setInfo", + type:"POST", + dataType: "json", + data: { + category_id: album_id, + name: $("#cat-name").val(), + comment: $("#cat-comment").val(), + status: $("#cat-locked").is(":checked")? "public":"private", + commentable: $("#cat-commentable").is(":checked")? "true":"false", + apply_commentable_to_subalbums: $("#cat-apply-commentable-on-sub").is(":checked")? "true":"false", + }, + success:function(data) { + if (data.stat == "ok") { + save_button_set_loading(false) + + $('.info-message').show() + $('.cat-modification .cat-modify-info-subcontent').html(str_just_now) + $('.cat-modification .cat-modify-info-content').html(str_just_now) + setTimeout( + function() { + $('.info-message').hide() + }, + 5000 + ) + } else { + $('.info-error').show() + setTimeout( + function() { + $('.info-error').hide() + }, + 5000 + ) + } + }, + error:function(XMLHttpRequest, textStatus, errorThrows) { + save_button_set_loading(false) + + $('.info-error').show() + setTimeout( + function() { + $('.info-error').hide() + }, + 5000 + ) + console.log(errorThrows); + } + }); + + if (parent_album != default_parent_album) { + jQuery.ajax({ + url: "ws.php?format=json&method=pwg.categories.move", + type:"POST", + dataType: "json", + data: { + category_id: album_id, + parent: parent_album, + pwg_token: pwg_token, + }, + success: function (data) { + if (data.stat === "ok") { + $(".cat-modify-ariane").html( + data.result.new_ariane_string + ) + default_parent_album = parent_album; + } else { + $('.info-error').show() + setTimeout( + function() { + $('.info-error').hide() + }, + 5000 + ) + } + }, + error: function(e) { + console.log(e.message); + } + }); + } + }) + + function save_button_set_loading(state = true) { + if (state) { + $('#cat-properties-save i').removeClass("icon-floppy") + $('#cat-properties-save i').addClass("icon-spin6") + $('#cat-properties-save i').addClass("animate-spin") + } else { + $('#cat-properties-save i').addClass("icon-floppy") + $('#cat-properties-save i').removeClass("icon-spin6") + $('#cat-properties-save i').removeClass("animate-spin") + } + + $('#cat-properties-save').attr("disabled", state) + } + + $(".deleteAlbum").on("click", function() { + + $.confirm({ + title: str_delete_album, + content : function () { + const self = this + return $.ajax({ + url: "ws.php?format=json&method=pwg.categories.calculateOrphans", + type: "GET", + data: { + category_id: album_id, + }, + success: function (raw_data) { + let data = JSON.parse(raw_data).result[0] + + let message = "

" + str_delete_album_and_his_x_subalbums + .replace("%s", ""+album_name+"") + .replace("%d", ""+nb_sub_albums+"") + "

" + + message += `
`; + message += + `
+ + +
`; + + if (data.nb_images_recursive) { + let t = 0 + message += `
+ + +
`; + } + + if (data.nb_images_becoming_orphan) + message += + `
+ + +
`; + message += `
`; + + self.setContent(message) + }, + error: function(message) { + console.log(message); + self.setContent("An error has occured while calculating orphans") + } + }); + }, + buttons: { + deleteAlbum: { + text: str_delete_album, + btnClass: 'btn-red', + action: function () { + this.showLoading() + let deletionMode = $('input[name="deletion-mode"]:checked').val(); + delete_album(deletionMode) + .then(()=>window.location.href = u_delete) + .catch((err)=> { + this.close() + console.log(err) + }) + return false + }, + }, + cancel: { + text: str_cancel + } + }, + ...jConfirm_confirm_options + }) + }); + + function delete_album(photo_deletion_mode) { + return new Promise((res, rej) => { + $.ajax({ + url: "ws.php?format=json&method=pwg.categories.delete", + type: "POST", + data: { + category_id: album_id, + photo_deletion_mode: photo_deletion_mode, + pwg_token : pwg_token, + }, + success: function (raw_data) { + res() + }, + error: function(message) { + rej(message) + } + }); + }) + } + + $('#refreshRepresentative').on('click', function(e) { + var method = 'pwg.categories.refreshRepresentative'; + + $('#refreshRepresentative i').removeClass("icon-ccw").addClass("icon-spin6").addClass("animate-spin") + + jQuery.ajax({ + url: "ws.php?format=json&method="+method, + type:"POST", + data: { + category_id: album_id + }, + success:function(data) { + var data = jQuery.parseJSON(data); + if (data.stat == 'ok') { + jQuery("#deleteRepresentative").show(); + + jQuery(".cat-modify-representative") + .attr('style', `background-image:url('${data.result.src}')`) + .removeClass('icon-dice-solid') + + } + else { + console.error(data); + } + $('#refreshRepresentative i').addClass("icon-ccw").removeClass("icon-spin6").removeClass("animate-spin") + }, + error:function(XMLHttpRequest, textStatus, errorThrows) { + console.error(errorThrows); + $('#refreshRepresentative i').addClass("icon-ccw").removeClass("icon-spin6").removeClass("animate-spin") + } + }); + + e.preventDefault(); + }); + + $('#deleteRepresentative').on('click', function(e) { + var method = 'pwg.categories.deleteRepresentative'; + + $('#deleteRepresentative i').removeClass("icon-cancel").addClass("icon-spin6").addClass("animate-spin") + + jQuery.ajax({ + url: "ws.php?format=json&method="+method, + type:"POST", + data: { + category_id: album_id + }, + success:function(data) { + var data = jQuery.parseJSON(data); + if (data.stat == 'ok') { + jQuery("#deleteRepresentative").hide(); + jQuery(".cat-modify-representative") + .attr('style', ``) + .addClass('icon-dice-solid') + } + else { + console.error(data); + } + $('#deleteRepresentative i').addClass("icon-cancel").removeClass("icon-spin6").removeClass("animate-spin") + }, + error:function(XMLHttpRequest, textStatus, errorThrows) { + console.error(errorThrows); + $('#deleteRepresentative i').addClass("icon-cancel").removeClass("icon-spin6").removeClass("animate-spin") + } + }); + + e.preventDefault(); + }); + + // Parent album popin + $("#cat-parent.icon-pencil").on("click", function (e) { + // Don't open the popin if you click on the album link + if (e.target.localName != 'a') { + linked_albums_open(); + set_up_popin(); + + if (parent_album != 0) { + $(".put-to-root").removeClass("notClickable"); + $(".put-to-root").click(function () { + add_related_category(0, str_root); + }); + } else { + $(".put-to-root").addClass("notClickable"); + } + } + }); + + $(".limitReached").html(str_no_search_in_progress); + $(".search-cancel-linked-album").hide(); + $(".linkedAlbumPopInContainer .searching").hide(); + $("#linkedAlbumSearch .search-input").on('input', function () { + if ($(this).val() != 0) { + $("#linkedAlbumSearch .search-cancel-linked-album").show() + } else { + $("#linkedAlbumSearch .search-cancel-linked-album").hide(); + } + + if ($(this).val().length > 2) { + linked_albums_search($(this).val()); + } else { + $(".limitReached").html(str_no_search_in_progress); + $("#searchResult").empty(); + } + }) + + $(".search-cancel-linked-album").on("click", function () { + $("#linkedAlbumSearch .search-input").val(""); + $("#linkedAlbumSearch .search-input").trigger("input"); + }) + + $(".allow-comments").on("click", function () { + jQuery.ajax({ + url: "ws.php?format=json&method=pwg.categories.setInfo", + type:"POST", + dataType: "json", + data: { + category_id: album_id, + commentable: true, + apply_commentable_to_subalbums: true, + }, + beforeSend: function () { + save_button_set_loading(true); + }, + success:function(data) { + if (data.stat == "ok") { + + save_button_set_loading(false); + if (!$("#cat-commentable").is(":checked")) { + $("#cat-commentable").trigger("click"); + } + + temp_txt = $(".info-message").text(); + $(".info-message").text(str_album_comment_allow); + $(".info-message").show(); + + setTimeout( + function() { + $('.info-message').hide() + $(".info-message").text(temp_txt); + }, + 5000 + ) + } else { + $('.info-error').show() + setTimeout( + function() { + $('.info-error').hide() + }, + 5000 + ) + } + }, + error:function(e) { + console.log(e); + save_button_set_loading(false); + } + }); + }); + $(".disallow-comments").on("click", function () { + jQuery.ajax({ + url: "ws.php?format=json&method=pwg.categories.setInfo", + type:"POST", + dataType: "json", + data: { + category_id: album_id, + commentable: false, + apply_commentable_to_subalbums: true, + }, + beforeSend: function () { + save_button_set_loading(true); + }, + success:function(data) { + if (data.stat == "ok") { + + save_button_set_loading(false); + if ($("#cat-commentable").is(":checked")) { + $("#cat-commentable").trigger("click"); + } + + temp_txt = $(".info-message").text(); + $(".info-message").text(str_album_comment_disallow); + $(".info-message").show(); + + setTimeout( + function() { + $('.info-message').hide() + $(".info-message").text(temp_txt); + }, + 5000 + ) + } else { + $('.info-error').show() + setTimeout( + function() { + $('.info-error').hide() + }, + 5000 + ) + } + }, + error:function(e) { + console.log(e); + save_button_set_loading(false); + } + }); + }); +}); + +// Parent album popin functions +function set_up_popin() { + $(".ClosePopIn").on('click', function () { + linked_albums_close(); + }); +} + +function linked_albums_close() { + $("#addLinkedAlbum").fadeOut(); +} +function linked_albums_open() { + $("#addLinkedAlbum").fadeIn(); + $(".search-input").val(""); + $(".search-input").focus(); + $("#searchResult").empty(); + $(".limitReached").html(str_no_search_in_progress); +} +function linked_albums_search(searchText) { + $(".linkedAlbumPopInContainer .searching").show(); + $.ajax({ + url: "ws.php?format=json&method=pwg.categories.getAdminList", + type: "POST", + dataType: "json", + data : { + search: searchText, + additional_output: "full_name_with_admin_links", + }, + before: function () { + + }, + success: function (raw_data) { + $(".linkedAlbumPopInContainer .searching").hide(); + + categories = raw_data.result.categories; + fill_results(categories); + + if (raw_data.result.limit_reached) { + $(".limitReached").html(str_result_limit.replace("%d", categories.length)); + } else { + if (categories.length == 1) { + $(".limitReached").html(str_album_found); + } else { + $(".limitReached").html(str_albums_found.replace("%d", categories.length)); + } + } + }, + error: function (e) { + $(".linkedAlbumPopInContainer .searching").hide(); + console.log(e.message); + } + }) +} + +function fill_results(cats) { + $("#searchResult").empty(); + cats.forEach(cat => { + $("#searchResult").append( + "
" + + "" + cat.fullname +"" + + "
" + ); + + // If the searched albums are in the children of the current album they become unclickable + // Same if the album is already selected + + if (parent_album == cat.id || cat.uppercats.split(',').includes(album_id+"")) { + $(" #"+ cat.id +".search-result-item").addClass("notClickable").attr("title", str_already_in_related_cats).on("click", function (event) { + event.preventDefault(); + }); + } else { + $("#"+ cat.id + ".search-result-item ").on("click", function () { + add_related_category(cat.id, cat.full_name_with_admin_links); + }); + } + }); +} + +function add_related_category(cat_id, cat_link_path) { + if (parent_album != cat_id) { + + $("#cat-parent").html( + cat_link_path + ); + + $(".search-result-item #" + cat_id).addClass("notClickable"); + parent_album = cat_id; + $(".invisible-related-categories-select").append(""); + + linked_albums_close(); + } +} + +function activateCommentDropdown() { + $(".toggle-comment-option").find(".comment-option").hide(); + + /* Display the option on the click on "..." */ + $(".toggle-comment-option").on("click", function () { + $(this).find(".comment-option").toggle(); + }) + + /* Hide img options and rename field on click on the screen */ + + $(document).mouseup(function (e) { + e.stopPropagation(); + let option_is_clicked = false + $(".comment-option span").each(function () { + if (!($(this).has(e.target).length === 0)) { + option_is_clicked = true; + } + }) + if (!option_is_clicked) { + $(".toggle-comment-option").find(".comment-option").hide(); + } + }); +} \ No newline at end of file diff --git a/admin/themes/default/js/tags.js b/admin/themes/default/js/tags.js index e01ab59b7..08811779e 100644 --- a/admin/themes/default/js/tags.js +++ b/admin/themes/default/js/tags.js @@ -5,8 +5,8 @@ var dataTags = $('.tag-container').data('tags'); $('#select-100').prop('checked', true) //Orphan tags -$('.tag-warning p a').on('click', () => { - let url = $('.tag-warning p a').data('url'); +$('.info-warning p a').on('click', () => { + let url = $('.info-warning p a').data('url'); let tags = orphan_tag_names; let str_orphans = str_orphan_tags.replace('%s1', tags.length).replace('%s2', tags.join(', ')); $.confirm({ @@ -32,7 +32,7 @@ $('.tag-warning p a').on('click', () => { keep : { text:str_keep_them, action: function() { - $('.tag-warning').hide(); + $('.info-warning').hide(); } } } @@ -823,17 +823,17 @@ function isDataSearched(tagObj) { Show Info -------*/ function showError(message) { - $('.tag-error p').html(message); - $('.tag-error').attr('title', message) - $('.tag-info').hide() - $('.tag-error').css('display', 'flex'); + $('.info-error p').html(message); + $('.info-error').attr('title', message) + $('.info-info').hide() + $('.info-error').css('display', 'flex'); } function showMessage(message) { - $('.tag-message p').html(message); - $('.tag-message').attr('title', message) - $('.tag-info').hide() - $('.tag-message').css('display', 'flex'); + $('.info-message p').html(message); + $('.info-message').attr('title', message) + $('.info-info').hide() + $('.info-message').css('display', 'flex'); } diff --git a/admin/themes/default/template/admin.tpl b/admin/themes/default/template/admin.tpl index ccaf64e87..ecc96808c 100644 --- a/admin/themes/default/template/admin.tpl +++ b/admin/themes/default/template/admin.tpl @@ -127,7 +127,7 @@ jQuery(document).ready(function() {
-

{$ADMIN_PAGE_TITLE}

+

{$ADMIN_PAGE_TITLE}{$ADMIN_PAGE_OBJECT_ID}

{if isset($TABSHEET)} {$TABSHEET} diff --git a/admin/themes/default/template/cat_modify.tpl b/admin/themes/default/template/cat_modify.tpl index 4886ead44..25f018440 100644 --- a/admin/themes/default/template/cat_modify.tpl +++ b/admin/themes/default/template/cat_modify.tpl @@ -1,407 +1,265 @@ {combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} -{include file='include/colorbox.inc.tpl'} -{combine_script id='LocalStorageCache' load='footer' path='admin/themes/default/js/LocalStorageCache.js'} +{combine_script id='cat_modify' load='footer' path='admin/themes/default/js/cat_modify.js'} {combine_script id='jquery.confirm' load='footer' require='jquery' path='themes/default/js/plugins/jquery-confirm.min.js'} -{* {combine_script id='cat_modify' load='footer' path='admin/themes/default/js/cat_modify.js'} *} - -{combine_script id='jquery.selectize' load='footer' path='themes/default/js/plugins/selectize.min.js'} -{combine_css id='jquery.selectize' path="themes/default/js/plugins/selectize.{$themeconf.colorscheme}.css"} +{combine_css path="themes/default/js/plugins/jquery-confirm.min.css"} +{combine_css path="admin/themes/default/fontello/css/animation.css" order=10} {* order 10 is required, see issue 1080 *} +{combine_script id='jquery.tipTip' load='footer' path='themes/default/js/plugins/jquery.tipTip.minified.js'} {footer_script} const has_images_associated_outside = '{"delete album and all %d photos, even the %d associated to other albums"|@translate|escape:javascript}'; const has_images_becomming_orphans = '{'delete album and the %d orphan photos'|@translate|escape:javascript}'; const has_images_recursives = '{'delete only album, not photos'|@translate|escape:javascript}'; const cat_nav = '{$CATEGORIES_NAV|escape:javascript}'; +const album_id = {$CAT_ID} +var parent_album = {$PARENT_CAT_ID} +var default_parent_album = {$PARENT_CAT_ID} +const album_name = "{$CAT_NAME}" +const nb_sub_albums = {$NB_SUBCATS} +const pwg_token = '{$PWG_TOKEN}' +const u_delete = '{$U_DELETE}' -{* *} -var categoriesCache = new CategoriesCache({ - serverKey: '{$CACHE_KEYS.categories}', - serverId: '{$CACHE_KEYS._hash}', - rootUrl: '{$ROOT_URL}' -}); +const str_cancel = '{'No, I have changed my mind'|@translate|@escape}' +const str_delete_album = '{'Delete album'|@translate|escape:javascript}' +const str_delete_album_and_his_x_subalbums = '{'Delete album "%s" and its %d sub-albums.'|@translate|escape:javascript}' +const str_just_now = '{'Just now'|@translate|escape:javascript}' -categoriesCache.selectize(jQuery('[data-selectize=categories]'), { - default: 0, - filter: function(categories, options) { - // remove itself and children - var filtered = jQuery.grep(categories, function(cat) { - return !(/\b{$CAT_ID}\b/.test(cat.uppercats)); - }); - - filtered.push({ - id: 0, - fullname: '------------', - global_rank: 0 - }); - - return filtered; - } -}); - -jQuery(document).ready(function() { - $("h1").append(' #{$CAT_ID} '+cat_nav+''); - - jQuery(document).on('click', '.refreshRepresentative', function(e) { - var $this = jQuery(this); - var method = 'pwg.categories.refreshRepresentative'; - - jQuery.ajax({ - url: "ws.php?format=json&method="+method, - type:"POST", - data: { - category_id: $this.data("category_id") - }, - success:function(data) { - var data = jQuery.parseJSON(data); - if (data.stat == 'ok') { - jQuery(".deleteRepresentative").show(); - - jQuery(".albumThumbailImage, .albumThumbnailRandom").on('load', function () { - cropImage(); - }) - - jQuery(".albumThumbailImage, .albumThumbnailRandom") - .attr('src', data.result.src) - .end().show(); - - jQuery(".albumThumbnailRandom").hide(); - } - else { - alert("error on "+method); - } - }, - error:function(XMLHttpRequest, textStatus, errorThrows) { - alert("serious error on "+method); - } - }); - - e.preventDefault(); - }); - - jQuery(document).on('click', '.deleteRepresentative', function(e) { - var $this = jQuery(this); - var method = 'pwg.categories.deleteRepresentative'; - - jQuery.ajax({ - url: "ws.php?format=json&method="+method, - type:"POST", - data: { - category_id: $this.data("category_id") - }, - success:function(data) { - var data = jQuery.parseJSON(data); - if (data.stat == 'ok') { - jQuery(".deleteRepresentative").hide(); - jQuery(".albumThumbnailImage").hide(); - jQuery(".albumThumbnailRandom").show(); - } - else { - alert("error on "+method); - } - }, - error:function(XMLHttpRequest, textStatus, errorThrows) { - alert("serious error on "+method); - } - }); - - e.preventDefault(); - }); - - $(".deleteAlbum").on("click", function() { - $.ajax({ - url: "ws.php?format=json&method=pwg.categories.calculateOrphans", - type: "GET", - data: { - category_id: {$CAT_ID}, - }, - success: function (raw_data) { - let data = JSON.parse(raw_data).result[0] - console.log(data); - if (data.nb_images_recursive == 0) { - $(".delete_popin ul").hide(); - } else { - if (data.nb_images_associated_outside == 0) { - $("#IMAGES_ASSOCIATED_OUTSIDE").hide(); - } else { - $("#IMAGES_ASSOCIATED_OUTSIDE .innerText").html(""); - $("#IMAGES_ASSOCIATED_OUTSIDE .innerText").append(has_images_associated_outside.replace('%d', data.nb_images_recursive).replace('%d', data.nb_images_associated_outside)); - } - if (data.nb_images_becoming_orphan == 0) { - $("#IMAGES_BECOMING_ORPHAN").hide(); - } else { - $("#IMAGES_BECOMING_ORPHAN .innerText").html(""); - $("#IMAGES_BECOMING_ORPHAN .innerText").append(has_images_becomming_orphans.replace('%d', data.nb_images_becoming_orphan)); - } - - } - }, - error: function(message) { - console.log(message); - } - }); - }); - - jQuery(".deleteAlbum").click(function() { - jQuery.colorbox({ - inline:true, - title:"{'delete album'|translate|escape:javascript}", - href:".delete_popin" - }); - - return false; - }); - - function set_photo_deletion_mode() { - if (jQuery("input[name=photo_deletion_mode]").length > 0) { - var $photo_deletion_mode = jQuery("input[name=photo_deletion_mode]:checked").val(); - jQuery("#deleteConfirm").data("photo_deletion_mode", $photo_deletion_mode); - } - } - - set_photo_deletion_mode(); - - jQuery("input[name=photo_deletion_mode]").change(function() { - set_photo_deletion_mode(); - }); - - jQuery("#deleteConfirm").click(function() { - if (jQuery("input[name=photo_deletion_mode]").length > 0) { - var $href = jQuery(this).attr("href"); - jQuery(this).attr("href", $href+"&photo_deletion_mode="+jQuery(this).data("photo_deletion_mode")); - } - }); - - jQuery(document).on('click', '.close-delete_popin', function(e) { - jQuery('.delete_popin').colorbox.close(); - e.preventDefault(); - }); -}); - -$(window).bind("load", function() { - cropImage(); -}); - -$(window).resize(function() { - cropImage(); -}); - -function cropImage() { - let image = $(".albumThumbailImage"); - let imageW = image[0].naturalWidth; - let imageH = image[0].naturalHeight; - let size = $('.catThumbnail').innerWidth(); - - if (imageW > imageH) { - image.css('height', size+'px'); - image.css('width', (imageW * size / imageH)+'px'); - } else { - image.css('width', size+'px'); - image.css('heigth', (imageH * size / imageW)+'px'); - } -} +const str_dont_delete_photos = '{'delete only album, not photos'|@translate|escape:javascript}'; +const str_delete_orphans = '{'delete album and the %d orphan photos'|@translate|escape:javascript}'; +const str_delete_all_photos = '{'delete album and all %d photos, even the %d associated to other albums'|@translate|escape:javascript}'; +str_albums_found = '{"%d albums found"|translate}'; +str_album_found = '{"1 album found"|translate}'; +str_result_limit = '{"%d+ albums found, try to refine the search"|translate|escape:javascript}'; +str_orphan = '{'This photo is an orphan'|@translate}'; +str_no_search_in_progress = '{'No search in progress'|@translate}'; +str_already_in_related_cats = '{'This albums is already in related categories list'|@translate}'; +str_album_comment_allow = '{'Comments allowed down the line'|@translate}'; +str_album_comment_disallow = '{'Comments disallowed down the line'|@translate}'; +str_root = '{'Root'|@translate}'; {/footer_script} -{html_style} -.delete_popin { - padding:20px 30px; -} +
-.delete_popin p { - margin:0; -} - -.delete_popin ul { - padding:0; - margin:30px 0; -} - -.delete_popin ul li { - list-style-type:none; - margin:10px 0; -} - -.delete_popin .buttonLike { - padding:5px; - margin-right:10px; -} - -.delete_popin p.popin-actions { - margin-top:30px; -} - -#cboxContent { - background: none; -} -{/html_style} - -
- -
- -
- {'Informations'|@translate} - -
- - -
-
- {if isset($representant) } - -
- -
-
- {if $representant.ALLOW_SET_RANDOM } - {'Refresh thumbnail'|@translate} - {/if} - {if isset($representant.ALLOW_DELETE)} - {'Remove thumbnail'|translate} - {/if} -
-
- {else} -
- {/if} -
+
+
+ {$CATEGORIES_NAV}
-
-
- {if isset($INFO_CREATION)} - {$INFO_CREATION} - {/if} - {$INFO_LAST_MODIFIED} - {if isset($INFO_PHOTO)} - {$INFO_PHOTO} - {/if} - {if isset($INFO_DIRECT_SUB)} - {$INFO_DIRECT_SUB} - {/if} - {if isset($U_SYNC) } - {'Directory'|@translate} : {$CAT_FULL_DIR} - {/if} -
-
- -
-
- {"Actions"|@translate} +
{if cat_admin_access($CAT_ID)} - {'Open in gallery'|@translate} + {/if} {if isset($U_MANAGE_ELEMENTS) } - {'Manage album photos'|@translate} + {/if} - {'Add Photos'|translate} + - {'Manage sub-albums'|@translate} + {if isset($U_SYNC) } - {'Synchronize'|@translate} + {/if} {if isset($U_DELETE) } - {'Delete album'|@translate} + {/if} + + {* *} + + +
+ {'Allow comments down the line'|translate} + {'Disallow comments down the line'|@translate} +
+
+ + {* Comment for extensions to add their custom actions *} +
+
+ +
+ +
+
+ {'Created'|@translate} + {$INFO_CREATION_SINCE} + {$INFO_CREATION}
+
+ {'Modified'|@translate} + {$INFO_LAST_MODIFIED_SINCE} + {$INFO_LAST_MODIFIED} +
+
+ {'Photos'|@translate} + {$INFO_PHOTO} + {$INFO_IMAGES_RECURSIVE} +
+
+ {'sub-albums'|@translate} + {$INFO_DIRECT_SUB} + {$INFO_SUBCATS} +
+ {if isset($U_SYNC) } +
+ {'Directory'} + {$CAT_FULL_DIR} +
+ {/if}
-
-
-
- - {'Publication'|@translate} - -
- {* {'Unlocked'|@translate} *} - - {'Locked'|@translate} - -
-
- {if isset($CAT_COMMENTABLE)} -
- {'Comments'|@translate} -
- {'Forbidden'|@translate} - - {'Authorized'|@translate} -
- +
+ {if isset($representant) and ($representant.ALLOW_SET_RANDOM || $representant.ALLOW_SET_RANDOM)} +
+ {if $representant.ALLOW_SET_RANDOM } + + + {'Refresh thumbnail'|@translate} + + {/if} + {if isset($representant.ALLOW_DELETE)} + + + {'Remove thumbnail'|translate} + {/if}
- {/if} + {/if} +
+ +
+
+ + +
+ +
+ + +
+ +
+ +
{$CATEGORIES_PARENT_NAV}
+
+ + {include file='include/album_selector.inc.tpl' + title={'New parent album'|@translate} + searchPlaceholder={'Search'|@translate} + show_root_btn=true + } + + {if isset($CAT_COMMENTABLE)} +
+
+ +
+ +
+ {/if} + +
+
+ + +
+
-
-
- {'Properties'|@translate} -

- {'Name'|@translate} -
- -

- -

- {'Description'|@translate} -
- -

- -{if isset($parent_category) } -

- {'Parent album'|@translate} -
- -

-{/if} - -

- -

-
- -
- -
-
- -

-{if $NB_SUBCATS == 0} - {'Delete album "%s".'|translate:$CATEGORY_FULLNAME} -{else} - {'Delete album "%s" and its %d sub-albums.'|translate:$CATEGORIES_NAV:$NB_SUBCATS} -{/if} -

-
    -
  • -
  • -
  • -
-

- {'Confirm deletion'|translate} - {'Cancel'|translate} -

+
-
{* #catModify *} \ No newline at end of file + \ No newline at end of file diff --git a/admin/themes/default/template/include/album_selector.inc.tpl b/admin/themes/default/template/include/album_selector.inc.tpl new file mode 100644 index 000000000..6b7c63ce4 --- /dev/null +++ b/admin/themes/default/template/include/album_selector.inc.tpl @@ -0,0 +1,34 @@ +{if empty($load_mode)}{$load_mode='footer'}{/if} +{include file='include/colorbox.inc.tpl' load_mode=$load_mode} + +
+
+ + +
+ +
+
+ {$title} +
+ + {if $show_root_btn} + +

{'or'|@translate}

+ {/if} + +
+ + + +
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/admin/themes/default/template/picture_modify.tpl b/admin/themes/default/template/picture_modify.tpl index eb884f91f..cbff7bd95 100644 --- a/admin/themes/default/template/picture_modify.tpl +++ b/admin/themes/default/template/picture_modify.tpl @@ -233,30 +233,10 @@ $('#action-delete-picture').on('click', function() { -
-
- - -
- -
-
- {'Associate to album'|@translate} -
- -
- - - -
-
-
-
- -
-
-
-
+{include file='include/album_selector.inc.tpl' + title={'Associate to album'|@translate} + searchPlaceholder={'Search'|@translate} +}