3 function follow_widget($value = "") {
5 return replace_macros(get_markup_template('follow.tpl'), array(
6 '$connect' => t('Add New Contact'),
7 '$desc' => t('Enter address or web location'),
8 '$hint' => t('Example: bob@example.com, http://example.com/barbara'),
10 '$follow' => t('Connect')
15 function findpeople_widget() {
16 require_once 'include/Contact.php';
20 $x = get_pconfig(local_user(), 'system', 'invites_remaining');
21 if ($x || is_site_admin()) {
22 $a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
23 . sprintf( tt('%d invitation available','%d invitations available', $x), $x)
28 return replace_macros(get_markup_template('peoplefind.tpl'), array(
29 '$findpeople' => t('Find People'),
30 '$desc' => t('Enter name or interest'),
31 '$label' => t('Connect/Follow'),
32 '$hint' => t('Examples: Robert Morgenstein, Fishing'),
33 '$findthem' => t('Find'),
34 '$suggest' => t('Friend Suggestions'),
35 '$similar' => t('Similar Interests'),
36 '$random' => t('Random Profile'),
37 '$inv' => t('Invite Friends')
42 function unavailable_networks() {
47 if (!plugin_enabled("appnet")) {
48 $networks[] = NETWORK_APPNET;
51 if (!plugin_enabled("fbpost") AND !plugin_enabled("facebook")) {
52 $networks[] = NETWORK_FACEBOOK;
55 if (!plugin_enabled("statusnet")) {
56 $networks[] = NETWORK_STATUSNET;
59 if (!plugin_enabled("pumpio")) {
60 $networks[] = NETWORK_PUMPIO;
63 if (!plugin_enabled("twitter")) {
64 $networks[] = NETWORK_TWITTER;
67 if (get_config("system", "ostatus_disabled")) {
68 $networks[] = NETWORK_OSTATUS;
71 if (!get_config("system", "diaspora_enabled")) {
72 $networks[] = NETWORK_DIASPORA;
75 if (!plugin_enabled("pnut")) {
76 $networks[] = NETWORK_PNUT;
79 if (!sizeof($networks)) {
83 $network_filter = implode("','", $networks);
85 $network_filter = "AND `network` NOT IN ('$network_filter')";
87 return $network_filter;
90 function networks_widget($baseurl, $selected = '') {
98 if (!feature_enabled(local_user(),'networks')) {
102 $extra_sql = unavailable_networks();
104 $r = q("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = %d AND `network` != '' $extra_sql ORDER BY `network`",
109 if (dbm::is_result($r)) {
110 require_once 'include/contact_selectors.php';
111 foreach ($r as $rr) {
112 /// @TODO If 'network' is not there, this triggers an E_NOTICE
113 if ($rr['network']) {
114 $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
119 if (count($nets) < 2) {
123 return replace_macros(get_markup_template('nets.tpl'), array(
124 '$title' => t('Networks'),
126 '$sel_all' => (($selected == '') ? 'selected' : ''),
127 '$all' => t('All Networks'),
134 function fileas_widget($baseurl, $selected = '') {
135 if (! local_user()) {
139 if (! feature_enabled(local_user(),'filing')) {
143 $saved = get_pconfig(local_user(),'system', 'filetags');
144 if (! strlen($saved)) {
150 $cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
152 foreach ($matches as $mtch) {
153 $unescaped = xmlify(file_tag_decode($mtch[1]));
154 $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : ''));
158 return replace_macros(get_markup_template('fileas_widget.tpl'), array(
159 '$title' => t('Saved Folders'),
161 '$sel_all' => (($selected == '') ? 'selected' : ''),
162 '$all' => t('Everything'),
169 function categories_widget($baseurl, $selected = '') {
173 if (! feature_enabled($a->profile['profile_uid'],'categories')) {
177 $saved = get_pconfig($a->profile['profile_uid'],'system', 'filetags');
178 if (! strlen($saved)) {
184 $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER);
186 foreach ($matches as $mtch) {
187 $unescaped = xmlify(file_tag_decode($mtch[1]));
188 $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : ''));
192 return replace_macros(get_markup_template('categories_widget.tpl'), array(
193 '$title' => t('Categories'),
195 '$sel_all' => (($selected == '') ? 'selected' : ''),
196 '$all' => t('Everything'),
203 function common_friends_visitor_widget($profile_uid) {
207 if (local_user() == $profile_uid)
212 if (is_array($_SESSION['remote'])) {
213 foreach ($_SESSION['remote'] as $visitor) {
214 if ($visitor['uid'] == $profile_uid) {
215 $cid = $visitor['cid'];
223 $r = q("select id from contact where nurl = '%s' and uid = %d limit 1",
224 dbesc(normalise_link(get_my_url())),
227 if (dbm::is_result($r)) {
230 $r = q("select id from gcontact where nurl = '%s' limit 1",
231 dbesc(normalise_link(get_my_url()))
233 if (dbm::is_result($r))
239 if ($cid == 0 && $zcid == 0) {
243 require_once 'include/socgraph.php';
246 $t = count_common_friends($profile_uid, $cid);
248 $t = count_common_friends_zcid($profile_uid, $zcid);
255 $r = common_friends($profile_uid, $cid, 0, 5, true);
257 $r = common_friends_zcid($profile_uid, $zcid, 0, 5, true);
260 return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
261 '$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
262 '$base' => App::get_baseurl(),
263 '$uid' => $profile_uid,
264 '$cid' => (($cid) ? $cid : '0'),
265 '$linkmore' => (($t > 5) ? 'true' : ''),
266 '$more' => t('show more'),