summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-07-02 04:27:23 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-07-02 04:27:23 +0000
commit0142292c718eaf31e73c3ee0cd9ef427bc18de16 (patch)
tree69e3a1784a48af68ec65537d375058bb2cb61daa /modules
parente9ca98b69d45b935fe4963a345cba92a87164ddb (diff)
downloadbrdo-0142292c718eaf31e73c3ee0cd9ef427bc18de16.tar.gz
brdo-0142292c718eaf31e73c3ee0cd9ef427bc18de16.tar.bz2
#373201 by moshe weitzman, chx, Frando, eaton: Allow renderable array properties to be passed directly to theme functions.
Diffstat (limited to 'modules')
-rw-r--r--modules/blog/blog.module5
-rw-r--r--modules/blog/blog.pages.inc4
-rw-r--r--modules/book/book.module5
-rw-r--r--modules/comment/comment.module5
-rw-r--r--modules/node/node.module3
-rw-r--r--modules/simpletest/tests/common.test22
-rw-r--r--modules/simpletest/tests/common_test.info8
-rw-r--r--modules/simpletest/tests/common_test.module25
-rw-r--r--modules/statistics/statistics.module5
-rw-r--r--modules/taxonomy/taxonomy.module5
-rw-r--r--modules/tracker/tracker.css4
-rw-r--r--modules/tracker/tracker.pages.inc23
-rw-r--r--modules/translation/translation.module5
-rw-r--r--modules/upload/upload.module9
14 files changed, 95 insertions, 33 deletions
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 121fc25ed..c0ceee50d 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -99,8 +99,9 @@ function blog_node_view($node, $build_mode = 'full') {
'attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => $node->name))),
);
$node->content['links']['blog'] = array(
- '#type' => 'node_links',
- '#value' => $links,
+ '#theme' => 'links',
+ '#links' => $links,
+ '#attributes' => array('class' => 'links inline'),
);
}
}
diff --git a/modules/blog/blog.pages.inc b/modules/blog/blog.pages.inc
index ace4f8ece..c8596fd40 100644
--- a/modules/blog/blog.pages.inc
+++ b/modules/blog/blog.pages.inc
@@ -25,7 +25,7 @@ function blog_page_user($account) {
$build['blog_actions'] = array(
'#items' => $items,
- '#theme' => 'list',
+ '#theme' => 'item_list',
'#weight' => -1,
);
@@ -74,7 +74,7 @@ function blog_page_last() {
$items[] = l(t('Create new blog entry.'), "node/add/blog");
$build['blog_actions'] = array(
'#items' => $items,
- '#theme' => 'list',
+ '#theme' => 'item_list',
'#weight' => -1,
);
}
diff --git a/modules/book/book.module b/modules/book/book.module
index 8eba4dee8..825f53dd6 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -89,8 +89,9 @@ function book_node_view_link($node, $build_mode) {
if (!empty($links)) {
$node->content['links']['book'] = array(
- '#type' => 'node_links',
- '#value' => $links,
+ '#theme' => 'links',
+ '#links' => $links,
+ '#attributes' => array('class' => 'links inline'),
);
}
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 49e0ac4f6..5da3909bf 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -528,8 +528,9 @@ function comment_node_view($node, $build_mode) {
}
$node->content['links']['comment'] = array(
- '#type' => 'node_links',
- '#value' => $links,
+ '#theme' => 'links',
+ '#links' => $links,
+ '#attributes' => array('class' => 'links inline'),
);
// Append the list of comments to $node->content for node detail pages.
diff --git a/modules/node/node.module b/modules/node/node.module
index 9eec39e11..9934fcc1e 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -106,9 +106,6 @@ function node_theme() {
'node_admin_overview' => array(
'arguments' => array('name' => NULL, 'type' => NULL),
),
- 'node_links' => array(
- 'arguments' => array('element' => NULL),
- ),
);
}
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 905fe7cd0..538fb1b2a 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -587,6 +587,10 @@ class DrupalRenderUnitTestCase extends DrupalWebTestCase {
);
}
+ function setUp() {
+ parent::setUp('common_test');
+ }
+
/**
* Test sorting by weight.
*/
@@ -637,6 +641,24 @@ class DrupalRenderUnitTestCase extends DrupalWebTestCase {
// The elements should appear in output in the same order as the array.
$this->assertTrue(strpos($output, $second) < strpos($output, $first), t('Elements were not sorted.'));
}
+
+ /**
+ * Test passing arguments to the theme function.
+ */
+ function testDrupalRenderThemeArguments() {
+ $element = array(
+ '#theme' => 'common_test_foo',
+ );
+ // Test that defaults work.
+ $this->assertEqual(drupal_render($element), 'foobar', 'Defaults work');
+ dd(drupal_render($e), 'defaults'); $element = array(
+ '#theme' => 'common_test_foo',
+ '#foo' => $this->randomName(),
+ '#bar' => $this->randomName(),
+ );
+ // Test that passing arguments to the theme function works.
+ $this->assertEqual(drupal_render($element), $element['#foo'] . $element['#bar'], 'Passing arguments to theme functions works');
+ }
}
/**
diff --git a/modules/simpletest/tests/common_test.info b/modules/simpletest/tests/common_test.info
new file mode 100644
index 000000000..81a15472a
--- /dev/null
+++ b/modules/simpletest/tests/common_test.info
@@ -0,0 +1,8 @@
+; $Id$
+name = "Common Test"
+description = "Support module for Common tests."
+package = Testing
+version = VERSION
+core = 7.x
+files[] = common_test.module
+hidden = TRUE
diff --git a/modules/simpletest/tests/common_test.module b/modules/simpletest/tests/common_test.module
new file mode 100644
index 000000000..71d384d10
--- /dev/null
+++ b/modules/simpletest/tests/common_test.module
@@ -0,0 +1,25 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Helper module for the Common tests.
+ */
+
+/**
+ * Implement hook_theme().
+ */
+function common_test_theme() {
+ return array(
+ 'common_test_foo' => array(
+ 'arguments' => array('foo' => 'foo', 'bar' => 'bar'),
+ ),
+ );
+}
+
+/**
+ * Theme function for testing drupal_render() theming.
+ */
+function theme_common_test_foo($foo, $bar) {
+ return $foo . $bar;
+}
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 4cf85b935..7830b254c 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -114,8 +114,9 @@ function statistics_node_view($node, $build_mode) {
}
$node->content['links']['statistics'] = array(
- '#type' => 'node_links',
- '#value' => $links,
+ '#theme' => 'links',
+ '#links' => $links,
+ '#attributes' => array('class' => 'links inline'),
);
}
}
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 2434201d1..009c397a6 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -117,8 +117,9 @@ function taxonomy_node_view($node, $build_mode) {
}
$node->content['links']['terms'] = array(
- '#type' => 'node_links',
- '#value' => $links,
+ '#theme' => 'links',
+ '#links' => $links,
+ '#attributes' => array('class' => 'links inline'),
'#sorted' => TRUE,
);
}
diff --git a/modules/tracker/tracker.css b/modules/tracker/tracker.css
index 3a2d30f47..0fadc53a7 100644
--- a/modules/tracker/tracker.css
+++ b/modules/tracker/tracker.css
@@ -1,8 +1,8 @@
/* $Id$ */
-#tracker td.replies {
+.page-tracker td.replies {
text-align: center;
}
-#tracker table {
+.page-tracker table {
width: 100%;
}
diff --git a/modules/tracker/tracker.pages.inc b/modules/tracker/tracker.pages.inc
index d8dd9f344..b97933233 100644
--- a/modules/tracker/tracker.pages.inc
+++ b/modules/tracker/tracker.pages.inc
@@ -11,11 +11,6 @@
* Menu callback. Prints a listing of active nodes on the site.
*/
function tracker_page($account = NULL, $set_title = FALSE) {
- // Add CSS
- drupal_add_css(drupal_get_path('module', 'tracker') . '/tracker.css', array('preprocess' => FALSE));
-
- $header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated'));
-
// TODO: These queries are very expensive, see http://drupal.org/node/105639
$query = db_select('node', 'n', array('target' => 'slave'))->extend('PagerDefault');
$query->join('users', 'u', 'n.uid = u.uid');
@@ -73,10 +68,18 @@ function tracker_page($account = NULL, $set_title = FALSE) {
$rows[] = array(array('data' => t('No posts available.'), 'colspan' => '5'));
}
- $output = '<div id="tracker">';
- $output .= theme('table', $header, $rows);
- $output .= theme('pager', NULL);
- $output .= '</div>';
+ $page['tracker'] = array(
+ '#rows' => $rows,
+ '#header' => array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated')),
+ '#theme' => 'table',
+ '#attached_css' => array(drupal_get_path('module', 'tracker') . '/tracker.css' => array('preprocess' => FALSE)),
+ );
+ $page['pager'] = array(
+ '#theme' => 'pager',
+ '#quantity' => 25,
+ '#weight' => 10,
+ );
+ $page['#sorted'] = TRUE;
- return $output;
+ return $page;
}
diff --git a/modules/translation/translation.module b/modules/translation/translation.module
index b2e1ed9f3..de2eb4871 100644
--- a/modules/translation/translation.module
+++ b/modules/translation/translation.module
@@ -181,8 +181,9 @@ function translation_node_view($node, $build_mode) {
'attributes' => array('title' => $translations[$langcode]->title, 'class' => 'translation-link')
);
$node->content['links']['translation'] = array(
- '#type' => 'node_links',
- '#value' => $links,
+ '#theme' => 'links',
+ '#links' => $links,
+ '#attributes' => array('class' => 'links inline'),
);
}
}
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 86ed1ba3e..2d1d6aac4 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -60,11 +60,11 @@ function upload_perm() {
*/
function upload_node_links($node, $build_mode) {
$links = array();
-
+
// Display a link with the number of attachments
$num_files = 0;
foreach ($node->files as $file) {
- if ($file->list) {
+ if ((object)$file->list) {
$num_files++;
}
}
@@ -76,8 +76,9 @@ function upload_node_links($node, $build_mode) {
'fragment' => 'attachments'
);
$node->content['links']['upload_attachments'] = array(
- '#type' => 'node_links',
- '#value' => $links,
+ '#theme' => 'links',
+ '#links' => $links,
+ '#attributes' => array('class' => 'links inline'),
);
}
}