Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
$geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';

$tpl = Renderer::getMarkupTemplate('jot-header.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$newpost' => 'true',
'$baseurl' => System::baseUrl(true),
'$geotag' => $geotag,
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
$dice->create(\Friendica\App\Module::class),
$dice->create(\Friendica\App\Router::class),
$dice->create(\Friendica\Core\Config\IPConfiguration::class),
$dice->create(\Friendica\App\Authentication::class)
$dice->create(\Friendica\App\Authentication::class),
$dice->create(\Friendica\App\Page::class)
);
2 changes: 1 addition & 1 deletion mod/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function api_content(App $a)
* api/oauth/authorize interact with the user. return a standard page
*/

$a->page['template'] = "minimal";
DI::page()['template'] = "minimal";

// get consumer/client from request token
try {
Expand Down
10 changes: 5 additions & 5 deletions mod/cal.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ function cal_init(App $a)

$cal_widget = Widget\CalendarExport::getHTML();

if (empty($a->page['aside'])) {
$a->page['aside'] = '';
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}

$a->page['aside'] .= $vcard_widget;
$a->page['aside'] .= $cal_widget;
DI::page()['aside'] .= $vcard_widget;
DI::page()['aside'] .= $cal_widget;

return;
}
Expand All @@ -85,7 +85,7 @@ function cal_content(App $a)
$i18n = Event::getStrings();

$htpl = Renderer::getMarkupTemplate('event_head.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
'$module_url' => '/cal/' . $a->data['user']['nickname'],
'$modparams' => 2,
'$i18n' => $i18n,
Expand Down
8 changes: 4 additions & 4 deletions mod/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function common_content(App $a)
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['id' => $cid, 'uid' => $uid]);

if (DBA::isResult($contact)) {
$a->page['aside'] = "";
DI::page()['aside'] = "";
Model\Profile::load($a, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
}
} else {
Expand All @@ -54,10 +54,10 @@ function common_content(App $a)
'url' => 'contact/' . $cid
]);

if (empty($a->page['aside'])) {
$a->page['aside'] = '';
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}
$a->page['aside'] .= $vcard_widget;
DI::page()['aside'] .= $vcard_widget;
}
}

Expand Down
8 changes: 4 additions & 4 deletions mod/community.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function community_content(App $a, $update = 0)
'default_location' => $a->user['default-location'],
'nickname' => $a->user['nickname'],
'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'),
'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true),
'acl' => ACL::getFullSelectorHTML(DI::page(), $a->user, true),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
Expand Down Expand Up @@ -193,12 +193,12 @@ function community_content(App $a, $update = 0)
$o .= $pager->renderMinimal(count($r));
}

if (empty($a->page['aside'])) {
$a->page['aside'] = '';
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}

if (Feature::isEnabled(local_user(), 'trending_tags')) {
$a->page['aside'] .= TrendingTags::getHTML($content);
DI::page()['aside'] .= TrendingTags::getHTML($content);
}

$t = Renderer::getMarkupTemplate("community.tpl");
Expand Down
5 changes: 3 additions & 2 deletions mod/crepair.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
use Friendica\Module;
use Friendica\Util\Strings;
Expand Down Expand Up @@ -103,8 +104,8 @@ function crepair_content(App $a)
return;
}

if (empty($a->page['aside'])) {
$a->page['aside'] = '';
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}

if (DBA::isResult($contact)) {
Expand Down
50 changes: 26 additions & 24 deletions mod/display.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$conversation = '';
}

$a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('display-head.tpl'),
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('display-head.tpl'),
['$alternate' => $alternate,
'$conversation' => $conversation]);

