aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Wiki.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-11-30 13:30:50 +0100
committerMario Vavti <mario@mariovavti.com>2016-11-30 13:30:50 +0100
commitafffbb6487d8dc1806767ed2b2728ab56bf06669 (patch)
tree4f24bdcf1d1522c804db4fd0820acca4ffae94a7 /Zotlabs/Module/Wiki.php
parent53e4b55ea3722a161b308e4891a2e84ad9ba77af (diff)
downloadvolse-hubzilla-afffbb6487d8dc1806767ed2b2728ab56bf06669.tar.gz
volse-hubzilla-afffbb6487d8dc1806767ed2b2728ab56bf06669.tar.bz2
volse-hubzilla-afffbb6487d8dc1806767ed2b2728ab56bf06669.zip
go live with wiki mimetypes - you can now choose if a wiki will contain markdown or bb-code markup
Diffstat (limited to 'Zotlabs/Module/Wiki.php')
-rw-r--r--Zotlabs/Module/Wiki.php51
1 files changed, 34 insertions, 17 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index edd783a62..c4cc72ae8 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -202,11 +202,20 @@ class Wiki extends \Zotlabs\Web\Controller {
notice(t('Error retrieving page content') . EOL);
goaway('/'.argv(0).'/'.argv(1).'/'.$wikiUrlName);
}
- $content = ($p['content'] !== '' ? htmlspecialchars_decode($p['content'],ENT_COMPAT) : '"# New page\n"');
+
+ $mimeType = $p['mimeType'];
+
+ $rawContent = $p['mimeType'] == 'text/bbcode' ? htmlspecialchars_decode(json_decode($p['content']),ENT_COMPAT) : htmlspecialchars_decode($p['content'],ENT_COMPAT);
+ $content = ($p['content'] !== '' ? $rawContent : '"# New page\n"');
// Render the Markdown-formatted page content in HTML
- require_once('library/markdown.php');
- $html = wiki_generate_toc(zidify_text(purify_html(Markdown(wiki_bbcode(json_decode($content))))));
- $renderedContent = wiki_convert_links($html,argv(0).'/'.argv(1).'/'.$wikiUrlName);
+ if($mimeType == 'text/bbcode') {
+ $renderedContent = purify_html(bbcode($content));
+ }
+ else {
+ require_once('library/markdown.php');
+ $html = wiki_generate_toc(zidify_text(purify_html(Markdown(wiki_bbcode(json_decode($content))))));
+ $renderedContent = wiki_convert_links($html,argv(0).'/'.argv(1).'/'.$wikiUrlName);
+ }
$hide_editor = false;
$showPageControls = $wiki_editor;
$showNewWikiButton = $wiki_owner;
@@ -220,14 +229,13 @@ class Wiki extends \Zotlabs\Web\Controller {
}
$wikiModalID = random_string(3);
- $wikiModal = replace_macros(
- get_markup_template('generic_modal.tpl'), array(
- '$id' => $wikiModalID,
- '$title' => t('Revision Comparison'),
- '$ok' => t('Revert'),
- '$cancel' => t('Cancel')
- )
- );
+
+ $wikiModal = replace_macros(get_markup_template('generic_modal.tpl'), array(
+ '$id' => $wikiModalID,
+ '$title' => t('Revision Comparison'),
+ '$ok' => t('Revert'),
+ '$cancel' => t('Cancel')
+ ));
$o .= replace_macros(get_markup_template('wiki.tpl'),array(
'$wikiheaderName' => $wikiheaderName,
@@ -251,6 +259,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'$deny_cid' => $x['deny_cid'],
'$deny_gid' => $x['deny_gid'],
'$bang' => $x['bang'],
+ '$mimeType' => $mimeType,
'$content' => $content,
'$renderedContent' => $renderedContent,
'$wikiName' => array('wikiName', t('Enter the name of your new wiki:'), '', ''),
@@ -293,13 +302,21 @@ class Wiki extends \Zotlabs\Web\Controller {
// Render mardown-formatted text in HTML for preview
if((argc() > 2) && (argv(2) === 'preview')) {
$content = $_POST['content'];
- $resource_id = $_POST['resource_id'];
- require_once('library/markdown.php');
- $content = wiki_bbcode($content);
- $html = wiki_generate_toc(zidify_text(purify_html(Markdown($content))));
+ $resource_id = $_POST['resource_id'];
$w = wiki_get_wiki($resource_id);
$wikiURL = argv(0).'/'.argv(1).'/'.$w['urlName'];
- $html = wiki_convert_links($html,$wikiURL);
+
+ $mimeType = $w['mimeType'];
+
+ if($mimeType == 'text/bbcode') {
+ $html = purify_html(bbcode($content));
+ }
+ else {
+ require_once('library/markdown.php');
+ $content = wiki_bbcode($content);
+ $html = wiki_generate_toc(zidify_text(purify_html(Markdown($content))));
+ $html = wiki_convert_links($html,$wikiURL);
+ }
json_return_and_die(array('html' => $html, 'success' => true));
}