1
0
Fork 0
Move contact_selectors to src
This commit is contained in:
Michael Vogel 2018-01-10 13:59:50 +01:00 committed by GitHub
commit 05674206ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 158 additions and 174 deletions

View file

@ -9,7 +9,6 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
require_once "include/contact_selectors.php";
require_once "include/contact_widgets.php"; require_once "include/contact_widgets.php";
require_once "mod/proxy.php"; require_once "mod/proxy.php";

View file

@ -6,6 +6,7 @@
* @todo Automatically detect if incoming data is HTML or BBCode * @todo Automatically detect if incoming data is HTML or BBCode
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Config; use Friendica\Core\Config;
@ -38,7 +39,6 @@ require_once 'include/html2plain.php';
require_once 'mod/share.php'; require_once 'mod/share.php';
require_once 'mod/item.php'; require_once 'mod/item.php';
require_once 'include/security.php'; require_once 'include/security.php';
require_once 'include/contact_selectors.php';
require_once 'include/html2bbcode.php'; require_once 'include/html2bbcode.php';
require_once 'mod/wall_upload.php'; require_once 'mod/wall_upload.php';
require_once 'mod/proxy.php'; require_once 'mod/proxy.php';
@ -610,7 +610,7 @@ function api_get_user(App $a, $contact_id = null)
} }
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$network_name = network_to_name($r[0]['network'], $r[0]['url']); $network_name = ContactSelector::networkToName($r[0]['network'], $r[0]['url']);
// If no nick where given, extract it from the address // If no nick where given, extract it from the address
if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) { if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) {
@ -734,7 +734,7 @@ function api_get_user(App $a, $contact_id = null)
$uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]); $uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]);
} }
$network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']); $network_name = ContactSelector::networkToName($uinfo[0]['network'], $uinfo[0]['url']);
$pcontact_id = Contact::getIdForURL($uinfo[0]['url'], 0, true); $pcontact_id = Contact::getIdForURL($uinfo[0]['url'], 0, true);
@ -1405,9 +1405,9 @@ function api_status_show($type)
} }
if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) { if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) {
$status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']); $status_info["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
} elseif (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) { } elseif (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
$status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')'); $status_info["source"] = trim($status_info["source"].' ('.ContactSelector::networkToName($lastwall['item_network'], $user_info['url']).')');
} }
// "uid" and "self" are only needed for some internal stuff, so remove it from here // "uid" and "self" are only needed for some internal stuff, so remove it from here
@ -1496,11 +1496,11 @@ function api_users_show($type)
} }
if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) { if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) {
$user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']); $user_info["status"]["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
} }
if (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) { if (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
$user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')'); $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) . ')');
} }
} }
@ -3131,9 +3131,9 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
} }
if (($item['item_network'] != "") && ($status["source"] == 'web')) { if (($item['item_network'] != "") && ($status["source"] == 'web')) {
$status["source"] = network_to_name($item['item_network'], $user_info['url']); $status["source"] = ContactSelector::networkToName($item['item_network'], $user_info['url']);
} elseif (($item['item_network'] != "") && (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) { } elseif (($item['item_network'] != "") && (ContactSelector::networkToName($item['item_network'], $user_info['url']) != $status["source"])) {
$status["source"] = trim($status["source"].' ('.network_to_name($item['item_network'], $user_info['url']).')'); $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['item_network'], $user_info['url']).')');
} }

View file

