5 function follow_widget($value = "") {
7 return replace_macros(get_markup_template('follow.tpl'), array(
8 '$connect' => t('Add New Contact'),
9 '$desc' => t('Enter address or web location'),
10 '$hint' => t('Example: bob@example.com, http://example.com/barbara'),
12 '$follow' => t('Connect')
17 function findpeople_widget() {
18 require_once 'include/Contact.php';
22 if (get_config('system', 'invitation_only')) {
23 $x = get_pconfig(local_user(), 'system', 'invites_remaining');
24 if ($x || is_site_admin()) {
25 $a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
26 . sprintf( tt('%d invitation available', '%d invitations available', $x), $x)
31 return replace_macros(get_markup_template('peoplefind.tpl'), array(
32 '$findpeople' => t('Find People'),
33 '$desc' => t('Enter name or interest'),
34 '$label' => t('Connect/Follow'),
35 '$hint' => t('Examples: Robert Morgenstein, Fishing'),
36 '$findthem' => t('Find'),
37 '$suggest' => t('Friend Suggestions'),
38 '$similar' => t('Similar Interests'),
39 '$random' => t('Random Profile'),
40 '$inv' => t('Invite Friends'),
41 '$directory' => t('View Global Directory')
46 function unavailable_networks() {
51 if (!plugin_enabled("appnet")) {
52 $networks[] = NETWORK_APPNET;
55 if (!plugin_enabled("fbpost") && !plugin_enabled("facebook")) {
56 $networks[] = NETWORK_FACEBOOK;
59 if (!plugin_enabled("statusnet")) {
60 $networks[] = NETWORK_STATUSNET;
63 if (!plugin_enabled("pumpio")) {
64 $networks[] = NETWORK_PUMPIO;
67 if (!plugin_enabled("twitter")) {
68 $networks[] = NETWORK_TWITTER;
71 if (get_config("system", "ostatus_disabled")) {
72 $networks[] = NETWORK_OSTATUS;
75 if (!get_config("system", "diaspora_enabled")) {
76 $networks[] = NETWORK_DIASPORA;
79 if (!plugin_enabled("pnut")) {
80 $networks[] = NETWORK_PNUT;
83 if (!sizeof($networks)) {
87 $network_filter = implode("','", $networks);
89 $network_filter = "AND `network` NOT IN ('$network_filter')";
91 return $network_filter;
94 function networks_widget($baseurl, $selected = '') {
102 if (!feature_enabled(local_user(), 'networks')) {
106 $extra_sql = unavailable_networks();
108 $r = q("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = %d AND `network` != '' $extra_sql ORDER BY `network`",
113 if (dbm::is_result($r)) {
114 require_once 'include/contact_selectors.php';
115 foreach ($r as $rr) {
116 /// @TODO If 'network' is not there, this triggers an E_NOTICE
117 if ($rr['network']) {
118 $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
123 if (count($nets) < 2) {
127 return replace_macros(get_markup_template('nets.tpl'), array(
128 '$title' => t('Networks'),
130 '$sel_all' => (($selected == '') ? 'selected' : ''),
131 '$all' => t('All Networks'),
138 function fileas_widget($baseurl, $selected = '') {
139 if (! local_user()) {
143 if (! feature_enabled(local_user(), 'filing')) {
147 $saved = get_pconfig(local_user(), 'system', 'filetags');
148 if (! strlen($saved)) {
154 $cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
156 foreach ($matches as $mtch) {
157 $unescaped = xmlify(file_tag_decode($mtch[1]));
158 $terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
162 return replace_macros(get_markup_template('fileas_widget.tpl'), array(
163 '$title' => t('Saved Folders'),
165 '$sel_all' => (($selected == '') ? 'selected' : ''),
166 '$all' => t('Everything'),
173 function categories_widget($baseurl, $selected = '') {
177 if (! feature_enabled($a->profile['profile_uid'], 'categories')) {
181 $saved = get_pconfig($a->profile['profile_uid'], 'system', 'filetags');
182 if (! strlen($saved)) {
188 $cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
191 foreach ($matches as $mtch) {
192 $unescaped = xmlify(file_tag_decode($mtch[1]));
193 $terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
197 return replace_macros(get_markup_template('categories_widget.tpl'), array(
198 '$title' => t('Categories'),
200 '$sel_all' => (($selected == '') ? 'selected' : ''),
201 '$all' => t('Everything'),
208 function common_friends_visitor_widget($profile_uid) {
212 if (local_user() == $profile_uid) {
218 if (is_array($_SESSION['remote'])) {
219 foreach ($_SESSION['remote'] as $visitor) {
220 if ($visitor['uid'] == $profile_uid) {
221 $cid = $visitor['cid'];
229 $r = q("select id from contact where nurl = '%s' and uid = %d limit 1",
230 dbesc(normalise_link(get_my_url())),
233 if (dbm::is_result($r)) {
236 $r = q("select id from gcontact where nurl = '%s' limit 1",
237 dbesc(normalise_link(get_my_url()))
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'),