BxBaseStudioFunctions.php 5.4 KB

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