From f9b732482d1776ba0c8cad593157589189f6bedd Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 28 Nov 2016 15:24:49 +0100 Subject: some basic work for implementing mimetypes for wikis --- Zotlabs/Module/Wiki.php | 7 +++---- include/wiki.php | 16 +++++++++++----- view/tpl/wikilist.tpl | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 37ebe2a38..d43b71f92 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -34,10 +34,7 @@ class Wiki extends \Zotlabs\Web\Controller { notice( t('Not found') . EOL); return; } - - $tab = 'wiki'; - - + require_once('include/wiki.php'); require_once('include/acl_selectors.php'); require_once('include/conversation.php'); @@ -151,6 +148,7 @@ class Wiki extends \Zotlabs\Web\Controller { '$create' => t('Create New'), '$submit' => t('Submit'), '$wikiName' => array('wikiName', t('Wiki name')), + '$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => 'Markdown', 'text/bbcode' => 'BB Code']), '$name' => t('Name'), '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], @@ -322,6 +320,7 @@ class Wiki extends \Zotlabs\Web\Controller { $wiki['rawName'] = $_POST['wikiName']; $wiki['htmlName'] = escape_tags($_POST['wikiName']); $wiki['urlName'] = urlencode($_POST['wikiName']); + $wiki['mimeType'] = $_POST['mimeType']; if($wiki['urlName'] === '') { notice( t('Error creating wiki. Invalid name.') . EOL); goaway('/wiki'); diff --git a/include/wiki.php b/include/wiki.php index eb87840f6..c6ef7fe59 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -139,6 +139,9 @@ function wiki_create_wiki($channel, $observer_hash, $wiki, $acl) { if (!set_iconfig($arr, 'wiki', 'urlName', $wiki['urlName'], true)) { return array('item' => null, 'success' => false); } + if (!set_iconfig($arr, 'wiki', 'mimteType', $wiki['mimeType'], true)) { + return array('item' => null, 'success' => false); + } $post = item_store($arr); $item_id = $post['item_id']; @@ -179,17 +182,20 @@ function wiki_get_wiki($resource_id) { $rawName = get_iconfig($w, 'wiki', 'rawName'); $htmlName = get_iconfig($w, 'wiki', 'htmlName'); $urlName = get_iconfig($w, 'wiki', 'urlName'); + $mimeType = get_iconfig($w, 'wiki', 'mimeType'); $path = get_iconfig($w, 'wiki', 'path'); if (!realpath(__DIR__ . '/../' . $path)) { return array('wiki' => null, 'path' => null); } // Path to wiki exists $abs_path = realpath(__DIR__ . '/../' . $path); - return array( 'wiki' => $w, - 'path' => $abs_path, - 'rawName' => $rawName, - 'htmlName' => $htmlName, - 'urlName' => $urlName + return array( + 'wiki' => $w, + 'path' => $abs_path, + 'rawName' => $rawName, + 'htmlName' => $htmlName, + 'urlName' => $urlName, + 'mimeType' => $mimeType ); } } diff --git a/view/tpl/wikilist.tpl b/view/tpl/wikilist.tpl index 27fb6370e..c7cdfaa43 100644 --- a/view/tpl/wikilist.tpl +++ b/view/tpl/wikilist.tpl @@ -9,6 +9,8 @@
{{include file="field_input.tpl" field=$wikiName}} + {{* include file="field_select.tpl" field=$mimeType *}} + {{include file="field_checkbox.tpl" field=$notify}}
-- cgit v1.2.3