aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-06-20 13:43:36 -0700
committerredmatrix <git@macgirvin.com>2016-06-20 13:43:36 -0700
commit3a43b1d85d12497eeee99ad5948e4ee420809418 (patch)
treeb5158036e1b10961e09d4c6275074c01cc0bf69f /include
parent01bfadaeaa6440586aba74cf098b38a9a134a510 (diff)
parent670d12219b3afb84b4180a0dae71077dbda4f09d (diff)
downloadvolse-hubzilla-3a43b1d85d12497eeee99ad5948e4ee420809418.tar.gz
volse-hubzilla-3a43b1d85d12497eeee99ad5948e4ee420809418.tar.bz2
volse-hubzilla-3a43b1d85d12497eeee99ad5948e4ee420809418.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'include')
-rw-r--r--include/datetime.php2
-rw-r--r--include/wiki.php44
2 files changed, 44 insertions, 2 deletions
diff --git a/include/datetime.php b/include/datetime.php
index bf58866e9..600ad6ec4 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -224,7 +224,7 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
$pickers = '';
if(!$pickdate) $pickers .= ',datepicker: false';
- if(!$picktime) $pickers .= ',timepicker: false';
+ if(!$picktime) $pickers .= ',timepicker: false, closeOnDateSelect:true';
$extra_js = '';
if($minfrom != '')
diff --git a/include/wiki.php b/include/wiki.php
index d60f4a3a7..a89db3358 100644
--- a/include/wiki.php
+++ b/include/wiki.php
@@ -347,7 +347,7 @@ function wiki_revert_page($arr) {
$resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
$commitHash = ((array_key_exists('commitHash',$arr)) ? $arr['commitHash'] : null);
if (! $commitHash) {
- return array('content' => $content, 'message' => 'No commit has provided', 'success' => false);
+ return array('content' => $content, 'message' => 'No commit was provided', 'success' => false);
}
$w = wiki_get_wiki($resource_id);
if (!$w['path']) {
@@ -378,6 +378,48 @@ function wiki_revert_page($arr) {
}
}
+function wiki_compare_page($arr) {
+ $pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
+ $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
+ $currentCommit = ((array_key_exists('currentCommit',$arr)) ? $arr['currentCommit'] : 'HEAD');
+ $compareCommit = ((array_key_exists('compareCommit',$arr)) ? $arr['compareCommit'] : null);
+ if (! $compareCommit) {
+ return array('message' => 'No compare commit was provided', 'success' => false);
+ }
+ $w = wiki_get_wiki($resource_id);
+ if (!$w['path']) {
+ return array('message' => 'Error reading wiki', 'success' => false);
+ }
+ $page_path = $w['path'].'/'.$pageUrlName.'.md';
+ if (is_readable($page_path) === true) {
+ $reponame = ((array_key_exists('title', $w['wiki'])) ? urlencode($w['wiki']['title']) : 'repo');
+ if($reponame === '') {
+ $reponame = 'repo';
+ }
+ $git = new GitRepo('', null, false, $w['wiki']['title'], $w['path']);
+ $compareContent = $currentContent = '';
+ try {
+ foreach ($git->git->tree($currentCommit) as $object) {
+ if ($object['type'] == 'blob' && $object['file'] === $pageUrlName.'.md' ) {
+ $currentContent = $git->git->cat->blob($object['hash']);
+ }
+ }
+ foreach ($git->git->tree($compareCommit) as $object) {
+ if ($object['type'] == 'blob' && $object['file'] === $pageUrlName.'.md' ) {
+ $compareContent = $git->git->cat->blob($object['hash']);
+ }
+ }
+ require_once('library/class.Diff.php');
+ $diff = Diff::toTable(Diff::compare($currentContent, $compareContent));
+ } catch (\PHPGit\Exception\GitException $e) {
+ return array('message' => 'GitRepo error thrown', 'success' => false);
+ }
+ return array('diff' => $diff, 'message' => '', 'success' => true);
+ } else {
+ return array('message' => 'Page file not writable', 'success' => false);
+ }
+}
+
function wiki_git_commit($arr) {
$files = ((array_key_exists('files', $arr)) ? $arr['files'] : null);
$all = ((array_key_exists('all', $arr)) ? $arr['all'] : false);