(upstream) * @author Robert Rackl (upstream) * @author lainme */ // must be run within Dokuwiki if (!defined('DOKU_INC')) die(); class syntax_plugin_miniblog_entry extends DokuWiki_Syntax_Plugin { public function getType() { return 'substition'; } public function getSort() { return 380; } public function getPType() { return 'block'; } public function connectTo($mode) { $this->Lexer->addSpecialPattern('', $mode, 'plugin_miniblog_entry'); } public function handle($match, $state, $pos, Doku_Handler $handler){ return trim(mb_substr($match, 10, -1)); } public function render($mode, Doku_Renderer $renderer, $data) { global $INPUT; global $INFO; if ($mode != 'xhtml') return false; // disable cache and toc $renderer->info['cache'] = false; $INFO['prependTOC'] = false; $entries = plugin_load('helper', 'miniblog_entry')->entry_list('blog'); $num = 5; // display 5 entries per page // slice $page = $num*$INPUT->int('page', 0); // index of first entry in current page $less = (($page > 0) ? max(0, ($page-$num)/$num) : -1); // previous page $more = ((count($entries) > $page+$num) ? ($page+$num)/$num : -1); // next page $entries = array_slice($entries, $page, $num); // comment count $source = 'count.js'; $option = array('disqus_shortname' => $this->getConf('shortname')); $renderer->doc .= plugin_load('helper', 'miniblog_comment')->comment_script($source, $option); // contents if ($data == 'twentyfifteen') { $this->render_twentyfifteen($renderer, $entries, $less, $more); } else { $this->render_default($renderer, $entries, $less, $more); } return true; } function render_default($renderer, $entries, $less, $more) { global $ID; // show entries foreach ($entries as $entry) { list($head, $content) = plugin_load('helper', 'miniblog_entry')->entry_content($entry['id']); $renderer->doc .= '

'.$head.'

'; $renderer->doc .= '

'; $renderer->doc .= dformat($entry['date']).' · '.$entry['user'].' · '; $renderer->doc .= '

'; $renderer->doc .= html_secedit($content, false); // no section edit button } // pagination if ($less !== -1) { $renderer->doc .= '

'.$this->getLang('newer').'

'; } if ($more !== -1) { $renderer->doc .= '

'.$this->getLang('older').'

'; } } function render_twentyfifteen($renderer, $entries, $less, $more) { global $ID; // show entries foreach ($entries as $entry) { list($head, $content) = plugin_load('helper', 'miniblog_entry')->entry_content($entry['id']); $renderer->doc .= '
'; $renderer->doc .= '
'; $renderer->doc .= '

'.$head.'

'; $renderer->doc .= html_secedit($content, false); // no section edit button $renderer->doc .= '
'; $renderer->doc .= '
'; $renderer->doc .= ''; $renderer->doc .= ''; $renderer->doc .= ''; $renderer->doc .= '
'; $renderer->doc .= '
'; } // pagination $renderer->doc .= ''; } }