Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/forum/forum.module @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
22 switch ($route_name) { | 22 switch ($route_name) { |
23 case 'help.page.forum': | 23 case 'help.page.forum': |
24 $output = ''; | 24 $output = ''; |
25 $output .= '<h3>' . t('About') . '</h3>'; | 25 $output .= '<h3>' . t('About') . '</h3>'; |
26 $output .= '<p>' . t('The Forum module lets you create threaded discussion forums with functionality similar to other message board systems. In a forum, users post topics and threads in nested hierarchies, allowing discussions to be categorized and grouped.') . '</p>'; | 26 $output .= '<p>' . t('The Forum module lets you create threaded discussion forums with functionality similar to other message board systems. In a forum, users post topics and threads in nested hierarchies, allowing discussions to be categorized and grouped.') . '</p>'; |
27 $output .= '<p>' . t('The Forum module adds and uses a content type called <em>Forum topic</em>. For background information on content types, see the <a href=":node_help">Node module help page</a>.', [':node_help' => \Drupal::url('help.page', ['name' => 'node'])]) . '</p>'; | 27 $output .= '<p>' . t('The Forum module adds and uses a content type called <em>Forum topic</em>. For background information on content types, see the <a href=":node_help">Node module help page</a>.', [':node_help' => Url::fromRoute('help.page', ['name' => 'node'])->toString()]) . '</p>'; |
28 $output .= '<p>' . t('A forum is represented by a hierarchical structure, consisting of:'); | 28 $output .= '<p>' . t('A forum is represented by a hierarchical structure, consisting of:'); |
29 $output .= '<ul>'; | 29 $output .= '<ul>'; |
30 $output .= '<li>' . t('<em>Forums</em> (for example, <em>Recipes for cooking vegetables</em>)') . '</li>'; | 30 $output .= '<li>' . t('<em>Forums</em> (for example, <em>Recipes for cooking vegetables</em>)') . '</li>'; |
31 $output .= '<li>' . t('<em>Forum topics</em> submitted by users (for example, <em>How to cook potatoes</em>), which start discussions.') . '</li>'; | 31 $output .= '<li>' . t('<em>Forum topics</em> submitted by users (for example, <em>How to cook potatoes</em>), which start discussions.') . '</li>'; |
32 $output .= '<li>' . t('Threaded <em>comments</em> submitted by users (for example, <em>You wash the potatoes first and then...</em>).') . '</li>'; | 32 $output .= '<li>' . t('Threaded <em>comments</em> submitted by users (for example, <em>You wash the potatoes first and then...</em>).') . '</li>'; |
35 $output .= '</p>'; | 35 $output .= '</p>'; |
36 $output .= '<p>' . t('For more information, see the <a href=":forum">online documentation for the Forum module</a>.', [':forum' => 'https://www.drupal.org/documentation/modules/forum']) . '</p>'; | 36 $output .= '<p>' . t('For more information, see the <a href=":forum">online documentation for the Forum module</a>.', [':forum' => 'https://www.drupal.org/documentation/modules/forum']) . '</p>'; |
37 $output .= '<h3>' . t('Uses') . '</h3>'; | 37 $output .= '<h3>' . t('Uses') . '</h3>'; |
38 $output .= '<dl>'; | 38 $output .= '<dl>'; |
39 $output .= '<dt>' . t('Setting up the forum structure') . '</dt>'; | 39 $output .= '<dt>' . t('Setting up the forum structure') . '</dt>'; |
40 $output .= '<dd>' . t('Visit the <a href=":forums">Forums page</a> to set up containers and forums to hold your discussion topics.', [':forums' => \Drupal::url('forum.overview')]) . '</dd>'; | 40 $output .= '<dd>' . t('Visit the <a href=":forums">Forums page</a> to set up containers and forums to hold your discussion topics.', [':forums' => Url::fromRoute('forum.overview')->toString()]) . '</dd>'; |
41 $output .= '<dt>' . t('Starting a discussion') . '</dt>'; | 41 $output .= '<dt>' . t('Starting a discussion') . '</dt>'; |
42 $output .= '<dd>' . t('The <a href=":create-topic">Forum topic</a> link on the <a href=":content-add">Add content</a> page creates the first post of a new threaded discussion, or thread.', [':create-topic' => \Drupal::url('node.add', ['node_type' => 'forum']), ':content-add' => \Drupal::url('node.add_page')]) . '</dd>'; | 42 $output .= '<dd>' . t('The <a href=":create-topic">Forum topic</a> link on the <a href=":content-add">Add content</a> page creates the first post of a new threaded discussion, or thread.', [':create-topic' => Url::fromRoute('node.add', ['node_type' => 'forum'])->toString(), ':content-add' => Url::fromRoute('node.add_page')->toString()]) . '</dd>'; |
43 $output .= '<dt>' . t('Navigating in the forum') . '</dt>'; | 43 $output .= '<dt>' . t('Navigating in the forum') . '</dt>'; |
44 $output .= '<dd>' . t('Enabling the Forum module provides a default <em>Forums</em> menu item in the Tools menu that links to the <a href=":forums">Forums page</a>.', [':forums' => \Drupal::url('forum.index')]) . '</dd>'; | 44 $output .= '<dd>' . t('Enabling the Forum module provides a default <em>Forums</em> menu item in the Tools menu that links to the <a href=":forums">Forums page</a>.', [':forums' => Url::fromRoute('forum.index')->toString()]) . '</dd>'; |
45 $output .= '<dt>' . t('Moving forum topics') . '</dt>'; | 45 $output .= '<dt>' . t('Moving forum topics') . '</dt>'; |
46 $output .= '<dd>' . t('A forum topic (and all of its comments) may be moved between forums by selecting a different forum while editing a forum topic. When moving a forum topic between forums, the <em>Leave shadow copy</em> option creates a link in the original forum pointing to the new location.') . '</dd>'; | 46 $output .= '<dd>' . t('A forum topic (and all of its comments) may be moved between forums by selecting a different forum while editing a forum topic. When moving a forum topic between forums, the <em>Leave shadow copy</em> option creates a link in the original forum pointing to the new location.') . '</dd>'; |
47 $output .= '<dt>' . t('Locking and disabling comments') . '</dt>'; | 47 $output .= '<dt>' . t('Locking and disabling comments') . '</dt>'; |
48 $output .= '<dd>' . t('Selecting <em>Closed</em> under <em>Comment settings</em> while editing a forum topic will lock (prevent new comments on) the thread. Selecting <em>Hidden</em> under <em>Comment settings</em> while editing a forum topic will hide all existing comments on the thread, and prevent new ones.') . '</dd>'; | 48 $output .= '<dd>' . t('Selecting <em>Closed</em> under <em>Comment settings</em> while editing a forum topic will lock (prevent new comments on) the thread. Selecting <em>Hidden</em> under <em>Comment settings</em> while editing a forum topic will hide all existing comments on the thread, and prevent new ones.') . '</dd>'; |
49 $output .= '</dl>'; | 49 $output .= '</dl>'; |
74 | 74 |
75 case 'forum.add_forum': | 75 case 'forum.add_forum': |
76 return '<p>' . t('A forum holds related forum topics.') . '</p>'; | 76 return '<p>' . t('A forum holds related forum topics.') . '</p>'; |
77 | 77 |
78 case 'forum.settings': | 78 case 'forum.settings': |
79 return '<p>' . t('Adjust the display of your forum topics. Organize the forums on the <a href=":forum-structure">forum structure page</a>.', [':forum-structure' => \Drupal::url('forum.overview')]) . '</p>'; | 79 return '<p>' . t('Adjust the display of your forum topics. Organize the forums on the <a href=":forum-structure">forum structure page</a>.', [':forum-structure' => Url::fromRoute('forum.overview')->toString()]) . '</p>'; |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 /** | 83 /** |
84 * Implements hook_theme(). | 84 * Implements hook_theme(). |
450 $variables['topics'][$id]->title = $topic->getTitle(); | 450 $variables['topics'][$id]->title = $topic->getTitle(); |
451 $variables['topics'][$id]->message = \Drupal::l(t('This topic has been moved'), new Url('forum.page', ['taxonomy_term' => $topic->forum_tid])); | 451 $variables['topics'][$id]->message = \Drupal::l(t('This topic has been moved'), new Url('forum.page', ['taxonomy_term' => $topic->forum_tid])); |
452 } | 452 } |
453 else { | 453 else { |
454 $variables['topics'][$id]->moved = FALSE; | 454 $variables['topics'][$id]->moved = FALSE; |
455 $variables['topics'][$id]->title_link = \Drupal::l($topic->getTitle(), $topic->urlInfo()); | 455 $variables['topics'][$id]->title_link = \Drupal::l($topic->getTitle(), $topic->toUrl()); |
456 $variables['topics'][$id]->message = ''; | 456 $variables['topics'][$id]->message = ''; |
457 } | 457 } |
458 $forum_submitted = [ | 458 $forum_submitted = [ |
459 '#theme' => 'forum_submitted', | 459 '#theme' => 'forum_submitted', |
460 '#topic' => (object) [ | 460 '#topic' => (object) [ |
476 if ($topic->new_replies) { | 476 if ($topic->new_replies) { |
477 $page_number = \Drupal::entityManager()->getStorage('comment') | 477 $page_number = \Drupal::entityManager()->getStorage('comment') |
478 ->getNewCommentPageNumber($topic->comment_count, $topic->new_replies, $topic, 'comment_forum'); | 478 ->getNewCommentPageNumber($topic->comment_count, $topic->new_replies, $topic, 'comment_forum'); |
479 $query = $page_number ? ['page' => $page_number] : NULL; | 479 $query = $page_number ? ['page' => $page_number] : NULL; |
480 $variables['topics'][$id]->new_text = \Drupal::translation()->formatPlural($topic->new_replies, '1 new post<span class="visually-hidden"> in topic %title</span>', '@count new posts<span class="visually-hidden"> in topic %title</span>', ['%title' => $variables['topics'][$id]->label()]); | 480 $variables['topics'][$id]->new_text = \Drupal::translation()->formatPlural($topic->new_replies, '1 new post<span class="visually-hidden"> in topic %title</span>', '@count new posts<span class="visually-hidden"> in topic %title</span>', ['%title' => $variables['topics'][$id]->label()]); |
481 $variables['topics'][$id]->new_url = \Drupal::url('entity.node.canonical', ['node' => $topic->id()], ['query' => $query, 'fragment' => 'new']); | 481 $variables['topics'][$id]->new_url = Url::fromRoute('entity.node.canonical', ['node' => $topic->id()], ['query' => $query, 'fragment' => 'new'])->toString(); |
482 } | 482 } |
483 | 483 |
484 // Build table rows from topics. | 484 // Build table rows from topics. |
485 $row = []; | 485 $row = []; |
486 $row[] = [ | 486 $row[] = [ |
564 $variables['forums'][$id]->icon_title = t('No new posts'); | 564 $variables['forums'][$id]->icon_title = t('No new posts'); |
565 if ($user->isAuthenticated()) { | 565 if ($user->isAuthenticated()) { |
566 $variables['forums'][$id]->new_topics = \Drupal::service('forum_manager')->unreadTopics($forum->id(), $user->id()); | 566 $variables['forums'][$id]->new_topics = \Drupal::service('forum_manager')->unreadTopics($forum->id(), $user->id()); |
567 if ($variables['forums'][$id]->new_topics) { | 567 if ($variables['forums'][$id]->new_topics) { |
568 $variables['forums'][$id]->new_text = \Drupal::translation()->formatPlural($variables['forums'][$id]->new_topics, '1 new post<span class="visually-hidden"> in forum %title</span>', '@count new posts<span class="visually-hidden"> in forum %title</span>', ['%title' => $variables['forums'][$id]->label()]); | 568 $variables['forums'][$id]->new_text = \Drupal::translation()->formatPlural($variables['forums'][$id]->new_topics, '1 new post<span class="visually-hidden"> in forum %title</span>', '@count new posts<span class="visually-hidden"> in forum %title</span>', ['%title' => $variables['forums'][$id]->label()]); |
569 $variables['forums'][$id]->new_url = \Drupal::url('forum.page', ['taxonomy_term' => $forum->id()], ['fragment' => 'new']); | 569 $variables['forums'][$id]->new_url = Url::fromRoute('forum.page', ['taxonomy_term' => $forum->id()], ['fragment' => 'new'])->toString(); |
570 $variables['forums'][$id]->icon_class = 'new'; | 570 $variables['forums'][$id]->icon_class = 'new'; |
571 $variables['forums'][$id]->icon_title = t('New posts'); | 571 $variables['forums'][$id]->icon_title = t('New posts'); |
572 } | 572 } |
573 $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics; | 573 $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics; |
574 } | 574 } |