<?php

require_once( BX_DIRECTORY_PATH_BASE . 'scripts/BxBaseCmtsView.php' );

/**
 * @see BxDolCmts
 */
class BxTemplCmtsView extends BxBaseCmtsView
{
    function BxTemplCmtsView( $sSystem, $iId, $iInit = 1 )
    {
        BxBaseCmtsView::BxBaseCmtsView( $sSystem, $iId, $iInit );
    }
	
	    function getCmtsInit ()
    {
        global $site;

        $sReturn = $sToggleAdd = $sUseHtmlAdd = '';

        if($this->iGlobAllowHtml == 1 && $this->iGlobUseTinyMCE == 1 && ($this->isEditAllowed() || $this->isPostReplyAllowed() || $this->isEditAllowedAll()) && !isset($GLOBALS['glBxDolCommentsEditorInitialized'])) { 
            bx_import('BxDolEditor');
            $oEditor = BxDolEditor::getObjectInstance();
            $sReturn .= $oEditor ? $oEditor->attachEditor ('textarea[name=CmtText]', BX_EDITOR_FULL) : '';
            $GLOBALS['glBxDolCommentsEditorInitialized'] = 1;
        }

        $aParams = array(
        	'sObjName' => $this->_sJsObjName,
        	'sBaseUrl' => $site['url'],
        	'sSystem' => $this->getSystemName(),
        	'sSystemTable' => $this->_aSystem['table_cmts'],
        	'iAuthorId' => $this->_getAuthorId(),
        	'iObjId' => $this->getId(),
        	'sOrder' => $this->getOrder(),
        	'sDefaultErrMsg' => _t('_Error occured'),
        	'sConfirmMsg' => _t('_Are_you_sure'),
        	'sAnimationEffect' => $this->_aSystem['animation_effect'],
        	'sAnimationSpeed' => $this->_aSystem['animation_speed'],
        	'isEditAllowed' => $this->isEditAllowed() || $this->isEditAllowedAll() ? 1 : 0,
        	'isRemoveAllowed' => $this->isRemoveAllowed() || $this->isRemoveAllowedAll() ? 1 : 0,
        	'iAutoHideRootPostForm' => $this->iAutoHideRootPostForm,
        	'sTextAreaId' => $this->sTextAreaId,
        	'iGlobAllowHtml' => $this->iGlobAllowHtml == 1 && $this->iGlobUseTinyMCE == 1 ? 1 : 0,
        	'iSecsToEdit' => (int)$this->getAllowedEditTime(),
        	'oCmtElements' => $this->_aCmtElements
        );

        $this->getExtraJs();
        $this->getExtraCss();
        return $sReturn . $sToggleAdd . $GLOBALS['oSysTemplate']->_wrapInTagJsCode(
        	"var " . $this->_sJsObjName . " = new BxDolCmts(" . json_encode($aParams) . ");" . 
        	($this->iGlobAllowHtml == 1 && $this->iGlobUseTinyMCE == 1 ? $this->_sJsObjName . ".createEditor(0, $('#cmts-box-" . $this->_sSystem . "-" . $this->_iId . "> .cmt-post-reply form [name=CmtText][tinypossible=true]'), true);" : "")
        );
    }

	
}
