diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-05-28 15:11:19 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-05-28 15:11:19 -0400 |
commit | ab54bf514921ae3fe0fafcdf154364815ed6375f (patch) | |
tree | 2066bc43694b344623f567fd5a87d5e77193794a /include/wiki.php | |
parent | 55b587002ea7e892d20010800f5892949f56d34a (diff) | |
download | volse-hubzilla-ab54bf514921ae3fe0fafcdf154364815ed6375f.tar.gz volse-hubzilla-ab54bf514921ae3fe0fafcdf154364815ed6375f.tar.bz2 volse-hubzilla-ab54bf514921ae3fe0fafcdf154364815ed6375f.zip |
Wiki pages can be saved.
Diffstat (limited to 'include/wiki.php')
-rw-r--r-- | include/wiki.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/wiki.php b/include/wiki.php index f97036c29..e01cc12c3 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -232,4 +232,26 @@ function wiki_get_page_content($arr) { // TODO: Check that the files are all text files return array('content' => json_encode($content), 'message' => '', 'success' => true); } +} + + +function wiki_save_page($arr) { + $pagename = ((array_key_exists('name',$arr)) ? $arr['name'] : ''); + $content = ((array_key_exists('content',$arr)) ? $arr['content'] : ''); + $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : ''); + $w = wiki_get_wiki($resource_id); + if (!$w['path']) { + return array('message' => 'Error reading wiki', 'success' => false); + } + $page_path = $w['path'].'/'.$pagename; + if (is_writable($page_path) === true) { + if(!file_put_contents($page_path, $content)) { + return array('message' => 'Error writing to page file', 'success' => false); + } + return array('message' => '', 'success' => true); + } else { + return array('message' => 'Page file not writable', 'success' => false); + } + + }
\ No newline at end of file |