aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php39
1 files changed, 16 insertions, 23 deletions
diff --git a/index.php b/index.php
index 28dfd3b4..899edd67 100644
--- a/index.php
+++ b/index.php
@@ -74,13 +74,13 @@ require_once 'application/Url.php';
74require_once 'application/Utils.php'; 74require_once 'application/Utils.php';
75require_once 'application/PluginManager.php'; 75require_once 'application/PluginManager.php';
76require_once 'application/Router.php'; 76require_once 'application/Router.php';
77require_once 'application/Thumbnailer.php';
78require_once 'application/Updater.php'; 77require_once 'application/Updater.php';
79use \Shaarli\Languages;
80use \Shaarli\ThemeUtils;
81use \Shaarli\Config\ConfigManager; 78use \Shaarli\Config\ConfigManager;
79use \Shaarli\Languages;
82use \Shaarli\Security\LoginManager; 80use \Shaarli\Security\LoginManager;
83use \Shaarli\Security\SessionManager; 81use \Shaarli\Security\SessionManager;
82use \Shaarli\ThemeUtils;
83use \Shaarli\Thumbnailer;
84 84
85// Ensure the PHP version is supported 85// Ensure the PHP version is supported
86try { 86try {
@@ -603,7 +603,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
603 if ($targetPage == Router::$PAGE_PICWALL) 603 if ($targetPage == Router::$PAGE_PICWALL)
604 { 604 {
605 if (! $conf->get('thumbnails.enabled')) { 605 if (! $conf->get('thumbnails.enabled')) {
606 header('Location: ?'); 606 $PAGE->renderPage('picwall');
607 exit; 607 exit;
608 } 608 }
609 609
@@ -614,23 +614,19 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
614 $thumbnailer = new Thumbnailer($conf); 614 $thumbnailer = new Thumbnailer($conf);
615 615
616 616
617 $cpt = 0; 617 $newThumbnailsCpt = 0;
618 // Get only links which have a thumbnail. 618 // Get only links which have a thumbnail.
619 foreach($links as $link) 619 foreach($links as $key => $link)
620 { 620 {
621 $permalink='?'.$link['shorturl'];
622 // Not a note, 621 // Not a note,
623 // and (never retrieved yet or no valid cache file) 622 // and (never retrieved yet or no valid cache file)
624 if ($link['url'][0] != '?' 623 if ($link['url'][0] != '?'
625 && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail']))) 624 && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail'])))
626 ) { 625 ) {
627 $link['thumbnail'] = $thumbnailer->get($link['url']); 626 $item = $LINKSDB[$key];
628 // FIXME! we really need to get rid of ArrayAccess... 627 $item['thumbnail'] = $thumbnailer->get($link['url']);
629 $item = $LINKSDB[$link['linkdate']]; 628 $LINKSDB[$key] = $item;
630 $item['thumbnail'] = $link['thumbnail']; 629 $newThumbnailsCpt++;
631 $LINKSDB[$link['linkdate']] = $item;
632 $updateDB = true;
633 $cpt++;
634 } 630 }
635 631
636 if (isset($link['thumbnail']) && $link['thumbnail'] !== false) { 632 if (isset($link['thumbnail']) && $link['thumbnail'] !== false) {
@@ -639,14 +635,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
639 635
640 // If we retrieved new thumbnails, we update the database every 20 links. 636 // If we retrieved new thumbnails, we update the database every 20 links.
641 // Downloading everything the first time may take a very long time 637 // Downloading everything the first time may take a very long time
642 if (!empty($updateDB) && $cpt == 20) { 638 if ($newThumbnailsCpt == 20) {
643 $LINKSDB->save($conf->get('resource.page_cache')); 639 $LINKSDB->save($conf->get('resource.page_cache'));
644 $updateDB = false; 640 $newThumbnailsCpt = 0;
645 $cpt = 0;
646 } 641 }
647 } 642 }
648 643
649 if (!empty($updateDB)) { 644 if ($newThumbnailsCpt > 0) {
650 $LINKSDB->save($conf->get('resource.page_cache')); 645 $LINKSDB->save($conf->get('resource.page_cache'));
651 } 646 }
652 647
@@ -1619,11 +1614,9 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager)
1619 if ($conf->get('thumbnails.enabled') && $link['url'][0] != '?' 1614 if ($conf->get('thumbnails.enabled') && $link['url'][0] != '?'
1620 && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail']))) 1615 && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail'])))
1621 ) { 1616 ) {
1622 $link['thumbnail'] = $thumbnailer->get($link['url']); 1617 $elem = $LINKSDB[$keys[$i]];
1623 // FIXME! we really need to get rid of ArrayAccess... 1618 $elem['thumbnail'] = $thumbnailer->get($link['url']);
1624 $item = $LINKSDB[$keys[$i]]; 1619 $LINKSDB[$keys[$i]] = $elem;
1625 $item['thumbnail'] = $link['thumbnail'];
1626 $LINKSDB[$keys[$i]] = $item;
1627 $updateDB = true; 1620 $updateDB = true;
1628 } 1621 }
1629 1622