DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:recent

Changelog Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Allows you to show the changelog in a page.

Last updated on
2005-08-12
Provides
Syntax

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to changes, querychangelog

Tagged with !broken, changelog, include, listing, recent

How to use

Simply write {{changelog}} in the source page.

How to install

First, Create a folder named 'recent' in 'lib/plugins' then create a file named 'syntax.php' in this folder and copy/paste this code :

<?php
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
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_recent extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'iDo',
            'email'  => 'iDo@woow-fr.com',
            'date'   => '12/08/2005',
            'name'   => 'Recent Plugin',
            'desc'   => 'Affiche les recents d\'un wiki',
            'url'    => 'http://www.dokuwiki.org/plugin:recent',
        );
    }
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }
    /**
     * Where to sort in?
     */
    function getSort(){
        return 105;
    }
    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
      $this->Lexer->addSpecialPattern("{{changelog}}",$mode,'plugin_recent');
    }
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        return true;
    }    
 
    /**
     * Create output
     */
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){	
            $renderer->doc .= '<div class="recents">';
            $renderer->doc .= $this->_Rethtml_recent();
            $renderer->doc .= '</div>';
            return true;
        }
        return false;
    }
 
    function _Rethtml_recent($first=0) {
       ob_start();
       html_recent($first);
       return ob_get_clean();
    }    
 
}
 
//Setup VIM: ex: et ts=4 enc=utf-8 :
?>

Contact

This my first plugin. i hope you'll like it ;)
ido [at] woow-fr [dot] com

Comments

Looks good :-), a couple of comments ;-)
Why create a separate file for your Rethtml_recent() function? Define it as a function within your plugin class and call it using $this->Rethtml_recent(). Note, per the syntax plugin guidelines, its good policy to prefix your own functions with an underscore. I see you have reworked the html_recent()1) function to output to a string. You could future proof your plugin by using PHP output buffering functions and calling html_recent() directly. All of which would make your code go something like this …
// at the top
require_once(DOKU_PLUGIN.'syntax.php');
// require_once('shorct.php'); -- remove this line
require_once(DOKU_INC.'inc/html.php');
 
// at the bottom
 
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){       		
//          $renderer->info['cache'] = FALSE;     // is this necessary? 
                                                  // a new revision, will automatically mean a fresh copy in the cache
            $renderer->doc .= '<div class="recents">';
            $renderer->doc .= $this->_Rethtml_recent();
            $renderer->doc .= '</div>';
            return true;
        }
        return false;
    }   
 
    function _Rethtml_recent($first=0) {
       ob_start();
       html_recent($first);
       return ob_get_clean();
    } 

I haven't tested the above, but you get the general idea. — Christopher Smith 2005-08-16 11:53

I will try this and update the code asap :) Ty ! iDo 2005-08-16 20:00 GMT +1
That's OK ! i have updated the code ! Thanks very much ! i did not know ob_start function. It's a very very good fonction !!! iDo 2005-08-17 09:27 GMT +1
Current version of code breaks XHTML conformity. This is the error: document type does not allow element “div” here; missing one of “object”, “applet”, “map”, “iframe”, “button”, “ins”, “del” start-tag. div class=“recents” couldnt locate the problem yet — Dirk Haage
“Parfait!” Thank you.
I changed the _Rethtml_recent() to NOT return the heading and the introduction line. It now looks like this:
    function _Rethtml_recent($first=0) {
       ob_start();
       html_recent($first);
       $html = ob_get_clean();
       $html = substr($html, strpos($html, '<ul'));
       return $html;
    }

Markus Birth

Here's a quick hack to display the latest 10 changes
No hack required, just change the recent config #~.~# — MF Low
Change the given method to get more control about recently changed pages. So i can list new pages the way i want ;) See live demo at the bottom of this page www.umingo.de
function _Rethtml_recent() {
	global $conf;
	global $ID;
	$startAt = 0;
	$numberOfEntries = 10;
 
        $recents = getRecents($startAt,$numberOfEntries ,'',RECENTS_SKIP_DELETED);
 
	//store output and return if method is finished
        ob_start();
	echo "<ul>";
	foreach($recents as $recent){
	  $date = date("d.m.y", $recent['date']);
	  echo "<li>";
	  echo "<span class='date'>".$date."</span> - ";
	  echo html_wikilink(':'.$recent['id'], useHeading('navigation')?null:$recent['id']);
	  echo "</li>";
        }
	echo "</ul>";
         return ob_get_clean();
 }   
1)
inc/html.php
plugin/recent.txt · Last modified: 2024-02-05 22:28 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki