$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
*/
$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.
$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);
// Manipulate columns data
- foreach ($data['cols'] as &$value) {
- foreach ($value as &$value2) {
- $value2['formatedDescription'] .= ' ಠ_ಠ';
- }
+ foreach ($data['linksToDisplay'] as &$value) {
+ $value['formatedDescription'] .= ' ಠ_ಠ';
}
// Add plugin content at the end of each link
- foreach ($data['cols'] as &$value) {
- foreach ($value as &$value2) {
- $value2['link_plugin'][] = 'DEMO';
- }
+ foreach ($data['linksToDisplay'] as &$value) {
+ $value['link_plugin'][] = 'DEMO';
}
return $data;
*/
function hook_markdown_render_daily($data, $conf)
{
+ //var_dump($data);die;
// Manipulate columns data
- foreach ($data['cols'] as &$value) {
- foreach ($value as &$value2) {
- if (!empty($value2['tags']) && noMarkdownTag($value2['tags'])) {
- $value2 = stripNoMarkdownTag($value2);
- continue;
- }
- $value2['formatedDescription'] = process_markdown(
- $value2['formatedDescription'],
- $conf->get('security.markdown_escape', true),
- $conf->get('security.allowed_protocols')
- );
+ foreach ($data['linksToDisplay'] as &$value) {
+ if (!empty($value['tags']) && noMarkdownTag($value['tags'])) {
+ $value = stripNoMarkdownTag($value);
+ continue;
}
+ $value['formatedDescription'] = process_markdown(
+ $value['formatedDescription'],
+ $conf->get('security.markdown_escape', true),
+ $conf->get('security.allowed_protocols')
+ );
}
return $data;
|| $data['_PAGE_'] == Router::$PAGE_DAILY
|| $data['_PAGE_'] == Router::$PAGE_EDITLINK
) {
-
+
$data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css';
}
$markdown = '# My title' . PHP_EOL . 'Very interesting content.';
$data = array(
// Columns data
- 'cols' => array(
- // First, second, third.
+ 'linksToDisplay' => array(
+ // nth link
0 => array(
- // nth link
- 0 => array(
- 'formatedDescription' => $markdown,
- ),
+ 'formatedDescription' => $markdown,
),
),
);
$data = hook_markdown_render_daily($data, $this->conf);
- $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<h1>'));
- $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<p>'));
+ $this->assertNotFalse(strpos($data['linksToDisplay'][0]['formatedDescription'], '<h1>'));
+ $this->assertNotFalse(strpos($data['linksToDisplay'][0]['formatedDescription'], '<p>'));
}
/**
$data = array(
// Columns data
- 'cols' => array(
- // First, second, third.
+ 'linksToDisplay' => array(
+ // nth link
0 => array(
- // nth link
- 0 => array(
- 'formatedDescription' => $str,
- 'tags' => NO_MD_TAG,
- 'taglist' => array(),
- ),
+ 'formatedDescription' => $str,
+ 'tags' => NO_MD_TAG,
+ 'taglist' => array(),
),
),
);
$data = hook_markdown_render_daily($data, $this->conf);
- $this->assertEquals($str, $data['cols'][0][0]['formatedDescription']);
+ $this->assertEquals($str, $data['linksToDisplay'][0]['formatedDescription']);
}
/**