]> git.mxchange.org Git - friendica.git/blob - src/Module/Home.php
Use template-displayed errors in TwoFactor\Verify
[friendica.git] / src / Module / Home.php
1 <?php
2
3 namespace Friendica\Module;
4
5 use Friendica\BaseModule;
6 use Friendica\Core\Hook;
7 use Friendica\Core\L10n;
8 use Friendica\Core\Renderer;
9
10 /**
11  * Home module - Landing page of the current node
12  */
13 class Home extends BaseModule
14 {
15         public static function content()
16         {
17                 if (!empty($_SESSION['theme'])) {
18                         unset($_SESSION['theme']);
19                 }
20
21                 if (!empty($_SESSION['mobile-theme'])) {
22                         unset($_SESSION['mobile-theme']);
23                 }
24
25                 $app = self::getApp();
26                 $config = $app->getConfig();
27
28                 // currently no returned data is used
29                 $ret = [];
30
31                 Hook::callAll('home_init', $ret);
32
33                 if (local_user() && ($app->user['nickname'])) {
34                         $app->internalRedirect('network');
35                 }
36
37                 if (strlen($config->get('system', 'singleuser'))) {
38                         $app->internalRedirect('/profile/' . $config->get('system', 'singleuser'));
39                 }
40
41                 $customHome = '';
42                 $defaultHeader = ($config->get('config', 'sitename') ? L10n::t('Welcome to %s', $config->get('config', 'sitename')) : '');
43
44                 $homeFilePath = $app->getBasePath() . '/home.html';
45                 $cssFilePath = $app->getBasePath() . '/home.css';
46
47                 if (file_exists($homeFilePath)) {
48                         $customHome = $homeFilePath;
49
50                         if (file_exists($cssFilePath)) {
51                                 $app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $app->getBaseURL() . '/home.css' . '" media="all" />';
52                         }
53                 }
54
55                 $login = Login::form($app->query_string, $config->get('config', 'register_policy') === Register::CLOSED ? 0 : 1);
56
57                 $content = '';
58                 Hook::callAll('home_content', $content);
59
60                 $tpl = Renderer::getMarkupTemplate('home.tpl');
61                 return Renderer::replaceMacros($tpl, [
62                         '$defaultheader' => $defaultHeader,
63                         '$customhome'    => $customHome,
64                         '$login'         => $login,
65                         '$content'       => $content,
66                 ]);
67         }
68 }