aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Help.php5
-rw-r--r--Zotlabs/Module/Network.php22
-rw-r--r--Zotlabs/Widget/Helpindex.php12
-rw-r--r--doc/toc.html62
-rw-r--r--include/conversation.php19
-rw-r--r--include/help.php62
-rw-r--r--view/js/mod_help.js124
-rw-r--r--view/tpl/help.tpl31
8 files changed, 209 insertions, 128 deletions
diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.php
index e98cb9d4d..f3cc3aa5f 100644
--- a/Zotlabs/Module/Help.php
+++ b/Zotlabs/Module/Help.php
@@ -88,12 +88,15 @@ class Help extends \Zotlabs\Web\Controller {
$heading = $headings[argv(1)];
$content = get_help_content();
+
+ $language = determine_help_language()['language'];
return replace_macros(get_markup_template('help.tpl'), array(
'$title' => t('$Projectname Documentation'),
'$tocHeading' => t('Contents'),
'$content' => $content,
- '$heading' => $heading
+ '$heading' => $heading,
+ '$language' => $language
));
}
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 36ae7f047..82c997270 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -116,7 +116,6 @@ class Network extends \Zotlabs\Web\Controller {
$spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0);
$cmin = ((x($_GET,'cmin')) ? intval($_GET['cmin']) : 0);
$cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99);
- $firehose = ((x($_GET,'fh')) ? intval($_GET['fh']) : 0);
$file = ((x($_GET,'file')) ? $_GET['file'] : '');
$xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : '');
@@ -290,9 +289,6 @@ class Network extends \Zotlabs\Web\Controller {
// We only launch liveUpdate if you aren't filtering in some incompatible
// way and also you aren't writing a comment (discovered in javascript).
- if($gid || $cid || $cmin || ($cmax != 99) || $star || $liked || $conv || $spam || $nouveau || $list)
- $firehose = 0;
-
$maxheight = get_pconfig(local_channel(),'system','network_divmore_height');
if(! $maxheight)
$maxheight = 400;
@@ -315,7 +311,7 @@ class Network extends \Zotlabs\Web\Controller {
'$liked' => (($liked) ? $liked : '0'),
'$conv' => (($conv) ? $conv : '0'),
'$spam' => (($spam) ? $spam : '0'),
- '$fh' => (($firehose) ? $firehose : '0'),
+ '$fh' => '0',
'$nouveau' => (($nouveau) ? $nouveau : '0'),
'$wall' => '0',
'$static' => $static,
@@ -409,17 +405,7 @@ class Network extends \Zotlabs\Web\Controller {
}
$abook_uids = " and abook.abook_channel = " . local_channel() . " ";
-
- $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false;
- if($firehose && (! $disable_discover_tab)) {
- require_once('include/channel.php');
- $sys = get_sys_channel();
- $uids = " and item.uid = " . intval($sys['channel_id']) . " ";
- \App::$data['firehose'] = intval($sys['channel_id']);
- }
- else {
- $uids = " and item.uid = " . local_channel() . " ";
- }
+ $uids = " and item.uid = " . local_channel() . " ";
if(get_pconfig(local_channel(),'system','network_list_mode'))
$page_mode = 'list';
@@ -516,7 +502,7 @@ class Network extends \Zotlabs\Web\Controller {
dbesc($parents_str)
);
- xchan_query($items,true,(($firehose) ? local_channel() : 0));
+ xchan_query($items,true);
$items = fetch_post_tags($items,true);
$items = conv_sort($items,$ordering);
}
@@ -546,7 +532,7 @@ class Network extends \Zotlabs\Web\Controller {
}
}
- if(($update_unseen) && (! $firehose)) {
+ if($update_unseen) {
$x = [ 'channel_id' => local_channel(), 'update' => 'unset' ];
call_hooks('update_unseen',$x);
if($x['update'] === 'unset' || intval($x['update'])) {
diff --git a/Zotlabs/Widget/Helpindex.php b/Zotlabs/Widget/Helpindex.php
index f23e73e75..8299cf16a 100644
--- a/Zotlabs/Widget/Helpindex.php
+++ b/Zotlabs/Widget/Helpindex.php
@@ -9,14 +9,22 @@ class Helpindex {
$o .= '<div class="widget">';
$level_0 = get_help_content('sitetoc');
- if(! $level_0)
- $level_0 = get_help_content('toc');
+ if(! $level_0) {
+ $path = 'toc';
+ $x = determine_help_language();
+ $lang = $x['language'];
+ if($lang !== 'en') {
+ $path = $lang . '/toc';
+ }
+ $level_0 = get_help_content($path);
+ }
$level_0 = preg_replace('/\<ul(.*?)\>/','<ul class="nav nav-pills flex-column">',$level_0);
$levels = array();
+ // TODO: Implement support for translations in hierarchical table of content files
if(argc() > 2) {
$path = '';
for($x = 1; $x < argc(); $x ++) {
diff --git a/doc/toc.html b/doc/toc.html
index 4da01d55d..1b7de3cb3 100644
--- a/doc/toc.html
+++ b/doc/toc.html
@@ -71,65 +71,3 @@
</div>
</div>
</div>
-<script>
- toc = {};
- // Generate the table of contents in the side nav menu (see view/tpl/help.tpl)
- $(document).ready(function () {
- $(".doco-section").find('a').each(function(){
- var url = document.createElement('a');
- url.href = window.location;
- var pageName = url.href.split('/').pop().split('#').shift().split('?').shift();
- var linkName = $(this).attr('href').split('/').pop();
- if(pageName === linkName) {
- var tocUl = $(this).closest('a').append('<ul>').find('ul');
- tocUl.removeClass(); // Classes are automatically added to <ul> elements by something else
- tocUl.toc({content: "#doco-content", headings: "h3"});
- tocUl.addClass('toc-content');
- tocUl.addClass('list-unstyled');
- tocUl.attr('id', 'doco-side-toc');
-
- }
- });
-
- $(document.body).trigger("sticky_kit:recalc");
-
- toc.contentTop = [];
- toc.edgeMargin = 20; // margin above the top or margin from the end of the page
- toc.topRange = 200; // measure from the top of the viewport to X pixels down
- // Set up content an array of locations
- $('#doco-side-toc').find('a').each(function(){
- toc.contentTop.push( $( '#'+$(this).attr('href').split('#').pop() ).offset().top );
- });
-
-
- // adjust side menu
- $(window).scroll(function(){
- var winTop = $(window).scrollTop(),
- bodyHt = $(document).height(),
- vpHt = $(window).height() + toc.edgeMargin; // viewport height + margin
- $.each( toc.contentTop, function(i,loc){
- if ( ( loc > winTop - toc.edgeMargin && ( loc < winTop + toc.topRange || ( winTop + vpHt ) >= bodyHt ) ) ){
- $('#doco-side-toc li')
- .removeClass('selected-doco-nav')
- .eq(i).addClass('selected-doco-nav');
- if (typeof($('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]) !== 'undefined') {
- window.history.pushState({}, '', location.href.split('#')[0] + '#' + $('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]);
- }
- }
- });
- });
-
- // When the page loads, it does not scroll to the section specified in the URL because it
- // has not been constructed yet by the script. This will reload the URL
- if (typeof(location.href.split('#')[1]) !== 'undefined') {
- var p = document.createElement('a');
- p.href = location.href;
- var portstr = '';
- if(p.port !== '') {
- portstr = ':'+ p.port;
- }
- var newref = p.protocol + '//'+ p.hostname + portstr + p.pathname + p.hash.split('?').shift();
- location.replace(newref)
- }
- });
-</script>
diff --git a/include/conversation.php b/include/conversation.php
index 9a48a83d2..ec445ba4c 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1623,7 +1623,6 @@ function network_tabs() {
$conv_active = '';
$spam_active = '';
$postord_active = '';
- $public_active = '';
if(x($_GET,'new')) {
$new_active = 'active';
@@ -1645,16 +1644,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';
}
@@ -1672,17 +1666,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'] : ''),
diff --git a/include/help.php b/include/help.php
index 4f9251b1b..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) {
@@ -107,20 +114,55 @@ 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;
+ } 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';
- $b = basename($s);
- $d = dirname($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;
+ }
- if($dirname !== '-') {
- $c = find_doc_file("$d/$lang/$b");
- if($c)
- return $c;
+ $b = basename($s);
+
+ for($i=1+$url_idx; $i<argc()-1; $i++) {
+ $path .= '/' . argv($i);
+ }
+ $c = find_doc_file($path . '/' . $b);
+ if($c)
+ return $c;
+ // Possibly a translation was requested that has not been translated, so fall
+ // back to the English version
+ $path = 'doc';
+ for($i=1+$url_idx; $i<argc()-1; $i++) {
+ $path .= '/' . argv($i);
}
+ $c = find_doc_file($path . '/' . $b);
+ if($c)
+ return $c;
+ // Try one last time to find the file at the explicit path input to the function
$c = find_doc_file($s);
if($c)
return $c;
diff --git a/view/js/mod_help.js b/view/js/mod_help.js
new file mode 100644
index 000000000..8ee89dd61
--- /dev/null
+++ b/view/js/mod_help.js
@@ -0,0 +1,124 @@
+function docoTocToggle() {
+ if ($('#doco-top-toc').is(':visible')) {
+ $('#doco-toc-toggle').removeClass('fa-cog').addClass('fa-caret-right');
+ } else {
+ $('#doco-toc-toggle').removeClass('fa-caret-right').addClass('fa-caret-down');
+ }
+ $('#doco-top-toc').toggle();
+
+ return false;
+}
+
+toc = {};
+// Generate the table of contents in the side nav menu (see view/tpl/help.tpl)
+$(document).ready(function () {
+ // Generate the table of contents in the side nav menu (see view/tpl/help.tpl)
+ $('#doco-top-toc').toc({content: "#doco-content", headings: "h3,h4,h5,h6"});
+
+ $(".doco-section").find('a').each(function () {
+ var url = document.createElement('a');
+ url.href = window.location;
+ var pageName = url.href.split('/').pop().split('#').shift().split('?').shift();
+ var linkName = $(this).attr('href').split('/').pop();
+ if (pageName === linkName) {
+ var tocUl = $(this).closest('a').append('<ul>').find('ul');
+ tocUl.removeClass(); // Classes are automatically added to <ul> elements by something else
+ tocUl.toc({content: "#doco-content", headings: "h3"});
+ tocUl.addClass('toc-content');
+ tocUl.addClass('list-unstyled');
+ tocUl.attr('id', 'doco-side-toc');
+
+ }
+ });
+
+ $(document.body).trigger("sticky_kit:recalc");
+
+ toc.contentTop = [];
+ toc.edgeMargin = 20; // margin above the top or margin from the end of the page
+ toc.topRange = 200; // measure from the top of the viewport to X pixels down
+ // Set up content an array of locations
+ $('#doco-side-toc').find('a').each(function () {
+ toc.contentTop.push($('#' + $(this).attr('href').split('#').pop()).offset().top);
+ });
+
+
+ // adjust side menu
+ $(window).scroll(function () {
+ var winTop = $(window).scrollTop(),
+ bodyHt = $(document).height(),
+ vpHt = $(window).height() + toc.edgeMargin; // viewport height + margin
+ $.each(toc.contentTop, function (i, loc) {
+ if ((loc > winTop - toc.edgeMargin && (loc < winTop + toc.topRange || (winTop + vpHt) >= bodyHt))) {
+ $('#doco-side-toc li')
+ .removeClass('selected-doco-nav')
+ .eq(i).addClass('selected-doco-nav');
+ if (typeof ($('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]) !== 'undefined') {
+ window.history.pushState({}, '', location.href.split('#')[0] + '#' + $('#doco-side-toc li').eq(i).find('a').attr('href').split('#')[1]);
+ }
+ }
+ });
+ });
+
+ // When the page loads, it does not scroll to the section specified in the URL because it
+ // has not been constructed yet by the script. This will reload the URL
+ if (typeof (location.href.split('#')[1]) !== 'undefined') {
+ var p = document.createElement('a');
+ p.href = location.href;
+ var portstr = '';
+ if (p.port !== '') {
+ portstr = ':' + p.port;
+ }
+ var newref = p.protocol + '//' + p.hostname + portstr + p.pathname + p.hash.split('?').shift();
+ location.replace(newref)
+ }
+
+
+ // Determine language translations available from the language selector menu itself
+ var langChoices = [];
+ $('.lang-selector').find('.lang-choice').each(function (idx, a) {
+ langChoices.push($(a).html());
+ });
+ // Parse the URL and insert the language code for the loaded language, based
+ // on the variable "help_language" that is declared in the help.tpl page template
+ var path = window.location.pathname.split('/');
+ var pathParts = [];
+ var pick_me = true;
+ for (var i = 0; i < path.length; i++) {
+ if(i === 2 && pick_me ) {
+ if(path[i].length > 0) {
+ pathParts.push(help_language);
+ pick_me = false;
+ if($.inArray(path[i], langChoices) < 0) {
+ i--;
+ }
+ }
+ } else {
+ if(path[i].length > 0) {
+ pathParts.push(path[i]);
+ }
+ }
+
+ }
+ // Update the address bar to reflect the loaded language
+ window.history.pushState({}, '', '/' + pathParts.join('/'));
+
+ // Highlight the language in the language selector that is currently viewed
+ $('.lang-selector').find('.lang-choice:contains("' + help_language + '")').addClass('active');
+
+ // Construct the links to the available translations based and populate the selector menu
+ $('.lang-selector').find('.lang-choice').each(function (idx, a) {
+ var langLink = [];
+
+ for (var i = 0; i < pathParts.length; i++) {
+
+ if(i === 1) {
+ langLink.push($(a).html());
+ } else {
+ langLink.push(pathParts[i]);
+ }
+
+ }
+ $(a).attr('href', '/' + langLink.join('/'));
+ });
+
+});
diff --git a/view/tpl/help.tpl b/view/tpl/help.tpl
index 43b061dcc..d36494123 100644
--- a/view/tpl/help.tpl
+++ b/view/tpl/help.tpl
@@ -1,5 +1,17 @@
<div id="help-content" class="generic-content-wrapper">
- <div class="section-title-wrapper">
+ <div class="clearfix section-title-wrapper">
+ <div class="pull-right">
+ <div class="btn-group">
+ <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown">
+ <i class="fa fa-language" style="font-size: 1.4em;"></i>
+ </button>
+ <div class="dropdown-menu dropdown-menu-right flex-column lang-selector">
+ <a class="dropdown-item lang-choice" href="/help">de</a>
+ <a class="dropdown-item lang-choice" href="/help">en</a>
+ <a class="dropdown-item lang-choice" href="/help">es</a>
+ </div>
+ </div>
+ </div>
<h2>{{$title}}: {{$heading}}</h2>
</div>
<div class="section-content-wrapper" id="doco-content">
@@ -13,21 +25,6 @@
{{$content}}
</div>
</div>
-
<script>
- // Generate the table of contents in the side nav menu (see view/tpl/help.tpl)
- $(document).ready(function () {
- $('#doco-top-toc').toc({content: "#doco-content", headings: "h3,h4,h5,h6"});
- });
-
- function docoTocToggle() {
- if($('#doco-top-toc').is(':visible')) {
- $('#doco-toc-toggle').removeClass('fa-cog').addClass('fa-caret-right');
- } else {
- $('#doco-toc-toggle').removeClass('fa-caret-right').addClass('fa-caret-down');
- }
- $('#doco-top-toc').toggle();
-
- return false;
- }
+ var help_language = '{{$language}}'
</script>