diff options
author | ArthurHoaro <arthur@hoa.ro> | 2018-07-05 20:29:55 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2018-07-05 20:34:22 +0200 |
commit | b302b3c584b84f22f0e6f187b072180ecbacdfab (patch) | |
tree | 297f72d8fcf6d158ebbb8198dee4e35a30ab0d7e /index.php | |
parent | fcba541e2f12c85ac56c6915ba1319fbdd3e6962 (diff) | |
download | Shaarli-b302b3c584b84f22f0e6f187b072180ecbacdfab.tar.gz Shaarli-b302b3c584b84f22f0e6f187b072180ecbacdfab.tar.zst Shaarli-b302b3c584b84f22f0e6f187b072180ecbacdfab.zip |
Thumbnails: add a common mode to only retrieve thumbs from popular media websites
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -603,7 +603,9 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
603 | // -------- Picture wall | 603 | // -------- Picture wall |
604 | if ($targetPage == Router::$PAGE_PICWALL) | 604 | if ($targetPage == Router::$PAGE_PICWALL) |
605 | { | 605 | { |
606 | if (! $conf->get('thumbnails.enabled')) { | 606 | $PAGE->assign('pagetitle', t('Picture wall') .' - '. $conf->get('general.title', 'Shaarli')); |
607 | if (! $conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) === Thumbnailer::MODE_NONE) { | ||
608 | $PAGE->assign('linksToDisplay', []); | ||
607 | $PAGE->renderPage('picwall'); | 609 | $PAGE->renderPage('picwall'); |
608 | exit; | 610 | exit; |
609 | } | 611 | } |
@@ -630,7 +632,6 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
630 | $PAGE->assign($key, $value); | 632 | $PAGE->assign($key, $value); |
631 | } | 633 | } |
632 | 634 | ||
633 | $PAGE->assign('pagetitle', t('Picture wall') .' - '. $conf->get('general.title', 'Shaarli')); | ||
634 | $PAGE->renderPage('picwall'); | 635 | $PAGE->renderPage('picwall'); |
635 | exit; | 636 | exit; |
636 | } | 637 | } |
@@ -1013,14 +1014,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
1013 | $conf->set('api.secret', escape($_POST['apiSecret'])); | 1014 | $conf->set('api.secret', escape($_POST['apiSecret'])); |
1014 | $conf->set('translation.language', escape($_POST['language'])); | 1015 | $conf->set('translation.language', escape($_POST['language'])); |
1015 | 1016 | ||
1016 | $thumbnailsEnabled = extension_loaded('gd') && !empty($_POST['enableThumbnails']); | 1017 | $thumbnailsMode = extension_loaded('gd') ? $_POST['enableThumbnails'] : Thumbnailer::MODE_NONE; |
1017 | $conf->set('thumbnails.enabled', $thumbnailsEnabled); | 1018 | if ($conf->get('thumbnails.enabled', Thumbnailer::MODE_NONE) !== Thumbnailer::MODE_NONE) { |
1018 | |||
1019 | if (! $conf->get('thumbnails.enabled') && $thumbnailsEnabled) { | ||
1020 | $_SESSION['warnings'][] = t( | 1019 | $_SESSION['warnings'][] = t( |
1021 | 'You have enabled thumbnails. <a href="?do=thumbs_update">Please synchonize them</a>.' | 1020 | 'You have enabled or changed thumbnails mode. <a href="?do=thumbs_update">Please synchonize them</a>.' |
1022 | ); | 1021 | ); |
1023 | } | 1022 | } |
1023 | $conf->set('thumbnails.mode', $thumbnailsMode); | ||
1024 | 1024 | ||
1025 | try { | 1025 | try { |
1026 | $conf->write($loginManager->isLoggedIn()); | 1026 | $conf->write($loginManager->isLoggedIn()); |
@@ -1061,6 +1061,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
1061 | $PAGE->assign('languages', Languages::getAvailableLanguages()); | 1061 | $PAGE->assign('languages', Languages::getAvailableLanguages()); |
1062 | $PAGE->assign('language', $conf->get('translation.language')); | 1062 | $PAGE->assign('language', $conf->get('translation.language')); |
1063 | $PAGE->assign('gd_enabled', extension_loaded('gd')); | 1063 | $PAGE->assign('gd_enabled', extension_loaded('gd')); |
1064 | $PAGE->assign('thumbnails_mode', $conf->get('thumbnails.mode', Thumbnailer::MODE_NONE)); | ||
1064 | $PAGE->assign('pagetitle', t('Configure') .' - '. $conf->get('general.title', 'Shaarli')); | 1065 | $PAGE->assign('pagetitle', t('Configure') .' - '. $conf->get('general.title', 'Shaarli')); |
1065 | $PAGE->renderPage('configure'); | 1066 | $PAGE->renderPage('configure'); |
1066 | exit; | 1067 | exit; |
@@ -1162,7 +1163,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
1162 | $link['title'] = $link['url']; | 1163 | $link['title'] = $link['url']; |
1163 | } | 1164 | } |
1164 | 1165 | ||
1165 | if ($conf->get('thumbnails.enabled')) { | 1166 | if ($conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) !== Thumbnailer::MODE_NONE) { |
1166 | $thumbnailer = new Thumbnailer($conf); | 1167 | $thumbnailer = new Thumbnailer($conf); |
1167 | $link['thumbnail'] = $thumbnailer->get($url); | 1168 | $link['thumbnail'] = $thumbnailer->get($url); |
1168 | } | 1169 | } |
@@ -1606,7 +1607,8 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager) | |||
1606 | $i = ($page-1) * $_SESSION['LINKS_PER_PAGE']; | 1607 | $i = ($page-1) * $_SESSION['LINKS_PER_PAGE']; |
1607 | $end = $i + $_SESSION['LINKS_PER_PAGE']; | 1608 | $end = $i + $_SESSION['LINKS_PER_PAGE']; |
1608 | 1609 | ||
1609 | if ($conf->get('thumbnails.enabled')) { | 1610 | $thumbnailsEnabled = $conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) !== Thumbnailer::MODE_NONE; |
1611 | if ($thumbnailsEnabled) { | ||
1610 | $thumbnailer = new Thumbnailer($conf); | 1612 | $thumbnailer = new Thumbnailer($conf); |
1611 | } | 1613 | } |
1612 | 1614 | ||
@@ -1633,7 +1635,7 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager) | |||
1633 | 1635 | ||
1634 | // Thumbnails enabled, not a note, | 1636 | // Thumbnails enabled, not a note, |
1635 | // and (never retrieved yet or no valid cache file) | 1637 | // and (never retrieved yet or no valid cache file) |
1636 | if ($conf->get('thumbnails.enabled') && $link['url'][0] != '?' | 1638 | if ($thumbnailsEnabled && $link['url'][0] != '?' |
1637 | && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail']))) | 1639 | && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail']))) |
1638 | ) { | 1640 | ) { |
1639 | $elem = $LINKSDB[$keys[$i]]; | 1641 | $elem = $LINKSDB[$keys[$i]]; |