Issue #1715458 by dawehner, damiankloip: Replace calls to ->title with label().

8.0.x
dereine 2012-08-12 19:10:25 +02:00 committed by Tim Plunkett
parent 51f953e2fd
commit 02a35e24f6
10 changed files with 65 additions and 55 deletions

View File

@ -31,7 +31,7 @@ class PluginStyleJumpMenuTest extends ViewsSqlTest {
$this->nodes['story'][] = $this->drupalCreateNode(array('type' => 'story')); $this->nodes['story'][] = $this->drupalCreateNode(array('type' => 'story'));
$this->nodes['story'][] = $this->drupalCreateNode(array('type' => 'story')); $this->nodes['story'][] = $this->drupalCreateNode(array('type' => 'story'));
$this->nodeTitles = array($this->nodes['page'][0]->title, $this->nodes['page'][1]->title, $this->nodes['story'][0]->title, $this->nodes['story'][1]->title); $this->nodeTitles = array($this->nodes['page'][0]->label(), $this->nodes['page'][1]->label(), $this->nodes['story'][0]->label(), $this->nodes['story'][1]->label());
} }

View File

@ -48,7 +48,7 @@ class UserTestCase extends ViewsSqlTest {
$expected = array(); $expected = array();
for ($i = 0; $i <= 1; $i++) { for ($i = 0; $i <= 1; $i++) {
$expected[$i] = array( $expected[$i] = array(
'node_title' => $this->nodes[$i]->title, 'node_title' => $this->nodes[$i]->label(),
'users_uid' => $this->nodes[$i]->uid, 'users_uid' => $this->nodes[$i]->uid,
'users_name' => $this->users[$i]->name, 'users_name' => $this->users[$i]->name,
); );

View File

@ -62,8 +62,8 @@ class WizardBasicTest extends WizardTestBase {
// it. // it.
$this->assertUrl($view2['page[path]']); $this->assertUrl($view2['page[path]']);
$this->assertText($view2['page[title]']); $this->assertText($view2['page[title]']);
$this->assertText($node1->title); $this->assertText($node1->label());
$this->assertText($node2->title); $this->assertText($node2->label());
// Check if we have the feed. // Check if we have the feed.
$this->assertLinkByHref(url($view2['page[feed_properties][path]'])); $this->assertLinkByHref(url($view2['page[feed_properties][path]']));
@ -72,9 +72,9 @@ class WizardBasicTest extends WizardTestBase {
// The feed should have the same title and nodes as the page. // The feed should have the same title and nodes as the page.
$this->assertText($view2['page[title]']); $this->assertText($view2['page[title]']);
$this->assertRaw(url('node/' . $node1->nid, array('absolute' => TRUE))); $this->assertRaw(url('node/' . $node1->nid, array('absolute' => TRUE)));
$this->assertText($node1->title); $this->assertText($node1->label());
$this->assertRaw(url('node/' . $node2->nid, array('absolute' => TRUE))); $this->assertRaw(url('node/' . $node2->nid, array('absolute' => TRUE)));
$this->assertText($node2->title); $this->assertText($node2->label());
// Go back to the views page and check if this view is there. // Go back to the views page and check if this view is there.
$this->drupalGet('admin/structure/views'); $this->drupalGet('admin/structure/views');
@ -103,8 +103,8 @@ class WizardBasicTest extends WizardTestBase {
// Make sure the view only displays the node we expect. // Make sure the view only displays the node we expect.
$this->assertUrl($view3['page[path]']); $this->assertUrl($view3['page[path]']);
$this->assertText($view3['page[title]']); $this->assertText($view3['page[title]']);
$this->assertText($node1->title); $this->assertText($node1->label());
$this->assertNoText($node2->title); $this->assertNoText($node2->label());
// Go back to the views page and check if this view is there. // Go back to the views page and check if this view is there.
$this->drupalGet('admin/structure/views'); $this->drupalGet('admin/structure/views');
@ -122,8 +122,8 @@ class WizardBasicTest extends WizardTestBase {
// Visit a random page (not the one that displays the view itself) and look // Visit a random page (not the one that displays the view itself) and look
// for the expected node title in the block. // for the expected node title in the block.
$this->drupalGet('user'); $this->drupalGet('user');
$this->assertText($node1->title); $this->assertText($node1->label());
$this->assertNoText($node2->title); $this->assertNoText($node2->label());
// Check if the export screen works. // Check if the export screen works.
$this->drupalGet('admin/structure/views/view/' . $view3['name'] . '/export'); $this->drupalGet('admin/structure/views/view/' . $view3['name'] . '/export');

View File

@ -57,16 +57,16 @@ class WizardItemsPerPageTest extends WizardTestBase {
$this->assertUrl($view['page[path]']); $this->assertUrl($view['page[path]']);
$this->assertText($view['page[title]']); $this->assertText($view['page[title]']);
$content = $this->drupalGetContent(); $content = $this->drupalGetContent();
$this->assertText($node5->title); $this->assertText($node5->label());
$this->assertText($node4->title); $this->assertText($node4->label());
$this->assertText($node3->title); $this->assertText($node3->label());
$this->assertText($node2->title); $this->assertText($node2->label());
$this->assertNoText($node1->title); $this->assertNoText($node1->label());
$this->assertNoText($page_node->title); $this->assertNoText($page_node->label());
$pos5 = strpos($content, $node5->title); $pos5 = strpos($content, $node5->label());
$pos4 = strpos($content, $node4->title); $pos4 = strpos($content, $node4->label());
$pos3 = strpos($content, $node3->title); $pos3 = strpos($content, $node3->label());
$pos2 = strpos($content, $node2->title); $pos2 = strpos($content, $node2->label());
$this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, t('The nodes appear in the expected order in the page display.')); $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, t('The nodes appear in the expected order in the page display.'));
// Put the block into the first sidebar region, visit a page that displays // Put the block into the first sidebar region, visit a page that displays
@ -79,15 +79,15 @@ class WizardItemsPerPageTest extends WizardTestBase {
$this->drupalPost('admin/structure/block', $edit, t('Save blocks')); $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this->drupalGet('user'); $this->drupalGet('user');
$content = $this->drupalGetContent(); $content = $this->drupalGetContent();
$this->assertText($node5->title); $this->assertText($node5->label());
$this->assertText($node4->title); $this->assertText($node4->label());
$this->assertText($node3->title); $this->assertText($node3->label());
$this->assertNoText($node2->title); $this->assertNoText($node2->label());
$this->assertNoText($node1->title); $this->assertNoText($node1->label());
$this->assertNoText($page_node->title); $this->assertNoText($page_node->label());
$pos5 = strpos($content, $node5->title); $pos5 = strpos($content, $node5->label());
$pos4 = strpos($content, $node4->title); $pos4 = strpos($content, $node4->label());
$pos3 = strpos($content, $node3->title); $pos3 = strpos($content, $node3->label());
$this->assertTrue($pos5 < $pos4 && $pos4 < $pos3, t('The nodes appear in the expected order in the block display.')); $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3, t('The nodes appear in the expected order in the block display.'));
} }
} }

View File

@ -44,12 +44,12 @@ class WizardSortingTest extends WizardTestBase {
$this->assertUrl($view1['page[path]']); $this->assertUrl($view1['page[path]']);
$this->assertText($view1['page[title]']); $this->assertText($view1['page[title]']);
$content = $this->drupalGetContent(); $content = $this->drupalGetContent();
$this->assertText($node1->title); $this->assertText($node1->label());
$this->assertText($node2->title); $this->assertText($node2->label());
$this->assertText($node3->title); $this->assertText($node3->label());
$pos1 = strpos($content, $node1->title); $pos1 = strpos($content, $node1->label());
$pos2 = strpos($content, $node2->title); $pos2 = strpos($content, $node2->label());
$pos3 = strpos($content, $node3->title); $pos3 = strpos($content, $node3->label());
$this->assertTrue($pos1 < $pos2 && $pos2 < $pos3, t('The nodes appear in the expected order in a view that sorts by oldest first.')); $this->assertTrue($pos1 < $pos2 && $pos2 < $pos3, t('The nodes appear in the expected order in a view that sorts by oldest first.'));
// Create a view that sorts newest first. // Create a view that sorts newest first.
@ -67,12 +67,12 @@ class WizardSortingTest extends WizardTestBase {
$this->assertUrl($view2['page[path]']); $this->assertUrl($view2['page[path]']);
$this->assertText($view2['page[title]']); $this->assertText($view2['page[title]']);
$content = $this->drupalGetContent(); $content = $this->drupalGetContent();
$this->assertText($node3->title); $this->assertText($node3->label());
$this->assertText($node2->title); $this->assertText($node2->label());
$this->assertText($node1->title); $this->assertText($node1->label());
$pos3 = strpos($content, $node3->title); $pos3 = strpos($content, $node3->label());
$pos2 = strpos($content, $node2->title); $pos2 = strpos($content, $node2->label());
$pos1 = strpos($content, $node1->title); $pos1 = strpos($content, $node1->label());
$this->assertTrue($pos3 < $pos2 && $pos2 < $pos1, t('The nodes appear in the expected order in a view that sorts by newest first.')); $this->assertTrue($pos3 < $pos2 && $pos2 < $pos1, t('The nodes appear in the expected order in a view that sorts by newest first.'));
} }
} }

