]> git.mxchange.org Git - friendica.git/blob - src/Module/Home.php
parameters now are having a default value and are optional
[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(array $parameters = [])
16         {
17                 $app = self::getApp();
18                 $config = $app->getConfig();
19
20                 // currently no returned data is used
21                 $ret = [];
22
23                 Hook::callAll('home_init', $ret);
24
25                 if (local_user() && ($app->user['nickname'])) {
26                         $app->internalRedirect('network');
27                 }
28
29                 if (strlen($config->get('system', 'singleuser'))) {
30                         $app->internalRedirect('/profile/' . $config->get('system', 'singleuser'));
31                 }
32
33                 $customHome = '';
34                 $defaultHeader = ($config->get('config', 'sitename') ? L10n::t('Welcome to %s', $config->get('config', 'sitename')) : '');
35
36                 $homeFilePath = $app->getBasePath() . '/home.html';
37                 $cssFilePath = $app->getBasePath() . '/home.css';
38
39                 if (file_exists($homeFilePath)) {
40                         $customHome = $homeFilePath;
41
42                         if (file_exists($cssFilePath)) {
43                                 $app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $app->getBaseURL() . '/home.css' . '" media="all" />';
44                         }
45                 }
46
47                 $login = Login::form($app->query_string, $config->get('config', 'register_policy') === Register::CLOSED ? 0 : 1);
48
49                 $content = '';
50                 Hook::callAll('home_content', $content);
51
52                 $tpl = Renderer::getMarkupTemplate('home.tpl');
53                 return Renderer::replaceMacros($tpl, [
54                         '$defaultheader' => $defaultHeader,
55                         '$customhome'    => $customHome,
56                         '$login'         => $login,
57                         '$content'       => $content,
58                 ]);
59         }
60 }