You are here

function filebrowser_view_D7_BAK in Filebrowser 8

Implements hook_init().

File

./filebrowser.module, line 369
Validates file path input on node form

Code

function filebrowser_view_D7_BAK($node, $view_mode) {
  if ($view_mode == "full") {
    _filebrowser_load_files($node);

    // Full node content view
    // ========================================================
    // Keep track of the current location and update breadcrumbs to reflect that.
    $breadcrumbs = array(
      l(t('Home'), NULL),
    );
    $breadcrumb_path = "";

    //print_r($node);

    //return;
    $path_elements = explode('/', rtrim($node->file_listing['.']['relative-path'], "/"));
    for ($i = 0; $i < count($path_elements); $i++) {
      $child_dir = $path_elements[$i] == '' ? '/' : $path_elements[$i];
      $breadcrumb_path .= $child_dir;
      $fid = db_query("SELECT fid FROM {node_dir_listing_content}\n                     WHERE path = :path", array(
        ':path' => $breadcrumb_path,
      ))
        ->fetchField();
      if ($child_dir == '/') {
        $label = $node->title;
      }
      else {
        $label = $child_dir;
      }
      if ($i < count($path_elements) - 1) {
        $breadcrumbs[] = l($label, "node/{$node->nid}/{$fid}");
      }
      else {
        $breadcrumbs[] = $label;
      }
    }
    drupal_set_breadcrumb($breadcrumbs);

    // Insert file listing  content part
    $current_view = _filebrowser_externals('presentations', $node->folder_presentation->default_view);
    $node->content['filebrowser_content'] = array(
      '#markup' => count($node->file_listing) == 0 ? '' : theme($current_view['theme'], array(
        'node' => $node,
      )),
      '#weight' => 1,
    );
    if ($node->folder_uploads->enabled && user_access(FILEBROWSER_UPLOAD)) {
      $node->content['filebrowser_form_upload'] = array(
        '#markup' => drupal_render(drupal_get_form('filebrowser_form_upload', $node)),
        '#weight' => 2,
      );
    }
    if ($node->folder_uploads->enabled && user_access(FILEBROWSER_CREATE_FOLDER)) {
      $node->content['filebrowser_form_create_folder'] = array(
        '#markup' => drupal_render(drupal_get_form('filebrowser_form_create_folder', $node)),
        '#weight' => 3,
      );
    }
    $statistics = array(
      'empty' => t('This folder is empty'),
    );
    if ($node->file_listing['.']['folders_count'] > 0) {
      $statistics['folders'] = format_plural($node->file_listing['.']['folders_count'], '1 dossier', '@count dossiers');
      $statistics['empty'] = NULL;
    }
    if ($node->file_listing['.']['files_count'] > 0) {
      $statistics['files'] = format_plural($node->file_listing['.']['files_count'], '1 file', '@count files');
      $statistics['size'] = format_size($node->file_listing['.']['size']);
      $statistics['empty'] = NULL;
    }
    $node->content['filebrowser_statistics'] = array(
      '#markup' => theme('dir_listing_statistics', $statistics),
      '#weight' => 3,
    );
  }

  // Insert filebrowser links
  $node->content['links']['filebrowser'] = array(
    '#theme' => 'links__node__blog',
    '#links' => _filebrowser_links($node),
    '#attributes' => array(
      'class' => array(
        'links',
        'inline',
      ),
    ),
  );
  return $node;
}