]> git.mxchange.org Git - friendica.git/blob - src/Module/Home.php
Merge pull request #8028 from annando/probe-timeout
[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 use Friendica\Module\Security\Login;
10
11 /**
12  * Home module - Landing page of the current node
13  */
14 class Home extends BaseModule
15 {
16         public static function content(array $parameters = [])
17         {
18                 $app = self::getApp();
19                 $config = $app->getConfig();
20
21                 // currently no returned data is used
22                 $ret = [];
23
24                 Hook::callAll('home_init', $ret);
25
26                 if (local_user() && ($app->user['nickname'])) {
27                         $app->internalRedirect('network');
28                 }
29
30                 if (strlen($config->get('system', 'singleuser'))) {
31                         $app->internalRedirect('/profile/' . $config->get('system', 'singleuser'));
32                 }
33
34                 $customHome = '';
35                 $defaultHeader = ($config->get('config', 'sitename') ? L10n::t('Welcome to %s', $config->get('config', 'sitename')) : '');
36
37                 $homeFilePath = $app->getBasePath() . '/home.html';
38                 $cssFilePath = $app->getBasePath() . '/home.css';
39
40                 if (file_exists($homeFilePath)) {
41                         $customHome = $homeFilePath;
42
43                         if (file_exists($cssFilePath)) {
44                                 $app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $app->getBaseURL() . '/home.css' . '" media="all" />';
45                         }
46                 }
47
48                 $login = Login::form($app->query_string, $config->get('config', 'register_policy') === Register::CLOSED ? 0 : 1);
49
50                 $content = '';
51                 Hook::callAll('home_content', $content);
52
53                 $tpl = Renderer::getMarkupTemplate('home.tpl');
54                 return Renderer::replaceMacros($tpl, [
55                         '$defaultheader' => $defaultHeader,
56                         '$customhome'    => $customHome,
57                         '$login'         => $login,
58                         '$content'       => $content,
59                 ]);
60         }
61 }