Commit 32e2e0fe authored by Joel Stein's avatar Joel Stein
Browse files

Added %size, %created, and %modified file name replacements.

parent b02bc5ad
Loading
Loading
Loading
Loading
+28 −3
Changes for filetree.module: 28 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -46,12 +46,30 @@ function filetree_tokens($type, $tokens, array $data = array(), array $options =
        case 'extension':
          $replacements[$original] = pathinfo($data['filepath'], PATHINFO_EXTENSION);
          break;
        case 'size':
          $replacements[$original] = format_size(filesize($data['filepath']));
          break;
        case 'created':
          $replacements[$original] = format_date(filectime($data['filepath']), 'filetree');
          break;
        case 'modified':
          $replacements[$original] = format_date(filemtime($data['filepath']), 'filetree');
          break;
      }
    }
  }
  return $replacements;
}

/**
 * Implements hook_date_format_types().
 */
function filetree_date_format_types() {
  return array(
    'filetree' => t('File Tree'),
  );
}

/**
 * Implements hook_filter_FILTER_settings().
 */
@@ -79,9 +97,16 @@ function _filetree_tips($filter, $format, $long = FALSE) {
    $output .= '<blockquote>[filetree dir="some-directory" multi="false" controls="false" absolute="false" exclude="CVS; directory1; directory2" dirname="%basename" dirtitle="Click to toggle this folder." filename="%basename" filetitle="Click to download this %extension file." animation="false"]</blockquote>';
    $output .= '<p>' . t('Available tokens for use within the "dirname", "dirtitle", "filename", and "filetitle" options include:') . '</p>';
    $output .= theme('item_list', array('items' => array(
      '%filename: ' . t("The file's name and extension."),
      '%basename: ' . t("The file's name, without extension."),
      '%extension: ' . t("The file's extension."),
      '%filename: ' . t('Filename, with extension.'),
      '%basename: ' . t('File name, without extension.'),
      '%extension: ' . t('File extension.'),
      '%size: ' . t('Size of the file in human-readable format.'),
      '%created: ' . t('Date the file was created, using the <a href="!url">File Tree format</a>.', array(
        '!url' => url('admin/config/regional/date-time'),
      )),
      '%modified: ' . t('Date the file was modified, using the <a href="!url">File Tree format</a>.', array(
        '!url' => url('admin/config/regional/date-time'),
      )),
    )));
    $output .= '<p>' . t('You can also read a <a href="http://drupal.org/project/filetree">detailed explanation of these options</a>.'). '</p>';
  }