Replace deprecated $a->page with DI::page()

This commit is contained in:
nupplaPhil 2019-12-30 20:02:09 +01:00
parent 6c2d13403e
commit 6d7362da41
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
48 changed files with 197 additions and 198 deletions

View file

@ -44,7 +44,7 @@ class AllFriends extends BaseModule
throw new HTTPException\BadRequestException(L10n::t('Invalid contact.'));
}
$app->page['aside'] = "";
DI::page()['aside'] = "";
Model\Profile::load($app, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
$total = Model\GContact::countAllFriends(local_user(), $cid);

View file

@ -51,8 +51,6 @@ abstract class BaseAdminModule extends BaseModule
public static function content(array $parameters = [])
{
$a = DI::app();
if (!is_site_admin()) {
notice(L10n::t('Please login to continue.'));
Session::set('return_path', DI::args()->getQueryString());
@ -64,7 +62,7 @@ abstract class BaseAdminModule extends BaseModule
}
// Header stuff
$a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/settings_head.tpl'), []);
/*
* Side bar links
@ -109,7 +107,7 @@ abstract class BaseAdminModule extends BaseModule
];
$t = Renderer::getMarkupTemplate('admin/aside.tpl');
$a->page['aside'] .= Renderer::replaceMacros($t, [
DI::page()['aside'] .= Renderer::replaceMacros($t, [
'$admin' => ['addons_admin' => Addon::getAdminList()],
'$subpages' => $aside_sub,
'$admtxt' => L10n::t('Admin'),

View file

@ -15,7 +15,7 @@ class BaseSettingsModule extends BaseModule
$a = DI::app();
$tpl = Renderer::getMarkupTemplate('settings/head.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$ispublic' => L10n::t('everybody')
]);
@ -102,7 +102,7 @@ class BaseSettingsModule extends BaseModule
$tabtpl = Renderer::getMarkupTemplate("generic_links_widget.tpl");
$a->page['aside'] = Renderer::replaceMacros($tabtpl, [
DI::page()['aside'] = Renderer::replaceMacros($tabtpl, [
'$title' => L10n::t('Settings'),
'$class' => 'settings-widget',
'$items' => $tabs,

View file

@ -46,7 +46,7 @@ class Bookmarklet extends BaseModule
'nickname' => $app->user['nickname'],
'lockstate' => ((is_array($app->user) && ((strlen($app->user['allow_cid'])) || (strlen($app->user['allow_gid'])) || (strlen($app->user['deny_cid'])) || (strlen($app->user['deny_gid'])))) ? 'lock' : 'unlock'),
'default_perms' => ACL::getDefaultUserPermissions($app->user),
'acl' => ACL::getFullSelectorHTML($app->page, $app->user, true),
'acl' => ACL::getFullSelectorHTML(DI::page(), $app->user, true),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),

View file

@ -252,8 +252,8 @@ class Contact extends BaseModule
$nets = $_GET['nets'] ?? '';
$rel = $_GET['rel'] ?? '';
if (empty($a->page['aside'])) {
$a->page['aside'] = '';
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}
$contact_id = null;
@ -347,10 +347,10 @@ class Contact extends BaseModule
$groups_widget = null;
}
$a->page['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $groups_widget . $networks_widget . $rel_widget;
DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $groups_widget . $networks_widget . $rel_widget;
$tpl = Renderer::getMarkupTemplate('contacts-head.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => DI::baseUrl()->get(true),
]);
@ -434,7 +434,7 @@ class Contact extends BaseModule
}
}
$a->page['aside'] = '';
DI::page()['aside'] = '';
return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [
'$header' => L10n::t('Drop contact'),
@ -472,7 +472,7 @@ class Contact extends BaseModule
if (!empty($a->data['contact']) && is_array($a->data['contact'])) {
$contact = $a->data['contact'];
$a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [
'$baseurl' => DI::baseUrl()->get(true),
]);

View file

@ -33,8 +33,8 @@ class Directory extends BaseModule
}
if (local_user()) {
$app->page['aside'] .= Widget::findPeople();
$app->page['aside'] .= Widget::follow();
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
}
$output = '';

View file

@ -137,7 +137,7 @@ class Group extends BaseModule
$a = DI::app();
$a->page['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone'));
DI::page()['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone'));
// With no group number provided we jump to the unassigned contacts as a starting point
// @TODO: Replace with parameter from router

View file

@ -41,16 +41,16 @@ class Help extends BaseModule
$title = basename($path);
$filename = $path;
$text = self::loadDocFile('doc/' . $path . '.md', $lang);
$a->page['title'] = L10n::t('Help:') . ' ' . str_replace('-', ' ', Strings::escapeTags($title));
DI::page()['title'] = L10n::t('Help:') . ' ' . str_replace('-', ' ', Strings::escapeTags($title));
}
$home = self::loadDocFile('doc/Home.md', $lang);
if (!$text) {
$text = $home;
$filename = "Home";
$a->page['title'] = L10n::t('Help');
DI::page()['title'] = L10n::t('Help');
} else {
$a->page['aside'] = Markdown::convert($home, false);
DI::page()['aside'] = Markdown::convert($home, false);
}
if (!strlen($text)) {
@ -104,7 +104,7 @@ class Help extends BaseModule
$html = implode("\n", $lines);
$a->page['aside'] = '<div class="help-aside-wrapper widget"><div id="toc-wrapper">' . $toc . '</div>' . $a->page['aside'] . '</div>';
DI::page()['aside'] = '<div class="help-aside-wrapper widget"><div id="toc-wrapper">' . $toc . '</div>' . DI::page()['aside'] . '</div>';
}
return $html;

View file

@ -42,7 +42,7 @@ class Home extends BaseModule
$customHome = $homeFilePath;
if (file_exists($cssFilePath)) {
$app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/home.css' . '" media="all" />';
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/home.css' . '" media="all" />';
}
}

View file

@ -114,9 +114,9 @@ class Compose extends BaseModule
Hook::callAll('jot_tool', $jotplugins);
// Output
$a->page->registerFooterScript(Theme::getPathForFile('js/ajaxupload.js'));
$a->page->registerFooterScript(Theme::getPathForFile('js/linkPreview.js'));
$a->page->registerFooterScript(Theme::getPathForFile('js/compose.js'));
DI::page()->registerFooterScript(Theme::getPathForFile('js/ajaxupload.js'));
DI::page()->registerFooterScript(Theme::getPathForFile('js/linkPreview.js'));
DI::page()->registerFooterScript(Theme::getPathForFile('js/compose.js'));
$tpl = Renderer::getMarkupTemplate('item/compose.tpl');
return Renderer::replaceMacros($tpl, [
@ -162,7 +162,7 @@ class Compose extends BaseModule
'$jotplugins' => $jotplugins,
'$sourceapp' => L10n::t($a->sourcename),
'$rand_num' => Crypto::randomDigits(12),
'$acl_selector' => ACL::getFullSelectorHTML($a->page, $a->user, $doesFederate, [
'$acl_selector' => ACL::getFullSelectorHTML(DI::page(), $a->user, $doesFederate, [
'allow_cid' => $contact_allow_list,
'allow_gid' => $group_allow_list,
'deny_cid' => $contact_deny_list,

View file

@ -84,51 +84,53 @@ class Profile extends BaseModule
if (!$update) {
ProfileModel::load($a, self::$which, self::$profile);
$a->page['htmlhead'] .= "\n";
$page = DI::page();
$page['htmlhead'] .= "\n";
$blocked = !local_user() && !Session::getRemoteContactID($a->profile['profile_uid']) && Config::get('system', 'block_public');
$userblock = !local_user() && !Session::getRemoteContactID($a->profile['profile_uid']) && $a->profile['hidewall'];
if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
$page['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
}
if (!empty($a->profile['openidserver'])) {
$a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\n";
$page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\n";
}
if (!empty($a->profile['openid'])) {
$delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";
$page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";
}
// site block
if (!$blocked && !$userblock) {
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $a->profile['pub_keywords'] ?? '');
if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
$page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
}
}
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";
$page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";
if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
$a->page['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
$page['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
}
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . self::$which . '" title="DFRN: ' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/" title="' . L10n::t('%s\'s posts', $a->profile['username']) . '"/>' . "\n";
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/comments" title="' . L10n::t('%s\'s comments', $a->profile['username']) . '"/>' . "\n";
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/activity" title="' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . self::$which . '" title="DFRN: ' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/" title="' . L10n::t('%s\'s posts', $a->profile['username']) . '"/>' . "\n";
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/comments" title="' . L10n::t('%s\'s comments', $a->profile['username']) . '"/>' . "\n";
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . self::$which . '/activity" title="' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . DI::baseUrl()->getHostname() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : ''));
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\n";
$page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\n";
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
foreach ($dfrn_pages as $dfrn) {
$a->page['htmlhead'] .= '<link rel="dfrn-' . $dfrn . '" href="' . System::baseUrl() . '/dfrn_' . $dfrn . '/' . self::$which . '" />' . "\n";
$page['htmlhead'] .= '<link rel="dfrn-' . $dfrn . '" href="' . System::baseUrl() . '/dfrn_' . $dfrn . '/' . self::$which . '" />' . "\n";
}
$a->page['htmlhead'] .= '<link rel="dfrn-poco" href="' . System::baseUrl() . '/poco/' . self::$which . '" />' . "\n";
$page['htmlhead'] .= '<link rel="dfrn-poco" href="' . System::baseUrl() . '/poco/' . self::$which . '" />' . "\n";
}
$category = $datequery = $datequery2 = '';
@ -191,9 +193,9 @@ class Profile extends BaseModule
$commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
$commvisitor = $commpage && $remote_contact;
$a->page['aside'] .= Widget::postedByYear(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'] ?? 0, true);
$a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], XML::escape($category));
$a->page['aside'] .= Widget::tagCloud();
DI::page()['aside'] .= Widget::postedByYear(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'] ?? 0, true);
DI::page()['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], XML::escape($category));
DI::page()['aside'] .= Widget::tagCloud();
if (Security::canWriteToUserWall($a->profile['profile_uid'])) {
$x = [
@ -207,7 +209,7 @@ class Profile extends BaseModule
|| strlen($a->user['deny_cid'])
|| strlen($a->user['deny_gid'])
) ? 'lock' : 'unlock',
'acl' => $is_owner ? ACL::getFullSelectorHTML($a->page, $a->user, true) : '',
'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->user, true) : '',
'bang' => '',
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
'profile_uid' => $a->profile['profile_uid'],

View file

@ -23,14 +23,12 @@ class Directory extends BaseSearchModule
$search = Strings::escapeTags(trim(rawurldecode($_REQUEST['search'] ?? '')));
$a = DI::app();
if (empty($a->page['aside'])) {
$a->page['aside'] = '';
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}
$a->page['aside'] .= Widget::findPeople();
$a->page['aside'] .= Widget::follow();
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
return self::performContactSearch($search);
}

View file

@ -66,7 +66,7 @@ class Index extends BaseSearchModule
}
if (local_user()) {
DI::app()->page['aside'] .= Widget\SavedSearches::getHTML('search?q=' . urlencode($search), $search);
DI::page()['aside'] .= Widget\SavedSearches::getHTML('search?q=' . urlencode($search), $search);
}
Nav::setSelected('search');

View file

@ -75,7 +75,6 @@ class Login extends BaseModule
*/
public static function form($return_path = null, $register = false, $hiddens = [])
{
$a = DI::app();
$o = '';
$noid = Config::get('system', 'no_openid');
@ -101,7 +100,7 @@ class Login extends BaseModule
if (local_user()) {
$tpl = Renderer::getMarkupTemplate('logout.tpl');
} else {
$a->page['htmlhead'] .= Renderer::replaceMacros(
DI::page()['htmlhead'] .= Renderer::replaceMacros(
Renderer::getMarkupTemplate('login_head.tpl'),
[
'$baseurl' => DI::baseUrl()->get(true)