BxBaseStudioPage.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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('BxDolStudioPage');
  12. bx_import('BxDolStudioTemplate');
  13. bx_import('BxTemplStudioFunctions');
  14. class BxBaseStudioPage extends BxDolStudioPage {
  15. function BxBaseStudioPage($mixedPageName) {
  16. parent::BxDolStudioPage($mixedPageName);
  17. }
  18. function getPageIndex() {
  19. if(!is_array($this->aPage) || empty($this->aPage))
  20. return BX_PAGE_DEFAULT;
  21. if(!$this->bPageMultiple)
  22. return !empty($this->aPage['index']) ? (int)$this->aPage['index'] : BX_PAGE_DEFAULT;
  23. else
  24. return !empty($this->aPage[$this->sPageSelected]['index']) ? (int)$this->aPage[$this->sPageSelected]['index'] : BX_PAGE_DEFAULT;
  25. }
  26. function getPageJs() {
  27. return array('common_anim.js', 'page.js');
  28. }
  29. function getPageJsObject() {
  30. return '';
  31. }
  32. function getPageCss() {
  33. $aCss = array('menu_top.css');
  34. if((int)$this->aPage['index'] == 3)
  35. $aCss[] = 'page_columns.css';
  36. return $aCss;
  37. }
  38. function getPageHeader() {
  39. if(empty($this->aPage) || !is_array($this->aPage))
  40. return '';
  41. return _t(!$this->bPageMultiple ? $this->aPage['caption'] : $this->aPage[$this->sPageSelected]['caption']);
  42. }
  43. function getPageBreadcrumb() {
  44. return array();
  45. }
  46. function getPageCaption() {
  47. if(empty($this->aPage) || !is_array($this->aPage))
  48. return '';
  49. $oTemplate = BxDolStudioTemplate::getInstance();
  50. $oFunctions = BxTemplStudioFunctions::getInstance();
  51. $sHelp = $this->getPageCaptionHelp();
  52. if(($bHelp = strlen($sHelp)) > 0) {
  53. $sHelp = $oFunctions->transBox($sHelp);
  54. $sHelp = $oTemplate->parseHtmlByName('page_caption_help_popup.html', array('content' => $sHelp));
  55. }
  56. $sActions = $this->getPageCaptionActions();
  57. if(($bActions = strlen($sActions)) > 0) {
  58. $sActions = $oFunctions->transBox($sActions);
  59. $sActions = $oTemplate->parseHtmlByName('page_caption_actions_popup.html', array('content' => $sActions));
  60. }
  61. $oTemplate->addInjection('injection_header', 'text', $sHelp . $sActions);
  62. //--- Menu Left ---//
  63. $aItems = array(
  64. 'back' => array(
  65. 'name' => 'back',
  66. 'icon' => 'th',
  67. 'link' => BX_DOL_URL_STUDIO . 'launcher.php',
  68. 'title' => '_adm_txt_back_to_launcher'
  69. )
  70. );
  71. bx_import('BxTemplStudioMenu');
  72. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_top_toolbar.html', 'menu_items' => $aItems));
  73. $sMenuLeft = $oMenu->getCode();
  74. //--- Menu Right ---//
  75. $aItems = array();
  76. if($bHelp)
  77. $aItems['help'] = array(
  78. 'name' => 'help',
  79. 'icon' => 'question-sign',
  80. 'onclick' => BX_DOL_STUDIO_PAGE_JS_OBJECT . ".togglePopup('help', this)",
  81. 'title' => '_adm_txt_show_help'
  82. );
  83. if($bActions)
  84. $aItems['actions'] = array(
  85. 'name' => 'actions',
  86. 'icon' => 'cog',
  87. 'onclick' => BX_DOL_STUDIO_PAGE_JS_OBJECT . ".togglePopup('actions', this)",
  88. 'title' => '_adm_txt_show_help'
  89. );
  90. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_top_toolbar.html', 'menu_items' => $aItems));
  91. $sMenuRight = $oMenu->getCode();
  92. $aTmplVars = array(
  93. 'menu_left' => $sMenuLeft,
  94. 'caption' => _t($this->aPage['caption']),
  95. 'menu_right' => $sMenuRight
  96. );
  97. return $oTemplate->parseHtmlByName('page_caption.html', $aTmplVars);
  98. }
  99. function getPageAttributes() {
  100. return '';
  101. }
  102. function getPageMenu($aMenu) {
  103. bx_import('BxTemplStudioMenu');
  104. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aMenu));
  105. return $oMenu->getCode();
  106. }
  107. function getPageCode($bHidden = false) {}
  108. protected function getPageCaptionHelp() {
  109. $oTemplate = BxDolStudioTemplate::getInstance();
  110. $sContent = _t('_adm_txt_show_help_content_empty');
  111. return $oTemplate->parseHtmlByName('page_caption_help.html', array('content' => $sContent));
  112. }
  113. protected function getPageCaptionActions() {
  114. if(empty($this->aActions))
  115. return "";
  116. $aForm = array(
  117. 'form_attrs' => array(
  118. 'id' => 'adm-page-actions',
  119. 'name' => 'adm-page-actions',
  120. 'action' => '',
  121. 'method' => 'post',
  122. ),
  123. 'params' => array(),
  124. 'inputs' => array()
  125. );
  126. foreach($this->aActions as $aAction) {
  127. $aInput = array(
  128. 'type' => $aAction['type'],
  129. 'name' => $aAction['name'],
  130. 'caption' => _t($aAction['caption'])
  131. );
  132. switch($aAction['type']) {
  133. case 'switcher':
  134. $aInput['checked'] = $aAction['checked'];
  135. $aInput['attrs']['onchange'] = $aAction['onchange'];
  136. break;
  137. }
  138. $aForm['inputs'][$aInput['name']] = $aInput;
  139. }
  140. bx_import('BxTemplStudioFormView');
  141. $oForm = new BxTemplStudioFormView($aForm);
  142. return BxDolStudioTemplate::getInstance()->parseHtmlByName('page_caption_actions.html', array('content' => $oForm->getCode()));
  143. }
  144. /**
  145. *
  146. * Block Methods
  147. *
  148. */
  149. function getBlockCaption($aBlock) {
  150. if(empty($aBlock) || !is_array($aBlock))
  151. return '';
  152. $oTemplate = BxDolStudioTemplate::getInstance();
  153. $aTmplActions = array();
  154. if(isset($aBlock['actions']) && is_array($aBlock['actions']))
  155. foreach($aBlock['actions'] as $aAction) {
  156. $sCaption = _t($aAction['caption']);
  157. $aTmplActions[] = array(
  158. 'name' => $aAction['name'],
  159. 'url' => $aAction['url'],
  160. 'title' => $sCaption,
  161. 'bx_if:show_onclick' => array(
  162. 'condition' => $aAction['onclick'] != '',
  163. 'content' => array(
  164. 'onclick' => $aAction['onclick']
  165. )
  166. ),
  167. 'caption' => $sCaption
  168. );
  169. }
  170. $aTmplVars = array(
  171. 'caption' => _t($aBlock['caption']),
  172. 'bx_if:show_actions' => array(
  173. 'condition' => count($aTmplActions) > 0,
  174. 'content' => array(
  175. 'bx_repeat:actions' => $aTmplActions
  176. )
  177. ),
  178. );
  179. return $oTemplate->parseHtmlByName('block_caption.html', $aTmplVars);
  180. }
  181. function getBlockPanelTop($aBlock) {
  182. if(empty($aBlock) || !is_array($aBlock))
  183. return '';
  184. $oTemplate = BxDolStudioTemplate::getInstance();
  185. $aTmplVars = array(
  186. 'content' => isset($aBlock['panel_top']) ? $aBlock['panel_top'] : ''
  187. );
  188. return $oTemplate->parseHtmlByName('block_panel_top.html', $aTmplVars);
  189. }
  190. function getBlockPanelBottom($aBlock) {
  191. if(empty($aBlock) || !is_array($aBlock))
  192. return '';
  193. $oTemplate = BxDolStudioTemplate::getInstance();
  194. $aTmplVars = array(
  195. 'content' => isset($aBlock['panel_bottom']) ? $aBlock['panel_bottom'] : ''
  196. );
  197. return $oTemplate->parseHtmlByName('block_panel_bottom.html', $aTmplVars);
  198. }
  199. protected function getJsResult($sMessage, $bTranslate = true, $bRedirect = false, $sRedirect = '', $sOnResult = '') {
  200. $aResult = array();
  201. $aResult['message'] = $bTranslate ? _t($sMessage) : $sMessage;
  202. if($bRedirect)
  203. $aResult['redirect'] = $sRedirect != '' ? $sRedirect : BX_DOL_URL_STUDIO;
  204. if(!empty($sOnResult))
  205. $aResult['on_result'] = $sOnResult;
  206. $oJson = new Services_JSON();
  207. $sResult = "window.parent." . BX_DOL_STUDIO_PAGE_JS_OBJECT . ".showMessage(" . $oJson->encode($aResult) . ");";
  208. return BxDolStudioTemplate::getInstance()->_wrapInTagJsCode($sResult);
  209. }
  210. }
  211. /** @} */