1
0
Fork 0

Rename Core\Network to Core\Protocol

This commit is contained in:
Hypolite Petovan 2018-02-05 12:57:41 -05:00
parent 157027a6f5
commit a0cdd9c674
5 changed files with 38 additions and 40 deletions

View file

@ -23,7 +23,7 @@ use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Network;
use Friendica\Core\Protocol;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
@ -249,33 +249,33 @@ define('PROTOCOL_SPLITTED_CONV', 6);
*/
/**
* @name Network
* @name Network constants
* @deprecated since version 3.6
* @see Friendica\Core\Network
* @see Friendica\Core\Protocol
*
* Network and protocol family types
* @{
*/
define('NETWORK_DFRN' , Network::DFRN); // Friendica, Mistpark, other DFRN implementations
define('NETWORK_ZOT' , Network::ZOT); // Zot! - Currently unsupported
define('NETWORK_OSTATUS' , Network::OSTATUS); // GNU-social, Pleroma, Mastodon, other OStatus implementations
define('NETWORK_FEED' , Network::FEED); // RSS/Atom feeds with no known "post/notify" protocol
define('NETWORK_DIASPORA' , Network::DIASPORA); // Diaspora
define('NETWORK_MAIL' , Network::MAIL); // IMAP/POP
define('NETWORK_FACEBOOK' , Network::FACEBOOK); // Facebook API
define('NETWORK_LINKEDIN' , Network::LINKEDIN); // LinkedIn
define('NETWORK_XMPP' , Network::XMPP); // XMPP - Currently unsupported
define('NETWORK_MYSPACE' , Network::MYSPACE); // MySpace - Currently unsupported
define('NETWORK_GPLUS' , Network::GPLUS); // Google+
define('NETWORK_PUMPIO' , Network::PUMPIO); // pump.io
define('NETWORK_TWITTER' , Network::TWITTER); // Twitter
define('NETWORK_DIASPORA2', Network::DIASPORA2); // Diaspora connector
define('NETWORK_STATUSNET', Network::STATUSNET); // Statusnet connector
define('NETWORK_APPNET' , Network::APPNET); // app.net - Dead protocol
define('NETWORK_NEWS' , Network::NEWS); // Network News Transfer Protocol - Currently unsupported
define('NETWORK_ICALENDAR', Network::ICALENDAR); // iCalendar - Currently unsupported
define('NETWORK_PNUT' , Network::PNUT); // pnut.io - Currently unsupported
define('NETWORK_PHANTOM' , Network::PHANTOM); // Place holder
define('NETWORK_DFRN' , Protocol::DFRN); // Friendica, Mistpark, other DFRN implementations
define('NETWORK_ZOT' , Protocol::ZOT); // Zot! - Currently unsupported
define('NETWORK_OSTATUS' , Protocol::OSTATUS); // GNU-social, Pleroma, Mastodon, other OStatus implementations
define('NETWORK_FEED' , Protocol::FEED); // RSS/Atom feeds with no known "post/notify" protocol
define('NETWORK_DIASPORA' , Protocol::DIASPORA); // Diaspora
define('NETWORK_MAIL' , Protocol::MAIL); // IMAP/POP
define('NETWORK_FACEBOOK' , Protocol::FACEBOOK); // Facebook API
define('NETWORK_LINKEDIN' , Protocol::LINKEDIN); // LinkedIn
define('NETWORK_XMPP' , Protocol::XMPP); // XMPP - Currently unsupported
define('NETWORK_MYSPACE' , Protocol::MYSPACE); // MySpace - Currently unsupported
define('NETWORK_GPLUS' , Protocol::GPLUS); // Google+
define('NETWORK_PUMPIO' , Protocol::PUMPIO); // pump.io
define('NETWORK_TWITTER' , Protocol::TWITTER); // Twitter
define('NETWORK_DIASPORA2', Protocol::DIASPORA2); // Diaspora connector
define('NETWORK_STATUSNET', Protocol::STATUSNET); // Statusnet connector
define('NETWORK_APPNET' , Protocol::APPNET); // app.net - Dead protocol
define('NETWORK_NEWS' , Protocol::NEWS); // Network News Transfer Protocol - Currently unsupported
define('NETWORK_ICALENDAR', Protocol::ICALENDAR); // iCalendar - Currently unsupported
define('NETWORK_PNUT' , Protocol::PNUT); // pnut.io - Currently unsupported
define('NETWORK_PHANTOM' , Protocol::PHANTOM); // Place holder
/**
* @}
*/

