doleditor.lib.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 = getDolGlobalString('FCKEDITOR_SKIN', 'moono-lisa');
  46. $colspan = 2;
  47. $thumbsbyrow = 6;
  48. print '<table class="noborder centpercent">';
  49. $var = false;
  50. // Title
  51. print '<tr class="liste_titre"><th width="35%">'.$langs->trans("DefaultSkin").'</th>';
  52. print '<th class="right">';
  53. print '</th></tr>';
  54. print '<tr class="oddeven">';
  55. print '<td>'.$langs->trans("ThemeDir").'</td>';
  56. print '<td>';
  57. foreach ($dirskins as $dirskin) {
  58. echo '"'.$dirskin.'" ';
  59. }
  60. print '</td>';
  61. print '</tr>';
  62. //
  63. print '<tr class="oddeven"><td colspan="'.$colspan.'">';
  64. print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
  65. $i = 0;
  66. foreach ($dirskins as $dir) {
  67. //print $dirroot.$dir;exit;
  68. $dirskin = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root
  69. $urltheme = dol_buildpath($dir, 1);
  70. if (is_dir($dirskin)) {
  71. $handle = opendir($dirskin);
  72. if (is_resource($handle)) {
  73. while (($subdir = readdir($handle)) !== false) {
  74. if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) != '.'
  75. && substr($subdir, 0, 3) != 'CVS' && !preg_match('/common|phones/i', $subdir)) {
  76. // Disable not stable themes (dir ends with _exp or _dev)
  77. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && preg_match('/_dev$/i', $subdir)) {
  78. continue;
  79. }
  80. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1 && preg_match('/_exp$/i', $subdir)) {
  81. continue;
  82. }
  83. print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
  84. if ($subdir == $selected_theme) {
  85. print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
  86. } else {
  87. print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
  88. }
  89. print '</div>';
  90. $i++;
  91. }
  92. }
  93. }
  94. }
  95. }
  96. print '</div></td></tr></table>';
  97. print '</td></tr>';
  98. print '</table>';
  99. }