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