Unlimited level threading is now a site option.

This commit is contained in:
Domovoy 2012-07-29 19:53:04 +02:00
parent 25015d3ab9
commit 2fc0fcdc18
3 changed files with 17 additions and 10 deletions

View file

@ -303,7 +303,7 @@ function localize_item(&$item){
* Recursively prepare a thread for HTML
*/
function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all=false) {
function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $thread_level=1) {
$result = array();
$wall_template = 'wall_thread.tpl';
@ -463,11 +463,11 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
} else {
$indent = 'comment';
// Collapse comments
if(($nb_items > 2) || $collapse_all) {
if(($nb_items > 2) || ($thread_level > 2)) {
if($items_seen == 1) {
$firstcollapsed = true;
}
if($collapse_all) {
if($thread_level > 2) {
if($items_seen == $nb_items)
$lastcollapsed = true;
}
@ -581,11 +581,12 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
}
$item_result['children'] = array();
if(count($item['children'])) {
$collapse_all_children = $collapse_all;
if(!$toplevelpost && !$collapse_all)
$collapse_all_children = true;
$item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all_children);
// Show children of children only if enabled
if(count($item['children'])
&& (($thread_level < 2) || get_config('system','thread_allow'))) {
$thread_level++;
$item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner, $thread_level);
}
$item_result['private'] = $item['private'];
$item_result['toplevel'] = ($toplevelpost ? 'toplevel_item' : '');
@ -668,7 +669,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa
// array with html for each thread (parent+comments)
$threads = array();
$threadsid = -1;
if($items && count($items)) {
if($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
@ -796,6 +797,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa
{
// Normal View
// Threaded comments, $thr_c is used for now since we don't know what other parts of friendica uses this function
// Better not rely on the new code for stuff we haven't examined yet
if($thr_c) {
@ -810,7 +812,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa
}
}
$threads = prepare_threads_body($a, $threads, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $previewing);
$threads = prepare_threads_body($a, $threads, $cmnt_tpl, $page_writeable, $mode, $profile_owner);
}
else {
@ -1168,6 +1170,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa
$threads[$threadsid]['items'][] = $arr['output'];
}
}
}
}

View file

@ -250,6 +250,7 @@ function admin_page_site_post(&$a){
$block_public = ((x($_POST,'block_public')) ? True : False);
$force_publish = ((x($_POST,'publish_all')) ? True : False);
$global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
$thread_allow = ((x($_POST,'thread_allow')) ? True : False);
$no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
$no_openid = !((x($_POST,'no_openid')) ? True : False);
$no_regfullname = !((x($_POST,'no_regfullname')) ? True : False);
@ -342,6 +343,7 @@ function admin_page_site_post(&$a){
} else {
set_config('system','directory_submit_url', $global_directory);
}
set_config('system','thread_allow', $thread_allow);
set_config('system','block_extended_register', $no_multi_reg);
set_config('system','no_openid', $no_openid);
@ -442,6 +444,7 @@ function admin_page_site(&$a) {
'$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.")),
'$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")),
'$global_directory' => array('directory_submit_url', t("Global directory update URL"), get_config('system','directory_submit_url'), t("URL to update the global directory. If this is not set, the global directory is completely unavailable to the application.")),
'$thread_allow' => array('thread_allow', t("Allow threaded items"), get_config('system','thread_allow'), t("Allow infinite level threading for items on this site.")),
'$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")),
'$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")),

View file

@ -71,6 +71,7 @@
{{ inc field_checkbox.tpl with $field=$diaspora_enabled }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$dfrn_only }}{{ endinc }}
{{ inc field_input.tpl with $field=$global_directory }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$thread_allow }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>