From b0dc3d3b4cc6c4c4151b2d7882062b6658637955 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 May 2014 21:33:39 -0700 Subject: [PATCH] add photo widget --- doc/Widgets.md | 23 ++++++++++++++--------- include/widgets.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/doc/Widgets.md b/doc/Widgets.md index 0f8d948ff..48006adcd 100644 --- a/doc/Widgets.md +++ b/doc/Widgets.md @@ -6,21 +6,19 @@ Some/many of these widgets have restrictions which may restrict the type of page * clock - displays the current time * args: military (1 or 0) - use 24 hour time as opposed to AM/PM - * +
 
* profile - displays a profile sidebar on pages which load profiles (pages with nickname in the URL) * tagcloud - display a tagcloud of webpage items * args: count - number of items to return (default 24) - * - +
 
* collections - collection selector for the current logged in channel * args: mode - one of "conversation", "group", "abook" depending on module - * - +
 
* suggestions - friend suggestions for the current logged on channel @@ -34,8 +32,7 @@ Some/many of these widgets have restrictions which may restrict the type of page * archive - date range selector for network and channel pages * args: 'wall' - 1 or 0, limit to wall posts or network/matrix posts (default) - * 'style': 'list' or 'select' - presentation format, a select form element or a list, default 'select' - * +
 
* fullprofile - same as profile currently @@ -69,8 +66,16 @@ Some/many of these widgets have restrictions which may restrict the type of page * bookmarkedchats - list of bookmarked chatrooms collected on this site for the current observer -* suggestechats - "interesting" chatrooms chosen for the current observer +* suggestedchats - "interesting" chatrooms chosen for the current observer * item - displays a single webpage item by mid -1 args: mid - message_id of webpage to display + * args: mid - message_id of webpage to display +
 
+ +* photo - display a single photo + * args: + * url - URL of photo, must be http or https + * zrl - use zid authenticated link + * style - CSS style string +
 
diff --git a/include/widgets.php b/include/widgets.php index 1b0e140c0..0f6d70ff7 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -719,4 +719,46 @@ $(document).ready(function() { EOT; return $o; -} \ No newline at end of file +} + + +/** + * @function widget_photo($arr) + * widget to display a single photo. + * @param array $arr; + * 'src' => URL of photo + * 'zrl' => true or false, use zid in url + * 'style' => CSS string + * URL must be an http or https URL + */ + + +function widget_photo($arr) { + + $style = $zrl = false; + $params = ''; + if(array_key_exists('src',$arr) && isset($arr['src'])) + $url = $arr['src']; + + if(strpos($url,'http') !== 0) + return ''; + + if(array_key_exists('style',$arr) && isset($arr['style'])) + $style = $arr['style']; + + if(array_key_exists('zrl',$arr) && isset($arr['zrl'])) + $zrl = (($arr['zrl']) ? true : false); + + if($zrl) + $url = zid($url); + + $o = '
'; + + $o .= ''; + + $o .= '
'; + + return $o; +}