4 use Friendica\Core\Config;
6 function follow_widget($value = "") {
8 return replace_macros(get_markup_template('follow.tpl'), array(
9 '$connect' => t('Add New Contact'),
10 '$desc' => t('Enter address or web location'),
11 '$hint' => t('Example: bob@example.com, http://example.com/barbara'),
13 '$follow' => t('Connect')
18 function findpeople_widget() {
19 require_once 'include/Contact.php';
22 $global_dir = Config::get('system', 'directory');
24 if (get_config('system', 'invitation_only')) {
25 $x = get_pconfig(local_user(), 'system', 'invites_remaining');
26 if ($x || is_site_admin()) {
27 $a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
28 . sprintf( tt('%d invitation available', '%d invitations available', $x), $x)
33 return replace_macros(get_markup_template('peoplefind.tpl'), array(
34 '$findpeople' => t('Find People'),
35 '$desc' => t('Enter name or interest'),
36 '$label' => t('Connect/Follow'),
37 '$hint' => t('Examples: Robert Morgenstein, Fishing'),
38 '$findthem' => t('Find'),
39 '$suggest' => t('Friend Suggestions'),
40 '$similar' => t('Similar Interests'),
41 '$random' => t('Random Profile'),
42 '$inv' => t('Invite Friends'),
43 '$directory' => t('View Global Directory'),
44 '$global_dir' => $global_dir
49 function unavailable_networks() {
54 if (!plugin_enabled("appnet")) {
55 $networks[] = NETWORK_APPNET;
58 if (!plugin_enabled("fbpost") && !plugin_enabled("facebook")) {
59 $networks[] = NETWORK_FACEBOOK;
62 if (!plugin_enabled("statusnet")) {
63 $networks[] = NETWORK_STATUSNET;
66 if (!plugin_enabled("pumpio")) {
67 $networks[] = NETWORK_PUMPIO;
70 if (!plugin_enabled("twitter")) {
71 $networks[] = NETWORK_TWITTER;
74 if (get_config("system", "ostatus_disabled")) {
75 $networks[] = NETWORK_OSTATUS;
78 if (!get_config("system", "diaspora_enabled")) {
79 $networks[] = NETWORK_DIASPORA;
82 if (!plugin_enabled("pnut")) {
83 $networks[] = NETWORK_PNUT;
86 if (!sizeof($networks)) {
90 $network_filter = implode("','", $networks);
92 $network_filter = "AND `network` NOT IN ('$network_filter')";
94 return $network_filter;
97 function networks_widget($baseurl, $selected = '') {
105 if (!feature_enabled(local_user(), 'networks')) {
109 $extra_sql = unavailable_networks();
111 $r = dba::p("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = ? AND `network` != '' $extra_sql ORDER BY `network`",
116 if (dbm::is_result($r)) {
117 require_once 'include/contact_selectors.php';
118 while ($rr = dba::fetch($r)) {
119 /// @TODO If 'network' is not there, this triggers an E_NOTICE
120 if ($rr['network']) {
121 $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
127 if (count($nets) < 2) {
131 return replace_macros(get_markup_template('nets.tpl'), array(
132 '$title' => t('Networks'),
134 '$sel_all' => (($selected == '') ? 'selected' : ''),
135 '$all' => t('All Networks'),
142 function fileas_widget($baseurl, $selected = '') {
143 if (! local_user()) {
147 if (! feature_enabled(local_user(), 'filing')) {
151 $saved = get_pconfig(local_user(), 'system', 'filetags');
152 if (! strlen($saved)) {
158 $cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
160 foreach ($matches as $mtch) {
161 $unescaped = xmlify(file_tag_decode($mtch[1]));
162 $terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
166 return replace_macros(get_markup_template('fileas_widget.tpl'), array(
167 '$title' => t('Saved Folders'),
169 '$sel_all' => (($selected == '') ? 'selected' : ''),
170 '$all' => t('Everything'),
177 function categories_widget($baseurl, $selected = '') {
181 if (! feature_enabled($a->profile['profile_uid'], 'categories')) {
185 $saved = get_pconfig($a->profile['profile_uid'], 'system', 'filetags');
186 if (! strlen($saved)) {
192 $cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
195 foreach ($matches as $mtch) {
196 $unescaped = xmlify(file_tag_decode($mtch[1]));
197 $terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
201 return replace_macros(get_markup_template('categories_widget.tpl'), array(
202 '$title' => t('Categories'),
204 '$sel_all' => (($selected == '') ? 'selected' : ''),
205 '$all' => t('Everything'),
212 function common_friends_visitor_widget($profile_uid) {
216 if (local_user() == $profile_uid) {
222 if (is_array($_SESSION['remote'])) {
223 foreach ($_SESSION['remote'] as $visitor) {
224 if ($visitor['uid'] == $profile_uid) {
225 $cid = $visitor['cid'];
233 $r = dba::select('contact', array('id'),
234 array('nurl' => normalise_link(get_my_url()), 'uid' => $profile_uid), array('limit' => 1));
235 if (dbm::is_result($r)) {
238 $r = dba::select('gcontact', array('id'), array('nurl' => normalise_link(get_my_url())), array('limit' => 1));
239 if (dbm::is_result($r))
245 if ($cid == 0 && $zcid == 0) {
249 require_once 'include/socgraph.php';
252 $t = count_common_friends($profile_uid, $cid);
254 $t = count_common_friends_zcid($profile_uid, $zcid);
261 $r = common_friends($profile_uid, $cid, 0, 5, true);
263 $r = common_friends_zcid($profile_uid, $zcid, 0, 5, true);
266 return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
267 '$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
268 '$base' => App::get_baseurl(),
269 '$uid' => $profile_uid,
270 '$cid' => (($cid) ? $cid : '0'),
271 '$linkmore' => (($t > 5) ? 'true' : ''),
272 '$more' => t('show more'),