aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
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 /Zotlabs
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 'Zotlabs')
-rw-r--r--Zotlabs/Lib/XConfig.php4
-rw-r--r--Zotlabs/Module/Wiki.php43
2 files changed, 43 insertions, 4 deletions
diff --git a/Zotlabs/Lib/XConfig.php b/Zotlabs/Lib/XConfig.php
index e28dcf559..7f3d0f2cd 100644
--- a/Zotlabs/Lib/XConfig.php
+++ b/Zotlabs/Lib/XConfig.php
@@ -122,7 +122,7 @@ class XConfig {
);
}
- App::$config[$xchan][$family][$key] = $value;
+ \App::$config[$xchan][$family][$key] = $value;
if($ret)
return $value;
@@ -157,4 +157,4 @@ class XConfig {
return $ret;
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 9e7d151b5..bef831de8 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -136,6 +136,16 @@ class Wiki extends \Zotlabs\Web\Controller {
// Render the Markdown-formatted page content in HTML
require_once('library/markdown.php');
+ $wikiModalID = random_string(3);
+ $wikiModal = replace_macros(
+ get_markup_template('generic_modal.tpl'), array(
+ '$id' => $wikiModalID,
+ '$title' => t('Revision Comparison'),
+ '$ok' => t('Revert'),
+ '$cancel' => t('Cancel')
+ )
+ );
+
$o .= replace_macros(get_markup_template('wiki.tpl'),array(
'$wikiheaderName' => $wikiheaderName,
'$wikiheaderPage' => $wikiheaderPage,
@@ -157,7 +167,10 @@ class Wiki extends \Zotlabs\Web\Controller {
'$pageName' => array('pageName', t('Enter the name of the new page:'), '', ''),
'$pageRename' => array('pageRename', t('Enter the new name:'), '', ''),
'$commitMsg' => array('commitMsg', '', '', '', '', 'placeholder="(optional) Enter a custom message when saving the page..."'),
- '$pageHistory' => $pageHistory['history']
+ '$pageHistory' => $pageHistory['history'],
+ '$wikiModal' => $wikiModal,
+ '$wikiModalID' => $wikiModalID,
+ '$commit' => 'HEAD'
));
head_add_js('library/ace/ace.js'); // Ace Code Editor
return $o;
@@ -412,7 +425,7 @@ class Wiki extends \Zotlabs\Web\Controller {
json_return_and_die(array('success' => false));
}
}
- $reverted = wiki_revert_page(array('commitHash' => $commitHash, 'observer' => \App::get_observer(), 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
+ $reverted = wiki_revert_page(array('commitHash' => $commitHash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
if($reverted['success']) {
json_return_and_die(array('content' => $reverted['content'], 'message' => '', 'success' => true));
} else {
@@ -420,6 +433,32 @@ class Wiki extends \Zotlabs\Web\Controller {
}
}
+ // Compare page revisions
+ if ((argc() === 4) && (argv(2) === 'compare') && (argv(3) === 'page')) {
+ $resource_id = $_POST['resource_id'];
+ $pageUrlName = $_POST['name'];
+ $compareCommit = $_POST['compareCommit'];
+ $currentCommit = $_POST['currentCommit'];
+ // Determine if observer has permission to revert pages
+ $nick = argv(1);
+ $channel = get_channel_by_nick($nick);
+ if (local_channel() !== intval($channel['channel_id'])) {
+ $observer_hash = get_observer_hash();
+ $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash);
+ if(!$perms['read']) {
+ logger('Wiki read permission denied.' . EOL);
+ json_return_and_die(array('success' => false));
+ }
+ }
+ $compare = wiki_compare_page(array('currentCommit' => $currentCommit, 'compareCommit' => $compareCommit, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
+ if($compare['success']) {
+ $diffHTML = '<table class="text-center" width="100%"><tr><td class="lead" width="50%">Current Revision</td><td class="lead" width="50%">Selected Revision</td></tr></table>' . $compare['diff'];
+ json_return_and_die(array('diff' => $diffHTML, 'message' => '', 'success' => true));
+ } else {
+ json_return_and_die(array('diff' => '', 'message' => 'Error comparing page', 'success' => false));
+ }
+ }
+
// Rename a page
if ((argc() === 4) && (argv(2) === 'rename') && (argv(3) === 'page')) {
$resource_id = $_POST['resource_id'];