/**
  * Render page form and assign data
  *
  */
 public function renderForm()
 {
     $cfg = cRegistry::getConfig();
     $tpl = cSmartyBackend::getInstance();
     $tpl->assign("submit", $cfg['path']['images'] . 'but_ok.gif');
     $tpl->assign("form_action", 'main.php?' . implode('&', array('area=debugbar', 'frame=4', 'contenido=' . cRegistry::getBackendSessionId(), 'action=save')));
     $tpl->assign("settings", getSystemPropertiesByType("dbg"));
     echo $tpl->fetch($cfg['templates']['debugbar_right_bottom']);
 }
/**
 * 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;
}