BxBaseStudioFunctions.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php defined('BX_DOL') or die('hack attempt');
  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 TridentView Trident Studio Representation classes
  7. * @ingroup TridentStudio
  8. * @{
  9. */
  10. class BxBaseStudioFunctions extends BxBaseFunctions implements iBxDolSingleton
  11. {
  12. function __construct($oTemplate = false)
  13. {
  14. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  15. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  16. parent::__construct($oTemplate ? $oTemplate : BxDolStudioTemplate::getInstance());
  17. }
  18. public static function getInstance()
  19. {
  20. if (!isset($GLOBALS['bxDolClasses']['BxBaseStudioFunctions']))
  21. $GLOBALS['bxDolClasses']['BxBaseStudioFunctions'] = new BxTemplStudioFunctions();
  22. return $GLOBALS['bxDolClasses']['BxBaseStudioFunctions'];
  23. }
  24. function getDesignBox($sTitle, $sContent, $aOptions = array())
  25. {
  26. $oTemplate = BxDolStudioTemplate::getInstance();
  27. $sId = isset($aOptions['id']) && $aOptions['id'] != '' ? bx_html_attribute($aOptions['id']) : '';
  28. $iIndex = isset($aOptions['db']) && !empty($aOptions['db']) ? (int)$aOptions['db'] : BX_DB_DEF;
  29. $bNote = isset($aOptions['note']) && $aOptions['note'] != '';
  30. return $oTemplate->parseHtmlByName('designbox_' . (int)$iIndex . '.html', array(
  31. 'id' => $sId != '' ? 'id="bx-db-container-' . $sId . '"' : '',
  32. 'title' => bx_process_output($sTitle),
  33. 'bx_if:note' => array(
  34. 'condition' => $bNote,
  35. 'content' => array(
  36. 'note' => $bNote ? bx_process_output($aOptions['note']) : ''
  37. )
  38. ),
  39. 'caption_item' => isset($aOptions['caption_item']) && $aOptions['caption_item'] != '' ? $this->getDesignBoxMenu('cpt-' . $sId, $aOptions['caption_item']) : '',
  40. 'content' => $sContent,
  41. 'bottom_item' => isset($aOptions['bottom_item']) && $aOptions['bottom_item'] != '' ? $this->getDesignBoxMenu('cpt-' . $sId, $aOptions['bottom_item']) : '',
  42. ));
  43. }
  44. function getDesignBoxMenu($sId, $mixedItems, $iIndex = 1)
  45. {
  46. $oTemplate = BxDolStudioTemplate::getInstance();
  47. if(is_array($mixedItems)) {
  48. $mixedButtons = array();
  49. foreach($mixedItems as $sId => $aAction) {
  50. $sClass = isset($aAction['class']) ? ' class="' . bx_html_attribute($aAction['class']) . '"' : '';
  51. $mixedButtons[] = array(
  52. 'id' => $sId,
  53. 'title' => bx_process_output(_t($aAction['title'])),
  54. 'class' => $sClass,
  55. 'icon' => isset($aAction['icon']) ? '<img' . $sClass . ' src="' . bx_html_attribute($aAction['icon']) . '" />' : '',
  56. 'href' => isset($aAction['href']) ? ' href="' . bx_html_attribute($aAction['href']) . '"' : '',
  57. 'target' => isset($aAction['target']) ? ' target="' . bx_html_attribute($aAction['target']) . '"' : '',
  58. 'on_click' => isset($aAction['onclick']) ? ' onclick="' . bx_html_attribute($aAction['onclick']) . '"' : '',
  59. 'bx_if:hide_active' => array(
  60. 'condition' => !isset($aAction['active']) || $aAction['active'] != 1,
  61. 'content' => array()
  62. ),
  63. 'bx_if:hide_inactive' => array(
  64. 'condition' => isset($aAction['active']) && $aAction['active'] == 1,
  65. 'content' => array()
  66. )
  67. );
  68. }
  69. } else
  70. $mixedButtons = $mixedItems;
  71. return $oTemplate->parseHtmlByName('designbox_menu_' . $iIndex . '.html', array('id' => $sId, 'bx_repeat:actions' => $mixedButtons));
  72. }
  73. function getLoginForm()
  74. {
  75. $oTemplate = BxDolStudioTemplate::getInstance();
  76. $sUrlRelocate = bx_get('relocate');
  77. if (empty($sUrlRelocate) || basename($sUrlRelocate) == 'index.php')
  78. $sUrlRelocate = '';
  79. $oTemplate->addJsTranslation(array('_adm_txt_login_username', '_adm_txt_login_password'));
  80. $sHtml = $oTemplate->parseHtmlByName('login_form.html', array (
  81. 'role' => BX_DOL_ROLE_ADMIN,
  82. 'csrf_token' => BxDolForm::genCsrfToken(true),
  83. 'relocate_url' => bx_html_attribute($sUrlRelocate),
  84. 'action_url' => BX_DOL_URL_ROOT . 'member.php',
  85. 'forgot_password_url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password'),
  86. ));
  87. $sHtml = $oTemplate->parseHtmlByName('login.html', array (
  88. 'form' => $this->transBox('bx-std-login-form-box', $sHtml, true),
  89. ));
  90. $oTemplate->setPageNameIndex(BX_PAGE_CLEAR);
  91. $oTemplate->setPageParams(array(
  92. 'css_name' => array('forms.css', 'login.css'),
  93. 'js_name' => array('jquery-ui/jquery.ui.position.min.js', 'jquery.form.min.js', 'jquery.dolPopup.js', 'login.js'),
  94. 'header' => _t('_adm_page_cpt_login'),
  95. ));
  96. $oTemplate->setPageContent ('page_main_code', $sHtml);
  97. $oTemplate->getPageCode();
  98. }
  99. }
  100. /** @} */