]> git.mxchange.org Git - friendica.git/commitdiff
Update functions and calls
authorAdam Magness <adam.magness@gmail.com>
Wed, 10 Jan 2018 03:42:04 +0000 (22:42 -0500)
committerAdam Magness <adam.magness@gmail.com>
Wed, 10 Jan 2018 03:42:04 +0000 (22:42 -0500)
Update function names and calls.

14 files changed:
include/api.php
include/contact_widgets.php
include/conversation.php
include/text.php
mod/allfriends.php
mod/common.php
mod/contacts.php
mod/dirfind.php
mod/nogroup.php
mod/notifications.php
mod/suggest.php
mod/viewcontacts.php
src/Content/ContactSelector.php
src/Object/Post.php

index e527cb003bb756b5bb94f4d0f8efae1bc020de50..bc60590a513799017ee7b379519899207796e2c7 100644 (file)
@@ -6,6 +6,7 @@
  * @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;
@@ -38,7 +39,6 @@ require_once 'include/html2plain.php';
 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';
@@ -610,7 +610,7 @@ function api_get_user(App $a, $contact_id = null)
                }
 
                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'])) {
@@ -734,7 +734,7 @@ function api_get_user(App $a, $contact_id = null)
                $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);
 
@@ -1405,9 +1405,9 @@ function api_status_show($type)
                }
 
                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
@@ -1496,11 +1496,11 @@ function api_users_show($type)
                }
 
                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']) . ')');
                }
        }
 
@@ -3131,9 +3131,9 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
                }
 
                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']).')');
                }
 
 
index 55e119c3fa55617b27c64d69ce3f39d465e82c2e..a1c93f142b2aaf1297c292aaddf5fe1353ce3c31 100644 (file)
@@ -1,8 +1,8 @@
 <?php
-
 /**
  * @file include/contact_widgets.php
  */
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Core\System;
 use Friendica\Core\Config;
@@ -10,8 +10,6 @@ use Friendica\Core\PConfig;
 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(
@@ -119,7 +117,7 @@ function networks_widget($baseurl, $selected = '')
        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);
index 472896ffec2e45c3d342e8d11cd036bd1c2a8f05..423d9884e778a5b293746256ab5e1dbc8a28cbae 100644 (file)
@@ -3,6 +3,7 @@
  * @file include/conversation.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
@@ -776,7 +777,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                                        '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),
index 0b763d687c69294752cbc64ade24f198748fc932..7ed561bbbbf0d21aae96885e4c85089d1f863dc5 100644 (file)
@@ -3,6 +3,7 @@
  * @file include/text.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Content\Smilies;
 use Friendica\Core\Config;
@@ -2048,16 +2049,14 @@ function formatBytes($bytes, $precision = 2) {
  */
 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;
        }
-
 }
 
 /**
index 9d6a6b0c7bda9345be974c35ba2f3ece97806718..88dddb3ee66f9256f0b953d41d81e89e78f6f50a 100644 (file)
@@ -4,12 +4,12 @@
  * @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)
@@ -86,7 +86,7 @@ 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,
index fc8829aa51a1c42a8fa5765eca123788fec4dd87..1f1e8c33770f6b99bcbd46af57f803aaa59fccee 100644 (file)
@@ -4,11 +4,11 @@
  * @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)
@@ -130,7 +130,7 @@ 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,
                );
index f673f84f1039ed61dc0d32ec4e4679385af4e760..a63591713a70343c710aa702b88ce966fa012709 100644 (file)
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * @file mod/contacts.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
@@ -12,7 +12,6 @@ use Friendica\Model\GContact;
 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';
 
@@ -506,8 +505,6 @@ function contacts_content(App $a)
                        '$baseurl' => System::baseUrl(true),
                ));
 
-               require_once 'include/contact_selectors.php';
-
                $dir_icon = '';
                $relation_text = '';
                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));
 
-               $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);
@@ -576,12 +573,12 @@ function contacts_content(App $a)
 
                $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 = '';
@@ -808,7 +805,7 @@ function contacts_content(App $a)
        $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,
@@ -959,7 +956,7 @@ function _contact_detail_for_template($rr)
                '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']),
        );
 }
 
index bef89a4794ce1f74b0bf7da01cdd3b74244a9792..06bb1d8da6684a847f6635587939ed1e3eacf915 100644 (file)
@@ -3,6 +3,7 @@
  * @file mod/dirfind.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\Config;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
@@ -12,7 +13,6 @@ use Friendica\Network\Probe;
 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) {
@@ -235,7 +235,7 @@ function dirfind_content(App $a, $prefix = "") {
                                        '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;
index 9f5425d9eb7c36604432d2106b895cd8ef75b723..7ebb5bd1f2179852e57ace38dbfa0cbd764c92ed 100644 (file)
@@ -3,12 +3,11 @@
  * @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()) {
@@ -53,7 +52,7 @@ function nogroup_content(App $a)
                                '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']),
                        );
                }
        }
index fe8422cc4a80a31460923c07fd44dc257893675d..e2de81e6c7f24a7f49dfe41602298fbe7c1d0b10 100644 (file)
@@ -1,17 +1,15 @@
 <?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) {
 
@@ -225,7 +223,7 @@ function notifications_content(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');
@@ -260,7 +258,7 @@ function notifications_content(App $a) {
                                                '$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'],
index deda2b2c6c93bbfdb5738c6807ac2d5b4ddad0a3..05a720f7b986704c48c5471c3d4f3fd2417bdbf6 100644 (file)
@@ -3,6 +3,7 @@
  * @file mod/suggest.php
  */
 use Friendica\App;
+use Friendica\Content\ContactSelector;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
@@ -76,8 +77,6 @@ function suggest_content(App $a) {
                return $o;
        }
 
-       require_once 'include/contact_selectors.php';
-
        foreach ($r as $rr) {
 
                $connlnk = System::baseUrl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
@@ -106,7 +105,7 @@ function suggest_content(App $a) {
                        '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;
index 1b4ff69c00285ad4b61f6536b0f4db084d479774..e4ebe3abb2d7e3e4095080ce168d548f225bd7cd 100644 (file)
@@ -1,12 +1,11 @@
 <?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())) {
@@ -116,7 +115,7 @@ function viewcontacts_content(App $a) {
                        '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']),
                );
        }
 
index c3db2406e303589d67973502cbc623c83154cd7e..bd8bcc989beefa14c74f1abb02dcc361e19d0d2e 100644 (file)
@@ -6,114 +6,122 @@ namespace Friendica\Content;
 
 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;
+       }
 }
index 97768bf56cd79c663d821e3f49da7c1ea89623cb..9ef00949f4f14d27f3ab81de8e3b688d0064232f 100644 (file)
@@ -1,12 +1,11 @@
 <?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;
@@ -397,7 +396,7 @@ class Post extends BaseObject
                        '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'],