| 1 |
<?php |
<?php |
| 2 |
// $Id: comment.views_default.inc,v 1.6 2008/06/10 21:30:43 merlinofchaos Exp $ |
// $Id: views_plugin_argument_default_user.inc,v 1.1 2008/09/03 19:21:30 merlinofchaos Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Contains the user from URL argument default plugin. |
* Contains the user from URL argument default plugin. |
| 9 |
* Default argument plugin to extract a user via menu_get_object |
* Default argument plugin to extract a user via menu_get_object |
| 10 |
*/ |
*/ |
| 11 |
class views_plugin_argument_default_user extends views_plugin_argument_default { |
class views_plugin_argument_default_user extends views_plugin_argument_default { |
| 12 |
var $option_name = 'default_argument_user'; |
function option_definition() { |
| 13 |
|
$options = parent::option_definition(); |
| 14 |
|
$options['user'] = array('default' => ''); |
| 15 |
|
|
| 16 |
function argument_form(&$form, &$form_state) { |
return $options; |
| 17 |
$form[$this->option_name] = array( |
} |
| 18 |
'#type' => 'checkbox', |
|
| 19 |
'#title' => t('Also look for a node and use the node author'), |
function options_form(&$form, &$form_state) { |
| 20 |
'#default_value' => !empty($this->argument->options[$this->option_name]), |
$form['user'] = array( |
| 21 |
'#process' => array('views_process_dependency'), |
'#type' => 'textfield', |
| 22 |
'#dependency' => array( |
'#title' => t('Default argument'), |
| 23 |
'radio:options[default_action]' => array('default'), |
'#default_value' => $this->options['user'], |
|
'radio:options[default_argument_type]' => array($this->id) |
|
|
), |
|
|
'#dependency_count' => 2, |
|
| 24 |
); |
); |
| 25 |
} |
} |
| 26 |
|
|
| 27 |
|
function convert_options(&$options) { |
| 28 |
|
if (!isset($options['user']) && isset($this->argument->options['default_argument_user'])) { |
| 29 |
|
$options['user'] = $this->argument->options['default_argument_user']; |
| 30 |
|
} |
| 31 |
|
} |
| 32 |
|
|
| 33 |
function get_argument() { |
function get_argument() { |
| 34 |
foreach (range(1, 3) as $i) { |
foreach (range(1, 3) as $i) { |
| 35 |
$user = menu_get_object('user', $i); |
$user = menu_get_object('user', $i); |
| 45 |
} |
} |
| 46 |
} |
} |
| 47 |
|
|
| 48 |
if (!empty($this->argument->options[$this->option_name])) { |
if (!empty($this->options['user'])) { |
| 49 |
foreach (range(1, 3) as $i) { |
foreach (range(1, 3) as $i) { |
| 50 |
$node = menu_get_object('node', $i); |
$node = menu_get_object('node', $i); |
| 51 |
if (!empty($node)) { |
if (!empty($node)) { |