Skip to content

Instantly share code, notes, and snippets.

@lupo49
Created January 8, 2012 22:31
Show Gist options
  • Save lupo49/1579950 to your computer and use it in GitHub Desktop.
Save lupo49/1579950 to your computer and use it in GitHub Desktop.
Patch for pagelist-plugin which allows displaying just a simple list of pages
diff --git a/helper.php b/helper.php
index 63e8b92..fd0b26e 100644
--- a/helper.php
+++ b/helper.php
@@ -125,6 +125,9 @@ class helper_plugin_pagelist extends DokuWiki_Plugin {
case 'list':
$this->style = 'list';
break;
+ case 'simplelist':
+ $this->style = 'simplelist'; // Displays pagenames only, no other information
+ break;
case 'header':
$this->showheader = true;
break;
@@ -173,10 +176,23 @@ class helper_plugin_pagelist extends DokuWiki_Plugin {
case 'list':
$class = 'ul';
break;
+ case 'simplelist':
+ $class = false;
+ break;
default:
$class = 'pagelist';
}
- $this->doc = '<table class="'.$class.'">'.DOKU_LF;
+
+ if($class) {
+ $this->doc = '<table class="'.$class.'">'.DOKU_LF;
+ } else {
+ // Simplelist is enabled; Skip header and firsthl
+ $this->showheader = false;
+ $this->showfirsthl = false;
+ //$this->doc .= DOKU_LF.DOKU_TAB.'</tr>'.DOKU_LF;
+ $this->doc .= '<ul>';
+ }
+
$this->page = NULL;
// check if some plugins are available - if yes, load them!
@@ -216,28 +232,44 @@ class helper_plugin_pagelist extends DokuWiki_Plugin {
if (!$id) return false;
$this->page = $page;
$this->_meta = NULL;
-
- // priority and draft
- if (!isset($this->page['draft'])) {
- $this->page['draft'] = ($this->_getMeta('type') == 'draft');
- }
- $class = '';
- if (isset($this->page['priority'])) $class .= 'priority'.$this->page['priority']. ' ';
- if ($this->page['draft']) $class .= 'draft ';
- if ($this->page['class']) $class .= $this->page['class'];
- if(!empty($class)) $class = ' class="' . $class . '"';
-
- $this->doc .= DOKU_TAB.'<tr'.$class.'>'.DOKU_LF;
-
- $this->_pageCell($id);
- if ($this->column['date']) $this->_dateCell();
- if ($this->column['user']) $this->_userCell();
- if ($this->column['desc']) $this->_descCell();
- foreach ($this->plugins as $plug => $col) {
- if ($this->column[$col]) $this->_pluginCell($plug, $col, $id);
+
+ if($this->style != 'simplelist') {
+ // priority and draft
+ if (!isset($this->page['draft'])) {
+ $this->page['draft'] = ($this->_getMeta('type') == 'draft');
+ }
+ $class = '';
+ if (isset($this->page['priority'])) $class .= 'priority'.$this->page['priority']. ' ';
+ if ($this->page['draft']) $class .= 'draft ';
+ if ($this->page['class']) $class .= $this->page['class'];
+ if(!empty($class)) $class = ' class="' . $class . '"';
+
+ $this->doc .= DOKU_TAB.'<tr'.$class.'>'.DOKU_LF;
+
+ $this->_pageCell($id);
+ if ($this->column['date']) $this->_dateCell();
+ if ($this->column['user']) $this->_userCell();
+ if ($this->column['desc']) $this->_descCell();
+ foreach ($this->plugins as $plug => $col) {
+ if ($this->column[$col]) $this->_pluginCell($plug, $col, $id);
+ }
+
+ $this->doc .= DOKU_TAB.'</tr>'.DOKU_LF;
+ } else {
+ $class = '';
+ // simplelist is enabled; just output pagename
+ $this->doc .= DOKU_TAB . '<li>' . DOKU_LF;
+ if(page_exists($id)) $class = 'wikilink1';
+ else $class = 'wikilink2';
+
+ if (!$this->page['title']) $this->page['title'] = str_replace('_', ' ', noNS($id));
+ $title = hsc($this->page['title']);
+
+ $content = '<a href="'.wl($id).'" class="'.$class.'" title="'.$id.'">'.$title.'</a>';
+ $this->doc .= $content;
+ $this->doc .= DOKU_TAB . '</li>' . DOKU_LF;
}
- $this->doc .= DOKU_TAB.'</tr>'.DOKU_LF;
return true;
}
@@ -245,8 +277,12 @@ class helper_plugin_pagelist extends DokuWiki_Plugin {
* Sets the list footer
*/
function finishList() {
- if (!isset($this->page)) $this->doc = '';
- else $this->doc .= '</table>'.DOKU_LF;
+ if(!$this->style != 'simplelist') {
+ if (!isset($this->page)) $this->doc = '';
+ else $this->doc .= '</table>'.DOKU_LF;
+ } else {
+ $this->doc .= '</ul>' . DOKU_LF;
+ }
// reset defaults
$this->helper_plugin_pagelist();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment