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
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
namespace Zotlabs\Widget;
class Wiki_pages {
function widget($arr) {
$channelname = ((array_key_exists('channel',$arr)) ? $arr['channel'] : '');
$c = channelx_by_nick($channelname);
if(! $c)
$c = \App::get_channel();
if(! $c)
return '';
$wikiname = '';
if(array_key_exists('refresh', $arr)) {
$not_refresh = (($arr['refresh']=== true) ? false : true);
}
else {
$not_refresh = true;
}
$pages = array();
if(! array_key_exists('resource_id', $arr)) {
$hide = true;
}
else {
$p = \Zotlabs\Lib\NativeWikiPage::page_list($c['channel_id'],get_observer_hash(),$arr['resource_id']);
if($p['pages']) {
$pages = $p['pages'];
$w = $p['wiki'];
// Wiki item record is $w['wiki']
$wikiname = $w['urlName'];
if (!$wikiname) {
$wikiname = '';
}
}
}
$can_create = perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'write_wiki');
$can_delete = ((local_channel() && (local_channel() == \App::$profile['uid'])) ? true : false);
return replace_macros(get_markup_template('wiki_page_list.tpl'), array(
'$hide' => $hide,
'$resource_id' => $arr['resource_id'],
'$not_refresh' => $not_refresh,
'$header' => t('Wiki Pages'),
'$channel' => $channelname,
'$wikiname' => $wikiname,
'$pages' => $pages,
'$canadd' => $can_create,
'$candel' => $can_delete,
'$addnew' => t('Add new page'),
'$pageName' => array('pageName', t('Page name')),
));
}
}
|