resolve merge conflict
This commit is contained in:
parent
157966eb11
commit
44cb68a356
@ -293,31 +293,43 @@ class Wiki extends \Zotlabs\Web\Controller {
|
|||||||
$p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
|
$p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
|
||||||
}
|
}
|
||||||
if(! ($p && $p['success'])) {
|
if(! ($p && $p['success'])) {
|
||||||
|
$x = new \Zotlabs\Widget\Wiki_pages();
|
||||||
|
|
||||||
|
$html = $x->create_missing_page([
|
||||||
|
'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));
|
||||||
notice( t('Error retrieving page content') . EOL);
|
notice( t('Error retrieving page content') . EOL);
|
||||||
goaway(z_root() . '/' . argv(0) . '/' . argv(1) );
|
//goaway(z_root() . '/' . argv(0) . '/' . argv(1) );
|
||||||
|
$renderedContent = Zlib\NativeWikiPage::convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
|
||||||
|
$showPageControls = $wiki_editor;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$mimeType = $p['pageMimeType'];
|
||||||
|
|
||||||
$mimeType = $p['pageMimeType'];
|
$sampleContent = (($mimeType == 'text/bbcode') ? '[h3]' . t('New page') . '[/h3]' : '### ' . t('New page'));
|
||||||
|
if($mimeType === 'text/plain')
|
||||||
|
$sampleContent = t('New page');
|
||||||
|
|
||||||
$sampleContent = (($mimeType == 'text/bbcode') ? '[h3]' . t('New page') . '[/h3]' : '### ' . t('New page'));
|
$content = (($p['content'] == '') ? $sampleContent : $p['content']);
|
||||||
if($mimeType === 'text/plain')
|
|
||||||
$sampleContent = t('New page');
|
|
||||||
|
|
||||||
$content = (($p['content'] == '') ? $sampleContent : $p['content']);
|
// Render the Markdown-formatted page content in HTML
|
||||||
|
if($mimeType == 'text/bbcode') {
|
||||||
// Render the Markdown-formatted page content in HTML
|
$renderedContent = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))), argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
|
||||||
if($mimeType == 'text/bbcode') {
|
}
|
||||||
$renderedContent = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))), argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
|
elseif($mimeType === 'text/plain') {
|
||||||
}
|
$renderedContent = str_replace(["\n",' ',"\t"],[EOL,' ',' '],htmlentities($content,ENT_COMPAT,'UTF-8',false));
|
||||||
elseif($mimeType === 'text/plain') {
|
}
|
||||||
$renderedContent = str_replace(["\n",' ',"\t"],[EOL,' ',' '],htmlentities($content,ENT_COMPAT,'UTF-8',false));
|
elseif($mimeType === 'text/markdown') {
|
||||||
}
|
$content = Zlib\MarkdownSoap::unescape($content);
|
||||||
elseif($mimeType === 'text/markdown') {
|
$html = Zlib\NativeWikiPage::generate_toc(zidify_text(MarkdownExtra::defaultTransform(Zlib\NativeWikiPage::bbcode($content))));
|
||||||
$content = Zlib\MarkdownSoap::unescape($content);
|
$renderedContent = Zlib\NativeWikiPage::convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
|
||||||
$html = Zlib\NativeWikiPage::generate_toc(zidify_text(MarkdownExtra::defaultTransform(Zlib\NativeWikiPage::bbcode($content))));
|
}
|
||||||
$renderedContent = Zlib\NativeWikiPage::convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
|
$showPageControls = $wiki_editor;
|
||||||
}
|
}
|
||||||
$showPageControls = $wiki_editor;
|
|
||||||
break;
|
break;
|
||||||
// default: // Strip the extraneous URL components
|
// default: // Strip the extraneous URL components
|
||||||
// goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName);
|
// goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName);
|
||||||
@ -563,9 +575,10 @@ class Wiki extends \Zotlabs\Web\Controller {
|
|||||||
// backslashes won't work well in the javascript functions
|
// backslashes won't work well in the javascript functions
|
||||||
$name = str_replace('\\','',$name);
|
$name = str_replace('\\','',$name);
|
||||||
|
|
||||||
if(urlencode(escape_tags($name)) === '') {
|
if(urlencode(escape_tags($_POST['pageName'])) === '') {
|
||||||
json_return_and_die(array('message' => 'Error creating page. Invalid name.', 'success' => false));
|
json_return_and_die(array('message' => 'Error creating page. Invalid name (' . print_r($_POST,true) . ').', 'success' => false));
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash, $name, $resource_id, $mimetype);
|
$page = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash, $name, $resource_id, $mimetype);
|
||||||
|
|
||||||
if($page['item_id']) {
|
if($page['item_id']) {
|
||||||
|
@ -5,6 +5,42 @@ namespace Zotlabs\Widget;
|
|||||||
|
|
||||||
class Wiki_pages {
|
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'],urldecode(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 = urlencode(escape_tags(urldecode(argv(3))));
|
||||||
|
|
||||||
|
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) {
|
function widget($arr) {
|
||||||
|
|
||||||
if(argc() < 3)
|
if(argc() < 3)
|
||||||
|
34
view/tpl/wiki_page_not_found.tpl
Normal file
34
view/tpl/wiki_page_not_found.tpl
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<h3>Page does not exist</h3>
|
||||||
|
<br /><br /><br />
|
||||||
|
{{if $canadd}}
|
||||||
|
<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}}
|
||||||
|
{{if $typelock}}
|
||||||
|
<input id="id_mimetype" type="hidden" name="mimetype" value="{{$lockedtype}}">
|
||||||
|
{{else}}
|
||||||
|
<div id="wiki_missing_page_options" style="display: none">
|
||||||
|
{{$mimetype}}
|
||||||
|
</div>
|
||||||
|
<div class="float-right fakelink" onClick="openClose('wiki_missing_page_options')">
|
||||||
|
{{$options}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
<button id="create-missing-page-submit" class="btn btn-primary" type="submit" name="submit" >{{$submit}}</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('#create-missing-page-submit').click(function (ev) {
|
||||||
|
$.post("wiki/{{$channel_address}}/create/page", {pageName: $('#id_missingPageName').val(), resource_id: window.wiki_resource_id, mimetype: $('#id_mimetype').val() },
|
||||||
|
function(data) {
|
||||||
|
if(data.success) {
|
||||||
|
window.location = data.url;
|
||||||
|
} else {
|
||||||
|
window.console.log('Error creating page. ('+data.message+')');
|
||||||
|
}
|
||||||
|
}, 'json');
|
||||||
|
ev.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{{/if}}
|
Reference in New Issue
Block a user