diff options
author | zotlabs <mike@macgirvin.com> | 2017-03-16 17:11:48 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-03-16 17:11:48 -0700 |
commit | 446b5550a2c2b52bb31db5b99602c42b9dfdade6 (patch) | |
tree | bc7cf06be9fe2561bddf29ee3d4a082241b75248 /Zotlabs/Widget/Random_block.php | |
parent | 051759580dc7aff7d5b349b3b5271f054c7d3423 (diff) | |
download | volse-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/Random_block.php')
-rw-r--r-- | Zotlabs/Widget/Random_block.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Random_block.php b/Zotlabs/Widget/Random_block.php new file mode 100644 index 000000000..465a51f97 --- /dev/null +++ b/Zotlabs/Widget/Random_block.php @@ -0,0 +1,46 @@ +<?php + +namespace Zotlabs\Widget; + +class Random_block { + + function widget($arr) { + + $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 ''; + + if(array_key_exists('contains',$arr)) + $contains = $arr['contains']; + + $o = ''; + + require_once('include/security.php'); + $sql_options = item_permissions_sql($channel_id); + + $randfunc = db_getfunc('RAND'); + + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v like '%s' and iconfig.k = 'BUILDBLOCK' and + item_type = %d $sql_options order by $randfunc limit 1", + intval($channel_id), + dbesc('%' . $contains . '%'), + intval(ITEM_TYPE_BLOCK) + ); + + if($r) { + $o = '<div class="widget bblock">'; + if($r[0]['title']) + $o .= '<h3>' . $r[0]['title'] . '</h3>'; + + $o .= prepare_text($r[0]['body'],$r[0]['mimetype']); + $o .= '</div>'; + } + + return $o; + } +} |