';
@@ -1523,6 +1783,10 @@ function contact_block() {
$o .= '
';
}
+
+ $arr = array('contacts' => $r, 'output' => $o);
+
+ call_hooks('contact_block_end', $arr);
return $o;
}}
@@ -1585,8 +1849,266 @@ function aes_encrypt($val,$ky)
return mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv( mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM));
}}
+
+/**
+ *
+ * Function: linkify
+ *
+ * Replace naked text hyperlink with HTML formatted hyperlink
+ *
+ */
+
if(! function_exists('linkify')) {
function linkify($s) {
$s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", '
$1', $s);
return($s);
-}}
\ No newline at end of file
+}}
+
+
+/**
+ *
+ * Function: smilies
+ *
+ * Description:
+ * Replaces text emoticons with graphical images
+ *
+ * @Parameter: string $s
+ *
+ * Returns string
+ */
+
+if(! function_exists('smilies')) {
+function smilies($s) {
+ $a = get_app();
+
+ return str_replace(
+ array( ':-)', ';-)', ':-(', ':(', ':-P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O'),
+ array(
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
'
+ ), $s);
+}}
+
+
+/**
+ *
+ * Function : profile_load
+ * @parameter App $a
+ * @parameter string $nickname
+ * @parameter int $profile
+ *
+ * Summary: Loads a profile into the page sidebar.
+ * The function requires a writeable copy of the main App structure, and the nickname
+ * of a registered local account.
+ *
+ * If the viewer is an authenticated remote viewer, the profile displayed is the
+ * one that has been configured for his/her viewing in the Contact manager.
+ * Passing a non-zero profile ID can also allow a preview of a selected profile
+ * by the owner.
+ *
+ * Profile information is placed in the App structure for later retrieval.
+ * Honours the owner's chosen theme for display.
+ *
+ */
+
+if(! function_exists('profile_load')) {
+function profile_load(&$a, $nickname, $profile = 0) {
+ if(remote_user()) {
+ $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
+ intval($_SESSION['visitor_id']));
+ if(count($r))
+ $profile = $r[0]['profile-id'];
+ }
+
+ $r = null;
+
+ if($profile) {
+ $profile_int = intval($profile);
+ $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile`
+ LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
+ WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d LIMIT 1",
+ dbesc($nickname),
+ intval($profile_int)
+ );
+ }
+ if(! count($r)) {
+ $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile`
+ LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
+ WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 LIMIT 1",
+ dbesc($nickname)
+ );
+ }
+
+ if(($r === false) || (! count($r))) {
+ notice( t('No profile') . EOL );
+ $a->error = 404;
+ return;
+ }
+
+ $a->profile = $r[0];
+
+
+ $a->page['title'] = $a->profile['name'];
+ $_SESSION['theme'] = $a->profile['theme'];
+
+ if(! (x($a->page,'aside')))
+ $a->page['aside'] = '';
+
+ $a->page['aside'] .= profile_sidebar($a->profile);
+ $a->page['aside'] .= contact_block();
+
+ return;
+}}
+
+
+/**
+ *
+ * Function: profile_sidebar
+ *
+ * Formats a profile for display in the sidebar.
+ * It is very difficult to templatise the HTML completely
+ * because of all the conditional logic.
+ *
+ * @parameter: array $profile
+ *
+ * Returns HTML string stuitable for sidebar inclusion
+ * Exceptions: Returns empty string if passed $profile is wrong type or not populated
+ *
+ */
+
+
+if(! function_exists('profile_sidebar')) {
+function profile_sidebar($profile) {
+
+ $o = '';
+ $location = '';
+ $address = false;
+
+ if((! is_array($profile)) && (! count($profile)))
+ return $o;
+
+ $fullname = '
' . $profile['name'] . '
';
+
+ $tabs = '';
+
+ $photo = '
';
+
+ $connect = (($profile['uid'] != local_user()) ? '
' . t('Connect') . '' : '');
+
+ if((x($profile,'address') == 1)
+ || (x($profile,'locality') == 1)
+ || (x($profile,'region') == 1)
+ || (x($profile,'postal-code') == 1)
+ || (x($profile,'country-name') == 1))
+ $address = true;
+
+ if($address) {
+ $location .= '
' . t('Location:') . ' ';
+ $location .= ((x($profile,'address') == 1) ? '
' . $profile['address'] . '
' : '');
+ $location .= (((x($profile,'locality') == 1) || (x($profile,'region') == 1) || (x($profile,'postal-code') == 1))
+ ? '
' . $profile['locality'] . ''
+ . ((x($profile['locality']) == 1) ? t(', ') : '')
+ . '' . $profile['region'] . ''
+ . ' ' . $profile['postal-code'] . '' : '');
+ $location .= ((x($profile,'country-name') == 1) ? '
' . $profile['country-name'] . '' : '');
+ $location .= '
';
+
+ }
+
+ $gender = ((x($profile,'gender') == 1) ? '
' . t('Gender:') . ' ' . $profile['gender'] . '
' : '');
+
+ $pubkey = ((x($profile,'pubkey') == 1) ? '
' . $profile['pubkey'] . '
' : '');
+
+ $marital = ((x($profile,'marital') == 1) ? '
♥ ' . t('Status:') . ' ' . $profile['marital'] . '