BxBaseStudioPolyglot.php 3.3 KB

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