You are here

function filebrowser_form_rename in Filebrowser 7.4

Same name and namespace in other branches
  1. 7.3 filebrowser.module \filebrowser_form_rename()

_state

Parameters

array $form:

array $fids:

Return value

mixed

1 string reference to 'filebrowser_form_rename'
filebrowser_page_rename in ./filebrowser.pages.inc

File

./filebrowser.module, line 1007

Code

function filebrowser_form_rename($form, &$form_state, $fids) {

  // Store original items.
  $original_files = array();

  // Array of text boxes with new names.
  $form['new_names'] = array(
    '#tree' => TRUE,
  );
  foreach ($fids as $fid) {
    $content = _filebrowser_node_content_load($fid);
    $node = node_load($content['nid']);
    $name = _filebrowser_safe_basename($content['path']);
    $path = _filebrowser_encoding_to_fs($node, _filebrowser_get_node_root($node) . $content['root']);
    $original_files[$fid] = array(
      'path' => $path,
      'display-name' => $name,
      'full-path' => $path . '/' . $name,
    );
    $form['new_names'][$fid] = array(
      '#type' => 'textfield',
      '#default_value' => $name,
    );
  }

  // Store original names into form values.
  $form['original_files'] = array(
    '#type' => 'value',
    '#value' => $original_files,
  );
  return confirm_form($form, t('Rename selected items...'), isset($_GET['destination']) ? $_GET['destination'] : 'node/' . $node->nid, t('This action cannot be undone.'), t('Rename'), t('Cancel'));
}