Location: PHPKode > projects > Ratawiki > ratawiki-0.5/wikisources/tool_recent.php
<?php
/**
@file	tool_recent.php
*/

/// See $tools on wiki.php
$tools['recent'] = 'tool_recent_changes';

/**
@brief	List recent changes in all the wiki.

	This used to require /bin/ls, but it was changed to use directory
	functions so as to increase compatibility with php's safe mode.
*/
function tool_recent_changes($doc = "")
{
    global $config;
    $history = $config['history'];


    $of = "";
    $files = array();
    $times = array();
    $d = opendir(getcwd()."/$config[datadir]");
    while ( ($f = readdir($d)) ) {
        if ( !preg_match("/^data-/", $f) ) { continue; }
        
        array_push($files, $f);
        array_push($times, filemtime("$config[datadir]/$f"));
    }
    array_multisort($times, SORT_ASC, $files, SORT_STRING);
    

    while ( $f = array_pop($files) )
    {
        if ( $f == NULL ) { break; }
        $doc = wiki_load_file("$config[datadir]/$f");
        
        $base = htmlspecialchars("$doc[name]");
        $b2 = preg_replace("/_/"," ",$base);
        $cat = wiki_clean_link($doc['category'], 
            "Ver todos los documentos en la categoría '$doc[category]'");
        
        $of .= "<tr><td rowspan=\"2\"><a href=\"$base\">$b2</a></td>".
            //"<td>".utf8_encode(strftime("%c",$time))."</td>".
            "<td style=\"font-size: x-small\">$doc[date] - $doc[author]</td>".
            "<td style=\"font-size: x-small\">$doc[notes]</td></tr>".
            "<tr>".
            "<td style=\"font-size: x-small\">$cat</td>".
            "<td class=\"actions\"><ul style=\"margin:0; padding: 0;\">".
            "<li><a href=\"$base?edit\">Editar</a></li>".
            "<li><a href=\"$base?history\">Historial</a></li>".
            "</ul></td></tr>\n";
        $history--;
        if ( $history == 0 ) break;
    }
    

    $out = <<<eot
<h1>Cambios recientes</h1>
<p>Listado de los &uacute;ltimos $config[history] cambios en el wiki.</p>
<table>
<tr><th>Documento</th>
<th>Autor y fecha / Categor&iacute;a</th>
<th>Notas / Acciones</th></tr>
$of
</table>
eot;
    $out = array(
        "name"  =>  "recent",
        "title" =>  "Cambios recientes",
        "keywords"  =>  "",
        "document"  =>  $out,
        "mtime"     => time(),
    );
    
    wiki_xhtml_wrap($out);
}
?>
Return current item: Ratawiki