mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-17 02:05:19 +02: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
|
@ -40,6 +40,7 @@ use Friendica\Object\Image;
|
|||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
require_once 'include/conversation.php';
|
||||
|
@ -47,7 +48,6 @@ require_once 'mod/share.php';
|
|||
require_once 'mod/item.php';
|
||||
require_once 'include/security.php';
|
||||
require_once 'mod/wall_upload.php';
|
||||
require_once 'mod/proxy.php';
|
||||
|
||||
define('API_METHOD_ANY', '*');
|
||||
define('API_METHOD_GET', 'GET');
|
||||
|
@ -2518,7 +2518,7 @@ function api_get_entitities(&$text, $bbcode)
|
|||
preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
|
||||
|
||||
foreach ($images[1] as $image) {
|
||||
$replace = proxy_url($image);
|
||||
$replace = ProxyUtils::proxifyUrl($image);
|
||||
$text = str_replace($image, $replace, $text);
|
||||
}
|
||||
return [];
|
||||
|
@ -2627,7 +2627,7 @@ function api_get_entitities(&$text, $bbcode)
|
|||
// If image cache is activated, then use the following sizes:
|
||||
// thumb (150), small (340), medium (600) and large (1024)
|
||||
if (!Config::get("system", "proxy_disabled")) {
|
||||
$media_url = proxy_url($url);
|
||||
$media_url = ProxyUtils::proxifyUrl($url);
|
||||
|
||||
$sizes = [];
|
||||
$scale = Image::getScalingDimensions($image[0], $image[1], 150);
|
||||
|
|
|
@ -20,6 +20,7 @@ use Friendica\Model\Term;
|
|||
use Friendica\Object\Post;
|
||||
use Friendica\Object\Thread;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -407,7 +408,6 @@ function visible_activity($item) {
|
|||
*
|
||||
*/
|
||||
function conversation(App $a, array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0) {
|
||||
require_once 'mod/proxy.php';
|
||||
|
||||
$ssl_state = ((local_user()) ? true : false);
|
||||
|
||||
|
@ -418,8 +418,10 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
|
||||
if (local_user()) {
|
||||
$str_blocked = PConfig::get(local_user(), 'system', 'blocked');
|
||||
|
||||
if ($str_blocked) {
|
||||
$arr_blocked = explode(',', $str_blocked);
|
||||
|
||||
for ($x = 0; $x < count($arr_blocked); $x ++) {
|
||||
$arr_blocked[$x] = trim($arr_blocked[$x]);
|
||||
}
|
||||
|
@ -477,6 +479,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
}
|
||||
} elseif ($mode === 'notes') {
|
||||
$profile_owner = local_user();
|
||||
|
||||
if (!$update) {
|
||||
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
|
||||
. "<script> var profile_uid = " . local_user()
|
||||
|
@ -484,6 +487,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
}
|
||||
} elseif ($mode === 'display') {
|
||||
$profile_owner = $a->profile['uid'];
|
||||
|
||||
if (!$update) {
|
||||
$live_update_div = '<div id="live-display"></div>' . "\r\n"
|
||||
. "<script> var profile_uid = " . defaults($_SESSION, 'uid', 0) . ";"
|
||||
|
@ -492,6 +496,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
} elseif ($mode === 'community') {
|
||||
$items = conversation_add_children($items, true, $order, $uid);
|
||||
$profile_owner = 0;
|
||||
|
||||
if (!$update) {
|
||||
$live_update_div = '<div id="live-community"></div>' . "\r\n"
|
||||
. "<script> var profile_uid = -1; var netargs = '" . substr($a->cmd, 10)
|
||||
|
@ -523,7 +528,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
|
||||
$page_template = get_markup_template("conversation.tpl");
|
||||
|
||||
if ($items && count($items)) {
|
||||
if (!empty($items)) {
|
||||
if ($mode === 'community') {
|
||||
$writable = true;
|
||||
} else {
|
||||
|
@ -645,7 +650,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
'name' => $profile_name_e,
|
||||
'sparkle' => $sparkle,
|
||||
'lock' => $lock,
|
||||
'thumb' => System::removedBaseUrl(proxy_url($item['author-avatar'], false, PROXY_SIZE_THUMB)),
|
||||
'thumb' => System::removedBaseUrl(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
|
||||
'title' => $title_e,
|
||||
'body' => $body_e,
|
||||
'tags' => $tags_e,
|
||||
|
@ -664,7 +669,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
|
|||
'indent' => '',
|
||||
'owner_name' => $owner_name_e,
|
||||
'owner_url' => $owner_url,
|
||||
'owner_photo' => System::removedBaseUrl(proxy_url($item['owner-avatar'], false, PROXY_SIZE_THUMB)),
|
||||
'owner_photo' => System::removedBaseUrl(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
|
||||
'plink' => get_plink($item),
|
||||
'edpost' => false,
|
||||
'isstarred' => $isstarred,
|
||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Database\DBA;
|
|||
*
|
||||
* @param $args Query parameters (1 to N parameters of different types)
|
||||
* @return array|bool Query array
|
||||
* @deprecated
|
||||
*/
|
||||
function q($sql) {
|
||||
$args = func_get_args();
|
||||
|
|
|
@ -20,8 +20,8 @@ use Friendica\Model\Item;
|
|||
use Friendica\Render\FriendicaSmarty;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Map;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
|
||||
require_once "mod/proxy.php";
|
||||
require_once "include/conversation.php";
|
||||
|
||||
/**
|
||||
|
@ -858,7 +858,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
|
|||
'$click' => defaults($contact, 'click', ''),
|
||||
'$class' => $class,
|
||||
'$url' => $url,
|
||||
'$photo' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
|
||||
'$photo' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
|
||||
'$name' => $contact['name'],
|
||||
'title' => $contact['name'] . ' [' . $contact['addr'] . ']',
|
||||
'$parkle' => $sparkle,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue