diff options
author | zotlabs <mike@macgirvin.com> | 2017-05-22 20:18:47 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-05-22 20:18:47 -0700 |
commit | 53057830e0388e0888cca925a99aa62cda0168cf (patch) | |
tree | d7e4863d37203e4e57d2ec8de2afa1958b76a665 /Zotlabs/Module | |
parent | 7ae0317b6a2bed323492ef987ddbaaf4f2a1a9b9 (diff) | |
download | volse-hubzilla-53057830e0388e0888cca925a99aa62cda0168cf.tar.gz volse-hubzilla-53057830e0388e0888cca925a99aa62cda0168cf.tar.bz2 volse-hubzilla-53057830e0388e0888cca925a99aa62cda0168cf.zip |
wiki auto language select to match webpages implementation
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Wiki.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index d577226dc..5a93046e3 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -192,12 +192,28 @@ class Wiki extends \Zotlabs\Web\Controller { goaway(z_root() . '/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/Home'); case 4: + default: // GET /wiki/channel/wiki/page // Fetch the wiki info and determine observer permissions $wikiUrlName = urldecode(argv(2)); - $pageUrlName = urldecode(argv(3)); + + $page_name = ''; + $ignore_language = false; + + for($x = 3; $x < argc(); $x ++) { + if($page_name === '' && argv($x) === '-') { + $ignore_language = true; + continue; + } + if($page_name) + $page_name .= '/'; + $page_name .= argv($x); + } + + $pageUrlName = urldecode($page_name); + $langPageUrlName = urldecode(\App::$language . '/' . $page_name); $w = Zlib\NativeWiki::exists_by_name($owner['channel_id'], $wikiUrlName); @@ -227,9 +243,15 @@ class Wiki extends \Zotlabs\Web\Controller { $wikiheaderPage = urldecode($pageUrlName); $renamePage = (($wikiheaderPage === 'Home') ? '' : t('Rename page')); + $p = []; - $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); - if(! $p['success']) { + if(! $ignore_language) { + $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $langPageUrlName)); + } + if(! ($p && $p['success'])) { + $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); + } + if(! ($p && $p['success'])) { notice( t('Error retrieving page content') . EOL); goaway(z_root() . '/' . argv(0) . '/' . argv(1) ); } @@ -251,8 +273,8 @@ class Wiki extends \Zotlabs\Web\Controller { } $showPageControls = $wiki_editor; break; - default: // Strip the extraneous URL components - goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); +// default: // Strip the extraneous URL components +// goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); } |