1
0

BxBaseStudioPage.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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, $aMarkers = array()) {
  103. bx_import('BxTemplStudioMenu');
  104. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aMenu));
  105. if(!empty($aMarkers))
  106. $oMenu->addMarkers($aMarkers);
  107. return $oMenu->getCode();
  108. }
  109. function getPageCode($bHidden = false) {}
  110. protected function getPageCaptionHelp() {
  111. $oTemplate = BxDolStudioTemplate::getInstance();
  112. $sContent = _t('_adm_txt_show_help_content_empty');
  113. return $oTemplate->parseHtmlByName('page_caption_help.html', array('content' => $sContent));
  114. }
  115. protected function getPageCaptionActions() {
  116. if(empty($this->aActions))
  117. return "";
  118. $aForm = array(
  119. 'form_attrs' => array(
  120. 'id' => 'adm-page-actions',
  121. 'name' => 'adm-page-actions',
  122. 'action' => '',
  123. 'method' => 'post',
  124. ),
  125. 'params' => array(),
  126. 'inputs' => array()
  127. );
  128. foreach($this->aActions as $aAction) {
  129. $aInput = array(
  130. 'type' => $aAction['type'],
  131. 'name' => $aAction['name'],
  132. 'caption' => _t($aAction['caption'])
  133. );
  134. switch($aAction['type']) {
  135. case 'switcher':
  136. $aInput['checked'] = $aAction['checked'];
  137. $aInput['attrs']['onchange'] = $aAction['onchange'];
  138. break;
  139. }
  140. $aForm['inputs'][$aInput['name']] = $aInput;
  141. }
  142. bx_import('BxTemplStudioFormView');
  143. $oForm = new BxTemplStudioFormView($aForm);
  144. return BxDolStudioTemplate::getInstance()->parseHtmlByName('page_caption_actions.html', array('content' => $oForm->getCode()));
  145. }
  146. /**
  147. *
  148. * Block Methods
  149. *
  150. */
  151. function getBlockCaption($aBlock) {
  152. if(empty($aBlock) || !is_array($aBlock))
  153. return '';
  154. $oTemplate = BxDolStudioTemplate::getInstance();
  155. $aTmplActions = array();
  156. if(isset($aBlock['actions']) && is_array($aBlock['actions']))
  157. foreach($aBlock['actions'] as $aAction) {
  158. $sCaption = _t($aAction['caption']);
  159. $aTmplActions[] = array(
  160. 'name' => $aAction['name'],
  161. 'url' => $aAction['url'],
  162. 'title' => $sCaption,
  163. 'bx_if:show_onclick' => array(
  164. 'condition' => $aAction['onclick'] != '',
  165. 'content' => array(
  166. 'onclick' => $aAction['onclick']
  167. )
  168. ),
  169. 'caption' => $sCaption
  170. );
  171. }
  172. $aTmplVars = array(
  173. 'caption' => _t($aBlock['caption']),
  174. 'bx_if:show_actions' => array(
  175. 'condition' => count($aTmplActions) > 0,
  176. 'content' => array(
  177. 'bx_repeat:actions' => $aTmplActions
  178. )
  179. ),
  180. );
  181. return $oTemplate->parseHtmlByName('block_caption.html', $aTmplVars);
  182. }
  183. function getBlockPanelTop($aBlock) {
  184. if(empty($aBlock) || !is_array($aBlock))
  185. return '';
  186. $oTemplate = BxDolStudioTemplate::getInstance();
  187. $aTmplVars = array(
  188. 'content' => isset($aBlock['panel_top']) ? $aBlock['panel_top'] : ''
  189. );
  190. return $oTemplate->parseHtmlByName('block_panel_top.html', $aTmplVars);
  191. }
  192. function getBlockPanelBottom($aBlock) {
  193. if(empty($aBlock) || !is_array($aBlock))
  194. return '';
  195. $oTemplate = BxDolStudioTemplate::getInstance();
  196. $aTmplVars = array(
  197. 'content' => isset($aBlock['panel_bottom']) ? $aBlock['panel_bottom'] : ''
  198. );
  199. return $oTemplate->parseHtmlByName('block_panel_bottom.html', $aTmplVars);
  200. }
  201. protected function getJsResult($sMessage, $bTranslate = true, $bRedirect = false, $sRedirect = '', $sOnResult = '') {
  202. $aResult = array();
  203. $aResult['message'] = $bTranslate ? _t($sMessage) : $sMessage;
  204. if($bRedirect)
  205. $aResult['redirect'] = $sRedirect != '' ? $sRedirect : BX_DOL_URL_STUDIO;
  206. if(!empty($sOnResult))
  207. $aResult['on_result'] = $sOnResult;
  208. $oJson = new Services_JSON();
  209. $sResult = "window.parent." . BX_DOL_STUDIO_PAGE_JS_OBJECT . ".showMessage(" . $oJson->encode($aResult) . ");";
  210. return BxDolStudioTemplate::getInstance()->_wrapInTagJsCode($sResult);
  211. }
  212. }
  213. /** @} */