diff options
author | ArthurHoaro <arthur@hoa.ro> | 2018-02-02 19:23:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-02 19:23:26 +0100 |
commit | a381c373b30ed04001ea31ff5c38e077edacaf18 (patch) | |
tree | ece5f4a9cf7e7d3a0ae5088f1f453cb572f02b3d /index.php | |
parent | bc3ce7ec2a652eec1441774958050cf83105560a (diff) | |
parent | 50142efd1b4b826f60b1e5673dba5ccbe26e0108 (diff) | |
download | Shaarli-a381c373b30ed04001ea31ff5c38e077edacaf18.tar.gz Shaarli-a381c373b30ed04001ea31ff5c38e077edacaf18.tar.zst Shaarli-a381c373b30ed04001ea31ff5c38e077edacaf18.zip |
Merge pull request #1074 from kalvn/feature/dailymarkdown
Executes daily hooks before creating columns.
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -616,6 +616,20 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) | |||
616 | $linksToDisplay[$key]['timestamp'] = $link['created']->getTimestamp(); | 616 | $linksToDisplay[$key]['timestamp'] = $link['created']->getTimestamp(); |
617 | } | 617 | } |
618 | 618 | ||
619 | $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000'); | ||
620 | $data = array( | ||
621 | 'pagetitle' => $conf->get('general.title') .' - '. format_date($dayDate, false), | ||
622 | 'linksToDisplay' => $linksToDisplay, | ||
623 | 'day' => $dayDate->getTimestamp(), | ||
624 | 'dayDate' => $dayDate, | ||
625 | 'previousday' => $previousday, | ||
626 | 'nextday' => $nextday, | ||
627 | ); | ||
628 | |||
629 | /* Hook is called before column construction so that plugins don't have | ||
630 | to deal with columns. */ | ||
631 | $pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn())); | ||
632 | |||
619 | /* We need to spread the articles on 3 columns. | 633 | /* We need to spread the articles on 3 columns. |
620 | I did not want to use a JavaScript lib like http://masonry.desandro.com/ | 634 | I did not want to use a JavaScript lib like http://masonry.desandro.com/ |
621 | so I manually spread entries with a simple method: I roughly evaluate the | 635 | so I manually spread entries with a simple method: I roughly evaluate the |
@@ -623,7 +637,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) | |||
623 | */ | 637 | */ |
624 | $columns = array(array(), array(), array()); // Entries to display, for each column. | 638 | $columns = array(array(), array(), array()); // Entries to display, for each column. |
625 | $fill = array(0, 0, 0); // Rough estimate of columns fill. | 639 | $fill = array(0, 0, 0); // Rough estimate of columns fill. |
626 | foreach($linksToDisplay as $key => $link) { | 640 | foreach($data['linksToDisplay'] as $key => $link) { |
627 | // Roughly estimate length of entry (by counting characters) | 641 | // Roughly estimate length of entry (by counting characters) |
628 | // Title: 30 chars = 1 line. 1 line is 30 pixels height. | 642 | // Title: 30 chars = 1 line. 1 line is 30 pixels height. |
629 | // Description: 836 characters gives roughly 342 pixel height. | 643 | // Description: 836 characters gives roughly 342 pixel height. |
@@ -639,18 +653,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) | |||
639 | $fill[$index] += $length; | 653 | $fill[$index] += $length; |
640 | } | 654 | } |
641 | 655 | ||
642 | $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000'); | 656 | $data['cols'] = $columns; |
643 | $data = array( | ||
644 | 'pagetitle' => $conf->get('general.title') .' - '. format_date($dayDate, false), | ||
645 | 'linksToDisplay' => $linksToDisplay, | ||
646 | 'cols' => $columns, | ||
647 | 'day' => $dayDate->getTimestamp(), | ||
648 | 'dayDate' => $dayDate, | ||
649 | 'previousday' => $previousday, | ||
650 | 'nextday' => $nextday, | ||
651 | ); | ||
652 | |||
653 | $pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn())); | ||
654 | 657 | ||
655 | foreach ($data as $key => $value) { | 658 | foreach ($data as $key => $value) { |
656 | $pageBuilder->assign($key, $value); | 659 | $pageBuilder->assign($key, $value); |