BxBaseStudioPolyglot.php 3.8 KB

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