X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=899edd67a282bdcd89e5b0620112df3caf2fad9c;hb=e85b7a05a177f803ae36ba5c12835313f31177bc;hp=28dfd3b473dbd3f7b39d61295a0ec055681afacd;hpb=a3724717ec37d4bd54dc117ef439c8a182157882;p=github%2Fshaarli%2FShaarli.git 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'; require_once 'application/Utils.php'; require_once 'application/PluginManager.php'; require_once 'application/Router.php'; -require_once 'application/Thumbnailer.php'; require_once 'application/Updater.php'; -use \Shaarli\Languages; -use \Shaarli\ThemeUtils; use \Shaarli\Config\ConfigManager; +use \Shaarli\Languages; use \Shaarli\Security\LoginManager; use \Shaarli\Security\SessionManager; +use \Shaarli\ThemeUtils; +use \Shaarli\Thumbnailer; // Ensure the PHP version is supported try { @@ -603,7 +603,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, if ($targetPage == Router::$PAGE_PICWALL) { if (! $conf->get('thumbnails.enabled')) { - header('Location: ?'); + $PAGE->renderPage('picwall'); exit; } @@ -614,23 +614,19 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, $thumbnailer = new Thumbnailer($conf); - $cpt = 0; + $newThumbnailsCpt = 0; // Get only links which have a thumbnail. - foreach($links as $link) + foreach($links as $key => $link) { - $permalink='?'.$link['shorturl']; // Not a note, // and (never retrieved yet or no valid cache file) if ($link['url'][0] != '?' && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail']))) ) { - $link['thumbnail'] = $thumbnailer->get($link['url']); - // FIXME! we really need to get rid of ArrayAccess... - $item = $LINKSDB[$link['linkdate']]; - $item['thumbnail'] = $link['thumbnail']; - $LINKSDB[$link['linkdate']] = $item; - $updateDB = true; - $cpt++; + $item = $LINKSDB[$key]; + $item['thumbnail'] = $thumbnailer->get($link['url']); + $LINKSDB[$key] = $item; + $newThumbnailsCpt++; } if (isset($link['thumbnail']) && $link['thumbnail'] !== false) { @@ -639,14 +635,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, // If we retrieved new thumbnails, we update the database every 20 links. // Downloading everything the first time may take a very long time - if (!empty($updateDB) && $cpt == 20) { + if ($newThumbnailsCpt == 20) { $LINKSDB->save($conf->get('resource.page_cache')); - $updateDB = false; - $cpt = 0; + $newThumbnailsCpt = 0; } } - if (!empty($updateDB)) { + if ($newThumbnailsCpt > 0) { $LINKSDB->save($conf->get('resource.page_cache')); } @@ -1619,11 +1614,9 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager) if ($conf->get('thumbnails.enabled') && $link['url'][0] != '?' && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail']))) ) { - $link['thumbnail'] = $thumbnailer->get($link['url']); - // FIXME! we really need to get rid of ArrayAccess... - $item = $LINKSDB[$keys[$i]]; - $item['thumbnail'] = $link['thumbnail']; - $LINKSDB[$keys[$i]] = $item; + $elem = $LINKSDB[$keys[$i]]; + $elem['thumbnail'] = $thumbnailer->get($link['url']); + $LINKSDB[$keys[$i]] = $elem; $updateDB = true; }