tmgmt_test.module 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * @file
  4. * Module file of the translation management test module.
  5. */
  6. /**
  7. * Implements hook_tmgmt_translator_plugin_info().
  8. */
  9. function tmgmt_test_tmgmt_translator_plugin_info() {
  10. return array(
  11. 'test_translator' => array(
  12. 'label' => t('Test translator'),
  13. 'description' => t('Simple translator for testing purposes.'),
  14. 'plugin controller class' => 'TMGMTTestTranslatorPluginController',
  15. 'ui controller class' => 'TMGMTTestTranslatorUIController',
  16. 'default settings' => array(
  17. 'expose_settings' => TRUE,
  18. ),
  19. ),
  20. );
  21. }
  22. /**
  23. * Implements hook_tmgmt_source_plugin_info().
  24. */
  25. function tmgmt_test_tmgmt_source_plugin_info() {
  26. return array(
  27. 'test_source' => array(
  28. 'label' => t('Test source'),
  29. 'description' => t('Simple source for testing purposes.'),
  30. 'plugin controller class' => 'TMGMTTestSourcePluginController',
  31. ),
  32. 'test_html_source' => array(
  33. 'label' => t('Test html source'),
  34. 'description' => t('HTML source for testing purposes.'),
  35. 'plugin controller class' => 'TMGMTTestHTMLSourcePluginController',
  36. ),
  37. );
  38. }
  39. /**
  40. * Implements hook_tmgmt_source_suggestions().
  41. */
  42. function tmgmt_test_tmgmt_source_suggestions(array $items, TMGMTJob $job) {
  43. $suggestions = array();
  44. foreach ($items as $item) {
  45. if ($item->plugin == 'test_source') {
  46. $suggestions[] = array(
  47. 'job_item' => tmgmt_job_item_create('test_source', $item->item_type . '_suggestion', $item->item_id),
  48. 'reason' => t('Test suggestion for @type source @id', array('@type' => $item->item_type,'@id' => $item->item_id)),
  49. 'from_item' => $item->tjiid,
  50. );
  51. }
  52. }
  53. return $suggestions;
  54. }
  55. /**
  56. * Implements hook_tmgmt_fle_text_processor_plugin_info().
  57. */
  58. function tmgmt_test_tmgmt_file_text_processor_plugin_info() {
  59. return array(
  60. 'test' => array(
  61. 'label' => t('Test'),
  62. 'plugin controller class' => 'TMGMTTestTextProcessor',
  63. ),
  64. );
  65. }
  66. /**
  67. * Implements hook_menu().
  68. */
  69. function tmgmt_test_menu() {
  70. $items['tmgmt-add-to-cart/%tmgmt_job_item'] = array(
  71. 'title' => 'Add to cart',
  72. 'description' => 'Provides the possibility to add testing job items into the cart.',
  73. 'page callback' => 'tmgmt_test_add_to_cart',
  74. 'page arguments' => array(1),
  75. 'access callback' => TRUE,
  76. 'type' => MENU_CALLBACK,
  77. );
  78. return $items;
  79. }
  80. /**
  81. * Callback to add given job item into the cart.
  82. */
  83. function tmgmt_test_add_to_cart(TMGMTJobITem $job_item) {
  84. tmgmt_ui_cart_get()->addExistingJobItems(array($job_item));
  85. }