link.views.inc 4.6 KB

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