index.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. $err = '';
  23. $tool_url = '';
  24. # Liste des thèmes
  25. $themes_root = dirname(__FILE__).'/../../../themes';
  26. $themes = new plugins($themes_root,'theme');
  27. $themes->getPlugins(false);
  28. $themes_list = $themes->getPluginsList();
  29. $is_writable = is_writable($themes_root);
  30. $dc_ini_file = dirname(__FILE__).'/../../../conf/dotclear.ini';
  31. $is_ini_writable = is_writable($dc_ini_file);
  32. # Installation d'un thème
  33. if ($is_writable && !empty($_GET['tool_url']))
  34. {
  35. $tool_url = $_GET['tool_url'];
  36. $parsed_url = parse_url($tool_url);
  37. if (empty($parsed_url['scheme']) || !preg_match('/^http|ftp$/',$parsed_url['scheme'])
  38. || empty($parsed_url['host']) || empty($parsed_url['path']))
  39. {
  40. $err = __('URL is not valid.');
  41. }
  42. else
  43. {
  44. if (($err = $themes->install($tool_url)) === true)
  45. {
  46. header('Location: tools.php?p=thememng');
  47. exit;
  48. }
  49. }
  50. }
  51. # Utilisation d'un thème
  52. $use = (!empty($_GET['use'])) ? $_GET['use'] : '';
  53. if ($is_ini_writable && in_array($use,array_keys($themes_list)))
  54. {
  55. $objIni = new iniFile($dc_ini_file);
  56. $objIni->editVar('dc_theme',$use);
  57. if ($objIni->saveFile() !== false) {
  58. header('Location: tools.php?p=thememng');
  59. exit;
  60. } else {
  61. $err = __('An error occured while writing configuration file.');
  62. }
  63. exit;
  64. }
  65. # Suppression d'un thème
  66. $delete = (!empty($_GET['delete'])) ? $_GET['delete'] : '';
  67. if ($is_writable && $delete != '' && in_array($delete,array_keys($themes_list)) && $delete != 'default')
  68. {
  69. files::deltree($themes_root.'/'.$delete);
  70. header('Location: tools.php?p=thememng');
  71. exit;
  72. }
  73. if($err != '')
  74. {
  75. buffer::str(
  76. '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.$err.'</div>'
  77. );
  78. }
  79. buffer::str(
  80. '<h2>'.__('Themes manager').'</h2>'.
  81. '<h3>'.__('Install a theme').'</h3>'
  82. );
  83. if (!$is_writable)
  84. {
  85. buffer::str(
  86. '<p>'.sprintf(__('The folder %s is not writable, please check its permissions.'),
  87. 'themes/').'</p>'
  88. );
  89. }
  90. else
  91. {
  92. buffer::str(
  93. '<form action="tools.php" method="get">'.
  94. '<p><label for="tool_url">'.__('Please give the URL (http or ftp) of the theme\'s file').' :</label>'.
  95. form::field('tool_url',50,'',$tool_url).'</p>'.
  96. '<p><input type="submit" class="submit" value="'.__('install').'" />'.
  97. '<input type="hidden" name="p" value="thememng" /></p>'.
  98. '</form>'
  99. );
  100. }
  101. buffer::str(
  102. '<p><a href="http://www.dotclear.net/themes/">'.__('Install new themes').'</a></p>'
  103. );
  104. buffer::str(
  105. '<h3>'.__('List of installed themes').'</h3>'.
  106. '<dl>'
  107. );
  108. foreach ($themes_list as $k => $v)
  109. {
  110. $themes->loadl10n($k);
  111. buffer::str(
  112. '<dt>'.
  113. ($k == dc_theme ? '<img src="images/selected.png" alt="'.__('Current theme').' - "/> ' : '').
  114. __($v['label']).' - '.$k.'</dt>'.
  115. '<dd>'.__($v['desc']).' <br />'.
  116. 'par '.$v['author'].' - '.__('version').' '.$v['version'].' <br />'
  117. );
  118. if ($k != dc_theme) {
  119. if ($is_ini_writable)
  120. {
  121. buffer::str(
  122. '<strong><a href="tools.php?p=thememng&amp;use='.$k.'">'.
  123. __('use this theme').'</a></strong> - '
  124. );
  125. }
  126. if ($is_writable)
  127. {
  128. buffer::str(
  129. '<a href="tools.php?p=thememng&amp;delete='.$k.'" '.
  130. 'onclick="return window.confirm(\''.__('Are you sure you want to delete this theme ?').'\')">'.
  131. __('delete').'</a>'
  132. );
  133. }
  134. }
  135. buffer::str('</dd>');
  136. }
  137. buffer::str('</dl>');
  138. ?>