editor.php 2.3 KB

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