Issue #148145 by andypost, cburschka, Gábor Hojtsy, alexweber, sun: Fixed 'Forums' title is not localized.
parent
951a389ef0
commit
478a624acc
|
@ -100,6 +100,8 @@ function forum_menu() {
|
||||||
);
|
);
|
||||||
$items['forum/%forum_forum'] = array(
|
$items['forum/%forum_forum'] = array(
|
||||||
'title' => 'Forums',
|
'title' => 'Forums',
|
||||||
|
'title callback' => 'entity_page_label',
|
||||||
|
'title arguments' => array(1),
|
||||||
'page callback' => 'forum_page',
|
'page callback' => 'forum_page',
|
||||||
'page arguments' => array(1),
|
'page arguments' => array(1),
|
||||||
'access arguments' => array('access content'),
|
'access arguments' => array('access content'),
|
||||||
|
@ -710,11 +712,11 @@ function forum_forum_load($tid = NULL) {
|
||||||
return $cache[$tid] = FALSE;
|
return $cache[$tid] = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If $tid is 0, create an empty object to hold the child terms.
|
// If $tid is 0, create an empty entity to hold the child terms.
|
||||||
elseif ($tid === 0) {
|
elseif ($tid === 0) {
|
||||||
$forum_term = (object) array(
|
$forum_term = entity_create('taxonomy_term', array(
|
||||||
'tid' => 0,
|
'tid' => 0,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if the requested term is a container.
|
// Determine if the requested term is a container.
|
||||||
|
@ -989,32 +991,6 @@ function forum_preprocess_block(&$variables) {
|
||||||
* @see forums.tpl.php
|
* @see forums.tpl.php
|
||||||
*/
|
*/
|
||||||
function template_preprocess_forums(&$variables) {
|
function template_preprocess_forums(&$variables) {
|
||||||
global $user;
|
|
||||||
|
|
||||||
$config = config('forum.settings');
|
|
||||||
$vid = $config->get('vocabulary');
|
|
||||||
$vocabulary = taxonomy_vocabulary_load($vid);
|
|
||||||
$title = !empty($vocabulary->name) ? $vocabulary->name : '';
|
|
||||||
|
|
||||||
// Breadcrumb navigation:
|
|
||||||
$breadcrumb[] = l(t('Home'), NULL);
|
|
||||||
if ($variables['tid']) {
|
|
||||||
$breadcrumb[] = l($vocabulary->name, 'forum');
|
|
||||||
}
|
|
||||||
if ($variables['parents']) {
|
|
||||||
$variables['parents'] = array_reverse($variables['parents']);
|
|
||||||
foreach ($variables['parents'] as $p) {
|
|
||||||
if ($p->tid == $variables['tid']) {
|
|
||||||
$title = $p->label();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$breadcrumb[] = l($p->label(), 'forum/' . $p->tid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
drupal_set_breadcrumb($breadcrumb);
|
|
||||||
drupal_set_title($title);
|
|
||||||
|
|
||||||
if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
|
if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
|
||||||
if (!empty($variables['forums'])) {
|
if (!empty($variables['forums'])) {
|
||||||
$variables['forums'] = theme('forum_list', $variables);
|
$variables['forums'] = theme('forum_list', $variables);
|
||||||
|
@ -1023,9 +999,8 @@ function template_preprocess_forums(&$variables) {
|
||||||
$variables['forums'] = '';
|
$variables['forums'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($variables['tid'] && !in_array($variables['tid'], $config->get('containers'))) {
|
if ($variables['tid'] && array_search($variables['tid'], config('forum.settings')->get('containers')) === FALSE) {
|
||||||
$variables['topics'] = theme('forum_topic_list', $variables);
|
$variables['topics'] = theme('forum_topic_list', $variables);
|
||||||
drupal_add_feed('taxonomy/term/' . $variables['tid'] . '/feed', 'RSS - ' . $title);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$variables['topics'] = '';
|
$variables['topics'] = '';
|
||||||
|
@ -1049,7 +1024,6 @@ function template_preprocess_forums(&$variables) {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
drupal_set_title(t('No forums defined'));
|
|
||||||
$variables['forums'] = '';
|
$variables['forums'] = '';
|
||||||
$variables['topics'] = '';
|
$variables['topics'] = '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,46 @@
|
||||||
*/
|
*/
|
||||||
function forum_page($forum_term = NULL) {
|
function forum_page($forum_term = NULL) {
|
||||||
$config = config('forum.settings');
|
$config = config('forum.settings');
|
||||||
|
$vocabulary = entity_load('taxonomy_vocabulary', $config->get('vocabulary'));
|
||||||
|
|
||||||
if (!isset($forum_term)) {
|
if (!isset($forum_term)) {
|
||||||
// On the main page, display all the top-level forums.
|
// On the main page, display all the top-level forums.
|
||||||
$forum_term = forum_forum_load(0);
|
$forum_term = forum_forum_load(0);
|
||||||
|
// Set the page title to forum's vocabulary name.
|
||||||
|
drupal_set_title($vocabulary->label());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Breadcrumb navigation.
|
||||||
|
$breadcrumb[] = l(t('Home'), NULL);
|
||||||
|
if ($forum_term->tid) {
|
||||||
|
// Parent of all forums is the vocabulary name.
|
||||||
|
$breadcrumb[] = l($vocabulary->label(), 'forum');
|
||||||
|
}
|
||||||
|
// Add all parent forums to breadcrumbs.
|
||||||
|
if ($forum_term->parents) {
|
||||||
|
foreach (array_reverse($forum_term->parents) as $parent) {
|
||||||
|
if ($parent->id() != $forum_term->tid) {
|
||||||
|
$breadcrumb[] = l($parent->label(), 'forum/' . $parent->id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drupal_set_breadcrumb($breadcrumb);
|
||||||
|
|
||||||
|
if ($forum_term->tid && array_search($forum_term->tid, $config->get('containers')) === FALSE) {
|
||||||
|
// Add RSS feed for forums.
|
||||||
|
drupal_add_feed('taxonomy/term/' . $forum_term->id() . '/feed', 'RSS - ' . $forum_term->label());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($forum_term->forums) && empty($forum_term->parents)) {
|
||||||
|
// Root of empty forum.
|
||||||
|
drupal_set_title(t('No forums defined'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$forum_per_page = $config->get('topics.page_limit');
|
$forum_per_page = $config->get('topics.page_limit');
|
||||||
$sortby = $config->get('topics.order');
|
$sort_by = $config->get('topics.order');
|
||||||
|
|
||||||
if (empty($forum_term->container)) {
|
if (empty($forum_term->container)) {
|
||||||
$topics = forum_get_topics($forum_term->tid, $sortby, $forum_per_page);
|
$topics = forum_get_topics($forum_term->tid, $sort_by, $forum_per_page);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$topics = '';
|
$topics = '';
|
||||||
|
@ -40,12 +70,9 @@ function forum_page($forum_term = NULL) {
|
||||||
'#topics' => $topics,
|
'#topics' => $topics,
|
||||||
'#parents' => $forum_term->parents,
|
'#parents' => $forum_term->parents,
|
||||||
'#tid' => $forum_term->tid,
|
'#tid' => $forum_term->tid,
|
||||||
'#sortby' => $sortby,
|
'#sortby' => $sort_by,
|
||||||
'#forums_per_page' => $forum_per_page,
|
'#forums_per_page' => $forum_per_page,
|
||||||
);
|
);
|
||||||
$build['#attached']['css'][] = drupal_get_path('module', 'forum') . '/forum.css';
|
$build['#attached']['css'][] = drupal_get_path('module', 'forum') . '/forum.css';
|
||||||
// @todo Returning a render array causes template_preprocess_forums() to be
|
return $build;
|
||||||
// invoked too late and the breadcrumb is rendered before that callback
|
|
||||||
// adjusted it.
|
|
||||||
return drupal_render($build);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,6 +220,15 @@ class ForumTest extends WebTestBase {
|
||||||
$this->drupalGet('forum/' . $this->forum['tid']);
|
$this->drupalGet('forum/' . $this->forum['tid']);
|
||||||
$this->drupalPost("node/$node->nid/edit", array(), t('Save'));
|
$this->drupalPost("node/$node->nid/edit", array(), t('Save'));
|
||||||
$this->assertResponse(200);
|
$this->assertResponse(200);
|
||||||
|
|
||||||
|
// Test the root forum page title change.
|
||||||
|
$this->drupalGet('forum');
|
||||||
|
$this->assertTitle(t('Forums | Drupal'));
|
||||||
|
$vocabulary = entity_load('taxonomy_vocabulary', $this->forum['vid']);
|
||||||
|
$vocabulary->set('name', 'Discussions');
|
||||||
|
$vocabulary->save();
|
||||||
|
$this->drupalGet('forum');
|
||||||
|
$this->assertTitle(t('Discussions | Drupal'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,7 +276,7 @@ class ForumTest extends WebTestBase {
|
||||||
|
|
||||||
// Edit forum taxonomy.
|
// Edit forum taxonomy.
|
||||||
// Restoration of the settings fails and causes subsequent tests to fail.
|
// Restoration of the settings fails and causes subsequent tests to fail.
|
||||||
$this->forumContainer = $this->editForumTaxonomy();
|
$this->forumContainer = $this->editForumVocabulary();
|
||||||
// Create forum container.
|
// Create forum container.
|
||||||
$this->forumContainer = $this->createForum('container');
|
$this->forumContainer = $this->createForum('container');
|
||||||
// Verify "edit container" link exists and functions correctly.
|
// Verify "edit container" link exists and functions correctly.
|
||||||
|
@ -328,38 +337,36 @@ class ForumTest extends WebTestBase {
|
||||||
/**
|
/**
|
||||||
* Edits the forum taxonomy.
|
* Edits the forum taxonomy.
|
||||||
*/
|
*/
|
||||||
function editForumTaxonomy() {
|
function editForumVocabulary() {
|
||||||
// Backup forum taxonomy.
|
// Backup forum taxonomy.
|
||||||
$vid = config('forum.settings')->get('vocabulary');
|
$vid = config('forum.settings')->get('vocabulary');
|
||||||
$original_settings = taxonomy_vocabulary_load($vid);
|
$original_vocabulary = entity_load('taxonomy_vocabulary', $vid);
|
||||||
|
|
||||||
// Generate a random name/description.
|
|
||||||
$title = $this->randomName(10);
|
|
||||||
$description = $this->randomName(100);
|
|
||||||
|
|
||||||
|
// Generate a random name and description.
|
||||||
$edit = array(
|
$edit = array(
|
||||||
'name' => $title,
|
'name' => $this->randomName(10),
|
||||||
'description' => $description,
|
'description' => $this->randomName(100),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Edit the vocabulary.
|
// Edit the vocabulary.
|
||||||
$this->drupalPost('admin/structure/taxonomy/' . $original_settings->id() . '/edit', $edit, t('Save'));
|
$this->drupalPost('admin/structure/taxonomy/' . $original_vocabulary->id() . '/edit', $edit, t('Save'));
|
||||||
$this->assertResponse(200);
|
$this->assertResponse(200);
|
||||||
$this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), 'Vocabulary was edited');
|
$this->assertRaw(t('Updated vocabulary %name.', array('%name' => $edit['name'])), 'Vocabulary was edited');
|
||||||
|
|
||||||
// Grab the newly edited vocabulary.
|
// Grab the newly edited vocabulary.
|
||||||
$this->container->get('plugin.manager.entity')->getStorageController('taxonomy_vocabulary')->resetCache();
|
$current_vocabulary = entity_load('taxonomy_vocabulary', $vid);
|
||||||
$current_settings = taxonomy_vocabulary_load($vid);
|
|
||||||
|
|
||||||
// Make sure we actually edited the vocabulary properly.
|
// Make sure we actually edited the vocabulary properly.
|
||||||
$this->assertEqual($current_settings->name, $title, 'The name was updated');
|
$this->assertEqual($current_vocabulary->name, $edit['name'], 'The name was updated');
|
||||||
$this->assertEqual($current_settings->description, $description, 'The description was updated');
|
$this->assertEqual($current_vocabulary->description, $edit['description'], 'The description was updated');
|
||||||
|
|
||||||
// Restore the original vocabulary.
|
// Restore the original vocabulary's name and description.
|
||||||
taxonomy_vocabulary_save($original_settings);
|
$current_vocabulary->set('name', $original_vocabulary->name);
|
||||||
drupal_static_reset('taxonomy_vocabulary_load');
|
$current_vocabulary->set('description', $original_vocabulary->description);
|
||||||
$current_settings = taxonomy_vocabulary_load($vid);
|
$current_vocabulary->save();
|
||||||
$this->assertEqual($current_settings->name, $original_settings->name, 'The original vocabulary settings were restored');
|
// Reload vocabulary to make sure changes are saved.
|
||||||
|
$current_vocabulary = entity_load('taxonomy_vocabulary', $vid);
|
||||||
|
$this->assertEqual($current_vocabulary->name, $original_vocabulary->name, 'The original vocabulary settings were restored');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue