BxBaseServiceWiki.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * Services for Wiki functionality
  11. */
  12. class BxBaseServiceWiki extends BxDol
  13. {
  14. protected $_bJsCssAdded = false;
  15. /**
  16. * @page service Service Calls
  17. * @section bx_system_general System Services
  18. * @subsection bx_system_general-wiki Wiki
  19. * @subsubsection bx_system_general-wiki_page wiki_page
  20. *
  21. * @code bx_srv('system', 'wiki_page', ["index"], 'TemplServiceWiki'); @endcode
  22. * @code {{~system:wiki_page:TemplServiceWiki["index"]~}} @endcode
  23. *
  24. * Display WIKI page.
  25. * @param $sUri categories object name
  26. *
  27. * @see BxBaseServiceWiki::serviceWikiPage
  28. */
  29. /**
  30. * @ref bx_system_general-wiki_page "wiki_page"
  31. */
  32. public function serviceWikiPage ($sWikiObjectUri, $sUri)
  33. {
  34. $oWiki = BxDolWiki::getObjectInstanceByUri($sWikiObjectUri);
  35. if (!$oWiki) {
  36. $oTemplate = BxDolTemplate::getInstance();
  37. $oTemplate->displayPageNotFound();
  38. return;
  39. }
  40. $oPage = BxDolPage::getObjectInstanceByModuleAndURI($oWiki->getObjectName(), $sUri);
  41. if ($oPage) {
  42. $oPage->displayPage();
  43. } else {
  44. if ($oWiki->isAllowed('add')) {
  45. $oPage = BxDolPage::getObjectInstanceByURI($sUri);
  46. if ($oPage) {
  47. $oTemplate = BxDolTemplate::getInstance();
  48. $oTemplate->displayErrorOccured(_t("_sys_wiki_error_page_exists", bx_process_output($sUri)));
  49. } else {
  50. echo "TODO: wiki - suggest to create page with specified URI. Display form where user can enter title(text input), text(plain textrea), languale (selectbox with currect site languages with current one pre-selected), revision comments (text input), title - will be page and first block title, text - will be content for first block. Default layout is page with one column and block without borders and title.";
  51. }
  52. }
  53. else {
  54. $oTemplate = BxDolTemplate::getInstance();
  55. $oTemplate->displayPageNotFound();
  56. }
  57. }
  58. }
  59. /**
  60. * @page service Service Calls
  61. * @section bx_system_general System Services
  62. * @subsection bx_system_general-wiki Wiki
  63. * @subsubsection bx_system_general-wiki_page wiki_page
  64. *
  65. * @code bx_srv('system', 'wiki_page', ["index"], 'TemplServiceWiki'); @endcode
  66. * @code {{~system:wiki_page:TemplServiceWiki["index"]~}} @endcode
  67. *
  68. * Add controls for edit, delete, translate, history, etc content
  69. * @param $sUri categories object name
  70. *
  71. * @see BxBaseServiceWiki::serviceWikiPage
  72. * @param $iBlockId block ID
  73. */
  74. /**
  75. * @ref bx_system_general-wiki_page "wiki_page"
  76. */
  77. public function serviceWikiControls ($oWikiObject, $aWikiVer, $sBlockId)
  78. {
  79. $this->_addCssJs ();
  80. if (!($oMenu = BxDolMenu::getObjectInstance('sys_wiki')))
  81. return '';
  82. $oMenu->setMenuObject($oWikiObject);
  83. $o = BxDolTemplate::getInstance();
  84. return $o->parseHtmlByName('wiki_controls.html', array(
  85. 'obj' => $oWikiObject->getObjectName(),
  86. 'block_id' => $sBlockId,
  87. 'menu' => $oMenu->getCode(),
  88. 'info' => bx_time_js($aWikiVer['added']), // 'TODO: On right - Last modified time and List of missing and outdated translations. History and Last modified time should be controlled by regular menu privacy, while other actions should have custom privacy for particular wiki object',
  89. 'options' => json_encode(array()),
  90. ));
  91. }
  92. protected function _addCssJs ()
  93. {
  94. if ($this->_bJsCssAdded)
  95. return false;
  96. $o = BxDolTemplate::getInstance();
  97. $o->addCss('wiki.css');
  98. $o->addJs('BxDolWiki.js');
  99. $this->_bJsCssAdded = true;
  100. }
  101. }
  102. /** @} */