wiki mimetype selection
This commit is contained in:
parent
4ff89a5862
commit
5e99295bf6
@ -55,7 +55,12 @@ class NativeWikiPage {
|
||||
}
|
||||
|
||||
|
||||
static public function create_page($channel_id, $observer_hash, $name, $resource_id) {
|
||||
static public function create_page($channel_id, $observer_hash, $name, $resource_id, $mimetype = 'text/bbcode') {
|
||||
|
||||
logger('mimetype: ' . $mimetype);
|
||||
|
||||
if(! in_array($mimetype,[ 'text/markdown','text/bbcode','text/plain','text/html']))
|
||||
$mimetype = 'text/markdown;
|
||||
|
||||
$w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id);
|
||||
|
||||
@ -68,6 +73,7 @@ class NativeWikiPage {
|
||||
$arr = [];
|
||||
$arr['uid'] = $channel_id;
|
||||
$arr['author_xchan'] = $observer_hash;
|
||||
$arr['mimetype'] = $mimetype;
|
||||
$arr['resource_type'] = 'nwikipage';
|
||||
$arr['resource_id'] = $resource_id;
|
||||
$arr['allow_cid'] = $w['wiki']['allow_cid'];
|
||||
|
@ -406,7 +406,7 @@ class Wiki extends \Zotlabs\Web\Controller {
|
||||
$r = Zlib\NativeWiki::create_wiki($owner, $observer_hash, $wiki, $acl);
|
||||
if($r['success']) {
|
||||
Zlib\NativeWiki::sync_a_wiki_item($owner['channel_id'],$r['item_id'],$r['item']['resource_id']);
|
||||
$homePage = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash,'Home', $r['item']['resource_id']);
|
||||
$homePage = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash,'Home', $r['item']['resource_id'], $wiki['mimeType']);
|
||||
if(! $homePage['success']) {
|
||||
notice( t('Wiki created, but error creating Home page.'));
|
||||
goaway(z_root() . '/wiki/' . $nick . '/' . $wiki['urlName']);
|
||||
@ -445,11 +445,13 @@ class Wiki extends \Zotlabs\Web\Controller {
|
||||
// Create a page
|
||||
if ((argc() === 4) && (argv(2) === 'create') && (argv(3) === 'page')) {
|
||||
|
||||
$mimetype = $_POST['mimetype'];
|
||||
|
||||
$resource_id = $_POST['resource_id'];
|
||||
// Determine if observer has permission to create a page
|
||||
|
||||
|
||||
|
||||
$perms = Zlib\NativeWiki::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash);
|
||||
$perms = Zlib\NativeWiki::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash, $mimetype);
|
||||
if(! $perms['write']) {
|
||||
logger('Wiki write permission denied. ' . EOL);
|
||||
json_return_and_die(array('success' => false));
|
||||
@ -459,7 +461,7 @@ class Wiki extends \Zotlabs\Web\Controller {
|
||||
if(urlencode(escape_tags($_POST['pageName'])) === '') {
|
||||
json_return_and_die(array('message' => 'Error creating page. Invalid name.', 'success' => false));
|
||||
}
|
||||
$page = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash, $name, $resource_id);
|
||||
$page = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash, $name, $resource_id, $mimetype);
|
||||
|
||||
if($page['item_id']) {
|
||||
$commit = Zlib\NativeWikiPage::commit(array(
|
||||
|
@ -50,6 +50,7 @@ class Wiki_pages {
|
||||
'$canadd' => $can_create,
|
||||
'$candel' => $can_delete,
|
||||
'$addnew' => t('Add new page'),
|
||||
'$mimetype' => mimetype_select(0,$p['mimeType'], [ 'text/markdown','text/bbcode' ]),
|
||||
'$pageName' => array('pageName', t('Page name')),
|
||||
'$refresh' => $arr['refresh']
|
||||
));
|
||||
|
@ -1786,15 +1786,15 @@ function layout_select($channel_id, $current = '') {
|
||||
}
|
||||
|
||||
|
||||
function mimetype_select($channel_id, $current = 'text/bbcode') {
|
||||
function mimetype_select($channel_id, $current = 'text/bbcode', $choices = null) {
|
||||
|
||||
$x = array(
|
||||
$x = (($choices) ? $choices : [
|
||||
'text/bbcode',
|
||||
'text/html',
|
||||
'text/markdown',
|
||||
'text/plain',
|
||||
'application/x-pdl'
|
||||
);
|
||||
]);
|
||||
|
||||
|
||||
if((App::$is_sys) || (channel_codeallowed($channel_id) && $channel_id == local_channel())){
|
||||
|
@ -21,6 +21,7 @@
|
||||
<div id="new-page-form-wrapper" class="sub-menu" style="display:none;">
|
||||
<form id="new-page-form" action="wiki/{{$channel_address}}/create/page" method="post" >
|
||||
<input type="hidden" name="resource_id" value="{{$resource_id}}">
|
||||
{{$mimetype}}
|
||||
{{include file="field_input.tpl" field=$pageName}}
|
||||
<button id="new-page-submit" class="btn btn-primary" type="submit" name="submit" >Submit</button>
|
||||
</form>
|
||||
@ -33,7 +34,7 @@
|
||||
{{if $canadd}}
|
||||
<script>
|
||||
$('#new-page-submit').click(function (ev) {
|
||||
$.post("wiki/{{$channel_address}}/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, mimetype: $('#id_mimetype').val() },
|
||||
function(data) {
|
||||
if(data.success) {
|
||||
window.location = data.url;
|
||||
|
Reference in New Issue
Block a user