BxBaseModGeneralTemplate.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 BaseGeneral Base classes for modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Module representation.
  13. */
  14. class BxBaseModGeneralTemplate extends BxDolModuleTemplate
  15. {
  16. protected $MODULE;
  17. protected $_oModule;
  18. function __construct(&$oConfig, &$oDb)
  19. {
  20. parent::__construct($oConfig, $oDb);
  21. $this->addCss ('main.css');
  22. }
  23. public function getModule()
  24. {
  25. if (!$this->_oModule) {
  26. $sName = $this->_oConfig->getName();
  27. $this->_oModule = BxDolModule::getInstance($sName);
  28. }
  29. return $this->_oModule;
  30. }
  31. public function getJsCode($sType, $aParams = array(), $bWrap = true)
  32. {
  33. $sBaseUri = $this->_oConfig->getBaseUri();
  34. $sJsClass = $this->_oConfig->getJsClass($sType);
  35. $sJsObject = $this->_oConfig->getJsObject($sType);
  36. $aParams = array_merge(array(
  37. 'sActionUri' => $sBaseUri,
  38. 'sActionUrl' => BX_DOL_URL_ROOT . $sBaseUri,
  39. 'sObjName' => $sJsObject,
  40. 'aHtmlIds' => array(),
  41. 'oRequestParams' => array()
  42. ), $aParams);
  43. $sContent = "var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode($aParams) . ");";
  44. return !$bWrap ? $sContent : $this->_wrapInTagJsCode($sContent);
  45. }
  46. function entryLocation ($iContentId)
  47. {
  48. $CNF = &$this->getModule()->_oConfig->CNF;
  49. if (empty($CNF['OBJECT_METATAGS']))
  50. return '';
  51. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  52. if (!($sLocationString = $oMetatags->locationsString($iContentId)))
  53. return '';
  54. $aVars = array (
  55. 'location' => $sLocationString
  56. );
  57. return $this->parseHtmlByName('entry-location.html', $aVars);
  58. }
  59. public function entryInfo($aData, $aValues = array())
  60. {
  61. $CNF = $this->_oConfig->CNF;
  62. $aValuesDefault = array();
  63. if (isset($aData[$CNF['FIELD_ADDED']]))
  64. $aValuesDefault[] = array(
  65. 'title' => _t('_sys_txt_field_created'),
  66. 'value' => bx_time_js($aData[$CNF['FIELD_ADDED']]),
  67. );
  68. if (isset($aData[$CNF['FIELD_CHANGED']]))
  69. $aValuesDefault[] = array(
  70. 'title' => _t('_sys_txt_field_updated'),
  71. 'value' => bx_time_js($aData[$CNF['FIELD_CHANGED']]),
  72. );
  73. $aValues = array_merge($aValuesDefault, $aValues);
  74. return $this->parseHtmlByName('entry-info.html', array(
  75. 'bx_repeat:info' => $aValues,
  76. ));
  77. }
  78. }
  79. /** @} */