editor.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Samples
  7. * @{
  8. */
  9. /**
  10. * @page samples
  11. * @section editor Visual editor
  12. */
  13. $aPathInfo = pathinfo(__FILE__);
  14. require_once ($aPathInfo['dirname'] . '/../inc/header.inc.php');
  15. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  16. bx_import('BxDolLanguages');
  17. bx_import('BxTemplFunctions');
  18. $oTemplate = BxDolTemplate::getInstance();
  19. $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
  20. $oTemplate->setPageHeader ("Visual editor");
  21. $oTemplate->setPageContent ('page_main_code', PageCompMainCode());
  22. $oTemplate->getPageCode();
  23. /**
  24. * page code function
  25. */
  26. function PageCompMainCode() {
  27. ob_start();
  28. if (bx_get('my_textarea'))
  29. echo 'Submitted data:<hr class="bx-def-hr" />' . bx_process_output(bx_get('my_textarea')) . '<hr class="bx-def-hr" />';
  30. echo '<form method="post" id="my_form">'; // form must have id
  31. echo '<textarea id="my_textarea" name="my_textarea" rows="20" cols="80">some text here</textarea>'; // print text area element
  32. echo '<input type="submit" value="Submit" class="bx-btn bx-def-margin-sec-top" style="float:none;" />';
  33. echo '</form>';
  34. bx_import('BxDolEditor'); // import editor class
  35. $oEditor = BxDolEditor::getObjectInstance(); // get default editor object instance
  36. if ($oEditor) // check if editor is available for using
  37. echo $oEditor->attachEditor ('#my_textarea'); // output HTML which will automatically apply editor to textarea element by its id
  38. // print all available editors and editors view modes below
  39. echo '<hr class="bx-def-hr" />';
  40. $aEditors = array('sys_cleditor', 'sys_tinymce');
  41. $aViewModes = array(BX_EDITOR_MINI => 'Mini', BX_EDITOR_STANDARD => 'Standard', BX_EDITOR_FULL => 'Full');
  42. foreach ($aViewModes as $iViewMode => $sViewModeHeader) {
  43. echo "<h1>$sViewModeHeader</h1>";
  44. foreach ($aEditors as $sEditor) {
  45. $sId = 'textarea_' . $sEditor . '_' . $iViewMode;
  46. echo '<textarea id="' . $sId . '" name="' . $sId . '" rows="20" cols="80">some text here</textarea>';
  47. $oEditor = BxDolEditor::getObjectInstance($sEditor);
  48. if (!$oEditor)
  49. continue;
  50. echo $oEditor->attachEditor ('#' . $sId, $iViewMode);
  51. echo '<hr class="bx-def-hr" />';
  52. }
  53. }
  54. return DesignBoxContent("Visual editor", ob_get_clean(), BX_DB_PADDING_DEF);
  55. }
  56. /** @} */