diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-06-16 10:26:47 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-06-16 10:26:47 +0200 |
commit | 28a7458e48d45bfa1e0a3df9ba0a5f7c13b3809b (patch) | |
tree | 7b13533527f03baee8d9cc4b339b535462ae7ada /Zotlabs | |
parent | 05ed20d336c505520fde94e44789d817d136c6f4 (diff) | |
parent | d457f11717da40f44d98eeba5b88e6f1e5636247 (diff) | |
download | volse-hubzilla-28a7458e48d45bfa1e0a3df9ba0a5f7c13b3809b.tar.gz volse-hubzilla-28a7458e48d45bfa1e0a3df9ba0a5f7c13b3809b.tar.bz2 volse-hubzilla-28a7458e48d45bfa1e0a3df9ba0a5f7c13b3809b.zip |
Merge branch 'dev' into sabre32
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/Apps.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Wiki.php | 54 |
2 files changed, 52 insertions, 4 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index ed06943a1..20556212a 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -264,6 +264,8 @@ class Apps { if(! $papp['photo']) $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); + self::translate_system_apps($papp); + $papp['papp'] = self::papp_encode($papp); if(! strstr($papp['url'],'://')) diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index f1f7b87b2..9e7d151b5 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -72,7 +72,8 @@ class Wiki extends \Zotlabs\Web\Controller { switch (argc()) { case 2: // Configure page template - $wikiheader = t('Wiki Sandbox'); + $wikiheaderName = t('Wiki'); + $wikiheaderPage = t('Sandbox'); $content = '"# Wiki Sandbox\n\nContent you **edit** and **preview** here *will not be saved*."'; $hide_editor = false; $showPageControls = false; @@ -113,7 +114,8 @@ class Wiki extends \Zotlabs\Web\Controller { } else { $wiki_editor = true; } - $wikiheader = urldecode($wikiUrlName) . ': ' . urldecode($pageUrlName); // show wiki name and page + $wikiheaderName = urldecode($wikiUrlName); + $wikiheaderPage = urldecode($pageUrlName); $p = wiki_get_page_content(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); if(!$p['success']) { notice('Error retrieving page content' . EOL); @@ -135,7 +137,8 @@ class Wiki extends \Zotlabs\Web\Controller { require_once('library/markdown.php'); $o .= replace_macros(get_markup_template('wiki.tpl'),array( - '$wikiheader' => $wikiheader, + '$wikiheaderName' => $wikiheaderName, + '$wikiheaderPage' => $wikiheaderPage, '$hideEditor' => $hide_editor, '$showPageControls' => $showPageControls, '$showNewWikiButton'=> $showNewWikiButton, @@ -152,6 +155,7 @@ class Wiki extends \Zotlabs\Web\Controller { '$renderedContent' => Markdown(json_decode($content)), '$wikiName' => array('wikiName', t('Enter the name of your new wiki:'), '', ''), '$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'] )); @@ -377,7 +381,7 @@ class Wiki extends \Zotlabs\Web\Controller { if($deleted['success']) { $ob = \App::get_observer(); $commit = wiki_git_commit(array( - 'commit_msg' => 'Deleted ' . $pageHtmlName, + 'commit_msg' => 'Deleted ' . $pageUrlName, 'resource_id' => $resource_id, 'observer' => $ob, 'files' => null @@ -416,6 +420,48 @@ class Wiki extends \Zotlabs\Web\Controller { } } + // Rename a page + if ((argc() === 4) && (argv(2) === 'rename') && (argv(3) === 'page')) { + $resource_id = $_POST['resource_id']; + $pageUrlName = $_POST['oldName']; + $pageNewName = $_POST['newName']; + if ($pageUrlName === 'Home') { + json_return_and_die(array('message' => 'Cannot rename Home','success' => false)); + } + if(urlencode(escape_tags($pageNewName)) === '') { + json_return_and_die(array('message' => 'Error renaming page. Invalid name.', 'success' => false)); + } + // Determine if observer has permission to rename 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['write']) { + logger('Wiki write permission denied. ' . EOL); + json_return_and_die(array('success' => false)); + } + } + $renamed = wiki_rename_page(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName, 'pageNewName' => $pageNewName)); + logger('$renamed: ' . json_encode($renamed)); + if($renamed['success']) { + $ob = \App::get_observer(); + $commit = wiki_git_commit(array( + 'commit_msg' => 'Renamed ' . urldecode($pageUrlName) . ' to ' . $renamed['page']['htmlName'], + 'resource_id' => $resource_id, + 'observer' => $ob, + 'files' => array($pageUrlName . '.md', $renamed['page']['fileName']), + 'all' => true + )); + if($commit['success']) { + json_return_and_die(array('name' => $renamed['page'], 'message' => 'Wiki git repo commit made', 'success' => true)); + } else { + json_return_and_die(array('message' => 'Error making git commit','success' => false)); + } + } else { + json_return_and_die(array('message' => 'Error renaming page', 'success' => false)); + } + } //notice('You must be authenticated.'); json_return_and_die(array('message' => 'You must be authenticated.', 'success' => false)); |