*/ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_discussion_threads extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Esther Brunner', 'email' => 'wikidesign@gmail.com', 'date' => '2006-12-04', 'name' => 'Discussion Plugin (threads component)', 'desc' => 'Displays a list of recently active discussions', 'url' => 'http://www.wikidesign.ch/en/plugin/discussion/start', ); } function getType(){ return 'substition'; } function getPType(){ return 'block'; } function getSort(){ return 306; } function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{threads>.+?\}\}',$mode,'plugin_discussion_threads'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ $match = substr($match, 10, -2); // strip {{threads> from start and }} from end return cleanID($match); } /** * Create output */ function render($mode, &$renderer, $ns) { global $ID; global $conf; if ($ns == ':') $ns = ''; elseif ($ns == '.') $ns = getNS($ID); $pages = $this->_threadList($ns); if (!count($pages)) return true; // nothing to display if ($mode == 'xhtml'){ // prevent caching to ensure content is always fresh $renderer->info['cache'] = false; // show form to start a new discussion thread? $perm_create = (auth_quickaclcheck($ns.':*') >= AUTH_CREATE); if ($perm_create && ($this->getConf('threads_formposition') == 'top')) $renderer->doc .= $this->_newThreadForm($ns); // main table $renderer->doc .= '
| '; // page title $id = $page['id']; $title = $page['title']; if (!$title) $title = str_replace('_', ' ', noNS($id)); $renderer->doc .= $renderer->internallink(':'.$id, $title).' | '; // last comment date if ($this->getConf('threads_showdate')){ $renderer->doc .= ''.date($conf['dformat'], $page['date']). ' | '; } // topic starter if ($this->getConf('threads_showuser')){ if ($page['user']) $renderer->doc .= ''.$page['user'].' | '; else $renderer->doc .= ''; } // number of replies if ($page['num'] == 0) $repl = ''; elseif ($page['num'] == 1) $repl = '1 '.$this->getLang('reply'); else $repl = $page['num'].' '.$this->getLang('replies'); $renderer->doc .= ' | '.$repl.' | '; $renderer->doc .= '