1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Contains the raw value argument default plugin.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Default argument plugin to use the raw value from the URL.
|
10
|
*
|
11
|
* @ingroup views_argument_default_plugins
|
12
|
*/
|
13
|
class views_plugin_argument_default_raw extends views_plugin_argument_default {
|
14
|
function option_definition() {
|
15
|
$options = parent::option_definition();
|
16
|
$options['index'] = array('default' => '');
|
17
|
$options['use_alias'] = array('default' => FALSE, 'bool' => TRUE);
|
18
|
|
19
|
return $options;
|
20
|
}
|
21
|
|
22
|
function options_form(&$form, &$form_state) {
|
23
|
parent::options_form($form, $form_state);
|
24
|
// Using range(1, 10) will create an array keyed 0-9, which allows arg() to
|
25
|
// properly function since it is also zero-based.
|
26
|
$form['index'] = array(
|
27
|
'#type' => 'select',
|
28
|
'#title' => t('Path component'),
|
29
|
'#default_value' => $this->options['index'],
|
30
|
'#options' => range(1, 10),
|
31
|
'#description' => t('The numbering starts from 1, e.g. on the page admin/structure/types, the 3rd path component is "types".'),
|
32
|
);
|
33
|
$form['use_alias'] = array(
|
34
|
'#type' => 'checkbox',
|
35
|
'#title' => t('Use path alias'),
|
36
|
'#default_value' => $this->options['use_alias'],
|
37
|
'#description' => t('Use path alias instead of internal path.'),
|
38
|
);
|
39
|
}
|
40
|
|
41
|
function get_argument() {
|
42
|
$path = NULL;
|
43
|
if ($this->options['use_alias']) {
|
44
|
$path = drupal_get_path_alias();
|
45
|
}
|
46
|
if ($arg = arg($this->options['index'], $path)) {
|
47
|
return $arg;
|
48
|
}
|
49
|
}
|
50
|
}
|