print_pdf.views.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /**
  3. * @file
  4. * PDF Version Views integration.
  5. *
  6. * @ingroup print
  7. */
  8. /**
  9. * Implements hook_views_data().
  10. */
  11. function print_pdf_views_data() {
  12. // The 'group' index will be used as a prefix in the UI for any of this
  13. // table's fields, sort criteria, etc. so it's easy to tell where they came
  14. // from.
  15. $data['print_pdf_node_conf']['table']['group'] = t('Printer-friendly version');
  16. $data['print_pdf_page_counter']['table']['group'] = t('Printer-friendly version');
  17. // This table references the {node} table. The declaration below creates an
  18. // 'implicit' relationship to the node table, so that when 'node' is the base
  19. // table, the fields are automatically available.
  20. $data['print_pdf_node_conf']['table']['join']['node'] = array(
  21. // 'left_field' is the primary key in the referenced table.
  22. // 'field' is the foreign key in this table.
  23. 'left_field' => 'nid',
  24. 'field' => 'nid',
  25. );
  26. $data['print_pdf_page_counter']['table']['join']['node'] = array(
  27. // 'left_field' is the primary key in the referenced table.
  28. // 'field' is the foreign key in this table.
  29. 'left_field' => 'nid',
  30. 'field' => 'path',
  31. 'handler' => 'print_join_page_counter',
  32. );
  33. // print_pdf_node_conf fields.
  34. $data['print_pdf_node_conf']['link'] = array(
  35. 'title' => t('PDF: Show link'),
  36. 'help' => t('Whether to show the PDF version link.'),
  37. 'field' => array(
  38. 'handler' => 'views_handler_field_boolean',
  39. 'click sortable' => TRUE,
  40. ),
  41. 'filter' => array(
  42. 'handler' => 'views_handler_filter_boolean_operator',
  43. 'label' => t('Active'),
  44. 'type' => 'yes-no',
  45. ),
  46. 'sort' => array(
  47. 'handler' => 'views_handler_sort',
  48. ),
  49. );
  50. $data['print_pdf_node_conf']['comments'] = array(
  51. 'title' => t('PDF: Show link in individual comments'),
  52. 'help' => t('Whether to show the PDF version link in individual comments.'),
  53. 'field' => array(
  54. 'handler' => 'views_handler_field_boolean',
  55. 'click sortable' => TRUE,
  56. ),
  57. 'filter' => array(
  58. 'handler' => 'views_handler_filter_boolean_operator',
  59. 'label' => t('Active'),
  60. 'type' => 'yes-no',
  61. ),
  62. 'sort' => array(
  63. 'handler' => 'views_handler_sort',
  64. ),
  65. );
  66. $data['print_pdf_node_conf']['url_list'] = array(
  67. 'title' => t('PDF: Show Printer-friendly URLs list'),
  68. 'help' => t('Whether to show the URL list.'),
  69. 'field' => array(
  70. 'handler' => 'views_handler_field_boolean',
  71. 'click sortable' => TRUE,
  72. ),
  73. 'filter' => array(
  74. 'handler' => 'views_handler_filter_boolean_operator',
  75. 'label' => t('Active'),
  76. 'type' => 'yes-no',
  77. ),
  78. 'sort' => array(
  79. 'handler' => 'views_handler_sort',
  80. ),
  81. );
  82. $data['print_pdf_node_conf']['size'] = array(
  83. 'title' => t('PDF: Paper size'),
  84. 'help' => t('Configured PDF paper size'),
  85. 'field' => array(
  86. 'handler' => 'views_handler_field',
  87. 'click sortable' => TRUE,
  88. ),
  89. 'filter' => array(
  90. 'handler' => 'views_handler_filter_string',
  91. ),
  92. 'sort' => array(
  93. 'handler' => 'views_handler_sort',
  94. ),
  95. );
  96. $data['print_pdf_node_conf']['orientation'] = array(
  97. 'title' => t('PDF: Page orientation'),
  98. 'help' => t('Configured PDF page orientation.'),
  99. 'field' => array(
  100. 'handler' => 'views_handler_field',
  101. 'click sortable' => TRUE,
  102. ),
  103. 'filter' => array(
  104. 'handler' => 'views_handler_filter_string',
  105. ),
  106. 'sort' => array(
  107. 'handler' => 'views_handler_sort',
  108. ),
  109. );
  110. // print_pdf_page_counter fields.
  111. $data['print_pdf_page_counter']['totalcount'] = array(
  112. 'title' => t('PDF: Number of page accesses'),
  113. 'help' => t('Counter of accesses to the PDF version for this node.'),
  114. 'field' => array(
  115. 'handler' => 'views_handler_field_numeric',
  116. 'click sortable' => TRUE,
  117. ),
  118. 'sort' => array(
  119. 'handler' => 'views_handler_sort',
  120. ),
  121. 'filter' => array(
  122. 'handler' => 'views_handler_filter_numeric',
  123. ),
  124. );
  125. $data['print_pdf_page_counter']['timestamp'] = array(
  126. 'title' => t('PDF: Last access'),
  127. 'help' => t("The date of the last access to the node's PDF version."),
  128. 'field' => array(
  129. 'handler' => 'views_handler_field_date',
  130. 'click sortable' => TRUE,
  131. ),
  132. 'sort' => array(
  133. 'handler' => 'views_handler_sort_date',
  134. ),
  135. 'filter' => array(
  136. 'handler' => 'views_handler_filter_date',
  137. ),
  138. );
  139. return $data;
  140. }