Exemple #1
0
 /**
  * Sets isEnable property value and attaches needed handlers
  *
  * @param bool $isEnabled
  */
 public static function setEnable($isEnabled = true)
 {
     if ($isEnabled && !self::$isEnabled) {
         self::$onBeforeHandleKey = AddEventHandler("main", "OnBeforeEndBufferContent", array(self::getInstance(), "OnBeforeEndBufferContent"));
         self::$onHandleKey = AddEventHandler("main", "OnEndBufferContent", array(self::getInstance(), "OnEndBufferContent"));
         self::$onRestartBufferHandleKey = AddEventHandler("main", "OnBeforeRestartBuffer", array(self::getInstance(), "OnBeforeRestartBuffer"));
         self::$isEnabled = true;
         \CJSCore::init(array("fc"), false);
     } elseif (!$isEnabled && self::$isEnabled) {
         if (self::$onBeforeHandleKey >= 0) {
             RemoveEventHandler("main", "OnBeforeEndBufferContent", self::$onBeforeHandleKey);
         }
         if (self::$onBeforeHandleKey >= 0) {
             RemoveEventHandler("main", "OnEndBufferContent", self::$onHandleKey);
         }
         if (self::$onRestartBufferHandleKey >= 0) {
             RemoveEventHandler("main", "OnBeforeRestartBuffer", self::$onRestartBufferHandleKey);
         }
         self::$isEnabled = false;
     }
 }
Exemple #2
0
 /**
  * Sets isEnable property value and attaches needle handlers
  * @param bool $isEnable
  */
 public static function setEnable($isEnable = true)
 {
     if ($isEnable && !self::$isEnable) {
         self::$onBeforeHandleKey = AddEventHandler("main", "OnBeforeEndBufferContent", array(__CLASS__, "OnBeforeEndBufferContent"));
         self::$onHandleKey = AddEventHandler("main", "OnEndBufferContent", array(__CLASS__, "OnEndBufferContent"));
         self::$isEnable = true;
         \CJSCore::init(array("fc"), false);
         $actionType = \Bitrix\Main\Context::getCurrent()->getServer()->get("HTTP_BX_ACTION_TYPE");
         if ($actionType == "get_dynamic") {
             //Is it the background request?
             self::$isBackgroundRequest = true;
         }
     } elseif (!$isEnable && self::$isEnable) {
         if (self::$onBeforeHandleKey >= 0) {
             RemoveEventHandler("main", "OnBeforeEndBufferContent", self::$onBeforeHandleKey);
         }
         if (self::$onBeforeHandleKey >= 0) {
             RemoveEventHandler("main", "OnEndBufferContent", self::$onHandleKey);
         }
         self::$isEnable = false;
     }
 }