View File

@ -15,9 +15,9 @@ class views_handler_argument_node_nid extends views_handler_argument_numeric {
function title_query() { function title_query() {
$titles = array(); $titles = array();
$result = db_query("SELECT n.title FROM {node} n WHERE n.nid IN (:nids)", array(':nids' => $this->value)); $nodes = node_load_multiple($this->value);
foreach ($result as $term) { foreach ($nodes as $node) {
$titles[] = check_plain($term->title); $titles[] = check_plain($node->label());
} }
return $titles; return $titles;
} }

View File

@ -17,10 +17,20 @@ class views_handler_argument_node_vid extends views_handler_argument_numeric {
function title_query() { function title_query() {
$titles = array(); $titles = array();
$result = db_query("SELECT n.title FROM {node_revision} n WHERE n.nid IN (:nids)", array(':nids' => $this->value)); $results = db_query("SELECT nr.vid, nr.nid, nr.title FROM {node_revision} nr WHERE nr.vid IN (:vids)", array(':vids' => $this->value))->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
foreach ($result as $term) {
$titles[] = check_plain($term->title); $nids = array();
foreach ($results as $result) {
$nids[] = $result['nid'];
} }
$nodes = node_load_multiple(array_unique($nids));
foreach ($results as $result) {
$nodes[$result['nid']]->set('title', $result['title']);
$titles[] = check_plain($nodes[$result['nid']]->label());
}
return $titles; return $titles;
} }
} }

