BxBaseStudioFunctions.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  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. defined('BX_DOL') or die('hack attempt');
  11. bx_import('BxDolStudioTemplate');
  12. bx_import('BxBaseFunctions');
  13. class BxBaseStudioFunctions extends BxBaseFunctions implements iBxDolSingleton {
  14. function BxBaseStudioFunctions($oTemplate = false) {
  15. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  16. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  17. parent::BxBaseFunctions($oTemplate ? $oTemplate : BxDolStudioTemplate::getInstance());
  18. }
  19. public static function getInstance() {
  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. $oTemplate = BxDolStudioTemplate::getInstance();
  26. $sId = isset($aOptions['id']) && $aOptions['id'] != '' ? bx_html_attribute($aOptions['id']) : '';
  27. $iIndex = isset($aOptions['db']) && !empty($aOptions['db']) ? (int)$aOptions['db'] : BX_DB_DEF;
  28. $bNote = isset($aOptions['note']) && $aOptions['note'] != '';
  29. return $oTemplate->parseHtmlByName('designbox_' . (int)$iIndex . '.html', array(
  30. 'id' => $sId != '' ? 'id="bx-db-container-' . $sId . '"' : '',
  31. 'title' => bx_process_output($sTitle),
  32. 'bx_if:note' => array(
  33. 'condition' => $bNote,
  34. 'content' => array(
  35. 'note' => $bNote ? bx_process_output($aOptions['note']) : ''
  36. )
  37. ),
  38. 'caption_item' => isset($aOptions['caption_item']) && $aOptions['caption_item'] != '' ? $this->getDesignBoxMenu('cpt-' . $sId, $aOptions['caption_item']) : '',
  39. 'content' => $sContent,
  40. 'bottom_item' => isset($aOptions['bottom_item']) && $aOptions['bottom_item'] != '' ? $this->getDesignBoxMenu('cpt-' . $sId, $aOptions['bottom_item']) : '',
  41. ));
  42. }
  43. function getDesignBoxMenu($sId, $mixedItems, $iIndex = 1) {
  44. $oTemplate = BxDolStudioTemplate::getInstance();
  45. if(is_array($mixedItems)) {
  46. $mixedButtons = array();
  47. foreach($mixedItems as $sId => $aAction) {
  48. $sClass = isset($aAction['class']) ? ' class="' . bx_html_attribute($aAction['class']) . '"' : '';
  49. $mixedButtons[] = array(
  50. 'id' => $sId,
  51. 'title' => bx_process_output(_t($aAction['title'])),
  52. 'class' => $sClass,
  53. 'icon' => isset($aAction['icon']) ? '<img' . $sClass . ' src="' . bx_html_attribute($aAction['icon']) . '" />' : '',
  54. 'href' => isset($aAction['href']) ? ' href="' . bx_html_attribute($aAction['href']) . '"' : '',
  55. 'target' => isset($aAction['target']) ? ' target="' . bx_html_attribute($aAction['target']) . '"' : '',
  56. 'on_click' => isset($aAction['onclick']) ? ' onclick="' . bx_html_attribute($aAction['onclick']) . '"' : '',
  57. 'bx_if:hide_active' => array(
  58. 'condition' => !isset($aAction['active']) || $aAction['active'] != 1,
  59. 'content' => array()
  60. ),
  61. 'bx_if:hide_inactive' => array(
  62. 'condition' => isset($aAction['active']) && $aAction['active'] == 1,
  63. 'content' => array()
  64. )
  65. );
  66. }
  67. }
  68. else
  69. $mixedButtons = $mixedItems;
  70. return $oTemplate->parseHtmlByName('designbox_menu_' . $iIndex . '.html', array('id' => $sId, 'bx_repeat:actions' => $mixedButtons));
  71. }
  72. function getLoginForm() {
  73. bx_import('BxDolPermalinks');
  74. bx_import('BxDolForm');
  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 = $this->transBox($sHtml);
  88. $sHtml = $oTemplate->parseHtmlByName('login.html', array (
  89. 'form' => $sHtml,
  90. ));
  91. $oTemplate->setPageNameIndex(BX_PAGE_CLEAR);
  92. $oTemplate->setPageParams(array(
  93. 'css_name' => array('forms.css', 'login.css'),
  94. 'js_name' => array('jquery.form.js', 'jquery.dolPopup.js', 'jquery.ui.position.min.js', 'login.js'),
  95. 'header' => _t('_adm_page_cpt_login'),
  96. ));
  97. $oTemplate->setPageContent ('page_main_code', $sHtml);
  98. $oTemplate->getPageCode();
  99. }
  100. }
  101. /** @} */