Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
// $Id$
// ---------------------------------------------------------------------------
// Drupal Hooks
/*
* Implementation of hook_help()
*/
function views_ui_help($section) {
switch ($section) {
case 'admin/help#views_ui':
return _views_ui_help_add();
case 'admin/modules#description':
return t('The views module creates customized views of node lists.');
case 'admin/views/import':
return t('You may import a view by cut-and-pasting the results of an export view. If the import is successful you will be taken to the Add View page with all of the settings of the imported view..');
case 'admin/views':
return t('This screen shows all of the views that are currently defined in your system. The default views are provided by Views and other modules and are automatically available. If a customized view of the same name exists, it will be used in place of a default view.');
}
if (!strncmp($section, 'admin/views', 11)) {
switch (arg(2)) {
case 'add':
case 'edit':
return t('Please see %s or the views documentation on drupal.org for help here.', array('%s' => l(t('the views help page'), 'admin/help/views_ui')));
case 'export':
return t('You may cut & paste this view into an import function on another system. The view will only work if all modules required by the view are installed on the target location.');
}
}
}
/*
* Because the add/edit page is kind of complicated.
*/
function _views_ui_help_add() {
$output = t('<p>A view retrieves some number of nodes from the database and displays them in a variety of formats.</p>');
$output .= t("<h3>View Types</h3>
<dl>
<dt><em>List View</em></dt><dd>A List View provides the data for each node retrieved in the form of an unordered list. Each item in the Fields section will be displayed; the Title will be displayed as a label. The order the items appear in the Fields list is the order the items will appear in the output. Leaving the title blank will cause the field to appear with no label (which is desirable in lists that just display titles, for example).</dd>
<dt><em>Table View</em></dt><dd>A Table View provides the data for each node as one row of a table. The Fields selected in the Fields list will be displayed in the order they are listed. The title column will be shown in the header. If you set the field to 'sortable' then the header will be click-sortable; be careful here as click-sorts will be processed after built-in sort criteria, and built-in sort criteria can easily make click-sorts invalid. If using click-sorts, choose a field to be the default sort; otherwise the first field presented will be the default sort.</dd>
<dt><em>Teaser List</em></dt><dd>A Teaser List will simply present the teaser of each node retrieved.</dd>
<dt><em>Full Nodes</em></dt><dd>This will show the full content of each node retrieved.</dd>
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<dt><em>Random Teaser</em></dt><dd>This will show a single random teaser.</dd>
<dt><em>Random Node</em></dt><dd>This will show a single random node's full view.</dd>
</dl>");
$output .= t("<h3>Fields</h3>\n");
$output .= t("<p>When using List or Table view, it is necessary to choose which fields will be displayed to the user.</p><dl>\n");
$fields = _views_get_fields();
foreach ($fields as $field) {
$output .= "<dt><em>$field[name]</em></dt><dd>$field[help]</dd>\n";
}
$output .= "</dl>\n";
$output .= t("<h3>Arguments</h3>\n");
$output .= t("<p>Arguments can be passed to the View through the URL, in order to create views that are configurable by the user. This is very useful to create views for taxonomy, or to sort by user. When using arguments, substitution is performed on the title. %1 will represent argument 1, %2 will represent argument 2. Each argument has a title field; this title is used if providing a summary view (which can matter because the argument is missing which could result in confusing phrases such as 'view for')</p><dl>\n");
$arguments = _views_get_arguments();
foreach ($arguments as $argument) {
$output .= "<dt><em>$argument[name]</em></dt><dd>$argument[help]</dd>\n";
}
$output .= "</dl>\n";
$output .= t("<h3>Filters</h3>\n");
$output .= t("<p>Views may be filtered to restrict the view on a number of criteria.</p><dl>\n");
$filters = _views_get_filters();
foreach ($filters as $filter) {
$output .= "<dt><em>$filter[name]</em></dt><dd>$filter[help]</dd>\n";
}
$output .= "</dl>\n";
$output .= t("<h3>Sorting Critera</h3>\n");
$output .= t("<p>The result set may be sorted on any of the following criteria.</p><dl>\n");
$sorts = _views_get_sorts();
foreach ($sorts as $sort) {
$output .= "<dt><em>$sort[name]</em></dt><dd>$sort[help]</dd>\n";
}
$output .= "</dl>\n";
return $output;
}
/*
* Implementation of hook_perm()
*/
function views_ui_perm() {
return array('administer views');
}
/*
* Implementation of hook_menu()
*/
function views_ui_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('path' => 'admin/views',
'title' => t('views'),
'callback' => 'views_ui_admin_page',
'access' => user_access('administer views'),
'type' => MENU_NORMAL_ITEM);
$items[] = array('path' => 'admin/views/list',
'title' => t('list'),
'callback' => 'views_ui_admin_page',
'access' => user_access('administer views'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => '-1');
$items[] = array('path' => 'admin/views/add',
'title' => t('add'),
'callback' => 'views_ui_admin_add_page',
'access' => user_access('administer views'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/views/clone',
'title' => t('clone'),
'callback' => 'views_ui_admin_clone_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/edit',
'title' => t('edit view'),
'callback' => 'views_ui_admin_edit_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/import',
'title' => t('import'),
'callback' => 'views_ui_admin_import_page',
'access' => user_access('administer views'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/views/export',
'title' => t('export view'),
'callback' => 'views_ui_admin_export_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/delete',
'title' => t('edit view'),
'callback' => 'views_ui_admin_delete_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/enable',
'callback' => 'views_ui_admin_enable_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/disable',
'callback' => 'views_ui_admin_disable_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
}
return $items;
}
/**
* hunmonk's module dependency check: see http://drupal.org/node/54463
*/
function views_ui_form_alter($form_id, &$form) {
if ($form_id == 'system_modules' && !$_POST) {
views_ui_system_module_validate($form);
}
}
/**
* hunmonk's module dependency check: see http://drupal.org/node/54463
*/
function views_ui_system_module_validate(&$form) {
$module = 'views_ui';
$dependencies = array('views');
foreach ($dependencies as $dependency) {
if (!in_array($dependency, $form['status']['#default_value'])) {
$missing_dependency = TRUE;
$missing_dependency_list[] = $dependency;
}
}
if (in_array($module, $form['status']['#default_value']) && isset($missing_dependency)) {
db_query("UPDATE {system} SET status = 0 WHERE type = 'module' AND name = '%s'", $module);
$key = array_search($module, $form['status']['#default_value']);
unset($form['status']['#default_value'][$key]);
drupal_set_message(t('The module %module was deactivated--it requires the following disabled/non-existant modules to function properly: %dependencies', array('%module' => $module, '%dependencies' => implode(', ', $missing_dependency_list))), 'error');
}
}
// ---------------------------------------------------------------------------
// Administrative Pages
/*
* This page lists all system views and provides links to edit them.
*/
function views_ui_admin_page() {
$numViews = 25;
drupal_set_title(t('administer views'));
$result = pager_query("SELECT vid, name, description, menu_title, page_title, block_title, url, page, menu, block FROM {view_view} ORDER BY name", $numViews);
while ($view = db_fetch_object($result)) {
$url = ($view->page ? l($view->url, $view->url) : t('No Page View'));
$provides = array();
if ($view->page) {
$provides[] = 'Page';
}
if ($view->block) {
$provides[] = 'Block';
}
if ($view->menu) {
$provides[] = 'Menu';
}
$items[] = array(
$view->name,
views_get_title($view, 'menu'),
$view->description,
implode(', ', $provides),
$url,
theme('links', array(
l(t('edit'), "admin/views/edit/$view->vid"),
l(t('export'), "admin/views/export/$view->vid"),
l(t('delete'), "admin/views/delete/$view->vid"),
l(t('clone'), "admin/views/clone/$view->vid"),
))
);
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
}
if ($items) {
$output = theme('table', array(t('View'), t('Title'), t('Description'), t('Provides'), t('URL'), t('Actions')), $items, array("cellpadding" => "4"), t('Existing Views'));
$output .= theme('pager', NULL, $numViews);
}
else {
$output .= t('<p>No views have currently been defined.</p>');
}
$result = db_query("SELECT name FROM {view_view}");
while ($view = db_fetch_object($result)) {
$used[$view->name] = true;
}
$output .= t('<p>Below are system default views; if you edit one of these, a view will be created that will override any system use of the view.</p>');
$items = array();
$default_views = _views_get_default_views();
$views_status = variable_get('views_defaults', array());
foreach ($default_views as $view) {
$url = ($view->page ? l($view->url, $view->url) : t('No Page View'));
if ($used[$view->name]) {
$status = t('Overridden');
}
else if (isset($views_status[$view->name])) {
if ($views_status[$view->name] == 'enabled') {
$status = t('Enabled');
$status = t('Disabled');
$status = t('Disabled');
$status = t('Enabled');
}
$provides = array();
if ($view->page) {
$provides[] = t('Page');
}
if ($view->block) {
$provides[] = t('Block');
}
if ($view->menu) {
$provides[] = t('Menu');
}
$links = array(l(t('add'), "admin/views/add/$view->name"));
else if ($status == t('Disabled')) {
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
$links[] = l(t('enable'), "admin/views/enable/$view->name");
}
$items[] = array($view->name, views_get_title($view, 'menu'), $view->description, implode(', ', $provides), $url, $status, theme('links', $links));
}
if ($items) {
$output .= theme('table', array(t('Default View'), t('Title'), t('Description'), t('Provides'), t('URL'), t('Status'), t('Actions')), $items, array("cellpadding" => "4"), t('Default Views'));
}
else {
$output .= t('<p>No views have currently been defined.</p>');
}
return $output;
}
/*
* Page to enable a disabled default view
*/
function views_ui_admin_enable_page($view = '') {
if ($view) {
$views_status = variable_get('views_defaults', array());
$views_status[$view] = 'enabled';
variable_set('views_defaults', $views_status);
menu_rebuild();
}
drupal_goto('admin/views');
}
/*
* Page to disable an enabled default view
*/
function views_ui_admin_disable_page($view = '') {
if ($view) {
$views_status = variable_get('views_defaults', array());
$views_status[$view] = 'disabled';
variable_set('views_defaults', $views_status);
menu_rebuild();
}
drupal_goto('admin/views');
}
/*
* Provide a textarea to paste a view export into.
*/
function views_ui_admin_import_page() {
$op = $_POST['edit']['name'];
if ($op) {
return views_ui_admin_add_page();
}
drupal_set_title("Import a View");
$form['view'] = array(
'#type' => 'textarea',
'#title' => t('Import View Code'),
'#cols' => 60,
'#rows' => 6,
'#description' => t('Cut and paste the results of an Export View here.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t("Submit"),
);
return drupal_get_form('views_import_view', $form);
}
/*
* Handle the submit button on importing a view.
*/
function views_import_view_submit($formid, $form) {
ob_start();
eval($form['view']);
ob_end_clean();
$tables = array_keys(_views_get_tables());
if (!is_array($view->requires) || !array_diff($view->requires, $tables)) {
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
drupal_set_title(t('Add a View'));
$output = _views_view_form($view, NULL);
print theme('page', $output);
exit;
}
else {
drupal_set_message(t("You don't seem to have the following requirements: ") . implode(', ', array_diff($view->requires, $tables)));
}
}
else {
drupal_set_message(t('Unable to get a view out of that.'));
}
}
/*
* Export a view for cut & paste.
*/
function views_ui_admin_export_page($vid = '') {
$code = views_create_view_code($vid);
$lines = substr_count($code, "\n");
$form['code'] = array(
'#type' => 'textarea',
'#title' => $view->name,
'#default_value' => $code,
'#rows' => $lines);
return drupal_get_form('views_export', $form);
}
/*
* Provide a form to add a view. Allow adding a view from default templates.
*/
function views_ui_admin_add_page($template = NULL) {
$op = $_POST['op'];
if ($op == t('Cancel')) {
return 'admin/views';
$view = _views_get_default_view($template);
drupal_set_title(t('Add a View'));
return _views_view_form($view, $op);
}
/*
* Provide a form to clone a view.
*/
function views_ui_admin_clone_page($viewname) {
$view = views_load_view($viewname);
if (!$view) {
return drupal_not_found();
}
drupal_set_title(t('Add a View'));
return _views_view_form($view, $op);
}
/*
* Provide a form to edit a view.
*/
function views_ui_admin_edit_page($vid = '') {
$op = $_POST['op'];
if ($op == t('Cancel')) {
drupal_goto('admin/views');
drupal_goto("admin/views/delete/$vid");
drupal_goto('admin/views');
}
drupal_set_title(t('Edit view %n', array('%n' => $view->name)));
return _views_view_form($view, $op);
}
/*
* Provide a form to confirm deletion of a view.
*/
function views_ui_admin_delete_page($vid = '') {
$view = _views_load_view($vid);
if (!$view) {
}
$form['vid'] = array('#type' => 'value', '#value' => $view->vid);
return confirm_form('views_delete_confirm', $form,
t('Are you sure you want to delete %title?', array('%title' => $view->name)),
$_GET['destination'] ? $_GET['destination'] : 'admin/views',
t('Delete'), t('Cancel')
);
}
/*
* Handle the submit button to delete a view.
*/
function views_delete_confirm_submit($formid, $form) {
if ($form['confirm']) {
_views_delete_view((object) $form);
menu_rebuild();
return 'admin/views';
}
}
/*
* Get an empty view with basic defaults.
*/
function _views_get_default_view($template = '') {
if ($template) {
$default_views = _views_get_default_views();
if (isset($default_views[$template])) {
$view = $default_views[$template];
}
}
$view = new stdClass();
$view->use_pager = true;
$view->nodes_per_page = variable_get('default_nodes_main', 10);
$view->page_header_format = variable_get('filter_default_format', 1);
Earl Miles
committed
$view->page_footer_format = variable_get('filter_default_format', 1);
$view->page_header_format = variable_get('filter_default_format', 1);
$view->block_header_format = variable_get('filter_default_format', 1);
$view->block_footer_format = variable_get('filter_default_format', 1);
$view->block_header_format = variable_get('filter_default_format', 1);
$view->vid = 0;
}
return _views_check_arrays($view);
}
// ---------------------------------------------------------------------------
// Select Box Definitions
// These should probably have string array keys that are easier to identify.
/**
* Select box entries for argument defaults.
*/
function _views_get_arguments_default() {
return array(
1 => t('Return Page Not Found'),
2 => t('Display All Values'),
3 => t('Summary, unsorted'),
4 => t('Summary, sorted ascending'),
5 => t('Summary, sorted descending'),
6 => t('Summary, sorted as view'),
Earl Miles
committed
7 => t('Use Empty Text'),
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
);
}
/**
* Select box entries for sort ordering.
*/
function _views_sortorders() {
return array(
'ASC' => t('Ascending'),
'DESC' => t('Descending')
);
}
/**
* Swap two items in an array.
*/
function _views_swap(&$arr, $a, $b) {
$temp = $arr[$a];
$arr[$a] = $arr[$b];
$arr[$b] = $temp;
}
/**
* Move an item up in an array.
*/
function _views_move_up(&$arr, $i) {
if ($i <= 0 || $i >= count($arr)) {
return; // can't do it.
}
_views_swap($arr, $i - 1, $i);
}
/**
* Move an item down in an array.
*/
function _views_move_down(&$arr, $i) {
if ($i >= count($arr) - 1 || $i < 0) {
return; // can't do it.
}
_views_swap($arr, $i + 1, $i);
}
/**
* Move an item to the front of an array.
*/
function _views_move_top(&$arr, $i) {
if ($i <= 0 || $i >= count($arr)) {
return; // can't do it.
}
$temp = $arr[$i];
for ($x = $i; $x > 0; $x--)
$arr[$x] = $arr[$x - 1];
$arr[0] = $temp;
}
/**
* Move an item to the end of an array.
*/
function _views_move_bottom(&$arr, $i) {
$end = count($arr) - 1;
if ($i >= $end || $i < 0) {
return; // can't do it.
}
$temp = $arr[$i];
for ($x = $i; $x < $end; $x++)
$arr[$x] = $arr[$x + 1];
$arr[$end] = $temp;
}
/**
* Figure out which of the many, many buttons on a form were clicked and
* handle it.
*/
function _views_check_sub_ops(&$form, &$order, $i) {
if ($form['delete']['#value']) {
unset($form['delete']['#value']);
unset($order[$i]);
$order = array_values($order); // reindex
$form['delete']['#printed'] = true;
$form['up']['#printed'] = true;
$form['down']['#printed'] = true;
$form['top']['#printed'] = true;
$form['bottom']['#printed'] = true;
return 'delete';
}
else foreach (array('up', 'down', 'top', 'bottom') as $dir) {
if ($form[$dir]['#value']) {
unset ($form[$dir]['#value']);
$func = "_views_move_$dir";
$func($order, $i);
return true;
}
}
return false;
}
/**
* Figure out if one of the add buttons on a form were clicked, and handle it.
*/
function _views_check_ops(&$view, $op, $form) {
if ($op == t('Add Filter')) {
$view->new_filter['id'] = $form['filter']['add']['id']['#value'];
return 'filter';
}
else if ($op == t('Add Criteria')) {
$view->new_sort['id'] = $form['sort']['add']['id']['#value'];
return 'sort';
}
else if ($op == t('Add Argument')) {
$view->new_argument['id'] = $form['argument']['add']['id']['#value'];
return 'argument';
}
else if ($op == t('Add Field')) {
$fieldbits = explode('.', $form['field']['add']['id']['#value']);
$view->new_field['id'] = $form['field']['add']['id']['#value'];
$view->new_field['tablename'] = $fieldbits[0];
$view->new_field['field'] = $fieldbits[1];
$view->new_field['label'] = $fieldnames[$form['field']['add']['id']['#value']];
$view->new_field['queryname'] = "$fieldbits[0]_$fieldbits[1]";
return 'field';
}
else if ($op == t('Expose Filter')) {
$view->new_exposed_filter['id'] = $form['exposed_filter']['add']['id']['#value'];
return 'filter';
}
}
/**
* Custom form element to do our nice images.
*/
function views_elements() {
$type['views_imagebutton'] = array('#input' => TRUE, '#button_type' => 'submit',);
function theme_views_imagebutton($element) {
return '<input type="image" class="form-'. $element['#button_type'] .'" name="'. $element['#name'] .'" value="'. check_plain($element['#default_value']) .'" '. drupal_attributes($element['#attributes']) . ' src="' . $element['#image'] . '" alt="' . $element['#title'] . '" title="' . $element['#title'] . "\" />\n";
}
function views_imagebutton_value() {
// null function guarantees default_value doesn't get moved to #value.
}
/**
* Set up the dynamic #options on a widget
*/
function views_ui_setup_widget($widget, $default_value, $argument = NULL) {
if (!$argument) {
$argument = $widget;
}
if (is_string($widget['#options']) && function_exists($widget['#options'])) {
$widget['#options'] = $widget['#options']('option', $argument);
}
if ($widget['#multiple'] && is_array($widget['#options'])) {
$widget['#size'] = min(count($widget['#options']), 8);
}
$widget['#default_value'] = $default_value;
return $widget;
}
/**
* Display all the guts of a view in a form for editing.
*/
function _views_view_form($view, $op = '') {
_views_check_arrays($view); // make sure arrays that might be empty get set
// Put in all our add buttons, then process them to see if they've been hit.
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
views_ui_add_add_button($form, 'field', _views_get_fields(true), t('Add Field'));
views_ui_add_add_button($form, 'argument', _views_get_arguments(true), t('Add Argument'));
views_ui_add_add_button($form, 'filter', _views_get_filters(true), t('Add Filter'));
views_ui_add_add_button($form, 'sort', _views_get_sorts(true), t('Add Criteria'));
$allbut = _views_check_ops($view, $op, $form);
if ($_POST['edit'] && $op != t('Save')) {
drupal_set_message(t('You have modified this view; changes will not be recorded until you Save the form.'));
}
$form['exposed_filter'] = array();
foreach (array('field', 'argument', 'filter', 'exposed_filter', 'sort') as $section) {
if (views_ui_add_section($form[$section], $view, $section)) {
$allbut = $section;
}
}
$form['vid'] = array(
'#type' => 'value',
'#value' => $view->vid,
);
$form['allbut'] = array(
'#type' => 'value',
'#value' => $allbut,
);
$form['changed'] = array(
'#type' => 'hidden',
'#value' => $view->changed,
);
$form['basic-info'] = array(
'#type' => 'fieldset',
'#collapsible' => true,
'#collapsed' => ($allbut != NULL),
'#title' => t('Basic Information'),
);
$form['basic-info']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $view->name,
'#size' => 20,
'#maxlength' => 32,
'#description' => t('The unique identifier of the view; it is only important for overridden views and views that modules or themes will need to use. Only alphanumeric and _ allowed here'),
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
'#required' => true,
);
$form['basic-info']['access'] = array(
'#type' => 'checkboxes',
'#title' => t('Access'),
'#default_value' => $view->access,
'#options' => views_handler_filter_role(),
'#description' => t('Only the checked roles will be able to see this view in any form; if no roles are checked, access will not be restricted.'),
);
$form['basic-info']['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => $view->description,
'#size' => 60,
'#maxlength' => 255,
'#description' => t('A description of the view for the admin list.'),
);
// page info
$form['page-info'] = array(
'#type' => 'fieldset',
'#collapsible' => true,
'#collapsed' => ($allbut != NULL || !$view->page),
'#title' => t('Page'),
);
'#type' => 'checkbox',
'#title' => t('Provide Page View'),
'#return_value' => 1,
'#default_value' => $view->page,
'#description' => t('If checked this view will be provided as a page. If not checked, the fields in this group will be ignored.'),
);
$form['page-info']['url'] = array(
'#type' => 'textfield',
'#title' => t('URL'),
'#default_value' => $view->url,
'#size' => 60,
'#maxlength' => 255,
'#description' => t('Enter the URL to use for this view in the form of \'dir/dir\'. Do not begin or end the URL with a /. Example: \'view/tracker\'. This is required if providing a page view. You can also add $arg as a placeholder for arguments passed in the URL, for example \'user/$arg/tracker\' or \'view/taxonomy/$arg\'. Note that any arguments listed here will be required, even if they are listed as optional below. You do not need to list arguments at the end of the path.'),
$form['page-info']['page_type'] = array(
'#type' => 'select',
'#title' => t('View Type'),
'#default_value' => $view->page_type,
Earl Miles
committed
'#options' => _views_get_style_plugins(true),
'#description' => t('How the nodes should be displayed to the user.'),
);
$form['page-info']['page_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $view->page_title,
'#size' => 60,
'#maxlength' => 255,
'#description' => t('The title that be shown at the top of the view. May be blank. This title ignores arguments; if you want your title to take arguments into account, use the "title" field in the arguments section.'),
);
$form['page-info']['use_pager'] = array(
'#type' => 'checkbox',
'#title' => t('Use Pager'),
'#return_value' => 1,
'#default_value' => $view->use_pager,
'#description' => t('If checked this query may be multiple pages. If not checked this query will be one page.'),
);
$form['page-info']['breadcrumb_no_home'] = array(
'#type' => 'checkbox',
'#title' => t('Breadcrumb trail should not include "Home"'),
'#return_value' => 1,
'#default_value' => $view->breadcrumb_no_home,
'#description' => t('If checked the breadcrumb trail for this page will discard "Home". Usually you will not set this, but this is used for the Front Page View, where it IS Home and should not leave a trail to itself.'),
);
$form['page-info']['nodes_per_page'] = array(
'#type' => 'textfield',
'#title' => t('Nodes per Page'),
'#default_value' => $view->nodes_per_page,
Earl Miles
committed
'#description' => t('The number of nodes to display per page. If 0, all nodes will be displayed. If not using a pager, this will be the maximum number of nodes in the list.'),
Earl Miles
committed
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
$form['page-info']['page_header_fieldset'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Header'),
);
$form['page-info']['page_header_fieldset']['page_header'] = array(
'#type' => 'textarea',
'#default_value' => $view->page_header,
'#cols' => 60,
'#rows' => 6,
'#description' => t('Text to display at the top of the view. May contain an explanation or links or whatever you like. Optional.'),
);
$form['page-info']['page_header_fieldset']['page_header_format'] = filter_form($view->page_header_format, 1, array('page_header_format'));
$form['page-info']['page_footer_fieldset'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Footer'),
);
$form['page-info']['page_footer_fieldset']['page_footer'] = array(
'#type' => 'textarea',
'#default_value' => $view->page_footer,
'#cols' => 60,
'#rows' => 6,
'#description' => t('Text to display at the bottom of the view. May contain an explanation or links or whatever you like. Optional.'),
);
$form['page-info']['page_footer_fieldset']['page_footer_format'] = filter_form($view->page_footer_format, 1, array('page_footer_format'));
$form['page-info']['page_empty_fieldset'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Empty Text'),
);
$form['page-info']['page_empty_fieldset']['page_empty'] = array(
'#type' => 'textarea',
'#default_value' => $view->page_empty,
'#cols' => 60,
'#rows' => 6,
'#description' => t('Text to display if a view returns no nodes. Optional.'),
);
$form['page-info']['page_empty_fieldset']['page_empty_format'] = filter_form($view->page_empty_format, 1, array('page_empty_format'));
Earl Miles
committed
'#collapsible' => TRUE,
'#collapsed' => TRUE,
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
'#title' => t('Menu'),
);
$form['page-info']['menu-info']['menu'] = array(
'#type' => 'checkbox',
'#title' => t('Provide Menu'),
'#return_value' => 1,
'#default_value' => $view->menu,
'#description' => t('If checked this view be given a menu entry in the Drupal menu system. If not checked the data in this group will be ignored.'),
);
$form['page-info']['menu-info']['menu_tab'] = array(
'#type' => 'checkbox',
'#title' => t('Provide Menu as Tab'),
'#return_value' => 1,
'#default_value' => $view->menu_tab,
'#description' => t("If checked this view's menu entry will be provided as a tab rather than in the main menu system."),
);
$form['page-info']['menu-info']['menu_tab_default'] = array(
'#type' => 'checkbox',
'#title' => t('Make Default Menu Tab'),
'#return_value' => 1,
'#default_value' => $view->menu_tab_default,
'#description' => t("If checked this view's menu entry will be provided as a tab, and will be the default tab for that URL path. For example, if the URL is 'tracker/all' and it is set as the default menu tab, it will be put into the menu as 'tracker' and 'tracker/all' will be the default tab. For tabs to work properly, one tab in the group must be set as the default."),
);
$form['page-info']['menu-info']['menu_tab_weight'] = array(
'#type' => 'textfield',
'#title' => t('Tab Weight'),
'#default_value' => $view->menu_tab_weight,
'#width' => 10,
'#description' => t('If this is a menu tab, select the weight; lower numbers will be further to the left.'),
);
$form['page-info']['menu-info']['menu_title'] = array(
'#type' => 'textfield',
'#title' => t('Menu Title'),
'#default_value' => $view->menu_title,
'#size' => 60,
'#maxlength' => 255,
'#description' => t('Enter the title to use for the menu entry or tab. If blank, the page title will be used.'),
);
// block info
$form['block-info'] = array(
'#type' => 'fieldset',
'#collapsible' => true,
'#collapsed' => ($allbut != NULL || !$view->block),
'#title' => t('Block'),
);
$form['block-info']['block'] = array(
'#type' => 'checkbox',
'#title' => t('Provide Block'),
'#return_value' => 1,
'#default_value' => $view->block,
'#description' => t('If checked this view will be provided as a block. If checked title may not be blank.'),
);
$form['block-info']['block_type'] = array(
'#type' => 'select',
'#title' => t('View Type'),
'#default_value' => $view->block_type,
Earl Miles
committed
'#options' => _views_get_style_plugins(true),
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
'#description' => t('How the nodes should be displayed to the user.'),
);
$form['block-info']['block_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $view->block_title,
'#size' => 60,
'#maxlength' => 255,
'#description' => t('The title that will be shown at the top of the block. May be blank.'),
);
$form['block-info']['nodes_per_block'] = array(
'#type' => 'textfield',
'#title' => t('Nodes per Block'),
'#default_value' => $view->nodes_per_block,
'#size' => 2,
'#maxlength' => 2,
'#description' => t('If using a block, the maximum number of items to display in the block. Pagers are not used in blocks.'),
'#attributes' => NULL,
);
$form['block-info']['block_more'] = array(
'#type' => 'checkbox',
'#title' => t('[More] Link?'),
'#return_value' => 1,
'#default_value' => $view->block_more,
'#description' => t('If using a view as both a page and a block, display a more link in the block that links to the view URL?'),
);
Earl Miles
committed
$form['block-info']['block_header_fieldset'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Header'),
);
$form['block-info']['block_header_fieldset']['block_use_page_header'] = array(
'#type' => 'checkbox',
'#title' => t('Use Page Header'),
'#return_value' => 1,
'#default_value' => $view->block_use_page_header,
'#description' => t('If checked, use the Page Header for block view instead. If so, you should leave the Block Header blank.'),
);
Earl Miles
committed
$form['block-info']['block_header_fieldset']['block_header'] = array(
'#type' => 'textarea',
'#title' => t('Header'),
'#default_value' => $view->block_header,
'#cols' => 60,
'#rows' => 6,
'#description' => t('Text to display at the top of the view. May contain an explanation or links or whatever you like. Optional.'),
);
Earl Miles
committed
$form['block-info']['block_header_fieldset']['block_header_format'] = filter_form($view->block_header_format, 1, array( 'block_header_format'));
$form['block-info']['block_footer_fieldset'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Footer'),
);
$form['block-info']['block_footer_fieldset']['block_use_page_footer'] = array(
'#type' => 'checkbox',
'#title' => t('Use Page Footer'),
'#return_value' => 1,
'#default_value' => $view->block_use_page_footer,
'#description' => t('If checked, use the page footer for block view instead. If so, you should leave the block footer blank.'),
);
$form['block-info']['block_footer_fieldset']['block_footer'] = array(