View File

@ -96,7 +96,7 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate
} }
// Save the title() handlers some work. // Save the title() handlers some work.
$this->argument->validated_title = check_plain($node->title); $this->argument->validated_title = check_plain($node->label());
if (empty($types)) { if (empty($types)) {
return TRUE; return TRUE;
@ -115,8 +115,8 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate
$test = drupal_map_assoc($nids->value); $test = drupal_map_assoc($nids->value);
$titles = array(); $titles = array();
$result = db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => $nids->value)); $nodes = node_load_multiple($nids->value);
foreach ($result as $node) { foreach ($nodes as $node) {
if ($types && empty($types[$node->type])) { if ($types && empty($types[$node->type])) {
return FALSE; return FALSE;
} }
@ -127,7 +127,7 @@ class views_plugin_argument_validate_node extends views_plugin_argument_validate
} }
} }
$titles[] = check_plain($node->title); $titles[] = check_plain($node->label());
unset($test[$node->nid]); unset($test[$node->nid]);
} }

View File

@ -182,7 +182,7 @@ function template_preprocess_views_view_row_search(&$vars) {
$node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index'); $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index');
$vars['url'] = url('node/' . $nid); $vars['url'] = url('node/' . $nid);
$vars['title'] = check_plain($node->title); $vars['title'] = check_plain($node->label());
$info = array(); $info = array();
$info['type'] = node_type_get_name($node); $info['type'] = node_type_get_name($node);

View File

@ -24,9 +24,9 @@ class views_handler_argument_user_uid extends views_handler_argument_numeric {
$titles = array(); $titles = array();
$result = db_query("SELECT u.name FROM {users} u WHERE u.uid IN (:uids)", array(':uids' => $this->value)); $users = user_load_multiple($this->value);
foreach ($result as $term) { foreach ($users as $account) {
$titles[] = check_plain($term->name); $titles[] = check_plain($account->label());
} }
return $titles; return $titles;
} }