diff options
author | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2016-01-16 13:44:23 +0100 |
---|---|---|
committer | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2016-01-16 13:44:23 +0100 |
commit | 983e170f20cfafadab7fb74bf5ca5b56e54205db (patch) | |
tree | 25b39449dcbf0636b5519c3beac2ec70b04510c1 /include | |
parent | 72353bf0446901f1711cba7a2e50dbce9bd06227 (diff) | |
parent | f66c6bfebfd48274c9b29cd62b1fac933c6530e4 (diff) | |
download | volse-hubzilla-983e170f20cfafadab7fb74bf5ca5b56e54205db.tar.gz volse-hubzilla-983e170f20cfafadab7fb74bf5ca5b56e54205db.tar.bz2 volse-hubzilla-983e170f20cfafadab7fb74bf5ca5b56e54205db.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include')
-rw-r--r-- | include/comanche.php | 1 | ||||
-rw-r--r-- | include/contact_selectors.php | 2 | ||||
-rw-r--r-- | include/identity.php | 35 | ||||
-rw-r--r-- | include/widgets.php | 32 |
4 files changed, 69 insertions, 1 deletions
diff --git a/include/comanche.php b/include/comanche.php index ca3ad336b..ddf331321 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -275,6 +275,7 @@ function comanche_widget($name, $text) { $vars = array(); $matches = array(); + $cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER); if ($cnt) { foreach ($matches as $mtch) { diff --git a/include/contact_selectors.php b/include/contact_selectors.php index 8671f1bd1..d44bee784 100644 --- a/include/contact_selectors.php +++ b/include/contact_selectors.php @@ -79,7 +79,7 @@ function network_to_name($s) { NETWORK_MAIL => t('Email'), NETWORK_DIASPORA => t('Diaspora'), NETWORK_FACEBOOK => t('Facebook'), - NETWORK_ZOT => t('Zot!'), + NETWORK_ZOT => t('Zot'), NETWORK_LINKEDIN => t('LinkedIn'), NETWORK_XMPP => t('XMPP/IM'), NETWORK_MYSPACE => t('MySpace'), diff --git a/include/identity.php b/include/identity.php index 1d908056f..deccaa299 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1737,3 +1737,38 @@ function auto_channel_create($account_id) { } +function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) { + + $r = q("select height, width, resource_id, type from photo where uid = %d and scale = %d and photo_usage = %d", + intval($channel_id), + intval($res), + intval(PHOTO_COVER) + ); + if(! $r) + return false; + + $output = false; + + $url = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $res ; + + switch($format) { + case 'bbcode': + $output = '[zrl=' . $r[0]['width'] . 'x' . $r[0]['height'] . ']' . $url . '[/zrl]'; + break; + case 'html': + $output = '<img class="zrl" width="' . $r[0]['width'] . '" height="' . $r[0]['height'] . '" src="' . $url . '" alt="' . t('cover photo') . '" />'; + break; + case 'array': + default: + $output = array( + 'width' => $r[0]['width'], + 'height' => $r[0]['type'], + 'type' => $r[0]['type'], + 'url' => $url + ); + break; + } + + return $output; + +}
\ No newline at end of file diff --git a/include/widgets.php b/include/widgets.php index 033ba44fe..7021ef49d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -936,6 +936,38 @@ function widget_photo($arr) { } +function widget_cover_photo($arr) { + + require_once('include/identity.php'); + $o = ''; + + $channel_id = 0; + if(array_key_exists('channel_id', $arr) && intval($arr['channel_id'])) + $channel_id = intval($arr['channel_id']); + if(! $channel_id) + $channel_id = get_app()->profile_uid; + if(! $channel_id) + return ''; + + if(array_key_exists('style', $arr) && isset($arr['style'])) + $style = $arr['style']; + else + $style = 'width:100%; padding-right: 10px; height: auto;'; + + // ensure they can't sneak in an eval(js) function + + if(strpos($style,'(') !== false) + return ''; + + $c = get_cover_photo($channel_id,'html'); + + if($c) { + $o = '<div class="widget">' . (($style) ? str_replace('alt=',' style="' . $style . '" alt=',$c) : $c) . '</div>'; + } + return $o; +} + + function widget_photo_rand($arr) { require_once('include/photos.php'); |