1 |
ca0757b9
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Filter by the file schema type.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
class views_handler_filter_schema_type extends views_handler_filter_in_operator {
|
8 |
|
|
function get_value_options() {
|
9 |
|
|
if (!isset($this->value_options)) {
|
10 |
|
|
$this->value_title = t('File Schema types');
|
11 |
|
|
$types = file_get_stream_wrappers(STREAM_WRAPPERS_VISIBLE);
|
12 |
|
|
$options = array();
|
13 |
|
|
foreach ($types as $type => $info) {
|
14 |
|
|
$options[$type] = t($info['name']);
|
15 |
|
|
}
|
16 |
|
|
asort($options);
|
17 |
|
|
$this->value_options = $options;
|
18 |
|
|
}
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
function op_simple() {
|
22 |
|
|
if (empty($this->value)) {
|
23 |
|
|
return;
|
24 |
|
|
}
|
25 |
|
|
$this->ensure_my_table();
|
26 |
|
|
|
27 |
|
|
// We use array_values() because the checkboxes keep keys and that can cause
|
28 |
|
|
// array addition problems.
|
29 |
|
|
$statements = array();
|
30 |
|
|
|
31 |
|
|
$not_in = $this->operator == 'not in' ? TRUE : FALSE;
|
32 |
|
|
$schema_operator = $not_in ? 'NOT LIKE' : 'LIKE';
|
33 |
|
|
$composite = $not_in ? ' AND ' : ' OR ';
|
34 |
|
|
|
35 |
|
|
foreach ($this->value as $schema) {
|
36 |
|
|
$statements[] = 'uri ' . $schema_operator . ' \'' . db_like($schema) . '://%\'';
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
$this->query->add_where_expression($this->options['group'], implode($composite, $statements));
|
40 |
|
|
}
|
41 |
|
|
} |