diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 96f3dee36..3e1f74e33 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -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 | // +-----------------------------------------------------------------------+ diff --git a/include/functions_picture.inc.php b/include/functions_picture.inc.php index 20c665862..0b3753217 100644 --- a/include/functions_picture.inc.php +++ b/include/functions_picture.inc.php @@ -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; +} + ?> \ No newline at end of file diff --git a/language/en_UK/common.lang.php b/language/en_UK/common.lang.php index bc3924b83..9bddb0bce 100644 --- a/language/en_UK/common.lang.php +++ b/language/en_UK/common.lang.php @@ -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'; + ?> diff --git a/language/fr_FR/common.lang.php b/language/fr_FR/common.lang.php index fbf55b16b..93f7c05db 100644 --- a/language/fr_FR/common.lang.php +++ b/language/fr_FR/common.lang.php @@ -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'; diff --git a/picture.php b/picture.php index eb5250965..38416c0a9 100644 --- a/picture.php +++ b/picture.php @@ -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( diff --git a/themes/default/template/picture.tpl b/themes/default/template/picture.tpl index 29266784f..632f85018 100644 --- a/themes/default/template/picture.tpl +++ b/themes/default/template/picture.tpl @@ -234,6 +234,14 @@ y.callService( {/if} + {if isset($PDF_NB_PAGES) and $current.path_ext=="pdf" } +