From 6c388575022cc10f28ed99e8e414fbc76a67bb00 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Wed, 23 Aug 2017 03:33:03 +0000 Subject: Repaired and extended support for help page translations including table of contents files at the top level. Moved help module javascript to mod_help.js. --- include/help.php | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/help.php b/include/help.php index 4f9251b1b..cbadd02d9 100644 --- a/include/help.php +++ b/include/help.php @@ -107,20 +107,39 @@ function preg_callback_help_include($matches) { } - +function determine_help_language() { + require_once('Text/LanguageDetect.php'); + $lang_detect = new Text_LanguageDetect(); + $lang_detect->setNameMode(2); + if($lang_detect->languageExists(argv(1))) { + $lang = argv(1); + $from_url = true; + } else { + $lang = \App::$language; + if(! isset($lang)) + $lang = 'en'; + $from_url = false; + } + return array('language' => $lang, 'from_url' => $from_url); +} function load_doc_file($s) { - $lang = \App::$language; - if(! isset($lang)) - $lang = 'en'; + $path = 'doc'; + $x = determine_help_language(); + $lang = $x['language']; + $url_idx = ($x['from_url'] ? 1 : 0); + if($x['from_url'] && $lang !== 'en') { + $path .= '/' . $lang; + } + $b = basename($s); - $d = dirname($s); - - if($dirname !== '-') { - $c = find_doc_file("$d/$lang/$b"); - if($c) - return $c; + + for($i=1+$url_idx; $i Date: Thu, 24 Aug 2017 11:19:11 +0000 Subject: Fixed incorrect language path when choosing the language from browser preference --- include/help.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/help.php b/include/help.php index cbadd02d9..f38f77854 100644 --- a/include/help.php +++ b/include/help.php @@ -128,7 +128,7 @@ function load_doc_file($s) { $x = determine_help_language(); $lang = $x['language']; $url_idx = ($x['from_url'] ? 1 : 0); - if($x['from_url'] && $lang !== 'en') { + if($lang !== 'en') { $path .= '/' . $lang; } -- cgit v1.2.3 From cf2609530fcffdc7f5477336232b7cfde8b6403f Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Thu, 24 Aug 2017 18:57:41 +0000 Subject: Added language selector menu for Help pages --- include/help.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/help.php b/include/help.php index f38f77854..ef6b77e12 100644 --- a/include/help.php +++ b/include/help.php @@ -32,6 +32,13 @@ function get_help_content($tocpath = false) { if(! $tocpath) \App::$page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title))); + if($tocpath !== false && + load_doc_file('doc/' . $path . '.md') === '' && + load_doc_file('doc/' . $path . '.bb') === '' && + load_doc_file('doc/' . $path . '.html') === '' + ) { + $path = 'toc'; + } $text = load_doc_file('doc/' . $path . '.md'); if(! $text) { @@ -110,7 +117,10 @@ function preg_callback_help_include($matches) { function determine_help_language() { require_once('Text/LanguageDetect.php'); $lang_detect = new Text_LanguageDetect(); + // Set this mode to recognize language by the short code like "en", "ru", etc. $lang_detect->setNameMode(2); + // If the language was specified in the URL, override the language preference + // of the browser. Default to English if both of these are absent. if($lang_detect->languageExists(argv(1))) { $lang = argv(1); $from_url = true; @@ -125,13 +135,16 @@ function determine_help_language() { function load_doc_file($s) { $path = 'doc'; + // Determine the language and modify the path accordingly $x = determine_help_language(); $lang = $x['language']; $url_idx = ($x['from_url'] ? 1 : 0); + // The English translation is at the root of /doc/. Other languages are in + // subfolders named by the language code such as "de", "es", etc. if($lang !== 'en') { $path .= '/' . $lang; } - + $b = basename($s); for($i=1+$url_idx; $i Date: Thu, 24 Aug 2017 21:47:01 +0200 Subject: ditch discover tab in favour of the public stream app --- include/conversation.php | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 2d5ccb5b1..78d90a6fc 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1616,7 +1616,6 @@ function network_tabs() { $conv_active = ''; $spam_active = ''; $postord_active = ''; - $public_active = ''; if(x($_GET,'new')) { $new_active = 'active'; @@ -1638,16 +1637,11 @@ function network_tabs() { $spam_active = 'active'; } - if(x($_GET,'fh')) { - $public_active = 'active'; - } - if (($new_active == '') && ($starred_active == '') && ($conv_active == '') && ($search_active == '') - && ($spam_active == '') - && ($public_active == '')) { + && ($spam_active == '')) { $no_active = 'active'; } @@ -1665,17 +1659,6 @@ function network_tabs() { // tabs $tabs = array(); - $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false; - - if(! $disable_discover_tab) { - $tabs[] = array( - 'label' => t('Discover'), - 'url' => z_root() . '/' . $cmd . '?f=&fh=1' , - 'sel' => $public_active, - 'title' => t('Imported public streams'), - ); - } - $tabs[] = array( 'label' => t('Commented Order'), 'url'=>z_root() . '/' . $cmd . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') . ((x($_GET,'gid')) ? '&gid=' . $_GET['gid'] : ''), -- cgit v1.2.3