From 7393dccde816bafca2e3efe534fae56339e2c536 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sat, 28 May 2016 12:33:07 -0400 Subject: Page content is loaded from the file on disk --- include/wiki.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include/wiki.php') diff --git a/include/wiki.php b/include/wiki.php index c1779e208..f97036c29 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -210,3 +210,26 @@ function wiki_create_page($name, $resource_id) { } } + +function wiki_get_page_content($arr) { + $page = ((array_key_exists('page',$arr)) ? $arr['page'] : ''); + // TODO: look for page resource_id and retrieve that way alternatively + $wiki_resource_id = ((array_key_exists('wiki_resource_id',$arr)) ? $arr['wiki_resource_id'] : ''); + $w = wiki_get_wiki($wiki_resource_id); + if (!$w['path']) { + return array('content' => null, 'message' => 'Error reading wiki', 'success' => false); + } + $page_path = $w['path'].'/'.$page; + if (is_readable($page_path) === true) { + if(filesize($page_path) === 0) { + $content = ''; + } else { + $content = file_get_contents($page_path); + if(!$content) { + return array('content' => null, 'message' => 'Error reading page content', 'success' => false); + } + } + // TODO: Check that the files are all text files + return array('content' => json_encode($content), 'message' => '', 'success' => true); + } +} \ No newline at end of file -- cgit v1.2.3