Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a Formats Tab on Edit photo page
* Add 3 new files for the tab creation (php, tpl and js) * Creation of a new API method : pwg.images.formats.remove * Adding translation in en_GB and fr_FR for the formats * Minor change on the head-button css class
- Loading branch information
Showing
13 changed files
with
371 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
// +-----------------------------------------------------------------------+ | ||
// | This file is part of Piwigo. | | ||
// | | | ||
// | For copyright and license information, please view the COPYING.txt | | ||
// | file that was distributed with this source code. | | ||
// +-----------------------------------------------------------------------+ | ||
|
||
if(!defined("PHPWG_ROOT_PATH")) | ||
{ | ||
die('Hacking attempt!'); | ||
} | ||
|
||
// +-----------------------------------------------------------------------+ | ||
// | Check Access and exit when user status is not ok | | ||
// +-----------------------------------------------------------------------+ | ||
check_status(ACCESS_ADMINISTRATOR); | ||
|
||
check_input_parameter('image_id', $_GET, false, PATTERN_ID); | ||
|
||
$query=' | ||
SELECT * | ||
FROM '.IMAGES_TABLE.' | ||
WHERE id = '. $_GET['image_id'] .' | ||
;'; | ||
$images = query2array($query); | ||
$image = $images[0]; | ||
|
||
$query = ' | ||
SELECT | ||
* | ||
FROM '.IMAGE_FORMAT_TABLE.' | ||
WHERE image_id = '.$_GET['image_id'].' | ||
;'; | ||
|
||
$formats = query2array($query); | ||
|
||
foreach ($formats as &$format) | ||
{ | ||
$format['download_url'] = 'action.php?format='.$format['format_id'].'&download'; | ||
|
||
|
||
$format['label'] = strtoupper($format['ext']); | ||
$lang_key = 'format '.strtoupper($format['ext']); | ||
if (isset($lang[$lang_key])) | ||
{ | ||
$format['label'] = $lang[$lang_key]; | ||
} | ||
|
||
$format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); | ||
} | ||
|
||
$template->assign(array( | ||
'ADD_FORMATS_URL' => get_root_url().'admin.php?page=photos_add&formats='.$_GET['image_id'], | ||
'IMG_SQUARE_SRC' => DerivativeImage::url(ImageStdParams::get_by_type(IMG_SQUARE), $image), | ||
'FORMATS' => $formats, | ||
'PWG_TOKEN' => get_pwg_token(), | ||
)); | ||
|
||
$template->set_filename('picture_formats', 'picture_formats.tpl'); | ||
|
||
$template->assign_var_from_handle('ADMIN_CONTENT', 'picture_formats'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function fitExtensions() { | ||
$(".format-card-ext span").each((i, node) => { | ||
let size = Math.min(180 * 1/node.innerHTML.length, 45) | ||
node.setAttribute('style', `font-size:${size}px`) | ||
}) | ||
} | ||
|
||
fitExtensions() | ||
|
||
$('.format-card').each((i, node) => { | ||
let card = $(node) | ||
let button = card.find(".format-delete") | ||
button.click(() => { | ||
console.log(card.data('id')); | ||
button.find('i').attr("class", "icon-spin6 animate-spin") | ||
$.ajax({ | ||
url: "ws.php?format=json&method=pwg.images.formats.delete", | ||
type: "POST", | ||
data: { | ||
pwg_token : pwg_token, | ||
format_id: card.data('id'), | ||
}, | ||
success: function (raw_data) { | ||
card.fadeOut("slow", () => { | ||
card.remove(); | ||
if ($('.format-card').length == 0) | ||
$('.no-formats').show() | ||
}) | ||
}, | ||
error: function(message) { | ||
console.log(message); | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{combine_css path="admin/themes/default/fontello/css/animation.css" order=10} {* order 10 is required, see issue 1080 *} | ||
{combine_script id='picture_formats' load='footer' path='admin/themes/default/js/picture_formats.js'} | ||
|
||
<script> | ||
const nbFormats = {count($FORMATS)} | ||
const pwg_token = "{$PWG_TOKEN}" | ||
</script> | ||
|
||
<div class="formats-header"> | ||
<a class="head-button-1 icon-plus-circled" href="{$ADD_FORMATS_URL}">{"Add formats"|@translate}</a> | ||
</div> | ||
<div class="formats-content"> | ||
<div class="no-formats" {if (count($FORMATS) != 0)}style="display:none"{/if}> | ||
{"No format for this picture"|@translate} | ||
</div> | ||
|
||
<div class="formats-list" {if (count($FORMATS) == 0)}style="display:none"{/if}> | ||
{foreach from=$FORMATS item=$format} | ||
<div class="format-card" data-id="{$format["format_id"]}" style="background-image: url('{$IMG_SQUARE_SRC}')"> | ||
<span class="format-card-size">{$format["filesize"]}</span> | ||
<div class="format-card-ext"><span>{$format["label"]}</span></div> | ||
<div class="format-card-actions"> | ||
<a href="{$format["download_url"]}" rel="nofollow"> <i class="icon-download"></i> </a> | ||
<a class="format-delete"> <i class="icon-trash-1"></i> </a> | ||
</div> | ||
</div> | ||
{/foreach} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.