streams/Zotlabs/Widget/Wiki_pages.php

66 lines
1.4 KiB
PHP
Raw Normal View History

2017-03-16 04:26:28 +00:00
<?php
namespace Zotlabs\Widget;
class Wiki_pages {
function widget($arr) {
if(argc() < 3)
return;
if(! $arr['resource_id']) {
2017-03-16 04:26:28 +00:00
2017-03-18 23:41:43 +00:00
$c = \App::get_channel();
if(! $c)
$c = channelx_by_nick(argv(1));
2017-03-18 23:41:43 +00:00
$w = \Zotlabs\Lib\NativeWiki::exists_by_name($c['channel_id'],argv(2));
$arr = array(
'resource_id' => $w['resource_id'],
'channel_id' => $c['channel_id'],
'channel_address' => $c['channel_address'],
'refresh' => false
);
2017-03-16 04:26:28 +00:00
}
$wikiname = '';
2017-03-16 04:26:28 +00:00
$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 = '';
2017-03-16 04:26:28 +00:00
}
}
$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'],
2017-03-16 04:26:28 +00:00
'$wikiname' => $wikiname,
'$pages' => $pages,
'$canadd' => $can_create,
'$candel' => $can_delete,
'$addnew' => t('Add new page'),
'$pageName' => array('pageName', t('Page name')),
'$refresh' => $arr['refresh']
2017-03-16 04:26:28 +00:00
));
}
}