doleditor.lib.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. * or see https://www.gnu.org/
  19. */
  20. /**
  21. * \file htdocs/core/lib/doleditor.lib.php
  22. * \brief Ensemble de fonctions de base pour la gestion des utilisaterus et groupes
  23. */
  24. /**
  25. * Show list of ckeditor's themes.
  26. *
  27. * @param User|null $fuser User concerned or null for global theme
  28. * @param int $edit 1 to add edit form
  29. * @return void
  30. */
  31. function show_skin($fuser, $edit = 0)
  32. {
  33. global $conf, $langs, $db;
  34. global $bc;
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  36. $formother = new FormOther($db);
  37. $dirskins = array('/includes/ckeditor/ckeditor/skins');
  38. if (!empty($conf->modules_parts['theme'])) { // Using this feature slow down application
  39. foreach ($conf->modules_parts['theme'] as $reldir) {
  40. $dirskins = array_merge($dirskins, (array) ($reldir.'theme'));
  41. }
  42. }
  43. $dirskins = array_unique($dirskins);
  44. // Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
  45. $selected_theme = '';
  46. if (empty($conf->global->FCKEDITOR_SKIN)) {
  47. $selected_theme = 'moono-lisa';
  48. } else {
  49. $selected_theme = $conf->global->FCKEDITOR_SKIN;
  50. }
  51. $colspan = 2;
  52. $thumbsbyrow = 6;
  53. print '<table class="noborder centpercent">';
  54. $var = false;
  55. // Title
  56. print '<tr class="liste_titre"><th width="35%">'.$langs->trans("DefaultSkin").'</th>';
  57. print '<th class="right">';
  58. print '</th></tr>';
  59. print '<tr class="oddeven">';
  60. print '<td>'.$langs->trans("ThemeDir").'</td>';
  61. print '<td>';
  62. foreach ($dirskins as $dirskin) {
  63. echo '"'.$dirskin.'" ';
  64. }
  65. print '</td>';
  66. print '</tr>';
  67. //
  68. print '<tr class="oddeven"><td colspan="'.$colspan.'">';
  69. print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
  70. $i = 0;
  71. foreach ($dirskins as $dir) {
  72. //print $dirroot.$dir;exit;
  73. $dirskin = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root
  74. $urltheme = dol_buildpath($dir, 1);
  75. if (is_dir($dirskin)) {
  76. $handle = opendir($dirskin);
  77. if (is_resource($handle)) {
  78. while (($subdir = readdir($handle)) !== false) {
  79. if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) <> '.'
  80. && substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir)) {
  81. // Disable not stable themes (dir ends with _exp or _dev)
  82. if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) {
  83. continue;
  84. }
  85. if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) {
  86. continue;
  87. }
  88. print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
  89. if ($subdir == $selected_theme) {
  90. print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
  91. } else {
  92. print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
  93. }
  94. print '</div>';
  95. $i++;
  96. }
  97. }
  98. }
  99. }
  100. }
  101. print '</div></td></tr></table>';
  102. print '</td></tr>';
  103. print '</table>';
  104. }