1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Contains the content ID argument handler.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Handler to accept an argument of the content ID of any object.
|
10 |
|
|
*
|
11 |
|
|
* @ingroup views
|
12 |
|
|
*/
|
13 |
|
|
class flag_handler_argument_entity_id extends views_handler_argument_numeric {
|
14 |
|
|
|
15 |
|
|
/**
|
16 |
|
|
* Returns the flag object associated with our argument.
|
17 |
|
|
*
|
18 |
|
|
* An argument is in some relationship. This function reaches out for this
|
19 |
|
|
* relationship and reads its 'flag' option, which holds the flag name.
|
20 |
|
|
*/
|
21 |
|
|
function get_flag() {
|
22 |
|
|
return $this->view->relationship[$this->options['relationship']]->get_flag();
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
/**
|
26 |
|
|
* Override the behavior of title(). Get the title of the appropriate objects.
|
27 |
|
|
*/
|
28 |
|
|
function title_query() {
|
29 |
|
|
if (!($flag = $this->get_flag())) {
|
30 |
76e2e7c3
|
Assos Assos
|
// Error message is printed by get_flag().
|
31 |
|
|
return array();
|
32 |
85ad3d82
|
Assos Assos
|
}
|
33 |
|
|
$views_info = $flag->get_views_info();
|
34 |
|
|
|
35 |
|
|
$titles = array();
|
36 |
76e2e7c3
|
Assos Assos
|
$placeholders = implode(', ', array_fill(0, count($this->value), '%d'));
|
37 |
85ad3d82
|
Assos Assos
|
|
38 |
|
|
$result = db_select($views_info['views table'], 'o')
|
39 |
|
|
->fields('o', array($views_info['title field']))
|
40 |
|
|
->condition('o.' . $views_info['join field'], $this->value, 'IN')
|
41 |
|
|
->execute();
|
42 |
|
|
foreach ($result as $title) {
|
43 |
|
|
$titles[] = check_plain($title->$views_info['title field']);
|
44 |
|
|
}
|
45 |
|
|
return $titles;
|
46 |
|
|
}
|
47 |
|
|
} |