/** * Returns an instance of this class. * @return DebugbarMessage */ public static function getInstance() { if (is_null(self::$_oInstance)) { self::$_oInstance = new self(); } return self::$_oInstance; }
/** * Prepare and run debugbar on code output * * @param string $code to prepare * @return string $code */ function run_debugbar($code) { // build data for general stuff $generalData = array('idart' => cRegistry::getArticleId(), 'idlang' => cRegistry::getLanguageId(), 'idcat' => cRegistry::getCategoryId(), 'idartlang' => cRegistry::getArticleLanguageId(), 'auth' => cRegistry::getAuth(), 'idclient' => cRegistry::getClientId(), 'frontendpath' => cRegistry::getFrontendPath(), 'frontendurl' => cRegistry::getFrontendUrl(), 'session' => cRegistry::getSession()); // build collectors data $configCollector = new ConfigCollector(cRegistry::getConfig()); $clientConfigCollector = new ClientConfigCollector(cRegistry::getClientConfig()); $generalCollector = new GeneralCollector($generalData); $debugbar = new ContenidoDebugBar(); // add tabs to debugbar based on configuration if (getSystemProperty("dbg", "dbg_request") == 1) { $debugbar->addCollector(new RequestDataCollector()); } if (getSystemProperty("dbg", "dbg_config") == 1) { $debugbar->addCollector($configCollector); } if (getSystemProperty("dbg", "dbg_clientconfig") == 1) { $debugbar->addCollector($clientConfigCollector); } if (getSystemProperty("dbg", "dbg_generalinfo") == 1) { $debugbar->addCollector($generalCollector); } if (getSystemProperty("dbg", "dbg_messages") == 1) { $debugbar->addCollector(new MessagesCollector()); $oMessage = DebugbarMessage::getInstance(); foreach ($oMessage->getMessages() as $message) { $debugbar["messages"]->addMessage($message); } } if (getSystemProperty("dbg", "dbg_exceptions") == 1) { $debugbar->addCollector(new ExceptionsCollector()); } if (getSystemProperty("dbg", "dbg_dbqueries") == 1) { global $cfg; if ($cfg['db']["enableProfiling"] === true) { $dbQueryCollector = new DbQueryCollector(cRegistry::getDb()->getProfileData()); $debugbar->addCollector($dbQueryCollector); } } // add default collectors $debugbar->addCollector(new MemoryCollector()); $debugbar->addCollector(new TimeDataCollector()); // add debugbar code to the page $debugbarRenderer = $debugbar->getJavascriptRenderer(); $baseUrl = cRegistry::getBackendUrl() . 'plugins/debugbar/vendor/maximebf/debugbar/src/DebugBar/Resources'; $debugbarRenderer->setBaseUrl($baseUrl); if (preg_match("#</head>#", $code)) { $code = preg_replace("#</head>#", $debugbarRenderer->renderHead() . "</head>", $code, 1); } if (preg_match("#</body>#", $code)) { $code = preg_replace("#</body>#", $debugbarRenderer->render() . "</body>", $code, 1); } return $code; }