BxBaseStudioFunctions.php 5.4 KB

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