BxBasePageWiki.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. * Wiki page
  11. */
  12. class BxBasePageWiki extends BxTemplPage
  13. {
  14. public function __construct($aObject, $oTemplate)
  15. {
  16. parent::__construct($aObject, $oTemplate);
  17. }
  18. public function getPageAPI ($aBlocks = [])
  19. {
  20. $aPage = parent::getPageAPI ($aBlocks);
  21. $aPagesList = BxDolPage::getObjectInstance('sys_sub_wiki_pages_list')->getPageContentAPI();
  22. if($aPagesList && ($aCell = $aPagesList['elements']['cell_center'] ?? false))
  23. $aPage['elements']['cell_left'] = $aCell;
  24. $sCell = 'center';
  25. if(($oWiki = BxDolWiki::getObjectInstance($this->_aObject['module'])) && $oWiki->isAllowed('add')) {
  26. $aLayoutColumns = $this->_oQuery->getPageLayoutColumns($this->_aObject['layout_id'], 'name');
  27. $aPage['elements']['cell_' . $sCell][] = bx_srv('system', 'wiki_add_block', [$oWiki, $this->_sObject, 'cell_' . $aLayoutColumns[$sCell]['index']], 'TemplServiceWiki');
  28. }
  29. return $aPage;
  30. }
  31. protected function _getPageCodeVars ()
  32. {
  33. $aVars = parent::_getPageCodeVars ();
  34. $oWiki = BxDolWiki::getObjectInstance($this->_aObject['module']);
  35. if ($oWiki && $oWiki->isAllowed('add')) {
  36. foreach ($aVars as $sKey => $sCell) {
  37. if (0 !== strncmp('cell_', $sKey, 5))
  38. continue;
  39. $aVars[$sKey] = $sCell . bx_srv('system', 'wiki_add_block', array($oWiki, $this->_sObject, $sKey), 'TemplServiceWiki');
  40. }
  41. }
  42. return $aVars;
  43. }
  44. }
  45. /** @} */