]> git.mxchange.org Git - friendica.git/blobdiff - index.php
Merge pull request #5860 from JonnyTischbein/issue_comment_wrap
[friendica.git] / index.php
index 359be7dcbabc4fb8145a7fee5dc503a481a16d95..19b85b935601077fe8ab8e1a6d0ad6fc3951d702 100644 (file)
--- a/index.php
+++ b/index.php
@@ -36,7 +36,7 @@ $a->backend = false;
 require_once "include/dba.php";
 
 // Missing DB connection: ERROR
-if ($a->mode & App::MODE_LOCALCONFIGPRESENT && !($a->mode & App::MODE_DBAVAILABLE)) {
+if ($a->getMode()->has(App\Mode::LOCALCONFIGPRESENT) && !$a->getMode()->has(App\Mode::DBAVAILABLE)) {
        System::httpExit(500, ['title' => 'Error 500 - Internal Server Error', 'description' => 'Apologies but the website is unavailable at the moment.']);
 }
 
@@ -48,7 +48,7 @@ if ($a->isMaxProcessesReached() || $a->isMaxLoadReached()) {
        System::httpExit(503, ['title' => 'Error 503 - Service Temporarily Unavailable', 'description' => 'System is currently overloaded. Please try again later.']);
 }
 
-if (!$a->isInstallMode()) {
+if (!$a->getMode()->isInstall()) {
        if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http")
                && (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL)
                && (substr(System::baseUrl(), 0, 8) == "https://")
@@ -107,7 +107,7 @@ if (!empty($_SESSION['language']) && $_SESSION['language'] !== $lang) {
        L10n::loadTranslationTable($lang);
 }
 
-if (!empty($_GET['zrl']) && $a->mode == App::MODE_NORMAL) {
+if (!empty($_GET['zrl']) && $a->getMode()->isNormal()) {
        $a->query_string = Profile::stripZrls($a->query_string);
        if (!local_user()) {
                // Only continue when the given profile link seems valid
@@ -130,7 +130,7 @@ if (!empty($_GET['zrl']) && $a->mode == App::MODE_NORMAL) {
        }
 }
 
-if (!empty($_GET['owt']) && $a->mode == App::MODE_NORMAL) {
+if (!empty($_GET['owt']) && $a->getMode()->isNormal()) {
        $token = $_GET['owt'];
        $a->query_string = Profile::stripQueryParam($a->query_string, 'owt');
        Profile::openWebAuthInit($token);
@@ -165,14 +165,14 @@ $_SESSION['last_updated'] = defaults($_SESSION, 'last_updated', []);
 
 // in install mode, any url loads install module
 // but we need "view" module for stylesheet
-if ($a->isInstallMode() && $a->module!="view") {
+if ($a->getMode()->isInstall() && $a->module != 'view') {
        $a->module = 'install';
-} elseif (!($a->mode & App::MODE_MAINTENANCEDISABLED) && $a->module != "view") {
+} elseif (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $a->module != 'view') {
        $a->module = 'maintenance';
 } else {
        check_url($a);
        check_db(false);
-       check_addons($a);
+       Addon::check();
 }
 
 Nav::setSelected('nothing');
@@ -320,7 +320,7 @@ if (file_exists($theme_info_file)) {
 
 /* initialise content region */
 
-if ($a->mode == App::MODE_NORMAL) {
+if ($a->getMode()->isNormal()) {
        Addon::callHooks('page_content_top', $a->page['content']);
 }
 
@@ -332,15 +332,21 @@ if ($a->module_loaded) {
        $a->page['page_title'] = $a->module;
        $placeholder = '';
 
+       Addon::callHooks($a->module . '_mod_init', $placeholder);
+
        if ($a->module_class) {
-               Addon::callHooks($a->module . '_mod_init', $placeholder);
                call_user_func([$a->module_class, 'init']);
        } else if (function_exists($a->module . '_init')) {
-               Addon::callHooks($a->module . '_mod_init', $placeholder);
                $func = $a->module . '_init';
                $func($a);
        }
 
+       // "rawContent" is especially meant for technical endpoints.
+       // This endpoint doesn't need any theme initialization or other comparable stuff.
+       if (!$a->error && $a->module_class) {
+               call_user_func([$a->module_class, 'rawContent']);
+       }
+
        if (function_exists(str_replace('-', '_', $a->getCurrentTheme()) . '_init')) {
                $func = str_replace('-', '_', $a->getCurrentTheme()) . '_init';
                $func($a);
@@ -426,16 +432,6 @@ if ($a->module != 'install' && $a->module != 'maintenance') {
 /**
  * Build the page - now that we have all the components
  */
-
-if (!$a->theme['stylesheet']) {
-       $stylesheet = $a->getCurrentThemeStylesheetPath();
-} else {
-       $stylesheet = $a->theme['stylesheet'];
-}
-
-$a->page['htmlhead'] = str_replace('{{$stylesheet}}', $stylesheet, $a->page['htmlhead']);
-//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet));
-
 if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) {
        $doc = new DOMDocument();