link.views.inc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * @file
  4. * Contains functions handling views integration.
  5. */
  6. /**
  7. * Implementation of hook_views_handlers().
  8. */
  9. /*function link_views_handlers() {
  10. return array(
  11. 'info' => array(
  12. 'path' => drupal_get_path('module', 'link') .'/views',
  13. ),
  14. 'handlers' => array(
  15. 'link_views_handler_argument_target' => array(
  16. 'parent' => 'views_handler_argument',
  17. ),
  18. 'link_views_handler_filter_protocol' => array(
  19. 'parent' => 'views_handler_filter_string',
  20. ),
  21. ),
  22. );
  23. }*/
  24. /**
  25. * Return CCK Views data for the link_field_settings($op == 'views data').
  26. *
  27. * @TODO: Is there some way to tell views I have formatters for it?
  28. */
  29. /*function link_views_content_field_data($field) {
  30. // Build the automatic views data provided for us by CCK.
  31. // This creates all the information necessary for the "url" field.
  32. $data = content_views_field_views_data($field);
  33. $db_info = content_database_info($field);
  34. $table_alias = content_views_tablename($field);
  35. $field_types = _content_field_types();
  36. // Tweak the automatic views data for the link "url" field.
  37. // Set the filter title to "@label URL"
  38. $data[$table_alias][$field['field_name'] .'_url']['filter']['title'] = t('@label URL', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']);
  39. // Remove the argument handling for URLs.
  40. unset($data[$table_alias][$field['field_name'] .'_url']['argument']);
  41. // Build out additional views data for the link "title" field.
  42. $data[$table_alias][$field['field_name'] .'_title'] = array(
  43. 'group' => t('Content'),
  44. 'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
  45. 'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
  46. 'argument' => array(
  47. 'field' => $db_info['columns']['title']['column'],
  48. 'tablename' => $db_info['table'],
  49. 'handler' => 'content_handler_argument_string',
  50. 'click sortable' => TRUE,
  51. 'name field' => '', // TODO, mimic content.views.inc :)
  52. 'content_field_name' => $field['field_name'],
  53. 'allow_empty' => TRUE,
  54. ),
  55. 'filter' => array(
  56. 'field' => $db_info['columns']['title']['column'],
  57. 'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))),
  58. 'tablename' => $db_info['table'],
  59. 'handler' => 'content_handler_filter_string',
  60. 'additional fields' => array(),
  61. 'content_field_name' => $field['field_name'],
  62. 'allow_empty' => TRUE,
  63. ),
  64. 'sort' => array(
  65. 'field' => $db_info['columns']['title']['column'],
  66. 'tablename' => $db_info['table'],
  67. 'handler' => 'content_handler_sort',
  68. 'content_field_name' => $field['field_name'],
  69. 'allow_empty' => TRUE,
  70. ),
  71. );
  72. // Build out additional Views filter for the link "protocol" pseudo field.
  73. // TODO: Add a protocol argument.
  74. $data[$table_alias][$field['field_name'] .'_protocol'] = array(
  75. 'group' => t('Content'),
  76. 'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
  77. 'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
  78. 'filter' => array(
  79. 'field' => $db_info['columns']['url']['column'],
  80. 'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))),
  81. 'tablename' => $db_info['table'],
  82. 'handler' => 'link_views_handler_filter_protocol',
  83. 'additional fields' => array(),
  84. 'content_field_name' => $field['field_name'],
  85. 'allow_empty' => TRUE,
  86. ),
  87. );
  88. // Build out additional Views argument for the link "target" pseudo field.
  89. // TODO: Add a target filter.
  90. $data[$table_alias][$field['field_name'] .'_target'] = array(
  91. 'group' => t('Content'),
  92. 'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
  93. 'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
  94. 'argument' => array(
  95. 'field' => $db_info['columns']['attributes']['column'],
  96. 'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
  97. 'tablename' => $db_info['table'],
  98. 'handler' => 'link_views_handler_argument_target',
  99. 'additional fields' => array(),
  100. 'content_field_name' => $field['field_name'],
  101. 'allow_empty' => TRUE,
  102. ),
  103. );
  104. return $data;
  105. }*/