upload_node_view

Versions
7
upload_node_view($node, $build_mode)

Implement hook_node_view().

Code

modules/upload/upload.module, line 339

<?php
function upload_node_view($node, $build_mode) {
  if (!isset($node->files)) {
    return;
  }

  if (user_access('view uploaded files') && $build_mode != 'rss') {
    if (count($node->files)) {
      if ($build_mode == 'full') {
        // 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, $build_mode);
      }
    }
  }

  if ($build_mode == '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->uri),
          'length' => $file->filesize,
          'type' => $file->filemime
        )
      );
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.