diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-05-03 10:11:35 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-05-03 10:11:35 +0000 |
commit | a8c30ed91ea00e24f809adc965b05f8292fbc236 (patch) | |
tree | 386db65fe5377df5373bf3e2a2b30bf1112a5fc7 /modules/upload | |
parent | 3d951475eaebab990a78d07acdc344eb50239e18 (diff) | |
download | brdo-a8c30ed91ea00e24f809adc965b05f8292fbc236.tar.gz brdo-a8c30ed91ea00e24f809adc965b05f8292fbc236.tar.bz2 |
- Patch #449718 by alienbrain: node_feed() is now using new node building API.
Diffstat (limited to 'modules/upload')
-rw-r--r-- | modules/upload/upload.module | 96 |
1 files changed, 45 insertions, 51 deletions
diff --git a/modules/upload/upload.module b/modules/upload/upload.module index a4406b11e..e71099b27 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -62,26 +62,24 @@ function upload_node_links($node, $teaser) { $links = array(); // Display a link with the number of attachments - if ($teaser && isset($node->files) && user_access('view uploaded files')) { - $num_files = 0; - foreach ($node->files as $file) { - if ($file->list) { - $num_files++; - } - } - if ($num_files) { - $links['upload_attachments'] = array( - 'title' => format_plural($num_files, '1 attachment', '@count attachments'), - 'href' => "node/$node->nid", - 'attributes' => array('title' => t('Read full article to view attachments.')), - 'fragment' => 'attachments' - ); - $node->content['links']['upload_attachments'] = array( - '#type' => 'node_links', - '#value' => $links, - ); + $num_files = 0; + foreach ($node->files as $file) { + if ($file->list) { + $num_files++; } } + if ($num_files) { + $links['upload_attachments'] = array( + 'title' => format_plural($num_files, '1 attachment', '@count attachments'), + 'href' => "node/$node->nid", + 'attributes' => array('title' => t('Read full article to view attachments.')), + 'fragment' => 'attachments' + ); + $node->content['links']['upload_attachments'] = array( + '#type' => 'node_links', + '#value' => $links, + ); + } } /** @@ -341,20 +339,45 @@ function upload_node_load($nodes, $types) { * Implementation of hook_node_view(). */ function upload_node_view($node, $teaser) { - if (isset($node->files) && user_access('view uploaded files')) { - // Add the attachments list to node body with a heavy - // weight to ensure they're below other elements. + if (!isset($node->files)) { + return; + } + + if (user_access('view uploaded files') && $node->build_mode != NODE_BUILD_RSS) { if (count($node->files)) { if (!$teaser) { + // Add the attachments list to node body with a heavy weight to ensure + // they're below other elements. $node->content['files'] = array( '#files' => $node->files, '#theme' => 'upload_attachments', '#weight' => 50, ); } + else { + upload_node_links($node, $teaser); + } } + } - upload_node_links($node, $teaser); + if ($node->build_mode == NODE_BUILD_RSS) { + // Add the first file as an enclosure to the RSS item. RSS allows only one + // enclosure per item. See: http://en.wikipedia.org/wiki/RSS_enclosure + foreach ($node->files as $file) { + if ($file->list) { + break; + } + } + if ($file->list) { + $node->rss_elements[] = array( + 'key' => 'enclosure', + 'attributes' => array( + 'url' => file_create_url($file->filepath), + 'length' => $file->filesize, + 'type' => $file->filemime + ) + ); + } } } @@ -410,35 +433,6 @@ function upload_node_search_result($node) { } /** - * Implementation of hook_node_rss_item(). - */ -function upload_node_rss_item($node) { - if (is_array($node->files)) { - $files = array(); - foreach ($node->files as $file) { - if ($file->list) { - $files[] = $file; - } - } - if (count($files) > 0) { - // RSS only allows one enclosure per item - $file = array_shift($files); - return array( - array( - 'key' => 'enclosure', - 'attributes' => array( - 'url' => file_create_url($file->filepath), - 'length' => $file->filesize, - 'type' => $file->filemime - ) - ) - ); - } - } - return array(); -} - -/** * Displays file attachments in table * * @ingroup themeable |