_oTemplate = $oTemplate ? $oTemplate : BxDolTemplate::getInstance(); } /** * Prevent cloning the instance */ public function __clone() { if (isset($GLOBALS['bxDolClasses'][get_class($this)])) trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR); } public static function getInstance() { if(!isset($GLOBALS['bxDolClasses']['BxTemplFunctions'])) $GLOBALS['bxDolClasses']['BxTemplFunctions'] = new BxTemplFunctions(); return $GLOBALS['bxDolClasses']['BxTemplFunctions']; } function TemplPageAddComponent($sKey) { switch( $sKey ) { case 'something': return false; // return here additional components default: return false; // if you have not such component, return false! } } function msgBox($sText, $iTimer = 0, $sOnClose = "") { $iId = time() . mt_rand(1, 1000); return $this->_oTemplate->parseHtmlByName('messageBox.html', array( 'id' => $iId, 'msgText' => $sText, 'bx_if:timer' => array( 'condition' => $iTimer > 0, 'content' => array( 'id' => $iId, 'time' => 1000 * $iTimer, 'on_close' => $sOnClose, ) ) )); } /** * Get standard popup box with title. * * @param string $sName - unique name * @param string $sTitle - translated title * @param string $sContent - content of the box * @return HTML string */ function popupBox($sName, $sTitle, $sContent, $isHiddenByDefault = false) { $iId = !empty($sName) ? $sName : time(); return $this->_oTemplate->parseHtmlByName('popup_box.html', array( 'id' => $iId, 'wrapper_style' => $isHiddenByDefault ? 'display:none;' : '', 'title' => $sTitle, 'content' => $sContent )); } /** * Get popup box without title. * * @param string $sName - unique name * @param string $sContent - content of the box * @return HTML string */ function transBox($sName, $sContent, $isHiddenByDefault = false, $isPlaceInCenter = false) { return $this->simpleBox($sName, $sContent, $isHiddenByDefault, $isPlaceInCenter, 'popup_trans.html'); } function slideBox($sName, $sContent, $isHiddenByDefault = false) { return $this->simpleBox($sName, $sContent, $isHiddenByDefault, false, 'popup_slide.html'); } function inlineBox($sName, $sContent, $isHiddenByDefault = false) { return $this->simpleBox($sName, $sContent, $isHiddenByDefault, false, 'popup_inline.html'); } protected function simpleBox($sName, $sContent, $isHiddenByDefault, $isPlaceInCenter, $sTemplate) { $iId = !empty($sName) ? $sName : time(); $sContent = $this->_oTemplate->parseHtmlByName($sTemplate, array( 'id' => $iId, 'wrapper_style' => $isHiddenByDefault ? 'display:none;' : '', 'content' => $sContent )); if($isPlaceInCenter) $sContent = '
';
$sPopup .= '';
return $bReturnString ? $sResult . $sPopup : array($sResult, $sPopup);
}
/**
* Display design box with specified title, template, content and menu.
* @param $sTitle - design box title, please note that some templates don't use title.
* @param $sContent - design box content.
* @param $iTemplateNum - number of design box template, use predefined contants only, default is BX_DB_DEF.
* @param $mixedMenu - design box menu, it can be:
* - object: instance of BxTemplMenu class
* - string: menu object identifier
* - array: array of menu links to create menu from
* @return string
*
* @see BX_DB_CONTENT_ONLY
* @see BX_DB_DEF
* @see BX_DB_EMPTY
* @see BX_DB_NO_CAPTION
* @see BX_DB_PADDING_CONTENT_ONLY
* @see BX_DB_PADDING_DEF
* @see BX_DB_PADDING_NO_CAPTION
*/
function designBoxContent ($sTitle, $sContent, $iTemplateNum = BX_DB_DEF, $mixedMenu = false)
{
return $this->_oTemplate->parseHtmlByName('designbox_' . (int)$iTemplateNum . '.html', array(
'title' => $sTitle,
'designbox_content' => $sContent,
'caption_item' => $this->designBoxMenu ($mixedMenu, array (array('menu' => 1))),
));
}
function designBoxMenu ($mixedMenu, $aButtons = array ())
{
$sCode = '';
$aButtonMenu = false;
if ($mixedMenu) {
$sMenu = '';
if (is_string($mixedMenu)) {
$oMenu = BxTemplMenu::getObjectInstance($mixedMenu);
$sMenu = $oMenu ? $oMenu->getCode () : $mixedMenu;
} elseif (is_object($mixedMenu) && is_a($mixedMenu, 'BxTemplMenu')) {
$sMenu = $mixedMenu->getCode();
} elseif (is_array($mixedMenu)) {
if (isset($mixedMenu['template']) && isset($mixedMenu['menu_items']))
$aMenu = $mixedMenu;
else
$aMenu = array ('template' => 'menu_vertical.html', 'menu_items' => $mixedMenu);
$oMenu = new BxTemplMenu($aMenu, $this->_oTemplate);
$sMenu = $oMenu->getCode ();
}
if ($sMenu) {
$sId = 'bx-menu-db-' . time() . rand(0, PHP_INT_MAX);
$sCode .= $this->slideBox($sId, $sMenu, true);
$aButtonMenu = array ('icon-a' => $this->_sDesignBoxIcon, 'onclick' => "bx_menu_slide('#" . $sId . "', this)");
}
}
if ($aButtons) {
$sCode .= '';
}
return $sCode;
}
/**
* Get logo URL.
* @return string
*/
function getMainLogoUrl()
{
$oDesigns = BxDolDesigns::getInstance();
$iFileId = (int)$oDesigns->getSiteLogo();
if (!$iFileId)
return false;
$oStorage = BxDolTranscoder::getObjectInstance('sys_custom_images');
$sFileUrl = $oStorage->getFileUrl($iFileId);
if (!$sFileUrl)
return false;
$iLogoWidth = (int)$oDesigns->getSiteLogoWidth();
if($iLogoWidth > 0)
$sFileUrl = bx_append_url_params($sFileUrl, array('x' => $iLogoWidth));
$iLogoHeight = (int)$oDesigns->getSiteLogoHeight();
if($iLogoHeight > 0)
$sFileUrl = bx_append_url_params($sFileUrl, array('y' => $iLogoHeight));
return $sFileUrl;
}
/**
* Get logo HTML.
* @return string
*/
function getMainLogo()
{
$oDesigns = BxDolDesigns::getInstance();
$sAlt = $oDesigns->getSiteLogoAlt();
if(empty($sAlt))
$sAlt = getParam('site_title');
$sLogo = $sAlt;
$sFileUrl = $this->getMainLogoUrl();
if (!empty($sFileUrl)) {
$iLogoWidth = (int)$oDesigns->getSiteLogoWidth();
$sMaxWidth = $iLogoWidth > 0 ? 'max-width:' . round($iLogoWidth/16, 3) . 'rem;' : '';
$iLogoHeight = (int)$oDesigns->getSiteLogoHeight();
$sMaxHeight = $iLogoHeight > 0 ? 'max-height:' . round($iLogoHeight/16, 3) . 'rem;' : '';
$sLogo = '