BxBaseStudioPolyglot.php 3.3 KB

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