print_pdf.views.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. // 'type' => 'INNER',
  26. );
  27. $data['print_pdf_page_counter']['table']['join']['node'] = array(
  28. // 'left_field' is the primary key in the referenced table.
  29. // 'field' is the foreign key in this table.
  30. 'left_field' => 'nid',
  31. 'field' => 'path',
  32. // 'type' => 'INNER',
  33. 'handler' => 'print_join_page_counter',
  34. );
  35. // print_pdf_node_conf fields
  36. $data['print_pdf_node_conf']['link'] = array(
  37. 'title' => t('PDF: Show link'),
  38. 'help' => t('Whether to show the PDF version link.'),
  39. 'field' => array(
  40. 'handler' => 'views_handler_field_boolean',
  41. 'click sortable' => TRUE,
  42. ),
  43. 'filter' => array(
  44. 'handler' => 'views_handler_filter_boolean_operator',
  45. 'label' => t('Active'),
  46. 'type' => 'yes-no',
  47. ),
  48. 'sort' => array(
  49. 'handler' => 'views_handler_sort',
  50. ),
  51. );
  52. $data['print_pdf_node_conf']['comments'] = array(
  53. 'title' => t('PDF: Show link in individual comments'),
  54. 'help' => t('Whether to show the PDF version link in individual comments.'),
  55. 'field' => array(
  56. 'handler' => 'views_handler_field_boolean',
  57. 'click sortable' => TRUE,
  58. ),
  59. 'filter' => array(
  60. 'handler' => 'views_handler_filter_boolean_operator',
  61. 'label' => t('Active'),
  62. 'type' => 'yes-no',
  63. ),
  64. 'sort' => array(
  65. 'handler' => 'views_handler_sort',
  66. ),
  67. );
  68. $data['print_pdf_node_conf']['url_list'] = array(
  69. 'title' => t('PDF: Show Printer-friendly URLs list'),
  70. 'help' => t('Whether to show the URL list.'),
  71. 'field' => array(
  72. 'handler' => 'views_handler_field_boolean',
  73. 'click sortable' => TRUE,
  74. ),
  75. 'filter' => array(
  76. 'handler' => 'views_handler_filter_boolean_operator',
  77. 'label' => t('Active'),
  78. 'type' => 'yes-no',
  79. ),
  80. 'sort' => array(
  81. 'handler' => 'views_handler_sort',
  82. ),
  83. );
  84. $data['print_pdf_node_conf']['size'] = array(
  85. 'title' => t('PDF: Paper size'),
  86. 'help' => t('Configured PDF paper size'),
  87. 'field' => array(
  88. 'handler' => 'views_handler_field',
  89. 'click sortable' => TRUE,
  90. ),
  91. 'filter' => array(
  92. 'handler' => 'views_handler_filter_string',
  93. ),
  94. 'sort' => array(
  95. 'handler' => 'views_handler_sort',
  96. ),
  97. );
  98. $data['print_pdf_node_conf']['orientation'] = array(
  99. 'title' => t('PDF: Page orientation'),
  100. 'help' => t('Configured PDF page orientation.'),
  101. 'field' => array(
  102. 'handler' => 'views_handler_field',
  103. 'click sortable' => TRUE,
  104. ),
  105. 'filter' => array(
  106. 'handler' => 'views_handler_filter_string',
  107. ),
  108. 'sort' => array(
  109. 'handler' => 'views_handler_sort',
  110. ),
  111. );
  112. // print_pdf_page_counter fields
  113. $data['print_pdf_page_counter']['totalcount'] = array(
  114. 'title' => t('PDF: Number of page accesses'),
  115. 'help' => t('Counter of accesses to the PDF version for this node.'),
  116. 'field' => array(
  117. 'handler' => 'views_handler_field_numeric',
  118. 'click sortable' => TRUE,
  119. ),
  120. 'sort' => array(
  121. 'handler' => 'views_handler_sort',
  122. ),
  123. 'filter' => array(
  124. 'handler' => 'views_handler_filter_numeric',
  125. ),
  126. );
  127. $data['print_pdf_page_counter']['timestamp'] = array(
  128. 'title' => t('PDF: Last access'),
  129. 'help' => t("The date of the last access to the node's PDF version."),
  130. 'field' => array(
  131. 'handler' => 'views_handler_field_date',
  132. 'click sortable' => TRUE,
  133. ),
  134. 'sort' => array(
  135. 'handler' => 'views_handler_sort_date',
  136. ),
  137. 'filter' => array(
  138. 'handler' => 'views_handler_filter_date',
  139. ),
  140. );
  141. return $data;
  142. }