aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Wiki.php18
-rw-r--r--Zotlabs/Widget/Wiki_pages.php57
-rw-r--r--view/tpl/wiki.tpl19
-rw-r--r--view/tpl/wiki_page_list.tpl16
4 files changed, 57 insertions, 53 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index f3b34401d..2f1fa01b7 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -207,9 +207,10 @@ class Wiki extends \Zotlabs\Web\Controller {
$ignore_language = true;
continue;
}
- if($page_name)
+ if($page_name) {
$page_name .= '/';
- $page_name .= argv($x);
+ }
+ $page_name .= argv($x);
}
$pageUrlName = urldecode($page_name);
@@ -296,7 +297,8 @@ class Wiki extends \Zotlabs\Web\Controller {
'$showPageControls' => $showPageControls,
'$editOrSourceLabel' => (($showPageControls) ? t('Edit') : t('Source')),
'$tools_label' => 'Page Tools',
- '$channel' => $owner['channel_address'],
+ '$channel_address' => $owner['channel_address'],
+ '$channel_id' => $owner['channel_id'],
'$resource_id' => $resource_id,
'$page' => $pageUrlName,
'$mimeType' => $mimeType,
@@ -495,10 +497,12 @@ class Wiki extends \Zotlabs\Web\Controller {
$x = new \Zotlabs\Widget\Wiki_pages();
- $page_list_html = $x->widget(array(
- 'resource_id' => $resource_id,
- 'refresh' => true,
- 'channel' => argv(1)));
+ $page_list_html = $x->widget([
+ 'resource_id' => $resource_id,
+ 'channel_id' => $owner['channel_id'],
+ 'channel_address' => $owner['channel_address'],
+ 'refresh' => true
+ ]);
json_return_and_die(array('pages' => $page_list_html, 'message' => '', 'success' => true));
}
diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php
index f992b3f93..53966b06f 100644
--- a/Zotlabs/Widget/Wiki_pages.php
+++ b/Zotlabs/Widget/Wiki_pages.php
@@ -7,58 +7,57 @@ class Wiki_pages {
function widget($arr) {
- $channelname = ((array_key_exists('channel',$arr)) ? $arr['channel'] : '');
- $c = channelx_by_nick($channelname);
+ if(argc() < 3)
+ return;
+
+ if(! $arr['resource_id']) {
- if(! $c)
$c = \App::get_channel();
- if(! $c)
- return '';
+ if(! $c)
+ $c = channelx_by_nick(argv(1));
- $wikiname = '';
- if(array_key_exists('refresh', $arr)) {
- $not_refresh = (($arr['refresh']=== true) ? false : true);
- }
- else {
- $not_refresh = true;
+ $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
+ );
}
+ $wikiname = '';
+
$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 = '';
- }
+
+ $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 = '';
}
}
-
$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,
+ '$channel_address' => $arr['channel_address'],
'$wikiname' => $wikiname,
'$pages' => $pages,
'$canadd' => $can_create,
'$candel' => $can_delete,
'$addnew' => t('Add new page'),
'$pageName' => array('pageName', t('Page name')),
+ '$refresh' => $arr['refresh']
));
}
}
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl
index 564db3324..7cd3708b8 100644
--- a/view/tpl/wiki.tpl
+++ b/view/tpl/wiki.tpl
@@ -115,7 +115,7 @@
});
$( "#rename-page-form" ).submit(function( event ) {
- $.post("wiki/{{$channel}}/rename/page",
+ $.post("wiki/{{$channel_address}}/rename/page",
{
oldName: window.wiki_page_name,
newName: $('#id_pageRename').val(),
@@ -177,7 +177,7 @@
});
$('#wiki-get-preview').click(function (ev) {
- $.post("wiki/{{$channel}}/preview", {
+ $.post("wiki/{{$channel_address}}/preview", {
{{if !$mimeType || $mimeType == 'text/markdown'}}
content: editor.getValue(),
{{else}}
@@ -200,7 +200,7 @@
});
$('#wiki-get-history').click(function (ev) {
- $.post("wiki/{{$channel}}/history/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id}, function (data) {
+ $.post("wiki/{{$channel_address}}/history/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id}, function (data) {
if (data.success) {
$('#page-history-list').html(data.historyHTML);
$('#page-tools').hide();
@@ -215,10 +215,9 @@
if (window.wiki_resource_id === '') {
return false;
}
- $.post("wiki/{{$channel}}/get/page/list/", {resource_id: window.wiki_resource_id}, function (data) {
+ $.post("wiki/{{$channel_address}}/get/page/list/", {channel_id: '{{$channel_id}}', resource_id: window.wiki_resource_id}, function (data) {
if (data.success) {
- $('#wiki_page_list_container').html(data.pages);
- $('#wiki_page_list_container').show();
+ $('#wiki_page_list').html(data.pages);
} else {
alert('Error fetching page list!');
window.console.log('Error fetching page list!');
@@ -245,7 +244,7 @@
ev.preventDefault();
return false;
}
- $.post("wiki/{{$channel}}/save/page", {
+ $.post("wiki/{{$channel_address}}/save/page", {
content: currentContent,
commitMsg: $('#id_commitMsg').val(),
name: window.wiki_page_name,
@@ -276,7 +275,7 @@
window.console.log('You must have a wiki page open in order to revert pages.');
return false;
}
- $.post("wiki/{{$channel}}/revert/page", {commitHash: commitHash, name: window.wiki_page_name, resource_id: window.wiki_resource_id},
+ $.post("wiki/{{$channel_address}}/revert/page", {commitHash: commitHash, name: window.wiki_page_name, resource_id: window.wiki_resource_id},
function (data) {
if (data.success) {
$('button[id^=revert-]').removeClass('btn-success');
@@ -299,7 +298,7 @@
window.console.log('You must have a wiki page open in order to revert pages.');
return false;
}
- $.post("wiki/{{$channel}}/compare/page", {
+ $.post("wiki/{{$channel_address}}/compare/page", {
compareCommit: compareCommit,
currentCommit: window.wiki_page_commit,
name: window.wiki_page_name,
@@ -442,8 +441,6 @@
};
$(document).ready(function () {
- wiki_refresh_page_list();
-
{{if !$mimeType || $mimeType == 'text/markdown'}}
$("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"});
window.editor.on("input", function() {
diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl
index 44fba15cc..6d09fcd5d 100644
--- a/view/tpl/wiki_page_list.tpl
+++ b/view/tpl/wiki_page_list.tpl
@@ -1,5 +1,6 @@
-{{if $not_refresh}}<div id="wiki_page_list_container" {{if $hide}} style="display: none;" {{/if}}>{{/if}}
+{{if ! $refresh}}
<div id="wiki_page_list" class="widget" >
+{{/if}}
<h3>{{$header}}</h3>
<ul class="nav nav-pills flex-column">
{{if $pages}}
@@ -8,7 +9,7 @@
{{if $page.resource_id && $candel}}
<i class="nav-link widget-nav-pills-icons fa fa-trash-o drop-icons" onclick="wiki_delete_page('{{$page.title}}', '{{$page.url}}', '{{$page.resource_id}}', '{{$page.link_id}}')"></i>
{{/if}}
- <a class="nav-link" href="/wiki/{{$channel}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a>
+ <a class="nav-link" href="/wiki/{{$channel_address}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a>
</li>
{{/foreach}}
{{/if}}
@@ -18,19 +19,21 @@
</ul>
{{if $canadd}}
<div id="new-page-form-wrapper" class="sub-menu" style="display:none;">
- <form id="new-page-form" action="wiki/{{$channel}}/create/page" method="post" >
+ <form id="new-page-form" action="wiki/{{$channel_address}}/create/page" method="post" >
<input type="hidden" name="resource_id" value="{{$resource_id}}">
{{include file="field_input.tpl" field=$pageName}}
<button id="new-page-submit" class="btn btn-primary" type="submit" name="submit" >Submit</button>
</form>
</div>
{{/if}}
+{{if ! $refresh}}
</div>
-{{if $not_refresh}}</div>{{/if}}
+{{/if}}
+{{if $canadd}}
<script>
$('#new-page-submit').click(function (ev) {
- $.post("wiki/{{$channel}}/create/page", {pageName: $('#id_pageName').val(), resource_id: window.wiki_resource_id},
+ $.post("wiki/{{$channel_address}}/create/page", {pageName: $('#id_pageName').val(), resource_id: window.wiki_resource_id},
function(data) {
if(data.success) {
window.location = data.url;
@@ -45,7 +48,7 @@
if(!confirm('Are you sure you want to delete the page: ' + wiki_page_name)) {
return;
}
- $.post("wiki/{{$channel}}/delete/page", {name: wiki_page_url, resource_id: wiki_resource_id},
+ $.post("wiki/{{$channel_address}}/delete/page", {name: wiki_page_url, resource_id: wiki_resource_id},
function (data) {
if (data.success) {
window.console.log('Page deleted successfully.');
@@ -74,3 +77,4 @@
return false;
}
</script>
+{{/if}}