mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-25 19:00:03 +03:00
issue #2170 update picture tpl to embed pdf reader
Add default config pdf_viewer_filesize_threshold Add function to get number of PDF pages Add translations update picture.php to send pdf filesize threshold and nb page to tpl update picture.tpl to add number of pages for PDF picture_content.tpl update for new config name and add translation functions. use embed for pdf if file ext = pdf
This commit is contained in:
parent
138f23d32f
commit
983d943548
8 changed files with 63 additions and 1 deletions
|
@ -296,6 +296,10 @@ $conf['linked_album_search_limit'] = 100;
|
|||
// 0 to disable.
|
||||
$conf['fs_quick_check_period'] = 24*60*60;
|
||||
|
||||
// This corresponds to the treshold where we no longer display the web browsers
|
||||
// PDF viewer. In MB (megabytes).
|
||||
$conf['pdf_viewer_filesize_threshold'] = 5;
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | email |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -135,4 +135,18 @@ UPDATE
|
|||
pwg_query($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of pages of a PDF file
|
||||
*
|
||||
* @param string $pdfPath
|
||||
* @return int
|
||||
*/
|
||||
function count_pdf_pages($pdfPath)
|
||||
{
|
||||
$pdftext = file_get_contents($pdfPath);
|
||||
$num = preg_match_all("/\/Page\W/", $pdftext, $dummy);
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
?>
|
|
@ -446,4 +446,8 @@ $lang['last 3 months'] = 'Last 3 months';
|
|||
$lang['last 24 hours'] = 'last 24 hours';
|
||||
$lang['Album already selected'] = 'Album already selected';
|
||||
$lang['Only the first %d albums are displayed, out of %d.'] = 'Only the first %d albums are displayed, out of %d.';
|
||||
$lang['Pages'] = "Pages";
|
||||
$lang['The PDF you requested is too large to display on this page.']= 'The PDF you requested is too large to display on this page.';
|
||||
$lang['Click here to display it']= 'Click here to display it';
|
||||
|
||||
?>
|
||||
|
|
|
@ -451,3 +451,6 @@ $lang['last 3 months'] = '3 derniers mois';
|
|||
$lang['last 24 hours'] = '24 dernières heures';
|
||||
$lang['Only the first %d albums are displayed, out of %d.'] = 'Seuls les %d premiers sont affichés, sur %d.';
|
||||
$lang['Album already selected'] = 'Album déjà sélectionné';
|
||||
$lang['Pages'] = "Pages";
|
||||
$lang['The PDF you requested is too large to display on this page.']= 'Le PDF que vous avez demandé est trop volumineux pour être affiché sur cette page.';
|
||||
$lang['Click here to display it']= 'Cliquez ici pour le voir';
|
||||
|
|
|
@ -971,6 +971,13 @@ SELECT id, name, permalink
|
|||
}
|
||||
}
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'PDF_VIEWER_FILESIZE_THRESHOLD' => $conf['pdf_viewer_filesize_threshold']*1024,
|
||||
'PDF_NB_PAGES' => count_pdf_pages($picture['current']['path'])
|
||||
)
|
||||
);
|
||||
|
||||
// maybe someone wants a special display (call it before page_header so that
|
||||
// they can add stylesheets)
|
||||
$element_content = trigger_change(
|
||||
|
|
|
@ -234,6 +234,14 @@ y.callService(
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{if isset($PDF_NB_PAGES) and $current.path_ext=="pdf" }
|
||||
<div id="Pages" class="imageInfo">
|
||||
<dt>{'Pages'|@translate}</dt>
|
||||
<dd>{$PDF_NB_PAGES}</dd>
|
||||
</tr>
|
||||
|
||||
{/if}
|
||||
|
||||
{if $display_info.rating_score and isset($rate_summary)}
|
||||
<div id="Average" class="imageInfo">
|
||||
<dt>{'Rating score'|@translate}</dt>
|
||||
|
|
|
@ -4,7 +4,20 @@
|
|||
{footer_script}var error_icon = "{$ROOT_URL}{$themeconf.icon_dir}/errors_small.png"{/footer_script}
|
||||
{/if}
|
||||
|
||||
<img class="file-ext-{if isset($current.file_ext)}{$current.file_ext}{/if} path-ext-{if isset($current.path_ext)}{$current.path_ext}{/if}" {if (isset($current.path_ext) and $current.path_ext == 'svg')} src="{$current.path}" {elseif $current.selected_derivative->is_cached()}src="{$current.selected_derivative->get_url()}"{$current.selected_derivative->get_size_htm()}{else}src="{$ROOT_URL}{$themeconf.img_dir}/ajax_loader.gif" data-src="{$current.selected_derivative->get_url()}"{/if} alt="{$ALT_IMG}" id="theMainImage" usemap="#map{$current.selected_derivative->get_type()}" title="{if isset($COMMENT_IMG)}{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}{else}{$current.TITLE_ESC} - {$ALT_IMG}{/if}">
|
||||
{if isset($current.path_ext) and $current.path_ext == 'pdf' and $current.filesize < $PDF_VIEWER_FILESIZE_THRESHOLD}
|
||||
<div>
|
||||
<embed src="{$ROOT_URL}{$current.path}" type="application/pdf" />
|
||||
</div>
|
||||
{else}
|
||||
<img class="file-ext-{if isset($current.file_ext)}{$current.file_ext}{/if} path-ext-{if isset($current.path_ext)}{$current.path_ext}{/if}" {if (isset($current.path_ext) and $current.path_ext == 'svg')} src="{$current.path}" {elseif $current.selected_derivative->is_cached()}src="{$current.selected_derivative->get_url()}"{$current.selected_derivative->get_size_htm()}{else}src="{$ROOT_URL}{$themeconf.img_dir}/ajax_loader.gif" data-src="{$current.selected_derivative->get_url()}"{/if} alt="{$ALT_IMG}" id="theMainImage" usemap="#map{$current.selected_derivative->get_type()}" title="{if isset($COMMENT_IMG)}{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}{else}{$current.TITLE_ESC} - {$ALT_IMG}{/if}">
|
||||
|
||||
{if isset($current.path_ext) and $current.path_ext == 'pdf' and $current.filesize > $PDF_VIEWER_FILESIZE_THRESHOLD}
|
||||
<div class="pdf-too-heavy">
|
||||
{'The PDF you requested is too large to display on this page.'|translate}</br>
|
||||
<a href="{$ROOT_URL}{$current.path}" target="_blank">{'Click here to display it'|translate}</a>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{foreach from=$current.unique_derivatives item=derivative key=derivative_type}{strip}
|
||||
<map name="map{$derivative->get_type()}">
|
||||
|
|
|
@ -414,6 +414,15 @@ TD.calDayCellFull, TD.calDayCellEmpty {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.pdf-too-heavy {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pdf-too-heavy a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#imageInfos {
|
||||
position: relative; /*for IE7 positioning of "who can see this photo"*/
|
||||
min-height: 120px;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue