aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Catcloud.php
blob: 5740caab72cc45423caddd68e447a301bad9a7ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php

namespace Zotlabs\Widget;

/**
 *   * Name: Category cloud
 *   * Description: Display category links in a cloud
 *   * Requires: channel, cards, articles
 */


class Catcloud {

	function widget($arr) {

		if((! \App::$profile['profile_uid']) || (! \App::$profile['channel_hash']))
			return '';

		$limit = ((array_key_exists('limit',$arr)) ? intval($arr['limit']) : 50);

		if(array_key_exists('type',$arr)) {
			switch($arr['type']) {

				case 'cards':

					if(! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_pages'))
						return '';

					return card_catblock(\App::$profile['profile_uid'], $limit, '', \App::$profile['channel_hash']);

				case 'articles':

					if(! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_pages'))
						return '';

					return article_catblock(\App::$profile['profile_uid'], $limit, '', \App::$profile['channel_hash']);


				default:
					break;
			}
		}


		if(! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_stream'))
			return '';

		return catblock(\App::$profile['profile_uid'], $limit, '', \App::$profile['channel_hash']);


	}

}