diff options
Diffstat (limited to 'modules/upload')
-rw-r--r-- | modules/upload/upload.module | 14 | ||||
-rw-r--r-- | modules/upload/upload.test | 7 |
2 files changed, 15 insertions, 6 deletions
diff --git a/modules/upload/upload.module b/modules/upload/upload.module index 518c90115..65cd225bd 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -56,13 +56,13 @@ function upload_perm() { } /** - * Implementation of hook_link(). + * Inject links into $node for attachments. */ -function upload_link($type, $node = NULL, $teaser = FALSE) { +function upload_nodeapi_links($node, $teaser) { $links = array(); // Display a link with the number of attachments - if ($teaser && $type == 'node' && isset($node->files) && user_access('view uploaded files')) { + if ($teaser && isset($node->files) && user_access('view uploaded files')) { $num_files = 0; foreach ($node->files as $file) { if ($file->list) { @@ -76,10 +76,12 @@ function upload_link($type, $node = NULL, $teaser = FALSE) { 'attributes' => array('title' => t('Read full article to view attachments.')), 'fragment' => 'attachments' ); + $node->content['links']['upload_attachments'] = array( + '#type' => 'node_links', + '#value' => $links, + ); } } - - return $links; } /** @@ -323,6 +325,8 @@ function upload_nodeapi_view($node, $teaser, $page) { ); } } + + upload_nodeapi_links($node, $teaser); } } diff --git a/modules/upload/upload.test b/modules/upload/upload.test index 1a3438844..a39f0ac96 100644 --- a/modules/upload/upload.test +++ b/modules/upload/upload.test @@ -44,12 +44,17 @@ class UploadTestCase extends DrupalWebTestCase { $this->uploadFile($node, $files[0]); $this->uploadFile($node, $files[1]); - // Check to see that uploaded file is listed and actually accessible. + // Check to see that uploaded file is listed in detail page and actually accessible. $this->assertText(basename($files[0]), basename($files[0]) . ' found on node.'); $this->assertText(basename($files[1]), basename($files[1]) . ' found on node.'); $this->checkUploadedFile(basename($files[0])); $this->checkUploadedFile(basename($files[1])); + + // Assure that the attachment link appears on teaser view and has correct count. + $node = node_load($node->nid); + $teaser = node_view($node, TRUE); + $this->assertTrue(strpos($teaser, format_plural(2, '1 attachment', '@count attachments')), 'Attachments link found on node teaser.'); // Fetch db record and use fid to rename and delete file. $upload = db_fetch_object(db_query('SELECT fid, description FROM {upload} WHERE nid = %d', array($node->nid))); |