public static function run($debug = FALSE)
 {
     $class = isset($_REQUEST['class']) ? $_REQUEST['class'] : '';
     $static = isset($_REQUEST['static']) ? $_REQUEST['static'] : '';
     $method = isset($_REQUEST['method']) ? $_REQUEST['method'] : '';
     $content = '';
     set_error_handler(array('AdiantiCoreApplication', 'errorHandler'));
     if (class_exists($class)) {
         if ($static) {
             $rf = new ReflectionMethod($class, $method);
             if ($rf->isStatic()) {
                 call_user_func(array($class, $method), $_REQUEST);
             } else {
                 call_user_func(array(new $class($_GET), $method), $_REQUEST);
             }
         } else {
             try {
                 $page = new $class($_GET);
                 ob_start();
                 $page->show($_GET);
                 $content = ob_get_contents();
                 ob_end_clean();
             } catch (Exception $e) {
                 ob_start();
                 if ($debug) {
                     new TExceptionView($e);
                     $content = ob_get_contents();
                 } else {
                     new TMessage('error', $e->getMessage());
                     $content = ob_get_contents();
                 }
                 ob_end_clean();
             }
         }
     } else {
         if (function_exists($method)) {
             call_user_func($method, $_REQUEST);
         } else {
             new TMessage('error', AdiantiCoreTranslator::translate('Class ^1 not found', " <b><i><u>{$class}</u></i></b>") . '.<br>' . AdiantiCoreTranslator::translate('Check the class name or the file name') . '.');
         }
     }
     if (!$static) {
         echo TPage::getLoadedCSS();
     }
     echo TPage::getLoadedJS();
     echo $content;
 }
Example #2
0
new TSession();
$menu_string = '';
if (TSession::getValue('logged')) {
    $content = file_get_contents("app/templates/{$template}/layout.html");
    ob_start();
    $callback = array('PermissaoSistema', 'checkPermission');
    $xml = new SimpleXMLElement(file_get_contents('menu.xml'));
    $menu = new TMenu($xml, $callback, 0, 'nav collapse', '');
    $menu->class = 'nav';
    $menu->id = 'side-menu';
    $menu->show();
    $menu_string = ob_get_clean();
} else {
    $content = file_get_contents("app/templates/{$template}/login.html");
}
$content = TApplicationTranslator::translateTemplate($content);
$content = str_replace('{LIBRARIES}', file_get_contents("app/templates/{$template}/libraries.html"), $content);
$content = str_replace('{URI}', $uri, $content);
$content = str_replace('{class}', isset($_REQUEST['class']) ? $_REQUEST['class'] : '', $content);
$content = str_replace('{template}', $template, $content);
$content = str_replace('{MENU}', $menu_string, $content);
$content = str_replace('{username}', TSession::getValue('nome'), $content);
$css = TPage::getLoadedCSS();
$js = TPage::getLoadedJS();
$content = str_replace('{HEAD}', $css . $js, $content);
if (isset($_REQUEST['class']) and TSession::getValue('logged')) {
    $url = "class=Home";
    //http_build_query($_REQUEST);
    $content = str_replace('//#javascript_placeholder#', "__adianti_load_page('engine.php?{$url}');", $content);
}
echo $content;