BxBaseStudioPolyglot.php 3.9 KB

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