mirror of
https://github.com/friendica/friendica
synced 2025-04-23 23:50:12 +00:00
[WIP] Rewrite to Proxy class: (#5507)
* Rewrite to Proxy class: - introduced new Friendica\Network\Proxy class for in exchange of proxy_*() functions - moved also all PROXY_* constants there as Proxy::* - removed now no longer needed mod/proxy.php loading as composer's auto-load will do this for us - renamed those proxy_*() functions to better names: + proxy_init() -> Proxy::init() (public) + proxy_url() -> Proxy::proxifyUrl() (public) + proxy_parse_html() -> Proxy::proxifyHtml() (public) + proxy_is_local_image() -> Proxy::isLocalImage() (private) + proxy_parse_query() -> Proxy::parseQuery() (private) + proxy_img_cb() -> Proxy::replaceUrl() (private) * Ops, need to set $a here ... * CR request: - moved Proxy class to Friendica\Module - extended BaseModule * Ops, no need for own instance of $a when self::getApp() is around. * Proxy-rewrite: - proxy_url() and proxy_parse_html() are both non-module functions (now methods) - so they must be splitted into a seperate class - also the SIZE_* and DEFAULT_TIME constants are both not relevant to module * No instances from utility classes * Fixed error: - proxify*() is now located in `Friendica\Util\ProxyUtils` * Moved back to original place, ops? How did they move here? Well, it was not intended by me. * Removed duplicate (left-over from split) constants and static array. Thank to MrPetovan finding it. * Renamed ProxyUtils -> Proxy and aliased it back to ProxyUtils.
This commit is contained in:
parent
bf87ad4fcf
commit
4d39164c1e
30 changed files with 578 additions and 448 deletions
|
@ -13,6 +13,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -243,7 +244,7 @@ class NotificationsManager extends BaseObject
|
|||
case 'system':
|
||||
$default_item_label = 'notify';
|
||||
$default_item_link = System::baseUrl(true) . '/notify/view/' . $it['id'];
|
||||
$default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
|
||||
$default_item_image = ProxyUtils::proxifyUrl($it['photo'], false, ProxyUtils::SIZE_MICRO);
|
||||
$default_item_url = $it['url'];
|
||||
$default_item_text = strip_tags(BBCode::convert($it['msg']));
|
||||
$default_item_when = DateTimeFormat::local($it['date'], 'r');
|
||||
|
@ -253,7 +254,7 @@ class NotificationsManager extends BaseObject
|
|||
case 'home':
|
||||
$default_item_label = 'comment';
|
||||
$default_item_link = System::baseUrl(true) . '/display/' . $it['parent-guid'];
|
||||
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
|
||||
$default_item_image = ProxyUtils::proxifyUrl($it['author-avatar'], false, ProxyUtils::SIZE_MICRO);
|
||||
$default_item_url = $it['author-link'];
|
||||
$default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['parent-author-name']);
|
||||
$default_item_when = DateTimeFormat::local($it['created'], 'r');
|
||||
|
@ -263,7 +264,7 @@ class NotificationsManager extends BaseObject
|
|||
default:
|
||||
$default_item_label = (($it['id'] == $it['parent']) ? 'post' : 'comment');
|
||||
$default_item_link = System::baseUrl(true) . '/display/' . $it['parent-guid'];
|
||||
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
|
||||
$default_item_image = ProxyUtils::proxifyUrl($it['author-avatar'], false, ProxyUtils::SIZE_MICRO);
|
||||
$default_item_url = $it['author-link'];
|
||||
$default_item_text = (($it['id'] == $it['parent'])
|
||||
? L10n::t("%s created a new post", $it['author-name'])
|
||||
|
@ -278,7 +279,7 @@ class NotificationsManager extends BaseObject
|
|||
$notif = [
|
||||
'label' => 'like',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'image' => ProxyUtils::proxifyUrl($it['author-avatar'], false, ProxyUtils::SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => L10n::t("%s liked %s's post", $it['author-name'], $it['parent-author-name']),
|
||||
'when' => $default_item_when,
|
||||
|
@ -291,7 +292,7 @@ class NotificationsManager extends BaseObject
|
|||
$notif = [
|
||||
'label' => 'dislike',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'image' => ProxyUtils::proxifyUrl($it['author-avatar'], false, ProxyUtils::SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => L10n::t("%s disliked %s's post", $it['author-name'], $it['parent-author-name']),
|
||||
'when' => $default_item_when,
|
||||
|
@ -304,7 +305,7 @@ class NotificationsManager extends BaseObject
|
|||
$notif = [
|
||||
'label' => 'attend',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'image' => ProxyUtils::proxifyUrl($it['author-avatar'], false, ProxyUtils::SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => L10n::t("%s is attending %s's event", $it['author-name'], $it['parent-author-name']),
|
||||
'when' => $default_item_when,
|
||||
|
@ -317,7 +318,7 @@ class NotificationsManager extends BaseObject
|
|||
$notif = [
|
||||
'label' => 'attendno',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'image' => ProxyUtils::proxifyUrl($it['author-avatar'], false, ProxyUtils::SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => L10n::t("%s is not attending %s's event", $it['author-name'], $it['parent-author-name']),
|
||||
'when' => $default_item_when,
|
||||
|
@ -330,7 +331,7 @@ class NotificationsManager extends BaseObject
|
|||
$notif = [
|
||||
'label' => 'attendmaybe',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'image' => ProxyUtils::proxifyUrl($it['author-avatar'], false, ProxyUtils::SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => L10n::t("%s may attend %s's event", $it['author-name'], $it['parent-author-name']),
|
||||
'when' => $default_item_when,
|
||||
|
@ -347,7 +348,7 @@ class NotificationsManager extends BaseObject
|
|||
$notif = [
|
||||
'label' => 'friend',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'image' => ProxyUtils::proxifyUrl($it['author-avatar'], false, ProxyUtils::SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => L10n::t("%s is now friends with %s", $it['author-name'], $it['fname']),
|
||||
'when' => $default_item_when,
|
||||
|
@ -622,7 +623,7 @@ class NotificationsManager extends BaseObject
|
|||
'madeby_zrl' => Contact::magicLink($it['url']),
|
||||
'madeby_addr' => $it['addr'],
|
||||
'contact_id' => $it['contact-id'],
|
||||
'photo' => ((x($it, 'fphoto')) ? proxy_url($it['fphoto'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
|
||||
'photo' => ((x($it, 'fphoto')) ? ProxyUtils::proxifyUrl($it['fphoto'], false, ProxyUtils::SIZE_SMALL) : "images/person-175.jpg"),
|
||||
'name' => $it['fname'],
|
||||
'url' => $it['furl'],
|
||||
'zrl' => Contact::magicLink($it['furl']),
|
||||
|
@ -650,7 +651,7 @@ class NotificationsManager extends BaseObject
|
|||
'uid' => $_SESSION['uid'],
|
||||
'intro_id' => $it['intro_id'],
|
||||
'contact_id' => $it['contact-id'],
|
||||
'photo' => ((x($it, 'photo')) ? proxy_url($it['photo'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
|
||||
'photo' => ((x($it, 'photo')) ? ProxyUtils::proxifyUrl($it['photo'], false, ProxyUtils::SIZE_SMALL) : "images/person-175.jpg"),
|
||||
'name' => $it['name'],
|
||||
'location' => BBCode::convert($it['glocation'], false),
|
||||
'about' => BBCode::convert($it['gabout'], false),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue