示例#1
0
 /**
  * @param $content
  * @return null|string
  */
 public function startBuffering($content)
 {
     if (!$this->isEnabled() || !is_object($GLOBALS["APPLICATION"]) || defined("BX_BUFFER_SHUTDOWN")) {
         return null;
     }
     $newBuffer = $GLOBALS["APPLICATION"]->buffer_content;
     $cnt = count($GLOBALS["APPLICATION"]->buffer_content_type);
     Asset::getInstance()->setMode(AssetMode::COMPOSITE);
     $this->compositeWasInjected = false;
     for ($i = 0; $i < $cnt; $i++) {
         $method = $GLOBALS["APPLICATION"]->buffer_content_type[$i]["F"];
         if (!is_array($method) || count($method) !== 2 || $method[0] !== $GLOBALS["APPLICATION"]) {
             continue;
         }
         if (in_array($method[1], array("GetCSS", "GetHeadScripts", "GetHeadStrings"))) {
             $newBuffer[$i * 2 + 1] = call_user_func_array($method, $GLOBALS["APPLICATION"]->buffer_content_type[$i]["P"]);
             if ($this->compositeWasInjected !== true && $method[1] === "GetHeadStrings") {
                 $this->compositeWasInjected = \CUtil::BinStrpos($newBuffer[$i * 2 + 1], "w.frameRequestStart") !== false;
             }
         }
     }
     Asset::getInstance()->setMode(AssetMode::STANDARD);
     return $this->compositeWasInjected === true ? implode("", $newBuffer) . $content : null;
 }