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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<?php
namespace Zotlabs\Widget;
use Zotlabs\Lib\NativeWiki;
class Wiki_pages {
function create_missing_page($arr) {
if(argc() < 4)
return;
$c = channelx_by_nick(argv(1));
$w = \Zotlabs\Lib\NativeWiki::exists_by_name($c['channel_id'],NativeWiki::name_decode(argv(2)));
$arr = array(
'resource_id' => $w['resource_id'],
'channel_id' => $c['channel_id'],
'channel_address' => $c['channel_address'],
'refresh' => false
);
$can_create = perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'write_wiki');
$can_delete = ((local_channel() && (local_channel() == \App::$profile['uid'])) ? true : false);
$pageName = NativeWiki::name_decode(escape_tags(argv(3)));
$wikiname = $w['urlName'];
return replace_macros(get_markup_template('wiki_page_not_found.tpl'), array(
'$resource_id' => $arr['resource_id'],
'$channel_address' => $arr['channel_address'],
'$wikiname' => $wikiname,
'$canadd' => $can_create,
'$candel' => $can_delete,
'$addnew' => t('Add new page'),
'$typelock' => $typelock,
'$lockedtype' => $w['mimeType'],
'$mimetype' => mimetype_select(0,$w['mimeType'],
[ 'text/markdown' => t('Markdown'), 'text/bbcode' => t('BBcode'), 'text/plain' => t('Text') ]),
'$pageName' => array('missingPageName', 'Create Page' , $pageName),
'$refresh' => $arr['refresh'],
'$options' => t('Options'),
'$submit' => t('Submit')
));
}
function widget($arr) {
if(argc() < 3)
return;
if(! $arr['resource_id']) {
$c = channelx_by_nick(argv(1));
$w = \Zotlabs\Lib\NativeWiki::exists_by_name($c['channel_id'],NativeWiki::name_decode(argv(2)));
$arr = array(
'resource_id' => $w['resource_id'],
'channel_id' => $c['channel_id'],
'channel_address' => $c['channel_address'],
'refresh' => false
);
}
$wikiname = '';
$pages = array();
$p = \Zotlabs\Lib\NativeWikiPage::page_list($arr['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 = '';
}
$typelock = $w['typelock'];
}
$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(
'$resource_id' => $arr['resource_id'],
'$header' => t('Wiki Pages'),
'$channel_address' => $arr['channel_address'],
'$wikiname' => $wikiname,
'$pages' => $pages,
'$canadd' => $can_create,
'$candel' => $can_delete,
'$addnew' => t('Add new page'),
'$typelock' => $typelock,
'$lockedtype' => $w['mimeType'],
'$mimetype' => mimetype_select(0,$w['mimeType'],
[ 'text/markdown' => t('Markdown'), 'text/bbcode' => t('BBcode'), 'text/plain' => t('Text') ]),
'$pageName' => array('pageName', t('Page name')),
'$refresh' => $arr['refresh'],
'$options' => t('Options'),
'$submit' => t('Submit')
));
}
}
|