aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Photo.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-16 17:11:48 -0700
committerzotlabs <mike@macgirvin.com>2017-03-16 17:11:48 -0700
commit446b5550a2c2b52bb31db5b99602c42b9dfdade6 (patch)
treebc7cf06be9fe2561bddf29ee3d4a082241b75248 /Zotlabs/Widget/Photo.php
parent051759580dc7aff7d5b349b3b5271f054c7d3423 (diff)
downloadvolse-hubzilla-446b5550a2c2b52bb31db5b99602c42b9dfdade6.tar.gz
volse-hubzilla-446b5550a2c2b52bb31db5b99602c42b9dfdade6.tar.bz2
volse-hubzilla-446b5550a2c2b52bb31db5b99602c42b9dfdade6.zip
the rest of the standard widgets converted
Diffstat (limited to 'Zotlabs/Widget/Photo.php')
-rw-r--r--Zotlabs/Widget/Photo.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Photo.php b/Zotlabs/Widget/Photo.php
new file mode 100644
index 000000000..10031f028
--- /dev/null
+++ b/Zotlabs/Widget/Photo.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+
+class Photo {
+
+
+ /**
+ * @brief Widget to display a single photo.
+ *
+ * @param array $arr associative array with
+ * * \e string \b src URL of photo; URL must be an http or https URL
+ * * \e boolean \b zrl use zid in URL
+ * * \e string \b style CSS string
+ *
+ * @return string with parsed HTML
+ */
+
+ function widget($arr) {
+
+ $style = $zrl = false;
+
+ 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'];
+
+ // ensure they can't sneak in an eval(js) function
+
+ if(strpbrk($style, '(\'"<>' ) !== false)
+ $style = '';
+
+ if(array_key_exists('zrl', $arr) && isset($arr['zrl']))
+ $zrl = (($arr['zrl']) ? true : false);
+
+ if($zrl)
+ $url = zid($url);
+
+ $o = '<div class="widget">';
+
+ $o .= '<img ' . (($zrl) ? ' class="zrl" ' : '')
+ . (($style) ? ' style="' . $style . '"' : '')
+ . ' src="' . $url . '" alt="' . t('photo/image') . '">';
+
+ $o .= '</div>';
+
+ return $o;
+ }
+}
+