aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/widgets.php11
-rw-r--r--include/wiki.php30
2 files changed, 35 insertions, 6 deletions
diff --git a/include/widgets.php b/include/widgets.php
index b19c36bc6..536af8818 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -914,6 +914,17 @@ function widget_wiki_pages($arr) {
));
}
+function widget_wiki_page_history($arr) {
+ require_once("include/wiki.php");
+ $pagename = ((array_key_exists('page', $arr)) ? $arr['page'] : '');
+ $resource_id = ((array_key_exists('resource_id', $arr)) ? $arr['resource_id'] : '');
+ $pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'page' => $pagename));
+
+ return replace_macros(get_markup_template('wiki_page_history.tpl'), array(
+ '$pageHistory' => $pageHistory['history']
+ ));
+}
+
function widget_bookmarkedchats($arr) {
if(! feature_enabled(App::$profile['profile_uid'],'ajaxchat'))
diff --git a/include/wiki.php b/include/wiki.php
index 6a94dc111..14e8cc53a 100644
--- a/include/wiki.php
+++ b/include/wiki.php
@@ -95,12 +95,6 @@ function wiki_create_wiki($channel, $observer_hash, $name, $acl) {
$arr['item_private'] = intval($acl->is_private());
$arr['verb'] = ACTIVITY_CREATE;
$arr['obj_type'] = ACTIVITY_OBJ_WIKI;
- $arr['object'] = json_encode(array(
- 'type' => $arr['obj_type'],
- 'title' => $arr['title'],
- 'id' => $arr['resource_id'],
- 'url' => $wiki_url
- ));
$arr['body'] = '[table][tr][td][h1]New Wiki[/h1][/td][/tr][tr][td][zrl=' . $wiki_url . ']' . $name . '[/zrl][/td][/tr][/table]';
// Save the path using iconfig. The file path should not be shared with other hubs
if (!set_iconfig($arr, 'wiki', 'path', $path, false)) {
@@ -221,6 +215,30 @@ function wiki_get_page_content($arr) {
}
}
+function wiki_page_history($arr) {
+ $pagename = ((array_key_exists('page',$arr)) ? $arr['page'] : '');
+ $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
+ $w = wiki_get_wiki($resource_id);
+ if (!$w['path']) {
+ return array('history' => null, 'message' => 'Error reading wiki', 'success' => false);
+ }
+ $page_path = $w['path'].'/'.$pagename;
+ if (!is_readable($page_path) === true) {
+ return array('history' => null, 'message' => 'Cannot read wiki page: ' . $page_path, 'success' => false);
+ }
+ $reponame = ((array_key_exists('title', $w['wiki'])) ? $w['wiki']['title'] : 'repo');
+ if($reponame === '') {
+ $reponame = 'repo';
+ }
+ $git = new GitRepo('sys', null, false, $w['wiki']['title'], $w['path']);
+ try {
+ $gitlog = $git->git->log('', $page_path , array('limit' => 50));
+ logger('gitlog: ' . json_encode($gitlog));
+ return array('history' => $gitlog, 'message' => '', 'success' => true);
+ } catch (\PHPGit\Exception\GitException $e) {
+ return array('history' => null, 'message' => 'GitRepo error thrown', 'success' => false);
+ }
+}
function wiki_save_page($arr) {
$pagename = ((array_key_exists('name',$arr)) ? $arr['name'] : '');