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