1
0

editor.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. $oEditor = BxDolEditor::getObjectInstance(); // get default editor object instance
  27. ob_start();
  28. if ('editor' == bx_get('action')) {
  29. echo '<textarea id="my_textarea_popup" name="my_textarea_popup" rows="20" cols="80">Hello World!</textarea>';
  30. echo $oEditor->attachEditor('#my_textarea_popup', BX_EDITOR_STANDARD, true);
  31. exit;
  32. }
  33. elseif (bx_get('my_textarea')) {
  34. echo 'Submitted data:<hr class="bx-def-hr" />' . bx_process_output(bx_get('my_textarea')) . '<hr class="bx-def-hr" />';
  35. }
  36. // standard editor
  37. echo '<form method="post" id="my_form">'; // form must have id
  38. echo '<textarea id="my_textarea" name="my_textarea" rows="20" cols="80">some text here</textarea>'; // print text area element
  39. echo '<input type="submit" value="Submit" class="bx-btn bx-def-margin-sec-top" style="float:none;" />';
  40. echo '</form><hr class="bx-def-hr" />';
  41. // standard editor in popup
  42. echo BxTemplFunctions::getInstance()->popupBox('bx-sample-editor-in-popup', 'popupBox', 'Editor in popup', true);
  43. echo '<button class="bx-btn" onclick="$(window).dolPopupAjax({url: \'' . BX_DOL_URL_ROOT . 'samples/editor.php?action=editor&_t=b'.time().'\', removeOnClose: true})">Editor in popup</button>';
  44. if ($oEditor) // check if editor is available for using
  45. echo $oEditor->attachEditor ('#my_textarea'); // output HTML which will automatically apply editor to textarea element by its id
  46. // print all available editors and editors view modes below
  47. /*
  48. echo '<hr class="bx-def-hr" />';
  49. $aEditors = array('sys_quill', 'bx_froala');
  50. $aViewModes = array(BX_EDITOR_MINI => 'Mini', BX_EDITOR_STANDARD => 'Standard', BX_EDITOR_FULL => 'Full');
  51. foreach ($aViewModes as $iViewMode => $sViewModeHeader) {
  52. echo "<h1>$sViewModeHeader</h1>";
  53. foreach ($aEditors as $sEditor) {
  54. $sId = 'textarea_' . $sEditor . '_' . $iViewMode;
  55. echo '<textarea id="' . $sId . '" name="' . $sId . '" rows="20" cols="80">some text here</textarea>';
  56. $oEditor = BxDolEditor::getObjectInstance($sEditor);
  57. if (!$oEditor)
  58. continue;
  59. echo $oEditor->attachEditor ('#' . $sId, $iViewMode);
  60. echo '<hr class="bx-def-hr" />';
  61. }
  62. }
  63. */
  64. return DesignBoxContent("Visual editor", ob_get_clean(), BX_DB_PADDING_DEF);
  65. }
  66. /** @} */