PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/fckeditor.php

https://bitbucket.org/speedealing/speedealing
PHP | 170 lines | 101 code | 28 blank | 41 comment | 20 complexity | 4ca0b1b6eb84003473126583e7e688c3 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
  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. *
  19. */
  20. /**
  21. * \file htdocs/admin/fckeditor.php
  22. * \ingroup fckeditor
  23. * \brief Page d'activation du module FCKeditor dans les autres modules
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  28. $langs->load("admin");
  29. $langs->load("fckeditor");
  30. $action = GETPOST('action','alpha');
  31. if (!$user->admin) accessforbidden();
  32. // Constante et traduction de la description du module
  33. $modules = array(
  34. 'SOCIETE' => 'FCKeditorForCompany',
  35. 'PRODUCTDESC' => 'FCKeditorForProduct',
  36. 'MAILING' => 'FCKeditorForMailing',
  37. 'DETAILS' => 'FCKeditorForProductDetails',
  38. );
  39. // Conditions pour que l'option soit proposee
  40. $conditions = array(
  41. 'SOCIETE' => 1,
  42. 'PRODUCTDESC' => (! empty($conf->product->enabled) || ! empty($conf->service->enabled)),
  43. 'MAILING' => ! empty($conf->mailing->enabled),
  44. 'DETAILS' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)),
  45. );
  46. // Picto
  47. $picto = array(
  48. 'SOCIETE' => 'generic',
  49. 'PRODUCTDESC' => 'product',
  50. 'MAILING' => 'email',
  51. 'DETAILS' => 'generic',
  52. );
  53. /*
  54. * Actions
  55. */
  56. foreach($modules as $const => $desc)
  57. {
  58. if ($action == 'activate_'.strtolower($const))
  59. {
  60. dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1",'chaine',0,'',$conf->entity);
  61. // Si fckeditor est active dans la description produit/service, on l'active dans les formulaires
  62. if ($const == 'PRODUCTDESC' && ! empty($conf->global->PRODUIT_DESC_IN_FORM))
  63. {
  64. dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1",'chaine',0,'',$conf->entity);
  65. }
  66. header("Location: ".$_SERVER["PHP_SELF"]);
  67. exit;
  68. }
  69. if ($action == 'disable_'.strtolower($const))
  70. {
  71. dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const,$conf->entity);
  72. header("Location: ".$_SERVER["PHP_SELF"]);
  73. exit;
  74. }
  75. }
  76. if (GETPOST('save','alpha'))
  77. {
  78. $res=dolibarr_set_const($db, "FCKEDITOR_TEST", GETPOST('formtestfield'),'chaine',0,'',$conf->entity);
  79. if ($res > 0) $mesg=$langs->trans("RecordModifiedSuccessfully");
  80. }
  81. /*
  82. * View
  83. */
  84. llxHeader();
  85. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  86. print_fiche_titre($langs->trans("AdvancedEditor"),$linkback,'setup');
  87. print '<br>';
  88. $var=true;
  89. if (empty($conf->use_javascript_ajax))
  90. {
  91. dol_htmloutput_errors('',array($langs->trans("NotAvailable"),$langs->trans("JavascriptDisabled")),1);
  92. }
  93. else
  94. {
  95. print '<table class="noborder" width="100%">';
  96. print '<tr class="liste_titre">';
  97. print '<td colspan="2">'.$langs->trans("ActivateFCKeditor").'</td>';
  98. print '<td align="center" width="100">'.$langs->trans("Action").'</td>';
  99. print "</tr>\n";
  100. // Modules
  101. foreach($modules as $const => $desc)
  102. {
  103. // Si condition non remplie, on ne propose pas l'option
  104. if (! $conditions[$const]) continue;
  105. $var=!$var;
  106. print "<tr ".$bc[$var].">";
  107. print '<td width="16">'.img_object("",$picto[$const]).'</td>';
  108. print '<td>'.$langs->trans($desc).'</td>';
  109. print '<td align="center" width="100">';
  110. $constante = 'FCKEDITOR_ENABLE_'.$const;
  111. $value = (isset($conf->global->$constante)?$conf->global->$constante:0);
  112. if ($value == 0)
  113. {
  114. print '<a href="'.$_SERVER['PHP_SELF'].'?action=activate_'.strtolower($const).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
  115. }
  116. else if ($value == 1)
  117. {
  118. print '<a href="'.$_SERVER['PHP_SELF'].'?action=disable_'.strtolower($const).'">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
  119. }
  120. print "</td>";
  121. print '</tr>';
  122. }
  123. print '</table>'."\n";
  124. dol_htmloutput_mesg($mesg);
  125. print '<br>'."\n";
  126. print_fiche_titre($langs->trans("TestSubmitForm"),'','');
  127. print '<form name="formtest" method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  128. $uselocalbrowser=true;
  129. $editor=new DolEditor('formtestfield',isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test','',200,'dolibarr_notes','In', true, $uselocalbrowser);
  130. $editor->Create();
  131. print '<center><br><input class="button" type="submit" name="save" value="'.$langs->trans("Save").'"></center>'."\n";
  132. print '</form>'."\n";
  133. /*
  134. print '<!-- Result -->';
  135. print $_POST["formtestfield"];
  136. print '<!-- Result -->';
  137. print $conf->global->FCKEDITOR_TEST;
  138. */
  139. }
  140. llxFooter();
  141. $db->close();
  142. ?>