aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-09-12 22:32:31 -0700
committerzotlabs <mike@macgirvin.com>2017-09-12 22:32:31 -0700
commit5e99295bf6f85e7a6d50e0c8f0701a9b37f03332 (patch)
tree73005cc356bc4e1060f28859247e76fe4c706c45
parent4ff89a58625e647ee74087dfab79ac6dd76cbe6c (diff)
downloadvolse-hubzilla-5e99295bf6f85e7a6d50e0c8f0701a9b37f03332.tar.gz
volse-hubzilla-5e99295bf6f85e7a6d50e0c8f0701a9b37f03332.tar.bz2
volse-hubzilla-5e99295bf6f85e7a6d50e0c8f0701a9b37f03332.zip
wiki mimetype selection
-rw-r--r--Zotlabs/Lib/NativeWikiPage.php8
-rw-r--r--Zotlabs/Module/Wiki.php10
-rw-r--r--Zotlabs/Widget/Wiki_pages.php1
-rw-r--r--include/text.php6
-rw-r--r--view/tpl/wiki_page_list.tpl3
5 files changed, 19 insertions, 9 deletions
diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php
index 78b54ebda..97dad5813 100644
--- a/Zotlabs/Lib/NativeWikiPage.php
+++ b/Zotlabs/Lib/NativeWikiPage.php
@@ -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'];
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 4dc11c683..3fb980955 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -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(
diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php
index 7285e2b42..ac6549ffd 100644
--- a/Zotlabs/Widget/Wiki_pages.php
+++ b/Zotlabs/Widget/Wiki_pages.php
@@ -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']
));
diff --git a/include/text.php b/include/text.php
index 51d711021..58e2b8256 100644
--- a/include/text.php
+++ b/include/text.php
@@ -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())){
diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl
index 6d09fcd5d..2e7fb8b9e 100644
--- a/view/tpl/wiki_page_list.tpl
+++ b/view/tpl/wiki_page_list.tpl
@@ -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;