book.views_convert.inc

Field conversion for fields handled by this module.

File

modules/book.views_convert.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Field conversion for fields handled by this module.
  5. */
  6. /**
  7. * Implementation of hook_views_convert().
  8. */
  9. function book_views_convert($display, $type, &$view, $field, $id = NULL) {
  10. switch ($type) {
  11. case 'field':
  12. switch ($field['tablename']) {
  13. case 'book_parent_node':
  14. switch ($field['field']) {
  15. case 'title':
  16. $item = $view->get_item($display, 'field', $id);
  17. if ($field['handler'] == 'views_handler_field_book_parent_title') {
  18. $item['link_to_node'] = TRUE;
  19. }
  20. $item['relationship'] = $view->add_item($display, 'relationship', 'book_parent', 'nid', array(), 'book_parent_nid');
  21. $item['table'] = 'node';
  22. $item['field'] = 'title';
  23. $view->set_item($display, 'field', $id, $item);
  24. break;
  25. }
  26. break;
  27. }
  28. break;
  29. case 'filter':
  30. switch ($field['tablename']) {
  31. case 'book':
  32. switch ($field['field']) {
  33. case 'parent':
  34. $operators = array('AND' => '=', 'OR' => '=', 'NOT' => '!=');
  35. $item = $view->get_item($display, 'filter', $id);
  36. $item['operator'] = $operators[$field['operator']];
  37. $item['relationship'] = $view->add_item($display, 'relationship', 'book_parent', 'nid', array(), 'book_parent_nid');
  38. $item['table'] = 'node';
  39. $item['field'] = 'nid';
  40. $view->set_item($display, 'filter', $id, $item);
  41. break;
  42. }
  43. break;
  44. }
  45. break;
  46. case 'sort':
  47. switch ($field['tablename']) {
  48. case 'book':
  49. switch ($field['field']) {
  50. case 'weight':
  51. $view->set_item_option($display, 'sort', $id, 'table', 'book_menu_links');
  52. break;
  53. }
  54. break;
  55. case 'book_parent_node':
  56. switch ($field['field']) {
  57. case 'title':
  58. $item = $view->get_item($display, 'sort', $id);
  59. $item['relationship'] = $view->add_item($display, 'relationship', 'book_parent', 'nid', array(), 'book_parent_nid');
  60. $item['table'] = 'node';
  61. $item['field'] = 'title';
  62. $view->set_item($display, 'sort', $id, $item);
  63. break;
  64. }
  65. break;
  66. }
  67. break;
  68. case 'argument':
  69. $options = $field['argoptions'];
  70. switch ($field['type']) {
  71. case 'book_parent':
  72. $options['relationship'] = $view->add_item($display, 'relationship', 'book_parent', 'nid', array(), 'book_parent_nid');
  73. $view->add_item($display, 'argument', 'node', 'nid', $options, $field['id']);
  74. break;
  75. }
  76. break;
  77. }
  78. }