Expand Down Expand Up @@ -281,7 +281,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
'default_location' => $a->user['default-location'],
'nickname' => $a->user['nickname'],
'lockstate' => (is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'),
'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true),
'acl' => ACL::getFullSelectorHTML(DI::page(), $a->user, true),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
Expand Down Expand Up @@ -342,39 +342,41 @@ function display_content(App $a, $update = false, $update_uid = 0)
$title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
$author_name = htmlspecialchars($author_name, ENT_COMPAT, 'UTF-8', true); // allow double encoding here

$page = DI::page();

if (DBA::exists('contact', ['unsearchable' => true, 'id' => [$item['contact-id'], $item['author-id'], $item['owner-id']]])) {
$a->page['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
$page['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
}

$a->page['htmlhead'] .= '<meta name="author" content="'.$author_name.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="fulltitle" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="description" content="'.$description.'" />'."\n";
DI::page()['htmlhead'] .= '<meta name="author" content="'.$author_name.'" />'."\n";
$page['htmlhead'] .= '<meta name="title" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta name="fulltitle" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta name="description" content="'.$description.'" />'."\n";

// Schema.org microdata
$a->page['htmlhead'] .= '<meta itemprop="name" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta itemprop="description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta itemprop="image" content="'.$image.'" />'."\n";
$a->page['htmlhead'] .= '<meta itemprop="author" content="'.$author_name.'" />'."\n";
$page['htmlhead'] .= '<meta itemprop="name" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta itemprop="description" content="'.$description.'" />'."\n";
$page['htmlhead'] .= '<meta itemprop="image" content="'.$image.'" />'."\n";
$page['htmlhead'] .= '<meta itemprop="author" content="'.$author_name.'" />'."\n";

// Twitter cards
$a->page['htmlhead'] .= '<meta name="twitter:card" content="summary" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$item["plink"].'" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:card" content="summary" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
$page['htmlhead'] .= '<meta name="twitter:url" content="'.$item["plink"].'" />'."\n";

// Dublin Core
$a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="DC.description" content="'.$description.'" />'."\n";
$page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta name="DC.description" content="'.$description.'" />'."\n";

// Open Graph
$a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:url" content="'.$item["plink"].'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";
$page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
$page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
$page['htmlhead'] .= '<meta property="og:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
$page['htmlhead'] .= '<meta property="og:url" content="'.$item["plink"].'" />'."\n";
$page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
$page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";
// article:tag

return $o;
Expand Down
3 changes: 2 additions & 1 deletion mod/editpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\FileTag;
use Friendica\Model\Item;
Expand Down Expand Up @@ -47,7 +48,7 @@ function editpost_content(App $a)
]);

$tpl = Renderer::getMarkupTemplate('jot-header.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$ispublic' => '&nbsp;', // L10n::t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
'$nickname' => $a->user['nickname']
Expand Down
18 changes: 9 additions & 9 deletions mod/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ function events_init(App $a)
return;
}

if (empty($a->page['aside'])) {
$a->page['aside'] = '';
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}

$cal_widget = CalendarExport::getHTML();

$a->page['aside'] .= $cal_widget;
DI::page()['aside'] .= $cal_widget;

return;
}
Expand Down Expand Up @@ -242,7 +242,7 @@ function events_content(App $a)
$i18n = Event::getStrings();

$htpl = Renderer::getMarkupTemplate('event_head.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
'$module_url' => '/events',
'$modparams' => 1,
'$i18n' => $i18n,
Expand Down Expand Up @@ -384,10 +384,10 @@ function events_content(App $a)
}

// ACL blocks are loaded in modals in frio
$a->page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
$a->page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js'));
$a->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
$a->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
DI::page()->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
DI::page()->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js'));
DI::page()->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
DI::page()->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));

$o = Renderer::replaceMacros($tpl, [
'$tabs' => $tabs,
Expand Down Expand Up @@ -489,7 +489,7 @@ function events_content(App $a)
$fminute = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00';

if (!$cid && in_array($mode, ['new', 'copy'])) {
$acl = ACL::getFullSelectorHTML($a->page, $a->user, false, ACL::getDefaultUserPermissions($orig_event));
$acl = ACL::getFullSelectorHTML(DI::page(), $a->user, false, ACL::getDefaultUserPermissions($orig_event));
} else {
$acl = '';
}
Expand Down
2 changes: 1 addition & 1 deletion mod/follow.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function follow_content(App $a)
'$keywords_label'=> L10n::t('Tags:')
]);

$a->page['aside'] = '';
DI::page()['aside'] = '';

$profiledata = Contact::getDetailsByURL($ret['url']);
if ($profiledata) {
Expand Down
4 changes: 2 additions & 2 deletions mod/match.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function match_content(App $a)
return '';
}

$a->page['aside'] .= Widget::findPeople();
$a->page['aside'] .= Widget::follow();
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();

$_SESSION['return_path'] = DI::args()->getCommand();

Expand Down
8 changes: 4 additions & 4 deletions mod/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ function message_init(App $a)
];

