summaryrefslogtreecommitdiff
path: root/sites/all/modules/file_entity/views/views_handler_argument_file_type.inc
blob: 3eb2fa5200282e3a644509e5c830c63751ce7d27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

/**
 * @file
 * Definition of views_handler_argument_file_type.
 */

/**
 * Argument handler to accept a file type.
 */
class views_handler_argument_file_type extends views_handler_argument_string {

  /**
   * Override the behavior of summary_name(). Get the user friendly version
   * of the file type.
   */
  function summary_name($data) {
    return $this->file_type($data->{$this->name_alias});
  }

  /**
   * Override the behavior of title(). Get the user friendly version of the
   * file type.
   */
  function title() {
    return $this->file_type($this->argument);
  }

  /**
   * Helper function to return the human-readable type of the file.
   */
  function file_type($type) {
    $output = file_entity_type_get_name($type);
    if (empty($output)) {
      $output = t('Unknown file type');
    }
    return check_plain($output);
  }
}