tmgmt.views.inc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /**
  3. * @file
  4. * Contains Views controllers for the translation management module.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function tmgmt_views_data() {
  10. $data = array();
  11. foreach (tmgmt_source_views_controller() as $controller) {
  12. $data += $controller->views_data();
  13. }
  14. return $data;
  15. }
  16. /**
  17. * Views controller class for the job item entity.
  18. */
  19. class TMGMTJobItemViewsController extends EntityDefaultViewsController {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function views_data() {
  24. $data = parent::views_data();
  25. $data['tmgmt_job_item']['label'] = array(
  26. 'title' => t('Label'),
  27. 'help' => t('Displays a label of the job item.'),
  28. 'field' => array(
  29. 'handler' => 'tmgmt_handler_field_tmgmt_entity_label',
  30. ),
  31. );
  32. $data['tmgmt_job_item']['type'] = array(
  33. 'title' => t('Type'),
  34. 'help' => t('Displays a type of the job item.'),
  35. 'field' => array(
  36. 'handler' => 'tmgmt_handler_field_tmgmt_job_item_type',
  37. ),
  38. );
  39. $data['tmgmt_job_item']['progress'] = array(
  40. 'title' => t('Progress'),
  41. 'help' => t('Displays the progress of a job item.'),
  42. 'real field' => 'tjiid',
  43. 'field' => array(
  44. 'handler' => 'tmgmt_handler_field_tmgmt_progress',
  45. ),
  46. );
  47. $data['tmgmt_job_item']['operations'] = array(
  48. 'title' => t('Operations'),
  49. 'help' => t('Displays a list of options which are available for a job item.'),
  50. 'real field' => 'tjiid',
  51. 'field' => array(
  52. 'handler' => 'tmgmt_handler_field_tmgmt_job_item_operations',
  53. ),
  54. );
  55. return $data;
  56. }
  57. }
  58. /**
  59. * Views controller class for the job entity.
  60. */
  61. class TMGMTJobViewsController extends EntityDefaultViewsController {
  62. /**
  63. * {@inheritdoc}
  64. */
  65. public function views_data() {
  66. $data = parent::views_data();
  67. $data['tmgmt_job']['operations'] = array(
  68. 'title' => t('Operations'),
  69. 'help' => t('Displays a list of options which are available for a job.'),
  70. 'real field' => 'tjid',
  71. 'field' => array(
  72. 'handler' => 'tmgmt_handler_field_tmgmt_job_operations',
  73. ),
  74. );
  75. $data['tmgmt_job']['progress'] = array(
  76. 'title' => t('Progress'),
  77. 'help' => t('Displays the progress of a job.'),
  78. 'real field' => 'tjid',
  79. 'field' => array(
  80. 'handler' => 'tmgmt_handler_field_tmgmt_progress',
  81. ),
  82. );
  83. $data['tmgmt_job']['word_count'] = array(
  84. 'title' => t('Word count'),
  85. 'help' => t('Displays the word count of a job.'),
  86. 'real field' => 'tjid',
  87. 'field' => array(
  88. 'handler' => 'tmgmt_handler_field_tmgmt_wordcount',
  89. ),
  90. );
  91. $data['tmgmt_job']['label']['field']['handler'] = 'tmgmt_handler_field_tmgmt_entity_label';
  92. $data['tmgmt_job']['translator']['field']['handler'] = 'tmgmt_handler_field_tmgmt_translator';
  93. $data['tmgmt_job']['job_item'] = array(
  94. 'title' => t('Job items'),
  95. 'help' => t('Get the job items of the job'),
  96. 'relationship' => array(
  97. 'base' => 'tmgmt_job_item',
  98. 'base field' => 'tjid',
  99. 'real field' => 'tjid',
  100. 'label' => t('Job items'),
  101. ),
  102. );
  103. $data['tmgmt_job']['item_count'] = array(
  104. 'title' => t('Job item count'),
  105. 'help' => t('Show the amount of job items per job (per job item status)'),
  106. 'real field' => 'tjid',
  107. 'field' => array(
  108. 'handler' => 'tmgmt_handler_field_tmgmt_job_item_count',
  109. ),
  110. );
  111. return $data;
  112. }
  113. }
  114. /**
  115. * Views controller class for the job message entity.
  116. */
  117. class TMGMTMessageViewsController extends EntityDefaultViewsController {
  118. /**
  119. * {@inheritdoc}
  120. */
  121. public function views_data() {
  122. $data = parent::views_data();
  123. $data['tmgmt_message']['message']['field']['handler'] = 'tmgmt_handler_field_tmgmt_message_message';
  124. return $data;
  125. }
  126. }
  127. interface TMGMTSourceViewsControllerInterface extends TMGMTPluginBaseInterface {
  128. /**
  129. * Defines the result for hook_views_data().
  130. */
  131. public function views_data();
  132. }
  133. /**
  134. * Vies controller class for source plugins.
  135. */
  136. class TMGMTDefaultSourceViewsController extends TMGMTPluginBase implements TMGMTSourceViewsControllerInterface {
  137. /**
  138. * {@inheritdoc}
  139. */
  140. public function views_data() {
  141. // @todo Implement this in a generic fashion.
  142. /* $key = $this->pluginInfo['something'];
  143. $data[$key]['tmgmt_translatable_types'] = array(
  144. 'title' => t('Translatable types'),
  145. 'help' => t('Filter translatable elements based on their types.'),
  146. 'filter' => array(
  147. 'handler' => 'views_handler_filter_in_operator',
  148. 'real field' => 'type',
  149. 'options callback' => 'tmgmt_source_translatable_item_types',
  150. 'options arguments' => array($this->pluginType),
  151. ),
  152. ); */
  153. return array();
  154. }
  155. }