1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 4require_once(DOKU_PLUGIN.'admin.php'); 5 6/** 7 * All DokuWiki plugins to extend the admin function 8 * need to inherit from this class 9 */ 10class admin_plugin_pagesEditees extends DokuWiki_Admin_Plugin { 11 var $cmd; 12 13 /** 14 * Constructor 15 */ 16 function admin_plugin_pagesEditees() { 17 $this->setupLocale(); 18 } 19 20 /** 21 * return some info 22 */ 23 function getInfo() { 24 return array( 25 'author' => 'Etienne M.', 26 'email' => 'emauvaisfr@yahoo.fr', 27 'date' => @file_get_contents(DOKU_PLUGIN.'pagesEditees/VERSION'), 28 'name' => 'Pages en cours d\'edition / Pages being edited', 29 'desc' => 'Affiche les pages en cours d\'edition / Displays the pages being edited', 30 'url' => 'http://www.dokuwiki.org/plugin:pageseditees', 31 ); 32 } 33 34 /** 35 * return prompt for admin menu 36 */ 37 function getMenuText($language) { 38 if (!$this->disabled) 39 return parent::getMenuText($language); 40 return ''; 41 } 42 43 /** 44 * return sort order for position in admin menu 45 */ 46 function getMenuSort() { 47 return 5000; 48 } 49 50 /** 51 * handle user request 52 */ 53 function handle() { 54 } 55 56 /** 57 * output appropriate html 58 */ 59 function html() { 60 global $lang; 61 global $INFO; 62 global $conf; 63 global $auth; 64 65 //Recherche des fichiers mlist dans le dossier meta 66 $pages = $this->list_pages($conf['savedir'].'/pages',true, $pages); 67 68 //Recherche dans chaque fichier txt trouve 69 foreach($pages as $page) { 70 preg_match("/pages\/(.*).txt$/",$page,$page2); 71 $page2=preg_replace("/\//",":",$page2[1]); 72 if ($page2) $listePages[]=$page2; 73 } 74 75 print "<h1>".$this->getLang('pged_titre')."</h1>"; 76 77 $pagelist = plugin_load('helper', 'pagelist'); 78 print "<table>"; 79 80 foreach($listePages as $page) { 81 //Si un fichier lock existe 82 $lock=wikiLockFN(cleanID($page)); 83 if (file_exists($lock)) { 84 if (!$pagelist) { 85 $titrePage=explode(":",$page); 86 $titrePage=$titrePage[sizeof($titrePage)-1]; 87 $titrePage=str_replace('_',' ',$titrePage); 88 } 89 else { 90 $pagelist->page['id']=$page; 91 $pagelist->page['exists'] = 1; 92 $pagelist->_meta=NULL; 93 $titrePage = $pagelist->_getMeta('title'); 94 if (!$titrePage) $titrePage = str_replace('_', ' ', noNS($page)); 95 $titrePage = hsc($titrePage); 96 } 97 98 $lien = "<a href='doku.php?id=".$page."' class='wikilink1' style='font-weight: lighter;' title='".$page."'>$titrePage</a>"; 99 100 $nom=file($lock); 101 $nom=$nom[0]; 102 $tmp=$auth->getUserData($nom); 103 $nomMEF=$tmp['name']; 104 if (!$nomMEF) $nomMEF=$nom; 105 106 $date=@strftime($conf['dformat'], filemtime($lock)); 107 $depuis=round((time() - filemtime($lock))/60,0); 108 109 print "<tr><td nowrap><ul><li><div class=\"li\">$lien</li></div></ul></td>"; 110 print "<td nowrap valign=\"top\" style=\"padding-left:10px;\">$nomMEF</td>"; 111 print "<td nowrap valign=\"top\" style=\"padding-left:10px;\">$date</td>"; 112 print "<td nowrap valign=\"top\" style=\"padding-left:10px;\">($depuis min)</td>"; 113 print "</tr>"; 114 } 115 } 116 print "</table>"; 117 118 if (!$date) print '<div class="level1"><p>'.$this->getLang('pged_nopged').'.</p></div>'; 119 } 120 121 function list_pages($dir, $recursive=false, $files=0) { 122 static $files; 123 124 if(is_dir($dir)) { 125 if($dh = opendir($dir)) { 126 while(($file = readdir($dh)) !== false) { 127 if($file != "." && $file != "..") { 128 if (is_dir($dir."/".$file)) 129 $this->list_pages($dir."/".$file, $recursive, $files); 130 else if (preg_match("/\.txt$/",$file)) 131 $files[]=$dir."/".$file; 132 } 133 } 134 closedir($dh); 135 } 136 } 137 return $files; 138 } 139} 140// vim:ts=4:sw=4:et:enc=utf-8: 141