You are here

tmgmt_test.module in Translation Management Tool 7

Module file of the translation management test module.

File

tests/tmgmt_test.module
View source
<?php

/**
 * @file
 * Module file of the translation management test module.
 */

/**
 * Implements hook_tmgmt_translator_plugin_info().
 */
function tmgmt_test_tmgmt_translator_plugin_info() {
  return array(
    'test_translator' => array(
      'label' => t('Test translator'),
      'description' => t('Simple translator for testing purposes.'),
      'plugin controller class' => 'TMGMTTestTranslatorPluginController',
      'ui controller class' => 'TMGMTTestTranslatorUIController',
      'default settings' => array(
        'expose_settings' => TRUE,
      ),
    ),
  );
}

/**
 * Implements hook_tmgmt_source_plugin_info().
 */
function tmgmt_test_tmgmt_source_plugin_info() {
  return array(
    'test_source' => array(
      'label' => t('Test source'),
      'description' => t('Simple source for testing purposes.'),
      'plugin controller class' => 'TMGMTTestSourcePluginController',
    ),
    'test_html_source' => array(
      'label' => t('Test html source'),
      'description' => t('HTML source for testing purposes.'),
      'plugin controller class' => 'TMGMTTestHTMLSourcePluginController',
    ),
  );
}

/**
 * Implements hook_tmgmt_source_suggestions().
 */
function tmgmt_test_tmgmt_source_suggestions(array $items, TMGMTJob $job) {
  $suggestions = array();
  foreach ($items as $item) {
    if ($item->plugin == 'test_source') {
      $suggestions[] = array(
        'job_item' => tmgmt_job_item_create('test_source', $item->item_type . '_suggestion', $item->item_id),
        'reason' => t('Test suggestion for @type source @id', array(
          '@type' => $item->item_type,
          '@id' => $item->item_id,
        )),
        'from_item' => $item->tjiid,
      );
    }
  }
  return $suggestions;
}

/**
 * Implements hook_tmgmt_fle_text_processor_plugin_info().
 */
function tmgmt_test_tmgmt_file_text_processor_plugin_info() {
  return array(
    'test' => array(
      'label' => t('Test'),
      'plugin controller class' => 'TMGMTTestTextProcessor',
    ),
  );
}

/**
 * Implements hook_menu().
 */
function tmgmt_test_menu() {
  $items['tmgmt-add-to-cart/%tmgmt_job_item'] = array(
    'title' => 'Add to cart',
    'description' => 'Provides the possibility to add testing job items into the cart.',
    'page callback' => 'tmgmt_test_add_to_cart',
    'page arguments' => array(
      1,
    ),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Callback to add given job item into the cart.
 */
function tmgmt_test_add_to_cart(TMGMTJobITem $job_item) {
  tmgmt_ui_cart_get()
    ->addExistingJobItems(array(
    $job_item,
  ));
}