BxBaseStudioPolyglot.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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('BxDolStudioPolyglot');
  12. class BxBaseStudioPolyglot extends BxDolStudioPolyglot {
  13. protected $sSubpageUrl;
  14. protected $aMenuItems = array(
  15. BX_DOL_STUDIO_PGT_TYPE_GENERAL,
  16. BX_DOL_STUDIO_PGT_TYPE_KEYS,
  17. BX_DOL_STUDIO_PGT_TYPE_ETEMPLATES
  18. );
  19. protected $aGridObjects = array(
  20. 'keys' => 'sys_studio_lang_keys',
  21. 'etemplates' => 'sys_studio_lang_etemplates',
  22. );
  23. function BxBaseStudioPolyglot($sPage = '') {
  24. parent::BxDolStudioPolyglot($sPage);
  25. $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'polyglot.php?page=';
  26. }
  27. function getPageCss() {
  28. return array_merge(parent::getPageCss(), array('forms.css', 'paginate.css', 'polyglot.css'));
  29. }
  30. function getPageJs() {
  31. return array_merge(parent::getPageJs(), array('jquery.autoresize.js', 'settings.js', 'polyglot.js'));
  32. }
  33. function getPageJsClass() {
  34. return 'BxDolStudioPolyglot';
  35. }
  36. function getPageJsObject() {
  37. return 'oBxDolStudioPolyglot';
  38. }
  39. function getPageJsCode($aOptions = array(), $bWrap = true) {
  40. $aOptions = array_merge($aOptions, array(
  41. 'sActionUrl' => BX_DOL_URL_STUDIO . 'polyglot.php'
  42. ));
  43. return parent::getPageJsCode($aOptions, $bWrap);
  44. }
  45. function getPageMenu($aMenu = array(), $aMarkers = array()) {
  46. $sJsObject = $this->getPageJsObject();
  47. $aMenu = array();
  48. foreach($this->aMenuItems as $sMenuItem)
  49. $aMenu[] = array(
  50. 'name' => $sMenuItem,
  51. 'icon' => 'mi-pgt-' . $sMenuItem . '.png',
  52. 'link' => $this->sSubpageUrl . $sMenuItem,
  53. 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
  54. 'selected' => $sMenuItem == $this->sPage
  55. );
  56. return parent::getPageMenu($aMenu);
  57. }
  58. function getPageCode($bHidden = false) {
  59. $sMethod = 'get' . ucfirst($this->sPage);
  60. if(!method_exists($this, $sMethod))
  61. return '';
  62. return $this->$sMethod();
  63. }
  64. protected function getGeneral() {
  65. $oTemplate = BxDolStudioTemplate::getInstance();
  66. bx_import('BxTemplStudioSettings');
  67. $oPage = new BxTemplStudioSettings(BX_DOL_STUDIO_STG_TYPE_DEFAULT, BX_DOL_STUDIO_STG_CATEGORY_LANGUAGES);
  68. $aTmplVars = array(
  69. 'js_object' => $this->getPageJsObject(),
  70. 'bx_repeat:blocks' => $oPage->getPageCode(),
  71. 'bx_if:show_new_key_popup' => array(
  72. 'condition' => false,
  73. 'content' => array()
  74. )
  75. );
  76. return $oTemplate->parseHtmlByName('polyglot.html', $aTmplVars);
  77. }
  78. protected function getKeys() {
  79. return $this->getGrid($this->aGridObjects['keys']);
  80. }
  81. protected function getEtemplates() {
  82. return $this->getGrid($this->aGridObjects['etemplates']);
  83. }
  84. protected function getGrid($sObjectName) {
  85. $oTemplate = BxDolStudioTemplate::getInstance();
  86. bx_import('BxDolGrid');
  87. $oGrid = BxDolGrid::getObjectInstance($sObjectName);
  88. if(!$oGrid)
  89. return '';
  90. $aTmplVars = array(
  91. 'bx_repeat:blocks' => array(
  92. array(
  93. 'caption' => '',
  94. 'panel_top' => '',
  95. 'items' => $oGrid->getCode(),
  96. 'panel_bottom' => ''
  97. )
  98. )
  99. );
  100. return $oTemplate->parseHtmlByName('polyglot.html', $aTmplVars);
  101. }
  102. }
  103. /** @} */