Issue #1208 : Implementation of the new album edit page

This commit is contained in:
Zacharie
2020-08-12 10:20:29 +02:00
committed by plegall
parent e6b0574cde
commit d4436b825d
7 changed files with 348 additions and 119 deletions
+56 -13
View File
@@ -99,6 +99,7 @@ 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'],
@@ -109,9 +110,9 @@ if (isset($_POST['submit']))
if ($conf['activate_comments'])
{
$data['commentable'] = isset($_POST['commentable'])?$_POST['commentable']:'false';
$data['commentable'] = isset($_POST['commentable'])? 'true':'false';
}
single_update(
CATEGORIES_TABLE,
$data,
@@ -131,11 +132,11 @@ UPDATE '.CATEGORIES_TABLE.'
// retrieve cat infos before continuing (following updates are expensive)
$cat_info = get_cat_info($_GET['cat_id']);
if ($_POST['visible']=='true_sub')
if (isset($_POST['visible']))
{
set_cat_visible(array($_GET['cat_id']), true, true);
}
elseif ($cat_info['visible'] != get_boolean( $_POST['visible'] ) )
elseif ($cat_info['visible'] != isset($_POST['visible']))
{
set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
}
@@ -317,7 +318,7 @@ SELECT
if ($min_date == $max_date)
{
$intro = l10n(
$info_title = l10n(
'This album contains %d photos, added on %s.',
$image_count,
format_date($min_date)
@@ -325,19 +326,64 @@ SELECT
}
else
{
$intro = l10n(
$info_title = l10n(
'This album contains %d photos, added between %s and %s.',
$image_count,
format_date($min_date),
format_date($max_date)
);
}
$info_photos = l10n('%d photos', $image_count);
$template->assign(
array(
'INFO_PHOTO' => $info_photos,
'INFO_TITLE' => $info_title
)
);
}
else
{
$intro = l10n('This album contains no photo.');
// date creation
$query = '
SELECT occured_on
FROM `'.ACTIVITY_TABLE.'`
WHERE object_id = '.$category['id'].'
AND object = "album"
AND action = "add"
';
$result = query2array($query);
if (count($result) > 0) {
$template->assign(
array(
'INFO_CREATION' => l10n('Created on %s',format_date($result[0]['occured_on']))
)
);
}
// Sub Albums
$query = '
SELECT COUNT(*)
FROM `'.CATEGORIES_TABLE.'`
WHERE id_uppercat = '.$category['id'].'
';
$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_ID' => l10n('Numeric identifier : %d',$category['id']),
'INFO_LAST_MODIFIED'=> l10n('Edited on %s',format_date($category['lastmodified']))
)
);
// info for deletion
$template->assign(
array(
@@ -349,10 +395,7 @@ $template->assign(
)
);
$intro.= '<br>'.l10n('Numeric identifier : %d', $category['id']);
$template->assign(array(
'INTRO' => $intro,
'U_MANAGE_RANKS' => $base_url.'element_set_ranks&amp;cat_id='.$category['id'],
'CACHE_KEYS' => get_admin_client_cache_keys(array('categories')),
));
@@ -393,7 +436,7 @@ if ($category['has_images'] or !empty($category['representative_picture_id']))
// representant ?
if (!empty($category['representative_picture_id']))
{
$tpl_representant['picture'] = get_category_representant_properties($category['representative_picture_id']);
$tpl_representant['picture'] = get_category_representant_properties($category['representative_picture_id'], IMG_SMALL);
}
// can the admin choose to set a new random representant ?
+7 -2
View File
@@ -989,15 +989,20 @@ SELECT uppercats
/**
*/
function get_category_representant_properties($image_id)
function get_category_representant_properties($image_id, $size = NULL)
{
$query = '
SELECT id,representative_ext,path
FROM '.IMAGES_TABLE.'
WHERE id = '.$image_id.'
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$src = DerivativeImage::thumb_url($row);
if ($size == NULL) {
$src = DerivativeImage::thumb_url($row);
} else {
$src = DerivativeImage::url($size, $row);
}
$url = get_root_url().'admin.php?page=photo-'.$image_id;
return array(
+7
View File
@@ -662,6 +662,13 @@ table.dataTable thead th, table.dataTable.no-footer {
background-color:#fff;
}
FORM#categoryOrdering p.albumTitle a { color: #5B5B5B; }
FORM#categoryOrdering p.albumActions a { border-left:1px solid #D6D6D6; background-color: #E8E8E8;}
.albumInfos {color: #999999;}
FORM#categoryOrdering p.albumActions a:hover {background-color: #FFA844; color: #3A3A3A;}
FORM#categoryOrdering p.albumActions .userSeparator {border: 1px solid #E1E1E1;}
#addAlbumOpen, #autoOrderOpen {border: 1px solid #D6D6D6; color: #5B5B5B;}
#addAlbumOpen:hover, #autoOrderOpen:hover {border: 1px solid #aaa; text-decoration: none;}
.afterUploadActions a {color: #3C3C3C; font-weight: bold; background-color: #FFA646;}
.afterUploadActions a:hover {text-decoration: none; background-color: #ff7700;}
.font-checkbox:hover {color: #FFA844;}
+119 -65
View File
@@ -45,11 +45,19 @@ jQuery(document).ready(function() {
success:function(data) {
var data = jQuery.parseJSON(data);
if (data.stat == 'ok') {
jQuery(".albumThumbnailImage")
.attr('href', data.result.url)
.find("img").attr('src', data.result.src)
.end().show();
console.log('plouk');
jQuery(".albumThumbailImage, .albumThumbnailRandom").on('load', function () {
cropImage();
})
jQuery(".albumThumbailImage, .albumThumbnailRandom")
.attr('src', data.result.src)
.end().show();
jQuery(".albumThumbnailEdit")
.attr('href', data.result.url)
jQuery(".albumThumbnailRandom").hide();
}
else {
@@ -132,6 +140,29 @@ jQuery(document).ready(function() {
});
});
$(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');
}
}
{/footer_script}
{html_style}
@@ -170,62 +201,106 @@ jQuery(document).ready(function() {
<div id="catModify">
<form action="{$F_ACTION}" method="POST">
<fieldset>
<legend><span class="icon-info-circled-1 icon-blue"></span>{'Informations'|@translate}</legend>
<table style="width:100%">
<tr>
<td id="albumThumbnail">
{if isset($representant) }
<a class="albumThumbnailImage" style="{if !isset($representant.picture)}display:none{/if}" href="{$representant.picture.url}"><img src="{$representant.picture.src}"></a>
<div id="catHeader">
{if isset($representant) }
<div class="catThumbnail">
<div class="thumbnailContainer">
<img class="albumThumbailImage" src="{$representant.picture.src}">
<img class="albumThumbnailRandom" style="{if isset($representant.picture)}display:none{/if}" src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_representant_random.png" alt="{'Random photo'|@translate}">
<p class="albumThumbnailActions" data-random_allowed="{$representant.ALLOW_SET_RANDOM}">
{assign var="action_separator" value=""}
{if $representant.ALLOW_SET_RANDOM }
<a href="#refresh" data-category_id="{$CAT_ID}" class="refreshRepresentative" title="{'Find a new representant by random'|@translate}">{'Refresh'|@translate}</a>
{assign var="action_separator" value="|"}
<div class="albumThumbnailActions" data-random_allowed="{$representant.ALLOW_SET_RANDOM}">
<div class="albumThumbnailActionContainer">
{if $representant.ALLOW_SET_RANDOM }
<a href="#refresh" data-category_id="{$CAT_ID}" class="refreshRepresentative icon-ccw" title="{'Find a new representant by random'|@translate}">{'Refresh'|@translate}</a>
{/if}
{if isset($representant.ALLOW_DELETE) }
<a href="#delete" data-category_id="{$CAT_ID}" class="deleteRepresentative icon-cancel" title="{'Delete Representant'|@translate}">{'Delete'|translate}</a>
{/if}
<a class="albumThumbnailEdit icon-pencil" style="{if !isset($representant.picture)}display:none{/if}" href="{$representant.picture.url}">{'Edit photo'|@translate}</a>
</div>
</div>
</div>
</div>
{/if}
{if isset($representant.ALLOW_DELETE) }
{$action_separator}
<a href="#delete" data-category_id="{$CAT_ID}" class="deleteRepresentative" title="{'Delete Representant'|@translate}">{'Delete'|translate}</a>
{/if}
</p>
{/if}
</td>
<div class="catInfo">
{if isset($INFO_CREATION)}
<span class="icon-green">{$INFO_CREATION}</span>
{/if}
<span class="icon-purple">{$INFO_LAST_MODIFIED}</span>
{if isset($INFO_PHOTO)}
<span class="icon-yellow" title="{$INFO_TITLE}">{$INFO_PHOTO}</span>
{/if}
{if isset($INFO_DIRECT_SUB)}
<span class="icon-blue">{$INFO_DIRECT_SUB}</span>
{/if}
<span class="icon-red" >{$INFO_ID}</span>
</div>
<td id="albumLinks">
<p>{$INTRO}</p>
<ul>
{if cat_admin_access($CAT_ID)}
<li><a class="icon-eye" href="{$U_JUMPTO}">{'jump to album'|@translate}</a></li>
{/if}
<div class="catAction">
<div class="container">
<strong>{"Actions"|@translate}</strong>
{if cat_admin_access($CAT_ID)}
<a class="icon-eye" href="{$U_JUMPTO}">{'jump to album'|@translate}</a>
{/if}
{if isset($U_MANAGE_ELEMENTS) }
<li><a class="icon-picture" href="{$U_MANAGE_ELEMENTS}">{'manage album photos'|@translate}</a></li>
{/if}
{if isset($U_MANAGE_ELEMENTS) }
<a class="icon-picture" href="{$U_MANAGE_ELEMENTS}">{'manage album photos'|@translate}</a>
{/if}
<li style="text-transform:lowercase;"><a class="icon-plus-circled" href="{$U_ADD_PHOTOS_ALBUM}">{'Add Photos'|translate}</a></li>
<a class="icon-plus-circled" href="{$U_ADD_PHOTOS_ALBUM}">{'Add Photos'|translate}</a>
<li><a class="icon-sitemap" href="{$U_CHILDREN}">{'manage sub-albums'|@translate}</a></li>
<a class="icon-sitemap" href="{$U_CHILDREN}">{'manage sub-albums'|@translate}</a>
{if isset($U_SYNC) }
<li><a class="icon-exchange" href="{$U_SYNC}">{'Synchronize'|@translate}</a> ({'Directory'|@translate} = {$CAT_FULL_DIR})</li>
{/if}
{if isset($U_SYNC) }
<a class="icon-exchange" href="{$U_SYNC}">{'Synchronize'|@translate}</a> ({'Directory'|@translate} = {$CAT_FULL_DIR})
{/if}
{if isset($U_DELETE) }
<li><a class="icon-trash deleteAlbum" href="#">{'delete album'|@translate}</a></li>
{/if}
</ul>
</td>
</tr>
</table>
{if isset($U_DELETE) }
<a class="icon-trash deleteAlbum" href="#">{'delete album'|@translate}</a>
{/if}
</div>
</div>
<div class="catLock">
<div class="container">
<strong>{'Publication'|@translate}</strong>
<div>
<span class="label">{'Unlock'|@translate}</span>
<label class="switch">
<input type="checkbox" name="visible" id="toggleSelectionMode" value="true" {if $CAT_VISIBLE == "true"}checked{/if}>
<span class="slider round"></span>
</label>
<span class="label">{'Lock'|@translate}</span>
</div>
{if isset($CAT_COMMENTABLE)}
<strong>{'Comments'|@translate}</strong>
<div>
<span class="label">{'Forbidden'|@translate}</span>
<label class="switch">
<input type="checkbox" name="commentable" id="commentable" value="true" {if $CAT_COMMENTABLE == "true"}checked{/if}>
<span class="slider round"></span>
</label>
<span class="label">{'Authorized'|@translate}</span>
<br>
<label id="applytoSubAction">
<label class="font-checkbox"><span class="icon-check"></span><input type="checkbox" name="apply_commentable_on_sub"></label>
{'Apply to sub-albums'|@translate}
</label>
</div>
{/if}
</div>
</div>
</div>
</fieldset>
<form action="{$F_ACTION}" method="POST">
<fieldset>
<legend><span class="icon-tools icon-red"></span>{'Properties'|@translate}</legend>
<p>
@@ -249,27 +324,6 @@ jQuery(document).ready(function() {
</p>
{/if}
<p>
<strong>{'Lock'|@translate}</strong>
<br>
<label class="font-checkbox"><span class="icon-dot-circled"></span><input type="radio" name="visible" value="true"{if $CAT_VISIBLE == "true"} checked="checked"{/if}>{'No'|translate}</label>
<label class="font-checkbox"><span class="icon-dot-circled"></span><input type="radio" name="visible" value="true_sub">{'No and unlock sub-albums'|translate}</label>
<label class="font-checkbox"><span class="icon-dot-circled"></span><input type="radio" name="visible" value="false"{if $CAT_VISIBLE == "false"} checked="checked"{/if}>{'Yes'|translate}</label>
</p>
{if isset($CAT_COMMENTABLE)}
<p>
<strong>{'Comments'|@translate}</strong>
<br>
<label class="font-checkbox"><span class="icon-dot-circled"></span><input type="radio" name="commentable" value="false"{if $CAT_COMMENTABLE == "false"} checked="checked"{/if}>{'No'|translate}</label>
<label class="font-checkbox"><span class="icon-dot-circled"></span><input type="radio" name="commentable" value="true"{if $CAT_COMMENTABLE == "true"} checked="checked"{/if}>{'Yes'|translate}</label>
<label id="applytoSubAction">
<label class="font-checkbox"><span class="icon-check"></span><input type="checkbox" name="apply_commentable_on_sub"></label>
{'Apply to sub-albums'|@translate}
</label>
</p>
{/if}
<p style="margin:0">
<button name="submit" type="submit" class="buttonLike">
<i class="icon-floppy"></i> {'Save Settings'|@translate}
+141 -33
View File
@@ -349,40 +349,158 @@ LI.menuLi {
padding: 12px 0;
margin-bottom: 5px;
}
/* */
#catModify TABLE { width: auto; }
/* Cat modify */
#catModify p {
line-height: 20px;
margin: 0 0 1.5em;
text-align: left;
#catHeader {
display: grid;
grid-template-columns: 25% 25% 25% 25%;
min-height: 200px;
}
#catModify p.albumThumbnailActions {
text-align:center;
white-space:nowrap;
#catHeader .catThumbnail {
position: relative;
overflow: hidden;
}
FIELDSET.elementEdit .thumb {
display: block;
float: right;
text-align: center;
#catHeader .catThumbnail .thumbnailContainer {
width: 100%;
padding-top: 100%;
}
TABLE.doubleSelect {
text-align: center;
margin: 0 auto;
width: 100%;
#catHeader .albumThumbailImage, #catHeader .albumThumbnailRandom, #catHeader .albumThumbnailActions, #catHeader .albumThumbnailActionContainer{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
TABLE.doubleSelect TD {
padding: 0 3px;
width: 50%;
#catHeader .albumThumbnailActions {
width: 101%;
height: 100%;
background-color: #00000070;
opacity: 0;
}
TABLE.doubleSelect SELECT.categoryList {
width: 100%; max-width: 100%; overflow-x: auto;
#catHeader .catThumbnail:hover .albumThumbnailActions {
opacity: 1;
}
#catHeader .albumThumbnailActionContainer {
display: flex;
flex-direction: column;
}
#catHeader .albumThumbnailActions a {
background-color: #ffffffbd;
margin: 10px;
padding: 10px 20px;
white-space: nowrap;
font-weight: bold;
color: #3C3C3C;
}
#catHeader .albumThumbnailActions a:hover {
color: #3C3C3C;
text-decoration: none;
background-color: #ff7700bd;
}
#catHeader .catInfo, #catHeader .catAction {
border-right: 1px solid #00000017;
}
#catHeader .catInfo {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
}
#catHeader .catInfo span {
padding: 10px;
border-radius: 20px;
font-weight: bold;
}
#catHeader .catAction {
display: flex;
position: relative;
justify-content: center;
align-items: center;
}
#catHeader .catAction .container {
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: baseline;
height: 100%;
padding-top: 30px;
}
#catHeader .catAction strong{
position: absolute;
top: 0;
color: #3C3C3C;
font-size: 16px;
}
#catHeader .catAction a {
text-transform: capitalize;
color: #888;
font-size: 14px;
white-space: nowrap;
}
#catHeader .catAction a:hover {
color: #3C3C3C;
text-decoration: none;
}
#catHeader .catAction a::before {
font-size: 20px;
margin-right: 10px;
}
#catHeader .catLock {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
#catHeader .catLock .container{
position: relative;
}
#catHeader .catLock strong {
color: #3C3C3C;
font-size: 16px;
}
#catHeader .catLock .container > div {
margin-top: 15px;
margin-bottom: 20px;
}
#catHeader .catLock > div .label {
font-size: 14px;
}
#catModify input[type="text"], #catModify textarea{
width: 50%;
background-color: #f8f8f8;
padding: 8px;
border-radius: 4px;
border-color: #DDD;
transition: ease 0.2s;
font-family: "Open Sans", "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;
}
#catModify button[type="submit"] {
margin: 13px;
font-size: 14px;
}
/* Search bar */
@@ -2666,17 +2784,7 @@ a#showPermissions:hover {text-decoration: none;}
color: rgba(29, 29, 29, 0.226);
}
/* Album Properties */
#albumThumbnail {
width:1%;
padding-right:10px;
text-align:center;
}
#albumThumbnail img {
border:2px solid #ddd;
}
/* Picture Edit */
#pictureModify {
display: flex;
margin: 0;
+17 -5
View File
@@ -358,11 +358,7 @@ div.token-input-dropdown ul li.token-input-selected-dropdown-item {background-co
background: #3c3939;
}
/* Album Properties */
#albumThumbnail img, #albumLinks {
border-color:#333;
}
/* Picture edit */
#picture-content input[type=text], #picture-content textarea, #picture-content .selectize-input, #picture-content select {
background-color: #444444;
border: 1px solid #666;
@@ -377,6 +373,22 @@ div.token-input-dropdown ul li.token-input-selected-dropdown-item {background-co
border-color: #333;
}
/* Album edit */
#catModify input[type="text"], #catModify textarea{
background-color: #444444;
border: 1px solid #666;
color: #c1c1c1;
}
#catHeader .catAction strong, #catHeader .catLock strong {
color: #c1c1c1;
}
#catHeader .catAction a:hover {
color: white;
}
.selectedComment {background-color:#555; color:#fff;}
.groups .Group-name>p {