BxBaseStudioLanguage.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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('BxDolStudioTemplate');
  11. bx_import('BxDolStudioLanguage');
  12. class BxBaseStudioLanguage extends BxDolStudioLanguage
  13. {
  14. protected $aMenuItems = array(
  15. BX_DOL_STUDIO_LANG_TYPE_SETTINGS => array('caption' => '_adm_lmi_cpt_settings', 'icon' => 'cogs')
  16. );
  17. function __construct($sLanguage = "", $sPage = "")
  18. {
  19. parent::__construct($sLanguage, $sPage);
  20. }
  21. function getPageCss()
  22. {
  23. return array_merge(parent::getPageCss(), array());
  24. }
  25. function getPageJs()
  26. {
  27. return array_merge(parent::getPageJs(), array('settings.js', 'language.js'));
  28. }
  29. function getPageJsObject()
  30. {
  31. return 'oBxDolStudioLanguage';
  32. }
  33. function getPageCaption()
  34. {
  35. $oTemplate = BxDolStudioTemplate::getInstance();
  36. $aTmplVars = array(
  37. 'js_object' => $this->getPageJsObject(),
  38. 'content' => parent::getPageCaption(),
  39. );
  40. return $oTemplate->parseHtmlByName('lang_page_caption.html', $aTmplVars);
  41. }
  42. function getPageAttributes()
  43. {
  44. if((int)$this->aLanguage['enabled'] == 0)
  45. return 'style="display:none"';
  46. return parent::getPageAttributes();
  47. }
  48. function getPageMenu($aMenu = array(), $aMarkers = array())
  49. {
  50. $sJsObject = $this->getPageJsObject();
  51. $aMenu = array();
  52. foreach($this->aMenuItems as $sName => $aItem)
  53. $aMenu[] = array(
  54. 'name' => $sName,
  55. 'icon' => $aItem['icon'],
  56. 'link' => BX_DOL_URL_STUDIO . 'languages.php?name=' . $this->sLanguage . '&page=' . $sName,
  57. 'title' => _t($aItem['caption']),
  58. 'selected' => $sName == $this->sPage
  59. );
  60. return parent::getPageMenu($aMenu);
  61. }
  62. function getPageCode($bHidden = false)
  63. {
  64. $sMethod = 'get' . ucfirst($this->sPage);
  65. if(!method_exists($this, $sMethod))
  66. return '';
  67. if((int)$this->aLanguage['enabled'] != 1)
  68. BxDolStudioTemplate::getInstance()->addInjection('injection_bg_style', 'text', ' bx-std-page-bg-empty');
  69. return $this->$sMethod();
  70. }
  71. protected function getSettings()
  72. {
  73. $oTemplate = BxDolStudioTemplate::getInstance();
  74. bx_import('BxTemplStudioSettings');
  75. $oPage = new BxTemplStudioSettings($this->sLanguage);
  76. $aTmplVars = array(
  77. 'bx_repeat:blocks' => $oPage->getPageCode(),
  78. );
  79. return $oTemplate->parseHtmlByName('language.html', $aTmplVars);
  80. }
  81. }
  82. /** @} */