1
0

BxBaseStudioPolyglot.php 3.8 KB

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