' . $str . '
';
- }
- return $o;
-}}
// wrapper to load a view template, checking for alternate
@@ -1649,13 +1849,19 @@ function format_like($cnt,$arr,$type,$id) {
if(! function_exists('load_view_file')) {
function load_view_file($s) {
+ global $lang, $a;
+ if(! isset($lang))
+ $lang = 'en';
$b = basename($s);
$d = dirname($s);
- $lang = get_config('system','language');
- if($lang === false)
- $lang = 'en';
if(file_exists("$d/$lang/$b"))
return file_get_contents("$d/$lang/$b");
+
+ $theme = current_theme();
+
+ if(file_exists("$d/theme/$theme/$b"))
+ return file_get_contents("$d/theme/$theme/$b");
+
return file_get_contents($s);
}}
@@ -1739,29 +1945,6 @@ return str_replace ("%","=",rawurlencode($s));
}}
-if(! function_exists('like_puller')) {
-function like_puller($a,$item,&$arr,$mode) {
-
- $url = '';
- $sparkle = '';
- $verb = (($mode === 'like') ? ACTIVITY_LIKE : ACTIVITY_DISLIKE);
-
- if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
- $url = $item['author-link'];
- if(($item['network'] === 'dfrn') && (! $item['self']) && ($item['author-link'] == $item['url'])) {
- $url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
- $sparkle = ' class="sparkle" ';
- }
- if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l']))))
- $arr[$item['parent'] . '-l'] = array();
- if(! isset($arr[$item['parent']]))
- $arr[$item['parent']] = 1;
- else
- $arr[$item['parent']] ++;
- $arr[$item['parent'] . '-l'][] = '';
+ $o .= '
';
$o .= '
';
@@ -1831,6 +2005,35 @@ function contact_block() {
}}
+if(! function_exists('micropro')) {
+function micropro($contact, $redirect = false, $class = '') {
+
+ if($class)
+ $class = ' ' . $class;
+
+ $url = $contact['url'];
+ $sparkle = '';
+
+ if($redirect) {
+ $a = get_app();
+ $redirect_url = $a->get_baseurl() . '/redir/' . $contact['id'];
+ if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === 'dfrn')) {
+ $url = $redirect_url;
+ $sparkle = ' sparkle';
+ }
+ }
+ $click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : '');
+ if($click)
+ $url = '';
+ return '
' . "\r\n";
+}}
+
+
+
if(! function_exists('search')) {
function search($s) {
$a = get_app();
@@ -1900,7 +2103,7 @@ function aes_encrypt($val,$ky)
if(! function_exists('linkify')) {
function linkify($s) {
- $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", '
$1', $s);
+ $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+]*)/", '
$1', $s);
return($s);
}}
@@ -1922,8 +2125,11 @@ function smilies($s) {
$a = get_app();
return str_replace(
- array( ':-)', ';-)', ':-(', ':(', ':-P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O'),
+ array( '<3', '</3', '<\\3', ':-)', ';-)', ':-(', ':(', ':-P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O'),
array(
+ '
',
+ '
',
+ '
',
'
',
'
',
'
',
@@ -2044,7 +2250,7 @@ function profile_sidebar($profile) {
$tabs = '';
- $photo = '
';
+ $photo = '
';
$connect = (($profile['uid'] != local_user()) ? '
' . t('Connect') . '' : '');
@@ -2072,9 +2278,9 @@ function profile_sidebar($profile) {
$pubkey = ((x($profile,'pubkey') == 1) ? '
' . $profile['pubkey'] . '
' : '');
- $marital = ((x($profile,'marital') == 1) ? '
♥ ' . t('Status:') . ' ' . $profile['marital'] . '
' . t('Birthdays this week:') . '
';
+ $total = 0;
+ foreach($r as $rr)
+ if(strlen($rr['name']))
+ $total ++;
+
+ $o .= '
' . t('Birthday Reminders') . ' ' . '(' . $total . ')' . '
';
+ $o .= '
' . t('Birthdays this week:') . '
';
$o .= '
' . t("\x28Adjusted for local time\x29") . '
';
$o .= '
';
foreach($r as $rr) {
+ if(! strlen($rr['name']))
+ continue;
$now = strtotime('now');
$today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
@@ -2211,7 +2424,7 @@ function get_birthdays() {
. '
' ;
}
- $o .= '
';
+ $o .= '';
}
return $o;
@@ -2241,10 +2454,15 @@ function link_compare($a,$b) {
if(! function_exists('prepare_body')) {
function prepare_body($item) {
+ return prepare_text($item['body']);
+}}
+
+if(! function_exists('prepare_text')) {
+function prepare_text($text) {
require_once('include/bbcode.php');
- $s = smilies(bbcode($item['body']));
+ $s = smilies(bbcode($text));
return $s;
}}
@@ -2263,15 +2481,187 @@ function prepare_body($item) {
* $cmd and string args are surrounded with ""
*/
-if(! function_exists('run_proc')) {
+if(! function_exists('proc_run')) {
function proc_run($cmd){
+
+ $a = get_app();
+
$args = func_get_args();
call_hooks("proc_run", $args);
+
+ if(count($args) && $args[0] === 'php')
+ $args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
- foreach ($args as &$arg){
- if(is_string($arg)) $arg='"'.$arg.'"';
+ foreach ($args as $arg){
+ $arg = escapeshellarg($arg);
}
$cmdline = implode($args," ");
proc_close(proc_open($cmdline." &",array(),$foo));
}}
+if(! function_exists('current_theme')) {
+function current_theme(){
+ $app_base_themes = array('duepuntozero', 'loozah');
+
+ $a = get_app();
+
+ $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
+ $theme_name = ((x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
+
+ if($theme_name && file_exists('view/theme/' . $theme_name . '/style.css'))
+ return($theme_name);
+
+ foreach($app_base_themes as $t) {
+ if(file_exists('view/theme/' . $t . '/style.css'))
+ return($t);
+ }
+
+ $fallback = glob('view/theme/*/style.css');
+ if(count($fallback))
+ return (str_replace('view/theme/','', str_replace("/style.css","",$fallback[0])));
+
+}}
+
+/*
+* Return full URL to theme which is currently in effect.
+* Provide a sane default if nothing is chosen or the specified theme does not exist.
+*/
+if(! function_exists('current_theme_url')) {
+function current_theme_url() {
+ global $a;
+ $t = current_theme();
+ return($a->get_baseurl() . '/view/theme/' . $t . '/style.css');
+}}
+
+if(! function_exists('feed_birthday')) {
+function feed_birthday($uid,$tz) {
+
+ /**
+ *
+ * Determine the next birthday, but only if the birthday is published
+ * in the default profile. We _could_ also look for a private profile that the
+ * recipient can see, but somebody could get mad at us if they start getting
+ * public birthday greetings when they haven't made this info public.
+ *
+ * Assuming we are able to publish this info, we are then going to convert
+ * the start time from the owner's timezone to UTC.
+ *
+ * This will potentially solve the problem found with some social networks
+ * where birthdays are converted to the viewer's timezone and salutations from
+ * elsewhere in the world show up on the wrong day. We will convert it to the
+ * viewer's timezone also, but first we are going to convert it from the birthday
+ * person's timezone to GMT - so the viewer may find the birthday starting at
+ * 6:00PM the day before, but that will correspond to midnight to the birthday person.
+ *
+ */
+
+ $birthday = '';
+
+ $p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+
+ if($p && count($p)) {
+ $tmp_dob = substr($p[0]['dob'],5);
+ if(intval($tmp_dob)) {
+ $y = datetime_convert($tz,$tz,'now','Y');
+ $bd = $y . '-' . $tmp_dob . ' 00:00';
+ $t_dob = strtotime($bd);
+ $now = strtotime(datetime_convert($tz,$tz,'now'));
+ if($t_dob < $now)
+ $bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
+ $birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME);
+ }
+ }
+
+ return $birthday;
+}}
+
+/**
+ * return atom link elements for all of our hubs
+ */
+
+if(! function_exists('feed_hublinks')) {
+function feed_hublinks() {
+
+ $hub = get_config('system','huburl');
+
+ $hubxml = '';
+ if(strlen($hub)) {
+ $hubs = explode(',', $hub);
+ if(count($hubs)) {
+ foreach($hubs as $h) {
+ $h = trim($h);
+ if(! strlen($h))
+ continue;
+ $hubxml .= '