| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup TridentCore Trident Core
- * @{
- */
- class BxDolModuleTemplate extends BxDolTemplate
- {
- protected $_oDb;
- protected $_oConfig;
- protected $_bObStarted = 0;
- /*
- * Constructor.
- */
- function __construct(&$oConfig, &$oDb, $sRootPath = BX_DIRECTORY_PATH_ROOT, $sRootUrl = BX_DOL_URL_ROOT)
- {
- parent::__construct($sRootPath, $sRootUrl);
- $this->_oDb = &$oDb;
- $this->_oConfig = &$oConfig;
- $sName = $oConfig->getName();
- $sHomePath = $oConfig->getHomePath();
- $sHomeUrl = $oConfig->getHomeUrl();
- $this->addLocation($sName, $sHomePath, $sHomeUrl);
- $this->addLocationJs($sName, $sHomePath . 'js/', $sHomeUrl . 'js/');
- }
- function addCss($mixedFiles, $bDynamic = false)
- {
- return $this->_addFiles(BxDolTemplate::getInstance(), 'addCss', 'addLocation', 'removeLocation', '', $mixedFiles, $bDynamic, true);
- }
- function addJs($mixedFiles, $bDynamic = false)
- {
- return $this->_addFiles(BxDolTemplate::getInstance(), 'addJs', 'addLocationJs', 'removeLocationJs', 'js/', $mixedFiles, $bDynamic, true);
- }
- function addJsTranslation($mixedKey)
- {
- BxDolTemplate::getInstance()->addJsTranslation($mixedKey);
- }
- function addStudioCss($mixedFiles, $bDynamic = false, $bSearchInModule = true)
- {
- return $this->_addFiles(BxDolStudioTemplate::getInstance(), 'addCss', 'addLocation', 'removeLocation', '', $mixedFiles, $bDynamic, $bSearchInModule);
- }
- function addStudioJs($mixedFiles, $bDynamic = false, $bSearchInModule = true)
- {
- return $this->_addFiles(BxDolStudioTemplate::getInstance(), 'addJs', 'addLocationJs', 'removeLocationJs', 'js/', $mixedFiles, $bDynamic, $bSearchInModule);
- }
- function _addFiles($oTemplate, $sFuncAddFiles, $sFuncAddLocation, $sFuncRemoveLocation, $sPath, $mixedFiles, $bDynamic = false, $bSearchInModule = true)
- {
- $sLocationKey = $bSearchInModule ? $oTemplate->$sFuncAddLocation($this->_oConfig->getName(), $this->_oConfig->getHomePath() . $sPath, $this->_oConfig->getHomeUrl() . $sPath) : '';
- $mixedResult = $oTemplate->$sFuncAddFiles($mixedFiles, $bDynamic);
- if($sLocationKey != '')
- $oTemplate->$sFuncRemoveLocation($sLocationKey);
- return $mixedResult;
- }
- function addStudioInjection($sKey, $sType, $sData, $iReplace = 0)
- {
- BxDolStudioTemplate::getInstance()->aPage['injections']['page_0'][$sKey][] = array(
- 'page_index' => 0,
- 'key' => $sKey,
- 'type' => $sType,
- 'data' => $sData,
- 'replace' => $iReplace
- );
- }
- function pageStart ()
- {
- if (0 == $this->_bObStarted) {
- ob_start ();
- $this->_bObStarted = 1;
- }
- }
- function pageEnd ($isGetContent = true)
- {
- if (1 == $this->_bObStarted) {
- $sRet = '';
- if ($isGetContent)
- $sRet = ob_get_clean();
- else
- ob_end_clean();
- $this->_bObStarted = 0;
- return $sRet;
- }
- }
- }
- /** @} */
|