doleditor.lib.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  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 <http://www.gnu.org/licenses/>.
  18. * or see http://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. {
  40. foreach($conf->modules_parts['theme'] as $reldir)
  41. {
  42. $dirskins=array_merge($dirskins,(array) ($reldir.'theme'));
  43. }
  44. }
  45. $dirskins=array_unique($dirskins);
  46. // Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
  47. $selected_theme='';
  48. if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme='moono-lisa';
  49. else $selected_theme=$conf->global->FCKEDITOR_SKIN;
  50. $colspan=2;
  51. $thumbsbyrow=6;
  52. print '<table class="noborder" width="100%">';
  53. $var=false;
  54. // Title
  55. print '<tr class="liste_titre"><th width="35%">'.$langs->trans("DefaultSkin").'</th>';
  56. print '<th align="right">';
  57. $url='http://ckeditor.com/addons/skins/all';
  58. /*print '<a href="'.$url.'" target="_blank">';
  59. print $langs->trans('DownloadMoreSkins');
  60. print '</a>';*/
  61. print '</th></tr>';
  62. print '<tr class="oddeven">';
  63. print '<td>'.$langs->trans("ThemeDir").'</td>';
  64. print '<td>';
  65. foreach($dirskins as $dirskin)
  66. {
  67. echo '"'.$dirskin.'" ';
  68. }
  69. print '</td>';
  70. print '</tr>';
  71. //
  72. print '<tr class="oddeven"><td colspan="'.$colspan.'">';
  73. print '<table class="nobordernopadding" width="100%"><tr><td><div align="center">';
  74. $i=0;
  75. foreach($dirskins as $dir)
  76. {
  77. //print $dirroot.$dir;exit;
  78. $dirskin=dol_buildpath($dir,0); // This include loop on $conf->file->dol_document_root
  79. $urltheme=dol_buildpath($dir,1);
  80. if (is_dir($dirskin))
  81. {
  82. $handle=opendir($dirskin);
  83. if (is_resource($handle))
  84. {
  85. while (($subdir = readdir($handle))!==false)
  86. {
  87. if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) <> '.'
  88. && substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
  89. {
  90. // Disable not stable themes (dir ends with _exp or _dev)
  91. if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) continue;
  92. if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) continue;
  93. print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
  94. if ($subdir == $selected_theme)
  95. {
  96. print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
  97. }
  98. else
  99. {
  100. print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
  101. }
  102. print '</div>';
  103. $i++;
  104. }
  105. }
  106. }
  107. }
  108. }
  109. print '</div></td></tr></table>';
  110. print '</td></tr>';
  111. print '</table>';
  112. }