aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2017-09-15 22:17:18 +0200
committerMario <mario@mariovavti.com>2017-09-15 22:17:18 +0200
commit373651c3dbb9d6d79b9c5a1519a7ef336f2d615e (patch)
treed71bc0bb8ab6880f10df4684296189d401e96171 /Zotlabs/Module
parent663802e6992858c026a4e9b325575bc064cc687d (diff)
downloadvolse-hubzilla-373651c3dbb9d6d79b9c5a1519a7ef336f2d615e.tar.gz
volse-hubzilla-373651c3dbb9d6d79b9c5a1519a7ef336f2d615e.tar.bz2
volse-hubzilla-373651c3dbb9d6d79b9c5a1519a7ef336f2d615e.zip
implement wiki editing
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Wiki.php35
1 files changed, 20 insertions, 15 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 013ffef70..6055b0b38 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -152,7 +152,7 @@ class Wiki extends \Zotlabs\Web\Controller {
$content = html_entity_decode($iv['body'],ENT_COMPAT,'UTF-8');
}
elseif($iv['mimetype'] === 'text/markdown') {
- $content = html_entity_decode(\Zlib\MarkdownSoap::unescape($iv['body']),ENT_COMPAT,'UTF-8');
+ $content = html_entity_decode(Zlib\MarkdownSoap::unescape($iv['body']),ENT_COMPAT,'UTF-8');
}
$fname = get_iconfig($iv['id'],'nwikipage','pagetitle') . Zlib\NativeWikiPage::get_file_ext($iv);
$zip->addFromString($fname,$content);
@@ -185,6 +185,7 @@ class Wiki extends \Zotlabs\Web\Controller {
switch(argc()) {
case 2:
$wikis = Zlib\NativeWiki::listwikis($owner, get_observer_hash());
+
if($wikis) {
$o .= replace_macros(get_markup_template('wikilist.tpl'), array(
'$header' => t('Wikis'),
@@ -473,36 +474,40 @@ class Wiki extends \Zotlabs\Web\Controller {
goaway('/' . argv(0) . '/' . $nick . '/');
}
- if($wiki['urlName'] === '') {
+ $arr = [];
+
+ $arr['urlName'] = urlencode(urlencode($_POST['origRawName']));
+
+ if($_POST['updateRawName'])
+ $arr['updateRawName'] = $_POST['updateRawName'];
+
+ if(($arr['urlName'] || $arr['updateRawName']) === '') {
notice( t('Error updating wiki. Invalid name.') . EOL);
goaway('/wiki');
return; //not reached
}
- $exists = Zlib\NativeWiki::exists_by_name($owner['channel_id'], $wiki['urlName']);
- if($exists['id']) {
+ $wiki = Zlib\NativeWiki::exists_by_name($owner['channel_id'], $arr['urlName']);
+
+ if($wiki['resource_id']) {
+
+ $arr['resource_id'] = $wiki['resource_id'];
- // Get ACL for permissions
$acl = new \Zotlabs\Access\AccessList($owner);
$acl->set_from_array($_POST);
- $r = Zlib\NativeWiki::create_wiki($owner, $observer_hash, $wiki, $acl);
+
+ $r = Zlib\NativeWiki::update_wiki($owner['channel_id'], $observer_hash, $arr, $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'], $wiki['mimeType']);
- if(! $homePage['success']) {
- notice( t('Wiki created, but error creating Home page.'));
- goaway(z_root() . '/wiki/' . $nick . '/' . $wiki['urlName']);
- }
- Zlib\NativeWiki::sync_a_wiki_item($owner['channel_id'],$homePage['item_id'],$r['item']['resource_id']);
- goaway(z_root() . '/wiki/' . $nick . '/' . $wiki['urlName'] . '/' . $homePage['page']['urlName']);
+ goaway(z_root() . '/wiki/' . $nick);
}
else {
- notice( t('Error creating wiki'));
+ notice( t('Error updating wiki'));
goaway(z_root() . '/wiki');
}
}
-
+ goaway(z_root() . '/wiki');
}
// Delete a wiki