mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 03:35:13 +00:00
random block widget
This commit is contained in:
parent
c785b5a90c
commit
b16f938830
4 changed files with 3461 additions and 3388 deletions
|
@ -90,5 +90,12 @@ Some/many of these widgets have restrictions which may restrict the type of page
|
||||||
* album - album name (very strongly recommended if you have lots of photos)
|
* album - album name (very strongly recommended if you have lots of photos)
|
||||||
* scale - typically 0 (original size), 1 (640px), or 2 (320px)
|
* scale - typically 0 (original size), 1 (640px), or 2 (320px)
|
||||||
* style - CSS style string
|
* style - CSS style string
|
||||||
|
* channel_id - if not your own
|
||||||
|
<br /> <br />
|
||||||
|
|
||||||
|
* random_block - display a random block element from your webpage design tools collection. Permissions are honoured.
|
||||||
|
* args:
|
||||||
|
* contains - only return blocks which include the contains string in the block name
|
||||||
|
* channel_id - if not your own
|
||||||
<br /> <br />
|
<br /> <br />
|
||||||
|
|
||||||
|
|
|
@ -874,3 +874,44 @@ function widget_photo_rand($arr) {
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function widget_random_block($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 = get_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 item_id on item.id = item_id.iid
|
||||||
|
where item.uid = %d and sid like '%s' and service = 'BUILDBLOCK' and
|
||||||
|
item_restrict = %d $sql_options order by $randfunc limit 1",
|
||||||
|
intval($channel_id),
|
||||||
|
dbesc('%' . $contains . '%'),
|
||||||
|
intval(ITEM_BUILDBLOCK)
|
||||||
|
);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
6799
util/messages.po
6799
util/messages.po
File diff suppressed because it is too large
Load diff
|
@ -1 +1 @@
|
||||||
2014-11-20.865
|
2014-11-22.867
|
||||||
|
|
Loading…
Reference in a new issue