editor.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 . "params.inc.php");
  16. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  17. bx_import('BxDolLanguages');
  18. bx_import('BxTemplFunctions');
  19. $oTemplate = BxDolTemplate::getInstance();
  20. $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
  21. $oTemplate->setPageHeader ("Visual editor");
  22. $oTemplate->setPageContent ('page_main_code', PageCompMainCode());
  23. $oTemplate->getPageCode();
  24. /**
  25. * page code function
  26. */
  27. function PageCompMainCode() {
  28. ob_start();
  29. if (bx_get('my_textarea'))
  30. echo 'Submitted data:<hr class="bx-def-hr" />' . bx_process_output(bx_get('my_textarea')) . '<hr class="bx-def-hr" />';
  31. echo '<form method="post" id="my_form">'; // form must have id
  32. echo '<textarea id="my_textarea" name="my_textarea" rows="20" cols="80">some text here</textarea>'; // print text area element
  33. echo '<input type="submit" value="Submit" class="bx-btn bx-def-margin-sec-top" style="float:none;" />';
  34. echo '</form>';
  35. bx_import('BxDolEditor'); // import editor class
  36. $oEditor = BxDolEditor::getObjectInstance(); // get default editor object instance
  37. if ($oEditor) // check if editor is available for using
  38. echo $oEditor->attachEditor ('#my_textarea'); // output HTML which will automatically apply editor to textarea element by its id
  39. // print all available editors and editors view modes below
  40. echo '<hr class="bx-def-hr" />';
  41. $aEditors = array('sys_cleditor', 'sys_tinymce');
  42. $aViewModes = array(BX_EDITOR_MINI => 'Mini', BX_EDITOR_STANDARD => 'Standard', BX_EDITOR_FULL => 'Full');
  43. foreach ($aViewModes as $iViewMode => $sViewModeHeader) {
  44. echo "<h1>$sViewModeHeader</h1>";
  45. foreach ($aEditors as $sEditor) {
  46. $sId = 'textarea_' . $sEditor . '_' . $iViewMode;
  47. echo '<textarea id="' . $sId . '" name="' . $sId . '" rows="20" cols="80">some text here</textarea>';
  48. $oEditor = BxDolEditor::getObjectInstance($sEditor);
  49. if (!$oEditor)
  50. continue;
  51. echo $oEditor->attachEditor ('#' . $sId, $iViewMode);
  52. echo '<hr class="bx-def-hr" />';
  53. }
  54. }
  55. return DesignBoxContent("Visual editor", ob_get_clean(), BX_DB_PADDING_DEF);
  56. }
  57. /** @} */