_oTemplate = $oTemplate ? $oTemplate : BxDolTemplate::getInstance();
$this->_sDesignBoxMenuTmplDefault = 'menu_block_submenu_ver.html';
$this->_sDesignBoxMenuIcon = 'ellipsis-v';
$this->_sDesignBoxMenuIconType = 'icon';
$this->_sDesignBoxMenuClick = "bx_menu_popup_inline('#{design_box_menu}', this, " . json_encode(array(
'moveToDocRoot' => false
)) . ")";
}
/**
* 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 getInstanceWithTemplate($oTemplate)
{
$sClassName = 'BxTemplFunctions';
if ($oTemplate){
$sClassName .= get_class($oTemplate);
}
if(!isset($GLOBALS['bxDolClasses'][$sClassName]))
$GLOBALS['bxDolClasses'][$sClassName] = new BxTemplFunctions($oTemplate);
return $GLOBALS['bxDolClasses'][$sClassName];
}
public static function getInstance()
{
return self::getInstanceWithTemplate(null);
}
function TemplPageAddComponent($sKey)
{
$mixedResult = false; // if you have not such component, return false!
switch($sKey) {
case 'sys_header_width':
$mixedResult = 'bx-def-page-width';
break;
}
return $mixedResult;
}
function msgBox($sText, $iTimer = 0, $sOnClose = "")
{
$iId = time() . mt_rand(1, 1000);
if($iTimer > 0)
BxDolTemplate::getInstance()->addJs(array('jquery.anim.js'));
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();
if(!is_array($sContent))
$sContent = array('content' => $sContent);
$sContent = $this->_oTemplate->parseHtmlByName($sTemplate, array_merge(array(
'id' => $iId,
'wrapper_class' => '',
'wrapper_style' => $isHiddenByDefault ? 'display:none;' : '',
'content' => ''
), $sContent));
if($isPlaceInCenter)
$sContent = '
' . $sContent . '
';
return $sContent;
}
function simpleBoxContent($sContent, $bWithIndent = true)
{
if(!$bWithIndent)
return $sContent;
return $this->_oTemplate->parseHtmlByName('popup_content_indent.html', array(
'content' => $sContent
));
}
function getIcon($sCode, $aAttrs = array())
{
$sIconFont = false;
$sIconA = false;
$sIconUrl = false;
$sIconHtml = false;
$sIconFontWithHtml = false;
$sClass = '';
if(!empty($aAttrs['class'])) {
$sClass = ' ' . $aAttrs['class'] .' ';
unset($aAttrs['class']);
}
$sAttrs = '';
foreach($aAttrs as $sKey => $sValue)
$sAttrs .= ' ' . $sKey . '="' . bx_html_attribute($sValue) . '"';
if (!empty($sCode)) {
if (is_numeric($sCode) && (int)$sCode > 0) {
$oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
$sIconUrl = $oStorage ? $oStorage->getFileUrlById((int)$sCode) : false;
}
else {
if (strpos($sCode, '<img') !== false || strpos($sCode, '
');
if ($sClass != '' && strpos($sIconHtmlClear, 'class="') !== false)
$sIconHtml = str_replace('class="', 'class="' . $sClass, $sIconHtml);
else
$sIconHtml = str_replace('