? af_720118_preview.patch Index: includes/advanced_forum_preprocess_forum_list.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/advanced_forum/includes/Attic/advanced_forum_preprocess_forum_list.inc,v retrieving revision 1.1.2.22 diff -u -p -r1.1.2.22 advanced_forum_preprocess_forum_list.inc --- includes/advanced_forum_preprocess_forum_list.inc 11 Feb 2011 20:57:09 -0000 1.1.2.22 +++ includes/advanced_forum_preprocess_forum_list.inc 19 Feb 2011 06:14:34 -0000 @@ -26,163 +26,138 @@ function _advanced_forum_preprocess_foru $variables['forum_id'] = $parent_id; unset($variables['tid']); - /* Deal with creating fake containers as necessary. */ + dsm($variables['forums']); - if (empty($parent_id)) { - // At the root /forum listing. Make sure all forums are in containers, - // creating fake ones if needed, so the table structure works properly. - $main_forum_page = TRUE; - $root_forums = FALSE; - $fake_container = FALSE; - $containers = FALSE; - $tids = array(); - foreach ($variables['forums'] as $id => $forum) { - // If uncontained forums come after an existing container, they'll - // be put into that container due to the ordering in the template. - // So don't bother with a fake container if there won't be anything - // in it. - if (!empty($forum->container) && !$fake_container) { - $containers = TRUE; - } - - if (empty($forum->container) && $forum->parents == array(0 => 0)) { - // This is a forum, not a container, and it has no parents. ie: forum - // at the root outside of any containers. - $root_forums = TRUE; - if (!$containers) { - // No containers come before this forum, even at the same level, - // so we need to make a fake container to hold it. - $fake_container = TRUE; + $table_counter = 0; + foreach ($variables['forums'] as $id => $forum) { + if ($forum->depth == 0) { + // This container / forum is at the root. We need to put it in a table. + + if (!empty($forum->container)) { + // Top level container always starts a new table. + $table_counter++; + $tables[$table_counter]['table_info'] = advanced_forum_process_forum($forum, TRUE); + } + else { + // This is a forum at the root. If it is the first or the first + // since the last container, make a new table. Otherwise, put it in + // the previous table. + if (empty($table_counter) || !empty($tables[$table_counter]['table_info']->container)) { + // This is the first root item or the current table belongs to a + // container. Start a new generic one. + $table_counter++; + $reset_row = TRUE; + $tables[$table_counter]['table_info']->name = t('Forum'); + $tables[$table_counter]['table_info']->linked_name = t('Forum'); } - $variables['forums'][$id]->depth++; - $tids[$forum->tid] = $forum->tid; - } - - // @TODO: Figure out what this does. - if ($root_forums && !empty($tids[$forum->parents[0]])) { - $variables['forums'][$id]->depth++; - $tids[$forum->tid] = $forum->tid; + + // Add the forum info to the table's item list. + $tables[$table_counter]['items'][$id] = advanced_forum_process_forum($forum, $reset_row); + $reset_row = FALSE; } } - - if ($fake_container) { - // Create the fake container and stick it at the top. - $container = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', '')); - $container->tid = 0; - $container->container = TRUE; - $container->num_topics = 0; - $variables['forums'] = array(0 => $container) + $variables['forums']; - } + elseif ($forum->depth == 1) { + // 1 level down is easy because we know that is displayed in full. + $tables[$table_counter]['items'][$id] = advanced_forum_process_forum($forum); + } + else { + // For simplicity, we are assuming forums have only one parent. + if (!empty($forum->container) || !empty($variables['forums'][$forum->parents[0]]->container)) { + // This is either a subcontainer or a forum under a subcontainer so + // treat it as a top level. + $tables[$table_counter]['items'][$id] = advanced_forum_process_forum($forum); + } + else { + // Subforum. + $tables[$table_counter]['items'][$forum->parents[0]]->subforum_list[$id] = advanced_forum_process_forum($forum); + } + } } - else { - // On a container or forum page. - - $main_forum_page = FALSE; - // We want to add in the container or use the parent forum as a container. - $container = taxonomy_get_term($parent_id); - $container->container = TRUE; - $container->num_topics = 0; - - // Add in the "container" at the top and bump up the depth of everything - // underneath. Note that we can't use array_unshift to add the container - // to the top as that changes all the keys. - $orginal_forums = $variables['forums']; - $variables['forums'] = array(); - $variables['forums'][$parent_id] = $container; - $variables['forums'][$parent_id]->depth = 0; - foreach ($orginal_forums as $id => $forum) { - $variables['forums'][$id] = $forum; - $variables['forums'][$id]->depth++; - } + + // Theme subforums and add post counts to parents. + foreach ($tables as $table_id => $table) { + foreach ($table['items'] as $item_id => $item) { + if (!empty($item->subforum_list)) { + $tables[$table_id]['items'][$item_id]->subforums = theme('advanced_forum_subforum_list', $item->subforum_list); + } + } } - - /* Organize all the forum data into the template variables */ + dsm($tables); + $variables['tables'] = $tables; +} + +function advanced_forum_process_forum($forum, $reset_row) { + static $row = 1; global $user; - $row = 0; + + if ($reset_row) { + // Allow zebra striping to reset for each table. + $row = 1; + } + // Sanitize each forum so that the template can safely print the data but skip the name of subforums. - foreach ($variables['forums'] as $id => $forum) { - $variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : ''; - $variables['forums'][$id]->link = url("forum/$forum->tid"); - $variables['forums'][$id]->name = empty($forum->parents[0]) ? check_plain($forum->name) : $forum->name; - $variables['forums'][$id]->is_container = !empty($forum->container); - $variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even'; - $row++; - - $variables['forums'][$id]->new_text = ''; - $variables['forums'][$id]->new_url = ''; - $variables['forums'][$id]->new_topics = 0; - $variables['forums'][$id]->old_topics = $forum->num_topics; - if ($user->uid) { - $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->tid, $user->uid); - if ($variables['forums'][$id]->new_topics) { - $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new', '@count new'); - $variables['forums'][$id]->new_url = url("forum/$forum->tid", array('fragment' => 'new')); - } - $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics; + $forum->description = !empty($forum->description) ? filter_xss_admin($forum->description) : ''; + $forum->link = url("forum/$forum->tid"); + $forum->name = empty($forum->parents[0]) ? check_plain($forum->name) : $forum->name; + $forum->linked_name = l($forum->name, $forum->link); + $forum->is_container = !empty($forum->container); + $forum->zebra = $row % 2 == 0 ? 'odd' : 'even'; + $row++; + + $forum->new_text = ''; + $forum->new_url = ''; + $forum->new_topics = 0; + $forum->old_topics = $forum->num_topics; + if ($user->uid) { + $forum->new_topics = _forum_topics_unread($forum->tid, $user->uid); + if ($forum->new_topics) { + $forum->new_text = format_plural($forum->new_topics, '1 new', '@count new'); + $forum->new_url = url("forum/$forum->tid", array('fragment' => 'new')); } + $forum->old_topics = $forum->num_topics - $forum->new_topics; + } - // Avoid notices if there is no last post. - $forum->last_post = (empty($forum->last_post)) ? '' : $forum->last_post; - $variables['forums'][$id]->last_reply = theme('forum_submitted', $forum->last_post); - - $variables['forums'][$id]->new_posts = 0; - $variables['forums'][$id]->new_text_posts = ''; - $variables['forums'][$id]->new_url_posts = ''; - $variables['forums'][$id]->old_posts = (empty($forum->num_posts)) ? '' : $forum->num_posts; - - if ($user->uid) { - // Show number of new posts as well as topics - if (variable_get('advanced_forum_get_new_comments', 0)) { - // This can cause performance issues, so allow it to be turned off - $variables['forums'][$id]->new_posts = advanced_forum_unread_replies_in_forum($forum->tid, $user->uid) + $variables['forums'][$id]->new_topics; - - if ($variables['forums'][$id]->new_posts) { - $variables['forums'][$id]->new_text_posts = format_plural($variables['forums'][$id]->new_posts, '1 new', '@count new'); - $variables['forums'][$id]->new_url_posts = url("forum/$forum->tid", array('fragment' => 'new')); - } - - if (isset($forum->num_posts)) { - $variables['forums'][$id]->old_posts = $forum->num_posts - $variables['forums'][$id]->new_posts; - } + // Avoid notices if there is no last post. + $forum->last_post = (empty($forum->last_post)) ? '' : $forum->last_post; + $forum->last_reply = theme('forum_submitted', $forum->last_post); + + $forum->new_posts = 0; + $forum->new_text_posts = ''; + $forum->new_url_posts = ''; + $forum->old_posts = (empty($forum->num_posts)) ? '' : $forum->num_posts; + + if ($user->uid) { + // Show number of new posts as well as topics + if (variable_get('advanced_forum_get_new_comments', 0)) { + // This can cause performance issues, so allow it to be turned off + $forum->new_posts = advanced_forum_unread_replies_in_forum($forum->tid, $user->uid) + $forum->new_topics; + + if ($forum->new_posts) { + $forum->new_text_posts = format_plural($forum->new_posts, '1 new', '@count new'); + $forum->new_url_posts = url("forum/$forum->tid", array('fragment' => 'new')); } - } - - // If there are new topics/posts, change the icon - if ($forum->new_topics || $forum->new_posts) { - $variables['forums'][$id]->icon_classes = "forum-list-icon forum-list-icon-new-posts"; - $variables['forums'][$id]->icon_text = t("New posts"); - } - else { - $variables['forums'][$id]->icon_classes = "forum-list-icon forum-list-icon-default"; - $variables['forums'][$id]->icon_text = t("No new"); - } - - // Add in the taxonomy image, if any - if ($variables['use_taxonomy_image']) { - $variables['forums'][$id]->forum_image = taxonomy_image_display($forum->tid); - } - if ($variables['forums'][$id]->depth > 1) { - // This is a subforum. Add it to the list for the compact listing. - $parent_id = $id; - for ($count = $variables['forums'][$id]->depth; $count > 1; $count--) { - $parent_id = $variables['forums'][$parent_id]->parents['0']; + if (isset($forum->num_posts)) { + $forum->old_posts = $forum->num_posts - $forum->new_posts; } - $variables['forums'][$parent_id]->subforum_list[$id] = $variables['forums'][$id]; } } - foreach ($variables['forums'] as $id => $forum) { - if (!empty($forum->subforum_list)) { - $variables['forums'][$id]->subforums = theme('advanced_forum_subforum_list', $forum->subforum_list); - unset($variables['forums'][$id]->subforum_list); - } - - if(!empty($forum->parents[0])){ - // Sanitize the subforums. - $variables['forums'][$id]->name = check_plain($forum->name); - } + // If there are new topics/posts, change the icon + if ($forum->new_topics || $forum->new_posts) { + $forum->icon_classes = "forum-list-icon forum-list-icon-new-posts"; + $forum->icon_text = t("New posts"); + } + else { + $forum->icon_classes = "forum-list-icon forum-list-icon-default"; + $forum->icon_text = t("No new"); } + // Add in the taxonomy image, if any + if ($variables['use_taxonomy_image']) { + $forum->forum_image = taxonomy_image_display($forum->tid); + } + + return $forum; } Index: styles/naked/advanced_forum.naked.forum-list.tpl.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/advanced_forum/styles/naked/Attic/advanced_forum.naked.forum-list.tpl.php,v retrieving revision 1.1.2.14 diff -u -p -r1.1.2.14 advanced_forum.naked.forum-list.tpl.php --- styles/naked/advanced_forum.naked.forum-list.tpl.php 19 Feb 2011 03:45:55 -0000 1.1.2.14 +++ styles/naked/advanced_forum.naked.forum-list.tpl.php 19 Feb 2011 06:14:34 -0000 @@ -32,102 +32,91 @@ */ ?> - - - $forum): ?> + $table): ?> + - is_container): ?> - - - 1): ?> - - - - - - - - - - - - - +
- name; ?> - - - -   - -
+ + + + + + + + + - - description): ?> - - - - + + description): ?> + + + + - - depth == 1): ?> - - + $item): ?> + - - - - - +
+ linked_name; ?> + + + +   + +
- description; ?> -
+ description; ?> +
- icon_text ?> + + icon_text ?> - forum_image; ?> + + forum_image; ?> - description)): ?> + description)): ?>
- description; ?> + description; ?>
- subforums)): ?> + subforums)): ?>
- : subforums; ?> + : subforums; ?>
-
num_topics ?> - new_topics): ?> +
num_topics ?> + new_topics): ?>
- num_posts ?> + num_posts ?> - new_posts): ?> + new_posts): ?>
- new_text_posts; ?> + new_text_posts; ?>
- last_reply ?> + last_reply ?>
+