Update function names and calls.
* @todo Automatically detect if incoming data is HTML or BBCode
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\System;
use Friendica\Core\Config;
require_once 'mod/share.php';
require_once 'mod/item.php';
require_once 'include/security.php';
-require_once 'include/contact_selectors.php';
require_once 'include/html2bbcode.php';
require_once 'mod/wall_upload.php';
require_once 'mod/proxy.php';
}
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 (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) {
$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);
}
if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) {
- $status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
- } elseif (($lastwall['item_network'] != "") && (network_to_name($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"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']);
+ } elseif (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
+ $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
}
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"])) {
- $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')');
+ 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"] . ' (' . ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) . ')');
}
}
}
if (($item['item_network'] != "") && ($status["source"] == 'web')) {
- $status["source"] = network_to_name($item['item_network'], $user_info['url']);
- } elseif (($item['item_network'] != "") && (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) {
- $status["source"] = trim($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'] != "") && (ContactSelector::networkToName($item['item_network'], $user_info['url']) != $status["source"])) {
+ $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['item_network'], $user_info['url']).')');
}
<?php
-
/**
* @file include/contact_widgets.php
*/
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
-require_once 'include/contact_selectors.php';
-
function follow_widget($value = "")
{
return replace_macros(get_markup_template('follow.tpl'), array(
while ($rr = dba::fetch($r)) {
/// @TODO If 'network' is not there, this triggers an E_NOTICE
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);
* @file include/conversation.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
'id' => (($preview) ? 'P0' : $item['item_id']),
'guid' => (($preview) ? 'Q0' : $item['guid']),
'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'])),
'profile_url' => $profile_link,
'item_photo_menu' => item_photo_menu($item),
* @file include/text.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Smilies;
use Friendica\Core\Config;
*/
function format_network_name($network, $url = 0) {
if ($network != "") {
- require_once 'include/contact_selectors.php';
if ($url != "") {
- $network_name = '<a href="'.$url.'">'.network_to_name($network, $url)."</a>";
+ $network_name = '<a href="'.$url.'">'.ContactSelector::networkToName($network, $url)."</a>";
} else {
- $network_name = network_to_name($network);
+ $network_name = ContactSelector::networkToName($network);
}
return $network_name;
}
-
}
/**
* @file mod/allfriends.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
-require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
function allfriends_content(App $a)
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'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,
'conntxt' => t('Connect'),
'connlnk' => $connlnk,
* @file include/common.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
-require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
function common_content(App $a)
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'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,
'id' => ++$id,
);
<?php
-
/**
* @file mod/contacts.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Group;
use Friendica\Network\Probe;
-require_once 'include/contact_selectors.php';
require_once 'include/contact_widgets.php';
require_once 'mod/proxy.php';
'$baseurl' => System::baseUrl(true),
));
- require_once 'include/contact_selectors.php';
-
$dir_icon = '';
$relation_text = '';
switch ($contact['rel']) {
$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
$tab_str = contacts_tab($a, $contact_id, 2);
$poll_interval = null;
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;
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 = '';
$tpl = get_markup_template("contacts-template.tpl");
$o .= replace_macros($tpl, array(
'$baseurl' => System::baseUrl(),
- '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
+ '$header' => t('Contacts') . (($nets) ? ' - ' . ContactSelector::networkToName($nets) : ''),
'$tabs' => $t,
'$total' => $total,
'$search' => $search_hdr,
'sparkle' => $sparkle,
'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
'url' => $url,
- 'network' => network_to_name($rr['network'], $rr['url']),
+ 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
);
}
* @file mod/dirfind.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Protocol\PortableContact;
require_once 'include/contact_widgets.php';
-require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
function dirfind_init(App $a) {
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
'account_type' => Contact::getAccountType($contact_details),
- 'network' => network_to_name($jj->network, $jj->url),
+ 'network' => ContactSelector::networkToName($jj->network, $jj->url),
'id' => ++$id,
);
$entries[] = $entry;
* @file mod/nogroup.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
-require_once 'include/contact_selectors.php';
-
function nogroup_init(App $a)
{
if (! local_user()) {
'about' => $contact_details['about'],
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
'url' => $rr['url'],
- 'network' => network_to_name($rr['network'], $rr['url']),
+ 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
);
}
}
<?php
-
/**
* @file mod/notifications.php
* @brief The notifications module
*/
-
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\NotificationsManager;
use Friendica\Core\System;
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) {
if ($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) {
$discard = t('Discard');
'$addr' => $it['addr'],
'$lbl_knowyou' => $lbl_knowyou,
'$lbl_network' => t('Network:'),
- '$network' => network_to_name($it['network'], $it['url']),
+ '$network' => ContactSelector::networkToName($it['network'], $it['url']),
'$knowyou' => $knowyou,
'$approve' => t('Approve'),
'$note' => $it['note'],
* @file mod/suggest.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
return $o;
}
- require_once 'include/contact_selectors.php';
-
foreach ($r as $rr) {
$connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
'connlnk' => $connlnk,
'photo_menu' => $photo_menu,
'ignore' => t('Ignore/Hide'),
- 'network' => network_to_name($rr['network'], $rr['url']),
+ 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
'id' => ++$id,
);
$entries[] = $entry;
<?php
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
-require_once('include/contact_selectors.php');
-
function viewcontacts_init(App $a) {
if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
'url' => $url,
'sparkle' => '',
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
- 'network' => network_to_name($rr['network'], $rr['url']),
+ 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
);
}
use Friendica\Database\DBM;
use Friendica\Protocol\Diaspora;
+use dba;
+/**
+ * @brief ContactSelector class
+ */
class ContactSelector
{
- 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;
- }
+ /**
+ * @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;
+ }
+
+ private static 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;
+ }
+
+ 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;
+ }
+
+ 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;
+ }
}
<?php
-
/**
* @file src/Object/Post.php
*/
-
namespace Friendica\Object;
use Friendica\BaseObject;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
'thread_level' => $thread_level,
'edited' => $edited,
'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'],
'commented' => $item['commented'],
'created_date' => $item['created'],