Merge pull request #7085 from nupplaphil/task/mod_home
Move mod/home to src/Module/Home
This commit is contained in:
commit
74fda8f390
64
mod/home.php
64
mod/home.php
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file mod/home.php
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
if(! function_exists('home_init')) {
|
||||
function home_init(App $a) {
|
||||
|
||||
$ret = [];
|
||||
Hook::callAll('home_init',$ret);
|
||||
|
||||
if (local_user() && ($a->user['nickname'])) {
|
||||
$a->internalRedirect('network');
|
||||
}
|
||||
|
||||
if (strlen(Config::get('system','singleuser'))) {
|
||||
$a->internalRedirect('profile/' . Config::get('system','singleuser'));
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
if(! function_exists('home_content')) {
|
||||
function home_content(App $a) {
|
||||
|
||||
if (!empty($_SESSION['theme'])) {
|
||||
unset($_SESSION['theme']);
|
||||
}
|
||||
if (!empty($_SESSION['mobile-theme'])) {
|
||||
unset($_SESSION['mobile-theme']);
|
||||
}
|
||||
|
||||
$customhome = false;
|
||||
$defaultheader = '<h1>' . (Config::get('config', 'sitename') ? L10n::t('Welcome to %s', Config::get('config', 'sitename')) : '') . '</h1>';
|
||||
|
||||
$homefilepath = $a->getBasePath() . "/home.html";
|
||||
$cssfilepath = $a->getBasePath() . "/home.css";
|
||||
if (file_exists($homefilepath)) {
|
||||
$customhome = $homefilepath;
|
||||
if (file_exists($cssfilepath)) {
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.System::baseUrl().'/home.css'.'" media="all" />';
|
||||
}
|
||||
}
|
||||
|
||||
$login = Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
|
||||
|
||||
$content = '';
|
||||
Hook::callAll("home_content",$content);
|
||||
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('home.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$defaultheader' => $defaultheader,
|
||||
'$customhome' => $customhome,
|
||||
'$login' => $login,
|
||||
'$content' => $content
|
||||
]);
|
||||
}}
|
|
@ -40,6 +40,7 @@ class Router
|
|||
*/
|
||||
public function collectRoutes()
|
||||
{
|
||||
$this->routeCollector->addRoute(['GET'], '[/]', Module\Home::class);
|
||||
$this->routeCollector->addGroup('/.well-known', function (RouteCollector $collector) {
|
||||
$collector->addRoute(['GET'], '/host-meta' , Module\WellKnown\HostMeta::class);
|
||||
$collector->addRoute(['GET'], '/nodeinfo[/1.0]' , Module\NodeInfo::class);
|
||||
|
@ -123,6 +124,7 @@ class Router
|
|||
$collector->addRoute(['POST'], '/{group:\d+}/remove/{contact:\d+}', Module\Group::class);
|
||||
});
|
||||
$this->routeCollector->addRoute(['GET'], '/hashtag', Module\Hashtag::class);
|
||||
$this->routeCollector->addRoute(['GET'], '/home', Module\Home::class);
|
||||
$this->routeCollector->addRoute(['GET'], '/inbox[/{nickname}]', Module\Inbox::class);
|
||||
$this->routeCollector->addGroup('/install', function (RouteCollector $collector) {
|
||||
$collector->addRoute(['GET', 'POST'], '[/]', Module\Install::class);
|
||||
|
@ -131,6 +133,7 @@ class Router
|
|||
$this->routeCollector->addRoute(['GET', 'POST'], '/itemsource[/{guid}]', Module\Itemsource::class);
|
||||
$this->routeCollector->addRoute(['GET', 'POST'], '/localtime', Module\Localtime::class);
|
||||
$this->routeCollector->addRoute(['GET', 'POST'], '/login', Module\Login::class);
|
||||
$this->routeCollector->addRoute(['GET', 'POST'], '/logout', Module\Logout::class);
|
||||
$this->routeCollector->addRoute(['GET'], '/magic', Module\Magic::class);
|
||||
$this->routeCollector->addRoute(['GET'], '/manifest', Module\Manifest::class);
|
||||
$this->routeCollector->addRoute(['GET'], '/nodeinfo/1.0', Module\NodeInfo::class);
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
|
||||
/**
|
||||
* Home module - Landing page of the current node
|
||||
*/
|
||||
class Home extends BaseModule
|
||||
{
|
||||
public static function content()
|
||||
{
|
||||
if (!empty($_SESSION['theme'])) {
|
||||
unset($_SESSION['theme']);
|
||||
}
|
||||
|
||||
if (!empty($_SESSION['mobile-theme'])) {
|
||||
unset($_SESSION['mobile-theme']);
|
||||
}
|
||||
|
||||
$app = self::getApp();
|
||||
$config = $app->getConfig();
|
||||
|
||||
// currently no returned data is used
|
||||
$ret = [];
|
||||
|
||||
Hook::callAll('home_init', $ret);
|
||||
|
||||
if (local_user() && ($app->user['nickname'])) {
|
||||
$app->internalRedirect('network');
|
||||
}
|
||||
|
||||
if (strlen($config->get('system', 'singleuser'))) {
|
||||
$app->internalRedirect('/profile/' . $config->get('system', 'singleuser'));
|
||||
}
|
||||
|
||||
$customHome = '';
|
||||
$defaultHeader = ($config->get('config', 'sitename') ? L10n::t('Welcome to %s', $config->get('config', 'sitename')) : '');
|
||||
|
||||
$homeFilePath = $app->getBaseURL() . '/home.html';
|
||||
$cssFilePath = $app->getBaseURL() . '/home.css';
|
||||
|
||||
if (file_exists($homeFilePath)) {
|
||||
$customHome = $homeFilePath;
|
||||
|
||||
if (file_exists($cssFilePath)) {
|
||||
$app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $app->getBaseURL() . '/home.css' . '" media="all" />';
|
||||
}
|
||||
}
|
||||
|
||||
$login = Login::form($app->query_string, $config->get('config', 'register_policy') === Register::CLOSED ? 0 : 1);
|
||||
|
||||
$content = '';
|
||||
Hook::callAll('home_content', $content);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('home.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$defaultheader' => $defaultHeader,
|
||||
'$customhome' => $customHome,
|
||||
'$login' => $login,
|
||||
'$content' => $content,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
{{if $customhome != false }}
|
||||
{{include file="$customhome"}}
|
||||
{{else}}
|
||||
{{$defaultheader nofilter}}
|
||||
<h1>{{$defaultheader nofilter}}</h1>
|
||||
{{/if}}
|
||||
|
||||
{{$login nofilter}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user