View file

@ -9,11 +9,11 @@ use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Network;
use Friendica\Core\Protocol;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Util\Network as NetworkUtil;
use Friendica\Util\Network;
require_once "mod/proxy.php";
@ -250,7 +250,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
}
if ($privmail) {
$trimmed = Network::formatMention($rr['url'], $rr['name']);
$trimmed = Protocol::formatMention($rr['url'], $rr['name']);
} else {
$trimmed = mb_substr($rr['name'],0,20);
}
@ -736,7 +736,7 @@ function navbar_complete(App $a) {
if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
$x = NetworkUtil::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
$x = Network::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
if ($x['success']) {
$j = json_decode($x['body'],true);
if ($j && isset($j['results'])) {

View file

@ -6,7 +6,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Network;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
@ -173,7 +173,7 @@ function display_fetchauthor($a, $item) {
$profiledata["photo"] = $matches[1];
}
$profiledata["nickname"] = $profiledata["name"];
$profiledata["network"] = Network::matchByProfileUrl($profiledata["url"]);
$profiledata["network"] = Protocol::matchByProfileUrl($profiledata["url"]);
$profiledata["address"] = "";
$profiledata["about"] = "";

View file

@ -13,13 +13,13 @@ use Friendica\Core\Addon;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Network;
use Friendica\Core\Protocol;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Object\Image;
use Friendica\Util\Map;
use Friendica\Util\Network as NetworkUtil;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
require_once "include/bbcode.php";
@ -521,7 +521,7 @@ class BBCode
} else {
$scaled = $mtch[1];
}
$i = NetworkUtil::fetchUrl($scaled);
$i = Network::fetchUrl($scaled);
if (!$i) {
return $srctext;
}
@ -1084,13 +1084,13 @@ class BBCode
if (x($data, "name") && x($data, "addr")) {
$userid_compact = $data["name"] . " (" . $data["addr"] . ")";
} else {
$userid_compact = Network::getAddrFromProfileUrl($profile, $author);
$userid_compact = Protocol::getAddrFromProfileUrl($profile, $author);
}
if (x($data, "addr")) {
$userid = $data["addr"];
} else {
$userid = Network::formatMention($profile, $author);
$userid = Protocol::formatMention($profile, $author);
}
if (x($data, "name")) {

View file

@ -1,19 +1,17 @@
<?php
/*
* @file src/Core/Network.php
* @file src/Core/Protocol.php
*/
namespace Friendica\Core;
use Friendica\Util;
use Friendica\Util\Network;
/**
* Manage compatibility with federated networks
*
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class Network
class Protocol
{
const DFRN = 'dfrn'; // Friendica, Mistpark, other DFRN implementations
const DIASPORA = 'dspr'; // Diaspora
@ -96,7 +94,7 @@ class Network
if (preg_match('=https?://(.*)/user/(.*)=ism', $profile_url, $matches)) {
$statusnet_host = $matches[1];
$statusnet_user = $matches[2];
$UserData = Util\Network::fetchUrl('http://' . $statusnet_host . '/api/users/show.json?user_id=' . $statusnet_user);
$UserData = Network::fetchUrl('http://' . $statusnet_host . '/api/users/show.json?user_id=' . $statusnet_user);
$user = json_decode($UserData);
if ($user) {
$matches[2] = $user->screen_name;