/[drupal]/contributions/modules/views_bulk_operations/views_bulk_operations.views.inc
ViewVC logotype

Contents of /contributions/modules/views_bulk_operations/views_bulk_operations.views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Jul 24 20:56:19 2008 UTC (16 months ago) by kratib
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
File MIME type: text/x-php
First import for D6
1 <?php
2 // $Id$
3
4 function views_bulk_operations_views_plugins() {
5 return array(
6 'style' => array(
7 'bulk' => array(
8 'title' => t('Bulk Operations'),
9 'help' => t('Displays nodes with checkmarks for bulk actions.'),
10 'handler' => 'views_bulk_operations_plugin_style',
11 'uses row plugin' => TRUE,
12 'uses fields' => TRUE,
13 'uses options' => TRUE,
14 'type' => 'normal',
15 ),
16 ),
17 );
18 }
19
20 class views_bulk_operations_plugin_style extends views_plugin_style {
21 function options(&$options) {
22 $options['selected_operations'] = array();
23 $this->populate_operations($options);
24 }
25
26 function options_form(&$form, &$form_values) {
27 $form['selected_operations'] = array(
28 '#type' => 'checkboxes',
29 '#title' => t('Selected operations'),
30 '#options' => $this->get_operations_options(),
31 '#default_value' => $this->options['selected_operations'],
32 );
33 }
34
35 function options_validate(&$form, &$form_values) {
36 }
37
38 function render() {
39 return drupal_get_form('views_bulk_operations_form', $this);
40 }
41
42 function get_selected_operations() {
43 $selected = array();
44 foreach (array_filter($this->options['selected_operations']) as $key => $operation) {
45 $selected[$key] = $this->options['all_operations'][$key]['label'];
46 }
47 return $selected;
48 }
49
50 function get_operation_info($key) {
51 return $this->options['all_operations'][$key];
52 }
53
54 private function get_operations_options() {
55 $options = array();
56 foreach ($this->options['all_operations'] as $key => $operation) {
57 $options[$key] = $operation['label'] .' ('. $operation['callback'] .')';
58 }
59 return $options;
60 }
61
62 private function populate_operations(&$options) {
63 $operations = array();
64
65 $node_operations = module_invoke_all('node_operations');
66 foreach ($node_operations as $operation) {
67 if (empty($operation['callback'])) continue;
68 $key = md5($operation['callback']);
69 $operations[$key] = array(
70 'label' => $operation['label'],
71 'callback' => $operation['callback'],
72 'callback arguments' => $operation['callback arguments'],
73 'configurable' => false,
74 'type' => 'node',
75 );
76 }
77
78 $action_operations = actions_list() + $this->get_custom_actions();
79 foreach ($action_operations as $callback => $values) {
80 foreach (array('node', 'workflow', 'email') as $type) {
81 if (0 != strcasecmp($type, $values['type'])) continue;
82 $key = md5($callback);
83 $operations[$key] = array(
84 'label' => $values['description'],
85 'callback' => $callback,
86 'callback arguments' => $values['parameters'],
87 'configurable' => $values['configurable'],
88 'type' => 'action',
89 );
90 break; // out of inner, type-searching loop
91 }
92 }
93
94 $options['all_operations'] = $operations;
95 }
96
97 private function get_custom_actions() {
98 $actions = array();
99 $result = db_query("SELECT * FROM {actions} WHERE parameters > ''");
100 while ($action = db_fetch_object($result)) {
101 $actions[$action->aid] = array(
102 'description' => $action->description,
103 'type' => $action->type,
104 'configurable' => FALSE,
105 'parameters' => $actions->parameters,
106 );
107 }
108 return $actions;
109 }
110 }
111

  ViewVC Help
Powered by ViewVC 1.1.2