tools.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__FILE__).'/inc/prepend.php';
  23. require dirname(__FILE__).'/../inc/libs/lib.buffer.php';
  24. if (!empty($_GET['logout'])) {
  25. $_SESSION = array();
  26. }
  27. $auth->check(9);
  28. include dirname(__FILE__).'/inc/connexion.php';
  29. $plugins_root = dirname(__FILE__).'/tools/';
  30. $plugins = new plugins($plugins_root);
  31. $plugins->getPlugins(true);
  32. $plugins_list = $plugins->getPluginsList();
  33. $PLUGIN_HEAD = '';
  34. $PLUGIN_BODY = '';
  35. if ((!empty($_REQUEST['p']) && !empty($plugins_list[$_REQUEST['p']])
  36. && $plugins_list[$_REQUEST['p']]['active']))
  37. {
  38. $p = $_REQUEST['p'];
  39. $plugins->loadl10n($p);
  40. buffer::init();
  41. include $plugins_root.$p.'/index.php';
  42. $PLUGIN_BODY = buffer::getContent();
  43. buffer::clean();
  44. $mySubMenu->addItem(__('Back to tools'),'tools.php',
  45. 'images/ico_retour.png',false);
  46. }
  47. openPage(__('Tools'),$PLUGIN_HEAD);
  48. if ($PLUGIN_BODY != '')
  49. {
  50. echo $PLUGIN_BODY;
  51. }
  52. else
  53. {
  54. echo '<h2>'.__('Tools').'</h2>';
  55. if (count($plugins_list) == 0)
  56. {
  57. echo '<p>Aucun outil n\'est disponible ou actif</p>';
  58. }
  59. else
  60. {
  61. # Traduction des plugins
  62. foreach ($plugins_list as $k => $v)
  63. {
  64. $plugins->loadl10n($k);
  65. $plugins_list[$k]['label'] = __($v['label']);
  66. $plugins_list[$k]['desc'] = __($v['desc']);
  67. }
  68. # Tri des plugins par leur nom
  69. uasort($plugins_list,create_function('$a,$b','return strcmp($a["label"],$b["label"]);'));
  70. # Liste des plugins
  71. echo '<dl class="plugin-list">';
  72. foreach ($plugins_list as $k => $v)
  73. {
  74. $plink = '<a href="tools.php?p='.$k.'">%s</a>';
  75. $plabel = (!empty($v['label'])) ? $v['label'] : $v['name'];
  76. echo '<dt>';
  77. if (file_exists($plugins_root.$k.'/icon.png')) {
  78. printf($plink,'<img alt="" src="tools/'.$k.'/icon.png" />');
  79. echo ' ';
  80. }
  81. printf($plink,$plabel);
  82. echo '</dt>';
  83. echo '<dd>'.$v['desc'].'</dd>';
  84. }
  85. echo '</dl>';
  86. }
  87. }
  88. closePage();
  89. ?>