@ -1,115 +0,0 @@
<?php
use Friendica\Database\DBM;
use Friendica\Protocol\Diaspora;
function contact_profile_assign($current,$foreign_net) {
$o = '';
$disabled = (($foreign_net) ? ' disabled="true" ' : '');
$o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
$r = q("SELECT `id`, `profile-name`, `is-default` FROM `profile` WHERE `uid` = %d",
intval($_SESSION['uid']));
if (DBM::is_result($r)) {
foreach ($r as $rr) {
$selected = (($rr['id'] == $current || ($current == 0 && $rr['is-default'] == 1)) ? " selected=\"selected\" " : "");
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
}
}
$o .= "</select>\r\n";
return $o;
}
function contact_reputation($current) {
$o = '';
$o .= "<select id=\"contact-reputation-selector\" name=\"reputation\" />\r\n";
$rep = array(
0 => t('Unknown | Not categorised'),
1 => t('Block immediately'),
2 => t('Shady, spammer, self-marketer'),
3 => t('Known to me, but no opinion'),
4 => t('OK, probably harmless'),
5 => t('Reputable, has my trust')
);
foreach ($rep as $k => $v) {
$selected = (($k == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"$k\" $selected >$v</option>\r\n";
}
$o .= "</select>\r\n";
return $o;
}
function contact_poll_interval($current, $disabled = false) {
$dis = (($disabled) ? ' disabled="disabled" ' : '');
$o = '';
$o .= "<select id=\"contact-poll-interval\" name=\"poll\" $dis />" . "\r\n";
$rep = array(
0 => t('Frequently'),
1 => t('Hourly'),
2 => t('Twice daily'),
3 => t('Daily'),
4 => t('Weekly'),
5 => t('Monthly')
);
foreach ($rep as $k => $v) {
$selected = (($k == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"$k\" $selected >$v</option>\r\n";
}
$o .= "</select>\r\n";
return $o;
}
function network_to_name($s, $profile = "") {
$nets = array(
NETWORK_DFRN => t('Friendica'),
NETWORK_OSTATUS => t('OStatus'),
NETWORK_FEED => t('RSS/Atom'),
NETWORK_MAIL => t('Email'),
NETWORK_DIASPORA => t('Diaspora'),
NETWORK_FACEBOOK => t('Facebook'),
NETWORK_ZOT => t('Zot!'),
NETWORK_LINKEDIN => t('LinkedIn'),
NETWORK_XMPP => t('XMPP/IM'),
NETWORK_MYSPACE => t('MySpace'),
NETWORK_GPLUS => t('Google+'),
NETWORK_PUMPIO => t('pump.io'),
NETWORK_TWITTER => t('Twitter'),
NETWORK_DIASPORA2 => t('Diaspora Connector'),
NETWORK_STATUSNET => t('GNU Social Connector'),
NETWORK_PNUT => t('pnut'),
NETWORK_APPNET => t('App.net')
);
call_hooks('network_to_name', $nets);
$search = array_keys($nets);
$replace = array_values($nets);
$networkname = str_replace($search, $replace, $s);
if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
$r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
if (DBM::is_result($r)) {
$networkname = $r['platform'];
}
}
return $networkname;
}

View file

@ -1,8 +1,8 @@
<?php <?php
/** /**
* @file include/contact_widgets.php * @file include/contact_widgets.php
*/ */
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Config; use Friendica\Core\Config;
@ -10,8 +10,6 @@ use Friendica\Core\PConfig;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\GContact; use Friendica\Model\GContact;
require_once 'include/contact_selectors.php';
function follow_widget($value = "") function follow_widget($value = "")
{ {
return replace_macros(get_markup_template('follow.tpl'), array( return replace_macros(get_markup_template('follow.tpl'), array(
@ -119,7 +117,7 @@ function networks_widget($baseurl, $selected = '')
while ($rr = dba::fetch($r)) { while ($rr = dba::fetch($r)) {
/// @TODO If 'network' is not there, this triggers an E_NOTICE /// @TODO If 'network' is not there, this triggers an E_NOTICE
if ($rr['network']) { if ($rr['network']) {
$nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' )); $nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
} }
} }
dba::close($r); dba::close($r);

View file

@ -3,6 +3,7 @@
* @file include/conversation.php * @file include/conversation.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
@ -776,7 +777,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'id' => (($preview) ? 'P0' : $item['item_id']), 'id' => (($preview) ? 'P0' : $item['item_id']),
'guid' => (($preview) ? 'Q0' : $item['guid']), 'guid' => (($preview) ? 'Q0' : $item['guid']),
'network' => $item['item_network'], 'network' => $item['item_network'],
'network_name' => network_to_name($item['item_network'], $profile_link), 'network_name' => ContactSelector::networkToName($item['item_network'], $profile_link),
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
'profile_url' => $profile_link, 'profile_url' => $profile_link,
'item_photo_menu' => item_photo_menu($item), 'item_photo_menu' => item_photo_menu($item),

View file

@ -3,6 +3,7 @@
* @file include/text.php * @file include/text.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Smilies; use Friendica\Content\Smilies;
use Friendica\Core\Config; use Friendica\Core\Config;
@ -2048,16 +2049,14 @@ function formatBytes($bytes, $precision = 2) {
*/ */
function format_network_name($network, $url = 0) { function format_network_name($network, $url = 0) {
if ($network != "") { if ($network != "") {
require_once 'include/contact_selectors.php';
if ($url != "") { if ($url != "") {
$network_name = '<a href="'.$url.'">'.network_to_name($network, $url)."</a>"; $network_name = '<a href="'.$url.'">'.ContactSelector::networkToName($network, $url)."</a>";
} else { } else {
$network_name = network_to_name($network); $network_name = ContactSelector::networkToName($network);
} }
return $network_name; return $network_name;
} }
} }
/** /**

View file

@ -4,12 +4,12 @@
* @file mod/allfriends.php * @file mod/allfriends.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php'; require_once 'mod/contacts.php';
function allfriends_content(App $a) function allfriends_content(App $a)
@ -86,7 +86,7 @@ function allfriends_content(App $a)
'tags' => $contact_details['keywords'], 'tags' => $contact_details['keywords'],
'about' => $contact_details['about'], 'about' => $contact_details['about'],
'account_type' => Contact::getAccountType($contact_details), 'account_type' => Contact::getAccountType($contact_details),
'network' => network_to_name($contact_details['network'], $contact_details['url']), 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu, 'photo_menu' => $photo_menu,
'conntxt' => t('Connect'), 'conntxt' => t('Connect'),
'connlnk' => $connlnk, 'connlnk' => $connlnk,

View file

@ -4,11 +4,11 @@
* @file include/common.php * @file include/common.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php'; require_once 'mod/contacts.php';
function common_content(App $a) function common_content(App $a)
@ -130,7 +130,7 @@ function common_content(App $a)
'tags' => $contact_details['keywords'], 'tags' => $contact_details['keywords'],
'about' => $contact_details['about'], 'about' => $contact_details['about'],
'account_type' => Contact::getAccountType($contact_details), 'account_type' => Contact::getAccountType($contact_details),
'network' => network_to_name($contact_details['network'], $contact_details['url']), 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu, 'photo_menu' => $photo_menu,
'id' => ++$id, 'id' => ++$id,
); );

View file

@ -1,9 +1,9 @@
<?php <?php
/** /**
* @file mod/contacts.php * @file mod/contacts.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
@ -12,7 +12,6 @@ use Friendica\Model\GContact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Network\Probe; use Friendica\Network\Probe;
require_once 'include/contact_selectors.php';
require_once 'include/contact_widgets.php'; require_once 'include/contact_widgets.php';
require_once 'mod/proxy.php'; require_once 'mod/proxy.php';
@ -506,8 +505,6 @@ function contacts_content(App $a)
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
)); ));
require_once 'include/contact_selectors.php';
$dir_icon = ''; $dir_icon = '';
$relation_text = ''; $relation_text = '';
switch ($contact['rel']) { switch ($contact['rel']) {
@ -552,7 +549,7 @@ function contacts_content(App $a)
$poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL)); $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL));
$nettype = t('Network type: %s', network_to_name($contact['network'], $contact["url"])); $nettype = t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
// tabs // tabs
$tab_str = contacts_tab($a, $contact_id, 2); $tab_str = contacts_tab($a, $contact_id, 2);
@ -576,12 +573,12 @@ function contacts_content(App $a)
$poll_interval = null; $poll_interval = null;
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL))) { if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL))) {
$poll_interval = contact_poll_interval($contact['priority'], (!$poll_enabled)); $poll_interval = ContactSelector::pollInterval($contact['priority'], (!$poll_enabled));
} }
$profile_select = null; $profile_select = null;
if ($contact['network'] == NETWORK_DFRN) { if ($contact['network'] == NETWORK_DFRN) {
$profile_select = contact_profile_assign($contact['profile-id'], (($contact['network'] !== NETWORK_DFRN) ? true : false)); $profile_select = ContactSelector::profileAssign($contact['profile-id'], (($contact['network'] !== NETWORK_DFRN) ? true : false));
} }
$follow = ''; $follow = '';
@ -808,7 +805,7 @@ function contacts_content(App $a)
$tpl = get_markup_template("contacts-template.tpl"); $tpl = get_markup_template("contacts-template.tpl");
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''), '$header' => t('Contacts') . (($nets) ? ' - ' . ContactSelector::networkToName($nets) : ''),
'$tabs' => $t, '$tabs' => $t,
'$total' => $total, '$total' => $total,
'$search' => $search_hdr, '$search' => $search_hdr,
@ -959,7 +956,7 @@ function _contact_detail_for_template($rr)
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']), 'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
'url' => $url, 'url' => $url,
'network' => network_to_name($rr['network'], $rr['url']), 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
); );
} }

View file

@ -8,7 +8,6 @@ use Friendica\Core\Config;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php'; require_once 'mod/contacts.php';
function crepair_init(App $a) function crepair_init(App $a)

View file

@ -3,6 +3,7 @@
* @file mod/dirfind.php * @file mod/dirfind.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
@ -12,7 +13,6 @@ use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
require_once 'include/contact_widgets.php'; require_once 'include/contact_widgets.php';
require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php'; require_once 'mod/contacts.php';
function dirfind_init(App $a) { function dirfind_init(App $a) {
@ -235,7 +235,7 @@ function dirfind_content(App $a, $prefix = "") {
'tags' => $contact_details['keywords'], 'tags' => $contact_details['keywords'],
'about' => $contact_details['about'], 'about' => $contact_details['about'],
'account_type' => Contact::getAccountType($contact_details), 'account_type' => Contact::getAccountType($contact_details),
'network' => network_to_name($jj->network, $jj->url), 'network' => ContactSelector::networkToName($jj->network, $jj->url),
'id' => ++$id, 'id' => ++$id,
); );
$entries[] = $entry; $entries[] = $entry;

View file

@ -8,7 +8,6 @@ use Friendica\Core\System;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Network\Probe; use Friendica\Network\Probe;
require_once 'include/contact_selectors.php';
function follow_post(App $a) { function follow_post(App $a) {

View file

@ -3,12 +3,11 @@
* @file mod/nogroup.php * @file mod/nogroup.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
require_once 'include/contact_selectors.php';
function nogroup_init(App $a) function nogroup_init(App $a)
{ {
if (! local_user()) { if (! local_user()) {
@ -53,7 +52,7 @@ function nogroup_content(App $a)
'about' => $contact_details['about'], 'about' => $contact_details['about'],
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
'url' => $rr['url'], 'url' => $rr['url'],
'network' => network_to_name($rr['network'], $rr['url']), 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
); );
} }
} }

View file

@ -1,17 +1,15 @@
<?php <?php
/** /**
* @file mod/notifications.php * @file mod/notifications.php
* @brief The notifications module * @brief The notifications module
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\NotificationsManager; use Friendica\Core\NotificationsManager;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
require_once("include/contact_selectors.php"); require_once "include/network.php";
require_once("include/network.php");
function notifications_post(App $a) { function notifications_post(App $a) {
@ -225,7 +223,7 @@ function notifications_content(App $a) {
if ($it["addr"] != "") if ($it["addr"] != "")
$header .= " <".$it["addr"].">"; $header .= " <".$it["addr"].">";
$header .= " (".network_to_name($it['network'], $it['url']).")"; $header .= " (".ContactSelector::networkToName($it['network'], $it['url']).")";
if ($it['network'] != NETWORK_DIASPORA) { if ($it['network'] != NETWORK_DIASPORA) {
$discard = t('Discard'); $discard = t('Discard');
@ -260,7 +258,7 @@ function notifications_content(App $a) {
'$addr' => $it['addr'], '$addr' => $it['addr'],
'$lbl_knowyou' => $lbl_knowyou, '$lbl_knowyou' => $lbl_knowyou,
'$lbl_network' => t('Network:'), '$lbl_network' => t('Network:'),
'$network' => network_to_name($it['network'], $it['url']), '$network' => ContactSelector::networkToName($it['network'], $it['url']),
'$knowyou' => $knowyou, '$knowyou' => $knowyou,
'$approve' => t('Approve'), '$approve' => t('Approve'),
'$note' => $it['note'], '$note' => $it['note'],

View file

@ -3,6 +3,7 @@
* @file mod/suggest.php * @file mod/suggest.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -76,8 +77,6 @@ function suggest_content(App $a) {
return $o; return $o;
} }
require_once 'include/contact_selectors.php';
foreach ($r as $rr) { foreach ($r as $rr) {
$connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']); $connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
@ -106,7 +105,7 @@ function suggest_content(App $a) {
'connlnk' => $connlnk, 'connlnk' => $connlnk,
'photo_menu' => $photo_menu, 'photo_menu' => $photo_menu,
'ignore' => t('Ignore/Hide'), 'ignore' => t('Ignore/Hide'),
'network' => network_to_name($rr['network'], $rr['url']), 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
'id' => ++$id, 'id' => ++$id,
); );
$entries[] = $entry; $entries[] = $entry;

View file

@ -7,8 +7,6 @@ use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
require_once 'include/contact_selectors.php';
function unfollow_post(App $a) { function unfollow_post(App $a) {
if (!local_user()) { if (!local_user()) {

View file

@ -1,12 +1,11 @@
<?php <?php
use Friendica\App; use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
require_once('include/contact_selectors.php');
function viewcontacts_init(App $a) { function viewcontacts_init(App $a) {
if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) { if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
@ -116,7 +115,7 @@ function viewcontacts_content(App $a) {
'url' => $url, 'url' => $url,
'sparkle' => '', 'sparkle' => '',
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
'network' => network_to_name($rr['network'], $rr['url']), 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
); );
} }

View file

@ -0,0 +1,115 @@
<?php
/**
* @file src/Content/ContactSelector.php
*/
namespace Friendica\Content;
use Friendica\Database\DBM;
use Friendica\Protocol\Diaspora;
use dba;
/**
* @brief ContactSelector class
*/
class ContactSelector
{
/**
* @param string $current current
* @param string $foreign_net network
*/
public static function profileAssign($current, $foreign_net)
{
$o = '';
$disabled = (($foreign_net) ? ' disabled="true" ' : '');
$o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
$s = dba::select('profile', ['id', 'profile-name', 'is-default'], ['uid' => $$_SESSION['uid']]);
$r = dba::inArray($s);
if (DBM::is_result($r)) {
foreach ($r as $rr) {
$selected = (($rr['id'] == $current || ($current == 0 && $rr['is-default'] == 1)) ? " selected=\"selected\" " : "");
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
}
}
$o .= "</select>\r\n";
return $o;
}
/**
* @param string $current current
* @param boolean $disabled optional, default false
* @return object
*/
public static function pollInterval($current, $disabled = false)
{
$dis = (($disabled) ? ' disabled="disabled" ' : '');
$o = '';
$o .= "<select id=\"contact-poll-interval\" name=\"poll\" $dis />" . "\r\n";
$rep = array(
0 => t('Frequently'),
1 => t('Hourly'),
2 => t('Twice daily'),
3 => t('Daily'),
4 => t('Weekly'),
5 => t('Monthly')
);
foreach ($rep as $k => $v) {
$selected = (($k == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"$k\" $selected >$v</option>\r\n";
}
$o .= "</select>\r\n";
return $o;
}
/**
* @param string $s network
* @param string $profile optional, default empty
* @return string
*/
public static function networkToName($s, $profile = "")
{
$nets = array(
NETWORK_DFRN => t('Friendica'),
NETWORK_OSTATUS => t('OStatus'),
NETWORK_FEED => t('RSS/Atom'),
NETWORK_MAIL => t('Email'),
NETWORK_DIASPORA => t('Diaspora'),
NETWORK_FACEBOOK => t('Facebook'),
NETWORK_ZOT => t('Zot!'),
NETWORK_LINKEDIN => t('LinkedIn'),
NETWORK_XMPP => t('XMPP/IM'),
NETWORK_MYSPACE => t('MySpace'),
NETWORK_GPLUS => t('Google+'),
NETWORK_PUMPIO => t('pump.io'),
NETWORK_TWITTER => t('Twitter'),
NETWORK_DIASPORA2 => t('Diaspora Connector'),
NETWORK_STATUSNET => t('GNU Social Connector'),
NETWORK_PNUT => t('pnut'),
NETWORK_APPNET => t('App.net')
);
call_hooks('network_to_name', $nets);
$search = array_keys($nets);
$replace = array_values($nets);
$networkname = str_replace($search, $replace, $s);
if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
$r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
if (DBM::is_result($r)) {
$networkname = $r['platform'];
}
}
return $networkname;
}
}

View file

@ -1,12 +1,11 @@
<?php <?php
/** /**
* @file src/Object/Post.php * @file src/Object/Post.php
*/ */
namespace Friendica\Object; namespace Friendica\Object;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Database\DBM; use Friendica\Database\DBM;
@ -397,7 +396,7 @@ class Post extends BaseObject
'thread_level' => $thread_level, 'thread_level' => $thread_level,
'edited' => $edited, 'edited' => $edited,
'network' => $item["item_network"], 'network' => $item["item_network"],
'network_name' => network_to_name($item['item_network'], $profile_link), 'network_name' => ContactSelector::networkToName($item['item_network'], $profile_link),
'received' => $item['received'], 'received' => $item['received'],
'commented' => $item['commented'], 'commented' => $item['commented'],
'created_date' => $item['created'], 'created_date' => $item['created'],