X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=067b8fcb972c3d6517d3448d7895d9502fc618e6;hb=a381c373b30ed04001ea31ff5c38e077edacaf18;hp=c2aaf84a14959590279bb07d809459141e49c7e5;hpb=bc3ce7ec2a652eec1441774958050cf83105560a;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index c2aaf84a..067b8fcb 100644 --- a/index.php +++ b/index.php @@ -616,6 +616,20 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) $linksToDisplay[$key]['timestamp'] = $link['created']->getTimestamp(); } + $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000'); + $data = array( + 'pagetitle' => $conf->get('general.title') .' - '. format_date($dayDate, false), + 'linksToDisplay' => $linksToDisplay, + 'day' => $dayDate->getTimestamp(), + 'dayDate' => $dayDate, + 'previousday' => $previousday, + 'nextday' => $nextday, + ); + + /* Hook is called before column construction so that plugins don't have + to deal with columns. */ + $pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn())); + /* We need to spread the articles on 3 columns. I did not want to use a JavaScript lib like http://masonry.desandro.com/ so I manually spread entries with a simple method: I roughly evaluate the @@ -623,7 +637,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) */ $columns = array(array(), array(), array()); // Entries to display, for each column. $fill = array(0, 0, 0); // Rough estimate of columns fill. - foreach($linksToDisplay as $key => $link) { + foreach($data['linksToDisplay'] as $key => $link) { // Roughly estimate length of entry (by counting characters) // Title: 30 chars = 1 line. 1 line is 30 pixels height. // Description: 836 characters gives roughly 342 pixel height. @@ -639,18 +653,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) $fill[$index] += $length; } - $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000'); - $data = array( - 'pagetitle' => $conf->get('general.title') .' - '. format_date($dayDate, false), - 'linksToDisplay' => $linksToDisplay, - 'cols' => $columns, - 'day' => $dayDate->getTimestamp(), - 'dayDate' => $dayDate, - 'previousday' => $previousday, - 'nextday' => $nextday, - ); - - $pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn())); + $data['cols'] = $columns; foreach ($data as $key => $value) { $pageBuilder->assign($key, $value);