$tpl = Renderer::getMarkupTemplate('message_side.tpl');
$a->page['aside'] = Renderer::replaceMacros($tpl, [
DI::page()['aside'] = Renderer::replaceMacros($tpl, [
'$tabs' => $tabs,
'$new' => $new,
]);
$base = System::baseUrl();

$head_tpl = Renderer::getMarkupTemplate('message-head.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
'$baseurl' => System::baseUrl(true),
'$base' => $base
]);
Expand Down Expand Up @@ -199,7 +199,7 @@ function message_content(App $a)
$o .= $header;

$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => System::baseUrl(true),
'$nickname' => $a->user['nickname'],
'$linkurl' => L10n::t('Please enter a link URL:')
Expand Down Expand Up @@ -355,7 +355,7 @@ function message_content(App $a)
}

$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => System::baseUrl(true),
'$nickname' => $a->user['nickname'],
'$linkurl' => L10n::t('Please enter a link URL:')
Expand Down
20 changes: 10 additions & 10 deletions mod/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ function network_init(App $a)
}
}

if (empty($a->page['aside'])) {
$a->page['aside'] = '';
if (empty(DI::page()['aside'])) {
DI::page()['aside'] = '';
}

$a->page['aside'] .= Group::sidebarWidget('network/0', 'network', 'standard', $group_id);
$a->page['aside'] .= ForumManager::widget(local_user(), $cid);
$a->page['aside'] .= Widget::postedByYear('network', local_user(), false);
$a->page['aside'] .= Widget::networks('network', $_GET['nets'] ?? '');
$a->page['aside'] .= Widget\SavedSearches::getHTML(DI::args()->getQueryString());
$a->page['aside'] .= Widget::fileAs('network', $_GET['file'] ?? '');
DI::page()['aside'] .= Group::sidebarWidget('network/0', 'network', 'standard', $group_id);
DI::page()['aside'] .= ForumManager::widget(local_user(), $cid);
DI::page()['aside'] .= Widget::postedByYear('network', local_user(), false);
DI::page()['aside'] .= Widget::networks('network', $_GET['nets'] ?? '');
DI::page()['aside'] .= Widget\SavedSearches::getHTML(DI::args()->getQueryString());
DI::page()['aside'] .= Widget::fileAs('network', $_GET['file'] ?? '');
}

/**
Expand Down Expand Up @@ -374,7 +374,7 @@ function networkFlatView(App $a, $update = 0)
(strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) ||
strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock'),
'default_perms' => ACL::getDefaultUserPermissions($a->user),
'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true),
'acl' => ACL::getFullSelectorHTML(DI::page(), $a->user, true),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
Expand Down Expand Up @@ -548,7 +548,7 @@ function networkThreadedView(App $a, $update, $parent)
(strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) ||
strlen($a->user['deny_cid']) || strlen($a->user['deny_gid']))) ? 'lock' : 'unlock'),
'default_perms' => ACL::getDefaultUserPermissions($a->user),
'acl' => ACL::getFullSelectorHTML($a->page, $a->user, true, $default_permissions),
'acl' => ACL::getFullSelectorHTML(DI::page(), $a->user, true, $default_permissions),
'bang' => (($gid || $cid || $nets) ? '!' : ''),
'visitor' => 'block',
'profile_uid' => local_user(),
Expand Down
6 changes: 2 additions & 4 deletions mod/ostatus_subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ function ostatus_subscribe_content(App $a)

$uid = local_user();

$a = \get_app();

$counter = intval($_REQUEST['counter']);

if (PConfig::get($uid, 'ostatus', 'legacy_friends') == '') {
Expand Down Expand Up @@ -65,7 +63,7 @@ function ostatus_subscribe_content(App $a)
$total = sizeof($friends);

if ($counter >= $total) {
$a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . System::baseUrl() . '/settings/connectors">';
DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . System::baseUrl() . '/settings/connectors">';
PConfig::delete($uid, 'ostatus', 'legacy_friends');
PConfig::delete($uid, 'ostatus', 'legacy_contact');
$o .= L10n::t('Done');
Expand Down Expand Up @@ -94,7 +92,7 @@ function ostatus_subscribe_content(App $a)

$o .= '<p>' . L10n::t('Keep this window open until done.') . '</p>';

$a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . System::baseUrl() . '/ostatus_subscribe?counter=' . $counter . '">';
DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . System::baseUrl() . '/ostatus_subscribe?counter=' . $counter . '">';

return $o;
}