Merge pull request #8113 from annando/build-query

Remove "f" parameter / network page parameter cleanup
This commit is contained in:
Hypolite Petovan 2020-01-13 15:23:54 -05:00 committed by GitHub
commit e64336b4d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 34 additions and 75 deletions

View File

@ -86,7 +86,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
$search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
$replace = '[url=' . DI::baseUrl() . '/redir/' . $cid
. '?f=1&url=' . '$1' . '][!#saved_image' . '$2' .'#!][/url]';
. '?url=' . '$1' . '][!#saved_image' . '$2' .'#!][/url]';
$newbody .= substr($origbody, 0, $pos['start']['open']);
$subject = substr($origbody, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
@ -935,7 +935,7 @@ function item_photo_menu($item) {
}
if ($cid && !$item['self']) {
$poke_link = 'poke/?f=&c=' . $cid;
$poke_link = 'poke?c=' . $cid;
$contact_url = 'contact/' . $cid;
$posts_link = 'contact/' . $cid . '/posts';

View File

@ -541,7 +541,7 @@ function dfrn_poll_content(App $a)
switch ($destination_url) {
case 'profile':
DI::baseUrl()->redirect('profile/' . $profile . '?f=&tab=profile');
DI::baseUrl()->redirect('profile/' . $profile . '?tab=profile');
break;
case 'photos':
DI::baseUrl()->redirect('photos/' . $profile);
@ -551,7 +551,7 @@ function dfrn_poll_content(App $a)
DI::baseUrl()->redirect('profile/' . $profile);
break;
default:
$appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
$appendix = (strstr($destination_url, '?') ? '&redir=1' : '?redir=1');
DI::baseUrl()->redirect($destination_url . $appendix);
break;
}

View File

@ -315,7 +315,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
}
if (!$update) {
$o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
$o .= "<script> var netargs = '?item_id=" . $item_id . "'; </script>";
}
$o .= conversation($a, [$item], new Pager(DI::args()->getQueryString()), 'display', $update_uid, false, 'commented', $item_uid);

View File

@ -86,19 +86,11 @@ function network_init(App $a)
// last selected tab is _not_ '/network?order=activity'.
// and this isn't a date query
$tab_baseurls = [
'', //all
'', //postord
'', //conv
'/new', //new
'', //starred
'', //bookmarked
];
$tab_args = [
'order=activity', //all
'order=post', //postord
'conv=1', //conv
'', //new
'new=1', //new
'star=1', //starred
'bmark=1', //bookmarked
];
@ -106,8 +98,6 @@ function network_init(App $a)
$k = array_search('active', $last_sel_tabs);
if ($k != 3) {
$net_baseurl .= $tab_baseurls[$k];
// parse out tab queries
$dest_qa = [];
$dest_qs = $tab_args[$k];
@ -152,7 +142,7 @@ function network_init(App $a)
* '/network?order=activity' => $activity_active = 'active'
* '/network?order=post' => $postord_active = 'active'
* '/network?conv=1', => $conv_active = 'active'
* '/network/new', => $new_active = 'active'
* '/network?new=1', => $new_active = 'active'
* '/network?star=1', => $starred_active = 'active'
* '/network?bmark=1', => $bookmarked_active = 'active'
*
@ -169,7 +159,7 @@ function network_query_get_sel_tab(App $a)
$conv_active = '';
$postord_active = '';
if (($a->argc > 1 && $a->argv[1] === 'new') || ($a->argc > 2 && $a->argv[2] === 'new')) {
if (!empty($_GET['new'])) {
$new_active = 'active';
}
@ -312,21 +302,7 @@ function network_content(App $a, $update = 0, $parent = 0)
$arr = ['query' => DI::args()->getQueryString()];
Hook::callAll('network_content_init', $arr);
$flat_mode = false;
if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) {
if ($a->argv[$x] === 'new') {
$flat_mode = true;
}
}
}
if (!empty($_GET['file'])) {
$flat_mode = true;
}
if ($flat_mode) {
if (!empty($_GET['new']) || !empty($_GET['file'])) {
$o = networkFlatView($a, $update);
} else {
$o = networkThreadedView($a, $update, $parent);
@ -916,11 +892,16 @@ function network_tabs(App $a)
$cmd = DI::args()->getCommand();
$def_param = [];
if (!empty($_GET['cid'])) {
$def_param['cid'] = $_GET['cid'];
}
// tabs
$tabs = [
[
'label' => L10n::t('Latest Activity'),
'url' => str_replace('/new', '', $cmd) . '?order=activity' . (!empty($_GET['cid']) ? '&cid=' . $_GET['cid'] : ''),
'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['order' => 'activity'])),
'sel' => $all_active,
'title' => L10n::t('Sort by latest activity'),
'id' => 'activity-order-tab',
@ -928,7 +909,7 @@ function network_tabs(App $a)
],
[
'label' => L10n::t('Latest Posts'),
'url' => str_replace('/new', '', $cmd) . '?order=post' . (!empty($_GET['cid']) ? '&cid=' . $_GET['cid'] : ''),
'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['order' => 'post'])),
'sel' => $post_active,
'title' => L10n::t('Sort by post received date'),
'id' => 'post-order-tab',
@ -936,14 +917,9 @@ function network_tabs(App $a)
],
];
$parameters = ['conv' => true];
if (!empty($_GET['cid'])) {
$parameters['cid'] = $_GET['cid'];
}
$tabs[] = [
'label' => L10n::t('Personal'),
'url' => str_replace('/new', '', $cmd) . '?' . http_build_query($parameters),
'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['conv' => true])),
'sel' => $conv_active,
'title' => L10n::t('Posts that mention or involve you'),
'id' => 'personal-tab',
@ -951,15 +927,9 @@ function network_tabs(App $a)
];
if (Feature::isEnabled(local_user(), 'new_tab')) {
if (!empty($_GET['cid'])) {
$query = '?' . http_build_query(['cid' => $_GET['cid']]);
} else {
$query = '';
}
$tabs[] = [
'label' => L10n::t('New'),
'url' => 'network/new' . $query,
'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['new' => true])),
'sel' => $new_active,
'title' => L10n::t('Activity Stream - by date'),
'id' => 'activitiy-by-date-tab',
@ -968,14 +938,9 @@ function network_tabs(App $a)
}
if (Feature::isEnabled(local_user(), 'link_tab')) {
$parameters = ['bmark' => true];
if (!empty($_GET['cid'])) {
$parameters['cid'] = $_GET['cid'];
}
$tabs[] = [
'label' => L10n::t('Shared Links'),
'url' => str_replace('/new', '', $cmd) . '?' . http_build_query($parameters),
'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['bmark' => true])),
'sel' => $bookmarked_active,
'title' => L10n::t('Interesting Links'),
'id' => 'shared-links-tab',
@ -983,14 +948,9 @@ function network_tabs(App $a)
];
}
$parameters = ['tar' => true];
if (!empty($_GET['cid'])) {
$parameters['cid'] = $_GET['cid'];
}
$tabs[] = [
'label' => L10n::t('Starred'),
'url' => str_replace('/new', '', $cmd) . '?' . http_build_query($parameters),
'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['star' => true])),
'sel' => $starred_active,
'title' => L10n::t('Favourite Posts'),
'id' => 'starred-posts-tab',

View File

@ -42,7 +42,7 @@ function oexchange_content(App $a) {
$tags = ((!empty($_REQUEST['tags']))
? '&tags=' . urlencode(Strings::escapeTags(trim($_REQUEST['tags']))) : '');
$s = Network::fetchUrl(DI::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
$s = Network::fetchUrl(DI::baseUrl() . '/parse_url?url=' . $url . $title . $description . $tags);
if (!strlen($s)) {
return;

View File

@ -1071,7 +1071,7 @@ function photos_content(App $a)
if ($order_field === 'posted') {
$order = [L10n::t('Show Newest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album), 'oldest'];
} else {
$order = [L10n::t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?f=&order=posted', 'newest'];
$order = [L10n::t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?order=posted', 'newest'];
}
$photos = [];
@ -1091,7 +1091,7 @@ function photos_content(App $a)
'id' => $rr['id'],
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id']
. ($order_field === 'posted' ? '?f=&order=posted' : ''),
. ($order_field === 'posted' ? '?order=posted' : ''),
'title' => L10n::t('View Photo'),
'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
'alt' => $imgalt_e,
@ -1191,10 +1191,10 @@ function photos_content(App $a)
}
if (!is_null($prv)) {
$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?f=&order=posted' : '');
$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : '');
}
if (!is_null($nxt)) {
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?f=&order=posted' : '');
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : '');
}
$tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
@ -1252,7 +1252,7 @@ function photos_content(App $a)
$photo = [
'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
'title'=> L10n::t('View Full Size'),
'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . DateTimeFormat::utcNow('ymdhis'),
'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?_u=' . DateTimeFormat::utcNow('ymdhis'),
'height' => $hires['height'],
'width' => $hires['width'],
'album' => $hires['album'],

View File

@ -51,7 +51,7 @@ final class Item
$categories[] = [
'name' => $savedFolderName,
'url' => $url,
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&cat=' . rawurlencode($savedFolderName) : ""),
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : ""),
'first' => $first,
'last' => false
];
@ -67,7 +67,7 @@ final class Item
$folders[] = [
'name' => $savedFolderName,
'url' => "#",
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . rawurlencode($savedFolderName) : ""),
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""),
'first' => $first,
'last' => false
];

View File

@ -239,7 +239,6 @@ class Nav
// The following nav links are only show to logged in users
if (local_user()) {
$nav['network'] = ['network', L10n::t('Network'), '', L10n::t('Conversations from your friends')];
$nav['net_reset'] = ['network/?f=', L10n::t('Network Reset'), '', L10n::t('Load Network page with no filters')];
$nav['home'] = ['profile/' . $a->user['nickname'], L10n::t('Home'), '', L10n::t('Your posts and conversations')];

View File

@ -222,7 +222,7 @@ function string2bb(element) {
match: /(^|\s)(\#)([^ \n]{2,})$/,
index: 3,
search: function(term, callback) {
$.getJSON(baseurl + '/hashtag/' + '?f=&t=' + term)
$.getJSON(baseurl + '/hashtag/' + '?t=' + term)
.done(function(data) {
callback($.map(data, function(entry) {
// .toLowerCase() enables case-insensitive search
@ -275,7 +275,7 @@ function string2bb(element) {
tags = {
match: /(^|\s)(\#)([^ \n]{2,})$/,
index: 3,
search: function(term, callback) { $.getJSON(baseurl + '/hashtag/' + '?f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); },
search: function(term, callback) { $.getJSON(baseurl + '/hashtag/' + '?t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); },
replace: function(item) { return "$1$2" + item.text; },
template: tag_format
};

View File

@ -498,7 +498,7 @@ function insertBBCodeInTextarea(BBCode, textarea) {
function NavUpdate() {
if (!stopped) {
var pingCmd = 'ping?format=json' + ((localUser != 0) ? '&f=&uid=' + localUser : '');
var pingCmd = 'ping?format=json' + ((localUser != 0) ? '&uid=' + localUser : '');
$.get(pingCmd, function(data) {
if (data.result) {
// send nav-update event
@ -980,7 +980,7 @@ Array.prototype.remove = function(item) {
function previewTheme(elm) {
theme = $(elm).val();
$.getJSON('pretheme?f=&theme=' + theme,function(data) {
$.getJSON('pretheme?theme=' + theme,function(data) {
$('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div><a href="' + data.img + '"><img src="' + data.img + '" width="320" height="240" alt="' + theme + '" /></a>');
});

View File

@ -127,7 +127,7 @@ function frio_item_photo_links(App $a, &$body_info)
function frio_item_photo_menu(App $a, &$arr)
{
foreach ($arr['menu'] as $k => $v) {
if (strpos($v, 'poke/?f=&c=') === 0 || strpos($v, 'message/new/') === 0) {
if (strpos($v, 'poke?c=') === 0 || strpos($v, 'message/new/') === 0) {
$v = 'javascript:addToModal(\'' . $v . '\'); return false;';
$arr['menu'][$k] = $v;
}
@ -181,7 +181,7 @@ function frio_contact_photo_menu(App $a, &$args)
// Add to pm and poke links a new key with the value 'modal'.
// Later we can make conditions in the corresponing templates (e.g.
// contact_template.tpl)
if (strpos($pokelink, 'poke/?f=&c=' . $cid) !== false) {
if (strpos($pokelink, 'poke?c=' . $cid) !== false) {
$args['menu']['poke'][3] = 'modal';
}