aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Cover_photo.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-16 17:11:48 -0700
committerMario Vavti <mario@mariovavti.com>2017-03-29 12:02:09 +0200
commit0bad26e116499d9b656c28f64c81275df4bbecb6 (patch)
treea5a30a33e97db03bb7fdeb156045ba41205546e8 /Zotlabs/Widget/Cover_photo.php
parentcd57483ed9069a26b52ae8d7d74fdc537da89946 (diff)
downloadvolse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.tar.gz
volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.tar.bz2
volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.zip
the rest of the standard widgets converted
Diffstat (limited to 'Zotlabs/Widget/Cover_photo.php')
-rw-r--r--Zotlabs/Widget/Cover_photo.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Cover_photo.php b/Zotlabs/Widget/Cover_photo.php
new file mode 100644
index 000000000..d2eb1be92
--- /dev/null
+++ b/Zotlabs/Widget/Cover_photo.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Cover_photo {
+
+ function widget($arr) {
+
+ require_once('include/channel.php');
+ $o = '';
+
+ if(\App::$module == 'channel' && $_REQUEST['mid'])
+ return '';
+
+ $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 = \App::$profile_uid;
+ if(! $channel_id)
+ return '';
+
+ $channel = channelx_by_n($channel_id);
+
+ if(array_key_exists('style', $arr) && isset($arr['style']))
+ $style = $arr['style'];
+ else
+ $style = 'width:100%; height: auto;';
+
+ // ensure they can't sneak in an eval(js) function
+
+ if(strpbrk($style,'(\'"<>') !== false)
+ $style = '';
+
+ if(array_key_exists('title', $arr) && isset($arr['title']))
+ $title = $arr['title'];
+ else
+ $title = $channel['channel_name'];
+
+ if(array_key_exists('subtitle', $arr) && isset($arr['subtitle']))
+ $subtitle = $arr['subtitle'];
+ else
+ $subtitle = str_replace('@','&#x40;',$channel['xchan_addr']);
+
+ $c = get_cover_photo($channel_id,'html');
+
+ if($c) {
+ $photo_html = (($style) ? str_replace('alt=',' style="' . $style . '" alt=',$c) : $c);
+
+ $o = replace_macros(get_markup_template('cover_photo_widget.tpl'),array(
+ '$photo_html' => $photo_html,
+ '$title' => $title,
+ '$subtitle' => $subtitle,
+ '$hovertitle' => t('Click to show more'),
+ ));
+ }
+ return $o;
+ }
+}