updated core to 7.58 (right after the site was hacked)

This commit is contained in:
2018-04-20 23:48:40 +02:00
parent 18f4aba146
commit 9344a61b61
711 changed files with 99690 additions and 480 deletions

View File

@@ -0,0 +1,196 @@
/**
* @file
* CSS for the tmgmt admin pages.
*/
.tmgmt-ui-info-item {
float: left;
margin-right: 80px;
}
.tmgmt-ui-job-items-suggestions fieldset {
padding-top: 13px;
}
table.tmgmt-ui-review td {
vertical-align: top;
}
table.tmgmt-ui-review input.unreviewed {
text-decoration: line-through;
}
table.tmgmt-ui-review tbody th {
background: none;
font-weight: bold;
}
.tmgmt-ui-data-item-label .form-item {
/* Get the label out of way, so the status icon can be placed at the same
relative position */
position: absolute;
}
.tmgmt-ui-state {
/* Visually align the icon in the center between left table border and the
first textarea.*/
margin: 1.8em -10px 1em 0;
text-align: center;
}
.tmgmt-ui-state .tmgmt-ui-icon {
margin: 0 auto;
}
/* Base settings for the icon. */
.tmgmt-ui-icon {
float: left;
color: #fff;
text-align: center;
border-style: solid;
box-shadow: 0 0 4px rgba(0,0,0,0.4);
-moz-box-shadow: 0 0 4px rgba(0,0,0,0.4);
-webkit-box-shadow: 0 0 4px rgba(0,0,0,0.4);
}
/* Icon colors. */
.tmgmt-ui-icon-green {
border-color: #080f00;
background: #336600;
background : -webkit-gradient(linear, left top, left bottom, from(#5dba00), to(#336600));
background : -moz-linear-gradient(top, #5dba00, #336600);
}
.tmgmt-ui-icon-darkgreen {
border-color: #080f00;
background: #264d00;
background : -webkit-gradient(linear, left top, left bottom, from(#336600), to(#264d00));
background : -moz-linear-gradient(top, #336600, #264d00);
}
.tmgmt-ui-icon-grey {
border-color: #444;
background: #666;
background : -webkit-gradient(linear, left top, left bottom, from(#aaa), to(#666));
background : -moz-linear-gradient(top, #aaa, #666);
}
.tmgmt-ui-icon-white {
border-color: #080f00;
background: #fff;
background : -webkit-gradient(linear, left top, left bottom, from(#fff), to(#aaa));
background : -moz-linear-gradient(top, #fff, #aaa);
}
.tmgmt-ui-icon-blue {
border-color: #080f00;
background: #007fff;
background : -webkit-gradient(linear, left top, left bottom, from(#007fff), to(#0050A0));
background : -moz-linear-gradient(top, #007fff, #0050A0);
}
.tmgmt-ui-icon-yellow {
border-color: #544300;
background: #a88700;
background : -webkit-gradient(linear, left top, left bottom, from(#ffcc00), to(#a88700));
background : -moz-linear-gradient(top, #ffcc00, #a88700);
}
.tmgmt-ui-icon-yellow {
border-color: #544300;
background: #a88700;
background : -webkit-gradient(linear, left top, left bottom, from(#ffcc00), to(#a88700));
background : -moz-linear-gradient(top, #ffcc00, #a88700);
}
.tmgmt-ui-icon-orange {
border-color: #210000;
background: #FF7f00;
background : -webkit-gradient(linear, left top, left bottom, from(#FF7f00), to(#A55000));
background : -moz-linear-gradient(top, #FF7f00, #A55000);
}
/* Icon sizes. */
.tmgmt-ui-icon-128 {
width: 128px;
height: 128px;
border-width: 3px;
line-height: 128px;
text-shadow: 0 -2px 0 rgba(0,0,0,0.5);
border-radius: 10px;
-moz-border-radius: 10px;
}
.tmgmt-ui-icon.tmgmt-ui-icon-128 span {
font-size: 118px;
}
.tmgmt-ui-icon-64 {
width: 64px;
height: 64px;
border-width: 1px;
line-height: 64px;
text-shadow: 0 -1px 0 rgba(0,0,0,0.5);
border-radius: 5px;
-moz-border-radius: 5px;
}
.tmgmt-ui-icon.tmgmt-ui-icon-64 span {
font-size: 52px;
}
.tmgmt-ui-icon-32 {
width: 32px;
height: 32px;
border-width: 1px;
line-height: 32px;
text-shadow: 0 -1px 0 rgba(0,0,0,0.5);
border-radius: 3px;
-moz-border-radius: 3px;
}
.tmgmt-ui-icon.tmgmt-ui-icon-32 span {
font-size: 23px;
}
.tmgmt-ui-icon-10 {
width: 10px;
height: 10px;
border-width: 1px;
line-height: 16px;
text-shadow: 0 -1px 0 rgba(0,0,0,0.5);
border-radius: 2px;
-moz-border-radius: 2px;
margin-left: 5px;
}
.tmgmt-one-legend{
float: left;
}
.tmgmt-legend-icon{
float: left;
margin: 4px 4px;
}
.tmgmt-legend-status{
width: 152px;
}
.tmgmt-sources-wrapper div.form-item {
float: left;
margin-right: 16px;
}
.tmgmt-sources-wrapper input.form-submit {
margin: 20px 0 0 0;
}
.tmgmt-source-operations-wrapper {
clear: both;
}
.view-tmgmt-node-source-overview .view-filters, .tmgmt-sources-wrapper {
margin-right: 310px;
}

View File

@@ -0,0 +1,9 @@
/**
* @file
* CSS for the tmgmt admin pages for theme seven.
*/
#content .tmgmt-color-legend{
float: right;
width: 310px;
}

View File

@@ -0,0 +1,156 @@
<?php
/**
* @file
* Contains TMGMTJobItemUICart.
*/
/**
* Represents a job item cart.
*
* @ingroup tmgmt_ui_cart
*/
class TMGMTJobItemUICart {
/**
* Singleton instance of cart.
*/
protected static $instance;
/**
* Array key to store the contents of $this->cart into the $_SESSION variable.
*
* @var string
*/
protected $session_key = 'tmgmt_cart';
/**
* An array to hold and manipulate the contents of the job item cart.
*
* @var array
*/
protected $cart;
/**
* Set up a new TMGMTJobItemUICart instance.
*
* Will load the cart from the session or initialize a new one if nothing has
* been stored yet.
*/
protected function __construct() {
if (!isset($_SESSION[$this->session_key])) {
$_SESSION[$this->session_key] = array();
}
$this->cart = &$_SESSION[$this->session_key];
}
/**
* Returns the singleton cart.
*
* @return TMGMTJobItemUICart
* An instance of the cart.
*/
public static function getInstance() {
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Adds existing job items into the cart.
*
* @param TMGMTJobItem[] $items
* Job items to be added.
*/
public function addExistingJobItems(array $items) {
foreach ($items as $item) {
if (!$this->isSourceItemAdded($item->plugin, $item->item_type, $item->item_id)) {
$this->cart[] = $item->tjiid;
}
}
}
/**
* Creates a job item and adds it into the cart.
*
* @param string $plugin
* The source plugin.
* @param string $item_type
* The source item type.
* @param $item_id
* The source item id.
*
* @return TMGMTJobItem|null
* Added job item. If the item exists NULL is returned.
*/
public function addJobItem($plugin, $item_type, $item_id) {
if ($this->isSourceItemAdded($plugin, $item_type, $item_id)) {
return NULL;
}
$job_item = tmgmt_job_item_create($plugin, $item_type, $item_id);
$job_item->save();
$this->cart[] = $job_item->tjiid;
return $job_item;
}
/**
* Checks if the source item has been added into the cart.
*
* @param string $plugin
* The source plugin.
* @param string $item_type
* The source type.
* @param int $source_id
* The source id.
*
* @return bool
* If the source item is in the cart.
*/
public function isSourceItemAdded($plugin, $item_type, $source_id) {
foreach ($this->getJobItemsFromCart() as $job_item) {
if ($job_item->item_id == $source_id && $job_item->item_type == $item_type && $job_item->plugin == $plugin) {
return TRUE;
}
}
return FALSE;
}
/**
* Remove job items from the cart.
*
* @param array $job_item_ids
* Job items to be removed.
*/
public function removeJobItems(array $job_item_ids) {
$this->cart = array_diff($this->cart, $job_item_ids);
}
/**
* Gets job items in the cart.
*
* @return TMGMTJobItem[] $items
* Job items in the cart.
*/
public function getJobItemsFromCart() {
return entity_load('tmgmt_job_item', $this->cart);
}
/**
* Gets count of items in the cart.
*
* @return int
* Number of items in the cart.
*/
public function count() {
return count($this->cart);
}
/**
* Remove all contents from the cart.
*/
public function emptyCart() {
$this->cart = array();
}
}

View File

@@ -0,0 +1,139 @@
<?php
/**
* @file
* Contains the job UI controller.
*/
/**
* Entity UI controller for the Job Entity.
*/
class TMGMTJobUIController extends EntityDefaultUIController {
/**
* Translation job that is a duplicate of an aborted job.
*
* @var TMGMTJob
*/
private $jobToResubmit = NULL;
/**
* {@inheritdoc}
*/
public function hook_menu() {
$id_count = count(explode('/', $this->path));
$wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object';
$items[$this->path . '/' . $wildcard] = array(
'title callback' => 'entity_label',
'title arguments' => array($this->entityType, $id_count),
'page callback' => 'tmgmt_ui_job_view',
'page arguments' => array($id_count),
'load arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('view', $this->entityType, $id_count),
'file' => $this->entityInfo['admin ui']['file'],
'file path' => $this->entityInfo['admin ui']['file path'],
);
$items[$this->path . '/' . $wildcard . '/delete'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $id_count, $id_count + 1),
'load arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('delete', $this->entityType, $id_count),
'type' => MENU_CALLBACK,
);
$items[$this->path . '/' . $wildcard . '/abort'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $id_count, $id_count + 1),
'load arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('abort', $this->entityType, $id_count),
'type' => MENU_CALLBACK,
);
$items[$this->path . '/' . $wildcard . '/resubmit'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $id_count, $id_count + 1),
'load arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('resubmit', $this->entityType, $id_count),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* {@inheritdoc}
*/
public function operationForm($form, &$form_state, $entity, $op) {
switch ($op) {
case 'delete':
$confirm_question = t('Are you sure you want to delete the translation job %label?', array('%label' => $entity->label()));
return confirm_form($form, $confirm_question, $this->path);
case 'abort':
return confirm_form($form, t('Abort this job?'), 'admin/tmgmt/jobs/' . $entity->tjid,
t('This will send a request to the translator to abort the job. After the action the job translation process will be aborted and only remaining action will be resubmitting it.'));
case 'resubmit':
return confirm_form($form, t('Resubmit as a new job?'), 'admin/tmgmt/jobs/' . $entity->tjid,
t('This creates a new job with the same items which can then be submitted again. In case the sources meanwhile changed, the new job will reflect the update.'));
}
drupal_not_found();
exit;
}
/**
* {@inheritdoc}
*/
public function applyOperation($op, $entity) {
switch ($op) {
case 'delete':
$entity->delete();
return t('Deleted the translation job %label.', array('%label' => $entity->label()));
case 'abort':
if (!$entity->abortTranslation()) {
// This is the case when a translator does not support the abort operation.
// It would make more sense to not display the button for the action,
// however we do not know if the translator is able to abort a job until
// we trigger the action.
foreach ($entity->getMessagesSince() as $message) {
if ($message->type == 'debug') {
continue;
}
if ($text = $message->getMessage()) {
// We want to persist also the type therefore we will set the
// messages directly and not return them.
drupal_set_message(filter_xss($text), $message->type);
}
}
}
break;
case 'resubmit':
$this->jobToResubmit = $entity->cloneAsUnprocessed();
$this->jobToResubmit->uid = $GLOBALS['user']->uid;
$this->jobToResubmit->save();
/** @var TMGMTJobItem $item */
foreach ($entity->getItems() as $item) {
$item_to_resubmit = $item->cloneAsActive();
$this->jobToResubmit->addExistingItem($item_to_resubmit);
}
$entity->addMessage('Job has been duplicated as a new job <a href="@url">#@id</a>.',
array('@url' => url('admin/tmgmt/jobs/' . $this->jobToResubmit->tjid), '@id' => $this->jobToResubmit->tjid));
$this->jobToResubmit->addMessage('This job is a duplicate of the previously aborted job <a href="@url">#@id</a>',
array('@url' => url('admin/tmgmt/jobs/' . $entity->tjid), '@id' => $entity->tjid));
return t('The aborted job has been duplicated. You can resubmit it now.');
}
return FALSE;
}
/**
* Operation form submit callback.
*/
public function operationFormSubmit($form, &$form_state) {
parent::operationFormSubmit($form, $form_state);
if ($form_state['op'] == 'resubmit') {
$form_state['redirect'] = $this->path . '/' . $this->jobToResubmit->tjid;
}
}
}

View File

@@ -0,0 +1,99 @@
<?php
/**
* @file
* Contains the job item UI controller.
*/
/**
* Entity UI controller for the Job Entity.
*/
class TMGMTJobItemUIController extends EntityDefaultUIController {
/**
* {@inheritdoc}
*/
public function hook_menu() {
$id_count = count(explode('/', $this->path));
$wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object';
$items[$this->path . '/' . $wildcard] = array(
'title callback' => 'entity_label',
'title arguments' => array($this->entityType, $id_count),
'page callback' => 'tmgmt_ui_job_item_view',
'page arguments' => array($id_count),
'load arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('view', 'tmgmt_job_item', $id_count),
'file' => $this->entityInfo['admin ui']['file'],
'file path' => $this->entityInfo['admin ui']['file path'],
);
$items[$this->path . '/' . $wildcard . '/view'] = array(
'title' => 'View',
'load arguments' => array($this->entityType),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[$this->path . '/' . $wildcard . '/reject/%'] = array(
'title' => 'Reject',
'page callback' => 'drupal_get_form',
'page arguments' => array('tmgmt_ui_translation_review_form_reject_confirm', $id_count, $id_count + 2),
'load arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('accept', $this->entityType, $id_count),
'type' => MENU_VISIBLE_IN_BREADCRUMB,
'file' => $this->entityInfo['admin ui']['file'],
'file path' => $this->entityInfo['admin ui']['file path'],
);
$items[$this->path . '/' . $wildcard . '/delete'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $id_count, $id_count + 1),
'load arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('delete', $this->entityType, $id_count),
'type' => MENU_CALLBACK,
);
$items[$this->path . '/' . $wildcard . '/accept'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $id_count, $id_count + 1),
'load arguments' => array($this->entityType),
'access callback' => 'entity_access',
'access arguments' => array('accept', $this->entityType, $id_count),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* {@inheritdoc}
*/
public function operationForm($form, &$form_state, $entity, $op) {
$controller = $entity->getSourceController();
$info = $controller->pluginInfo();
switch ($op) {
case 'delete':
$confirm_question = t('Are you sure you want to delete the %plugin translation job item for %label?', array('%plugin' => $info['label'], '%label' => $entity->label()));
return confirm_form($form, $confirm_question, $this->path);
case 'accept':
$confirm_question = t('Are you sure you want to accept the %plugin translation job item for %label?', array('%plugin' => $info['label'], '%label' => $entity->label()));
return confirm_form($form, $confirm_question, $this->path);
}
drupal_not_found();
exit;
}
/**
* {@inheritdoc}
*/
public function applyOperation($op, $entity) {
switch ($op) {
case 'delete':
$entity->delete();
return t('The translation job item %label has been deleted.', array('%label' => $entity->label()));
case 'accept':
$entity->accepted('The translation job item has been accepted by !user.', array('!user' => theme('username', array('account' => $GLOBALS['user']))));
return t('The translation job item %label has been accepted.', array('%label' => $entity->label()));
}
return FALSE;
}
}

View File

@@ -0,0 +1,164 @@
<?php
/**
* @file
* Contains the translator UI controller.
*/
/**
* Entity UI controller for the Translator Entity.
*/
class TMGMTTranslatorUIController extends EntityDefaultUIController {
/**
* {@inheritdoc}
*/
public function hook_menu() {
$items = parent::hook_menu();
$items[$this->path . '/add']['title'] = 'Add Translator';
unset($items[$this->path . '/add']['title callback']);
unset($items[$this->path . '/add']['title arguments']);
if (!empty($this->entityInfo['exportable'])) {
$items[$this->path . '/import']['title'] = 'Import Translator';
unset($items[$this->path . '/import']['title callback']);
unset($items[$this->path . '/import']['title arguments']);
}
return $items;
}
/**
* {@inheritdoc}
*/
public function overviewForm($form, &$form_state) {
$form['translators']['#tree'] = TRUE;
$form['translators']['#theme'] = 'tmgmt_ui_translator_overview_form';
$form['translators']['#entity_info'] = $this->entityInfo;
// Load all translator entities.
$translators = tmgmt_translator_load_multiple(FALSE);
foreach ($translators as $key => $translator) {
$form['translators'][$key] = $this->overviewFormRow(array(), $form_state, $translator, $key);
$form['translators'][$key]['#translator'] = $translator;
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
/**
* {@inheritdoc}
*/
public function overviewFormSubmit($form, &$form_state) {
// Update image effect weights.
if (!empty($form_state['values']['translators'])) {
$translators = tmgmt_translator_load_multiple(array_keys($form_state['values']['translators']));
foreach ($form_state['values']['translators'] as $key => $item) {
if (isset($translators[$key])) {
$translators[$key]->weight = $item['weight'];
entity_save($this->entityType, $translators[$key]);
}
}
}
}
/**
* Helper method for building a row in the overview form.
*/
protected function overviewFormRow($form, &$form_state, $entity, $id) {
$form['#weight'] = isset($form_state['input']['translators']) ? $form_state['input']['translators'][$id]['weight'] : NULL;
$form['label'] = array(
'#theme' => 'tmgmt_ui_translator_overview_item',
'#attached' => array('css' => array(drupal_get_path('module', 'tmgmt_ui') . '/css/tmgmt_ui.admin.css')),
'#label' => $entity->label(),
'#name' => !empty($this->entityInfo['exportable']) ? entity_id($this->entityType, $entity) : FALSE,
'#url' => FALSE,
'#description' => $entity->description,
'#entity_type' => $this->entityType,
);
// Add a row for the exportable status.
if (!empty($this->entityInfo['exportable'])) {
$form['status'] = array(
'#theme' => 'entity_status',
'#status' => $entity->{$this->statusKey},
);
}
$wrapper = entity_metadata_wrapper($this->entityType, $entity);
// Add a column to show the translator plugin via the metadata wrapper.
$form['plugin'] = array(
'#markup' => $wrapper->plugin->label(),
'#status' => $entity->{$this->statusKey},
);
$controller = $entity->getController();
$form['configured'] = array(
'#markup' => $controller->isAvailable($entity) ? t('Yes') : t('No'),
);
$form['weight'] = array(
'#type' => 'weight',
'#delta' => 30,
'#default_value' => $entity->weight,
);
// Add operations depending on the status.
if (entity_has_status($this->entityType, $entity, ENTITY_FIXED)) {
$form['operations']['clone'] = array(
'#type' => 'link',
'#title' => t('clone'),
'#href' => $this->path . '/manage/' . $id . '/clone',
);
}
else {
$form['operations']['edit'] = array(
'#type' => 'link',
'#title' => t('edit'),
'#href' => $this->path . '/manage/' . $id,
);
if (!empty($this->entityInfo['exportable'])) {
$form['operations']['clone'] = array(
'#type' => 'link',
'#title' => t('clone'),
'#href' => $this->path . '/manage/' . $id . '/clone',
);
}
if (empty($this->entityInfo['exportable']) || !entity_has_status($this->entityType, $entity, ENTITY_IN_CODE)) {
$form['operations']['delete'] = array(
'#type' => 'link',
'#title' => t('delete'),
'#href' => $this->path . '/manage/' . $id . '/delete',
'#options' => array('query' => drupal_get_destination()),
);
}
elseif (entity_has_status($this->entityType, $entity, ENTITY_OVERRIDDEN)) {
$form['operations']['revert'] = array(
'#type' => 'link',
'#title' => t('revert'),
'#href' => $this->path . '/manage/' . $id . '/revert',
'#options' => array('query' => drupal_get_destination()),
);
}
else {
$row[] = '';
}
}
if (!empty($this->entityInfo['exportable'])) {
$form['operations']['export'] = array(
'#type' => 'link',
'#title' => t('export'),
'#href' => $this->path . '/manage/' . $id . '/export',
);
}
return $form;
}
/**
* {@inheritdoc}
*/
public function applyOperation($op, $entity) {
if ($op == 'delete' && tmgmt_translator_busy($entity->name)) {
drupal_set_message(t("The translator %translator could not be deleted because it is currently being used by at least one active translation job.", array('%translator' => $entity->label())), 'error');
return FALSE;
}
return parent::applyOperation($op, $entity);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,315 @@
<?php
/**
* @file
* Theme file stub for tmgmt.
*/
/**
* Generic theme function for use with Render API.
*
* Renders the #title and #attributes properties if they are present.
*/
function theme_tmgmt_ui_element($variables) {
$element = $variables['element'];
// Use the #title attribute.
$title = '';
if (!empty($element['#title'])) {
$title = '<h3>' . check_plain($element['#title']) . '</h3>';
}
// Use #attributes to customize a wrapper <div>.
$attributes = '';
if (!empty($element['#attributes'])) {
$attributes = drupal_attributes($element['#attributes']);
}
// Render any child items.
if (!$element['#children']) {
$element['#children'] = drupal_render_children($element);
}
// Build simple output.
$output = "<div{$attributes}>{$title}{$element['#children']}</div>";
return $output;
}
/**
* Gets translation language status.
*
* @param array $variables
* - 'translation_status': A flag that determines the status. Possible values:
* original, missing, outofdate.
* - 'job_item': Current job item entity associated with translation.
*
* @return string
* Icon or a link icon that explains the translation status and possibly
* links to an active translation job.
*/
function theme_tmgmt_ui_translation_language_status_single($variables) {
switch ($variables['translation_status']) {
case 'original':
$label = t('Source language');
$icon_color = 'tmgmt-ui-icon-white';
break;
case 'missing':
$label = t('Not translated');
$icon_color = 'tmgmt-ui-icon-grey';
break;
case 'outofdate':
$label = t('Translation Outdated');
$icon_color = 'tmgmt-ui-icon-orange';
break;
default:
$label = t('Translation up to date');
$icon_color = 'tmgmt-ui-icon-green';
}
// Add classes to show the correct html icon.
$classes = array();
$classes[] = 'tmgmt-ui-icon';
// Icon size 10px square.
$classes[] = 'tmgmt-ui-icon-10';
$classes[] = $icon_color;
// Add necessary css file.
drupal_add_css(drupal_get_path('module', 'tmgmt_ui') . '/css/tmgmt_ui.admin.css');
$status = sprintf('<div class="%s" title="%s"><span></span></div>', implode(' ', $classes), $label);
// If we have an active job item, wrap it in a link.
if (!empty($variables['job_item'])) {
$job_item_wrapper = entity_metadata_wrapper('tmgmt_job_item', $variables['job_item']);
$label = t('Active job item: @state', array('@state' => $job_item_wrapper->state->label()));
$uri = $variables['job_item']->uri();
/** @var TMGMTJob $job */
$job = $variables['job_item']->getJob();
$job_wrapper = entity_metadata_wrapper('tmgmt_job', $job);
switch ($variables['job_item']->state) {
case TMGMT_JOB_ITEM_STATE_ACTIVE:
if ($job->isUnprocessed()) {
$uri = $job->uri();
$label = t('Active job item: @state', array('@state' => $job_wrapper->state->label()));
}
$icon_color = 'tmgmt-ui-icon-blue';
break;
case TMGMT_JOB_ITEM_STATE_REVIEW:
$icon_color = 'tmgmt-ui-icon-yellow';
break;
}
// Add classes to show the correct html icon.
$classes = array();
$classes[] = 'tmgmt-ui-icon';
// Icon size 10px square.
$classes[] = 'tmgmt-ui-icon-10';
$classes[] = $icon_color;
$job_status = sprintf('<div class="%s" title="%s"><span></span></div>', implode(' ', $classes), $label);
$status .= l($job_status, $uri['path'], array(
'query' => array('destination' => current_path()),
'html' => TRUE,
'attributes' => array('title' => $label),
));
}
return $status;
}
/**
* Renders a data item status as an HTML/CSS icon.
*/
function theme_tmgmt_ui_translator_review_form_element_status($variables) {
$classes = array();
$classes[] = 'tmgmt-ui-icon';
$classes[] = 'tmgmt-ui-icon-32'; // Icon size 32px square.
switch ($variables['status']['#value']) {
case TMGMT_DATA_ITEM_STATE_ACCEPTED:
$title = t('Accepted');
// Unicode character U+2611 BALLOT BOX WITH CHECK.
$icon = '&#x2611;';
$classes[] = 'tmgmt-ui-icon-darkgreen';
$classes[] = 'tmgmt-ui-state-accepted';
break;
case TMGMT_DATA_ITEM_STATE_REVIEWED:
$title = t('Reviewed');
// Unicode character U+2611 BALLOT BOX WITH CHECK.
$icon = '&#x2611;';
$classes[] = 'tmgmt-ui-icon-green';
$classes[] = 'tmgmt-ui-state-reviewed';
break;
case TMGMT_DATA_ITEM_STATE_TRANSLATED:
$title = t('Translated');
// Unicode character U+2610 BALLOT BOX.
$icon = '&#x2610;';
$classes[] = 'tmgmt-ui-icon-yellow';
$classes[] = 'tmgmt-ui-state-translated';
break;
case TMGMT_DATA_ITEM_STATE_PENDING:
default:
$title = t('Pending');
// Just an empty icon without a sign.
$icon = '';
$classes[] = 'tmgmt-ui-icon-grey';
$classes[] = 'tmgmt-ui-state-pending';
break;
}
return sprintf('<div class="%s" title="%s"><span>%s</span></div>', implode(' ', $classes), $title, $icon);
}
/**
* Render one single data item as a table row.
*/
function theme_tmgmt_ui_translator_review_form_element($variables) {
$element = $variables['element'];
// Label of all element groups.
if (!isset($element['#top_label'])) {
$element['#top_label'] = array_shift($element['#parent_label']);
}
// Label of the current data item.
if (!isset($element['#leave_label'])) {
$element['#leave_label'] = array_pop($element['#parent_label']);
}
// Do not repeat labels inside the same hierarchy.
if ($element['#top_label'] == $element['#leave_label']) {
$element['#leave_label'] = '';
}
$result = '<tr' . drupal_attributes(array('class' => $element['#zebra'])) . '>';
$row = array();
$leaf_label = '<label>' . $element['#leave_label'] . '</label>';
$leaf_label = '<div class="form-item form-type-label">' . $leaf_label . '</div>';
$row[] = array(
'data' => $leaf_label . '<div class="tmgmt-ui-state">' . drupal_render($element['status']) . '</div>',
'class' => 'tmgmt-ui-data-item-label',
);
$row[] = array(
'data' => drupal_render($element['source']),
'class' => 'tmgmt-ui-data-item-source',
);
$row[] = array(
'data' => drupal_render($element['translation']),
'class' => 'tmgmt-ui-data-item-translation',
);
$row[] = array(
'data' => drupal_render($element['actions']),
'class' => 'tmgmt-ui-data-item-actions',
);
foreach ($row as $cell) {
$result .= _theme_table_cell($cell);
}
$result .= '</tr>';
if (!empty($element['below'])) {
$result .= '<tr' . drupal_attributes(array('class' => $element['#zebra'])) . '>';
$result .= _theme_table_cell(array(
'data' => drupal_render($element['below']),
'colspan' => '4',
));
$result .= '</tr>';
}
return $result;
}
/**
* Renders a table containing a group of data items belonging to the same field.
*/
function theme_tmgmt_ui_translator_review_form($variables) {
$element = $variables['element'];
$result = '';
$labels = '';
$parent_label = '';
$element_groups = array();
$element_group = '';
foreach (element_children($element) as $key) {
// Label of all element groups.
$parent_label = array_shift($element[$key]['#parent_label']);
$element[$key]['#top_label'] = $parent_label;
$element[$key]['#leave_label'] = array_pop($element[$key]['#parent_label']);
// Start a new element group.
if ($labels != $element[$key]['#parent_label']) {
$labels = $element[$key]['#parent_label'];
if (!empty($labels)) {
// Append to previous group to the group collection.
if (!empty($element_group)) {
$element_groups[] = '<tbody>' . $element_group . '</tbody>';
}
// Header row for the current element group.
$cell = array(
// @todo: Deal with right to left languages.
'data' => check_plain(implode(t(' > '), $labels)),
'colspan' => 4,
);
$element_group = '<tr>' . _theme_table_cell($cell, TRUE) . '</tr>';
}
}
$element_group .= drupal_render($element[$key]);
}
// Append the last group to the group collection.
$element_groups[] = '<tbody>' . $element_group . '</tbody>';
// Display the label of all element groups inside a table header.
if (!empty($parent_label)) {
$cell = array(
'data' => $parent_label,
'colspan' => 5,
);
$result = '<thead><tr>' . _theme_table_cell($cell, TRUE) . '</tr></thead>' . implode('', $element_groups);
}
$table = '<table class="tmgmt-ui-review"><colgroup width="100" /><colgroup width="*" span="2" /><colgroup width="100" />' . $result . '</table>';
return '<div id="' . $element['#ajaxid'] . '">' . $table . '</div>';
}
/**
* Adds a description to the translator entity on the entity overview form.
*
* @see theme_entity_ui_overview_item()
*/
function theme_tmgmt_ui_translator_overview_item($variables) {
$output = theme('entity_ui_overview_item', $variables);
if (!empty($variables['description'])) {
$output = '<div class="tmgmt-ui-translator-label-wrapper">' . $output . '<div class="description">' . $variables['description'] . '</div></div>';
}
return $output;
}
/**
* Theme callback for adding the tabledrag to the translator entity overview
* form.
*/
function theme_tmgmt_ui_translator_overview_form($variables) {
$form = $variables['form'];
$colspan = !empty($form['#entity_info']['exportable']) ? 4 : 3;
$rows = array();
$header = array(
t('Label'),
t('Plugin'),
t('Configured'),
t('Status'),
array('data' => t('Operations'), 'colspan' => $colspan),
t('Weight'),
);
foreach (element_children($form) as $key) {
$row = array();
$form[$key]['weight']['#attributes']['class'] = array('tmgmt-ui-translator-weight');
$row[] = drupal_render($form[$key]['label']);
$row[] = drupal_render($form[$key]['plugin']);
$row[] = drupal_render($form[$key]['configured']);
$row[] = drupal_render($form[$key]['status']);
$operations = element_children($form[$key]['operations']);
foreach ($operations as $op) {
$row[] = array('data' => $form[$key]['operations'][$op]);
}
$row[] = drupal_render($form[$key]['weight']);
$rows[] = array('data' => $row, 'class' => array('draggable'));
}
drupal_add_tabledrag('tmgmt-ui-translator-overview', 'order', 'sibling', 'tmgmt-ui-translator-weight');
return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('None.'), 'attributes' => array('id' => 'tmgmt-ui-translator-overview')));
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* @file
* API documentation file for Translation Management API.
*/
/**
* Allows to alter job checkout workflow before the default behavior kicks in.
*
* Note: The default behavior will ignore jobs that have already been checked
* out. Remove jobs from the array to prevent the default behavior for them.
*
* @param $redirects
* List of redirects the user is supposed to be redirected to.
* @param $jobs
* Array with the translation jobs to be checked out.
*/
function hook_tmgmt_ui_job_checkout_before_alter(&$redirects, &$jobs) {
foreach ($jobs as $job) {
// Automatically check out all jobs using the default settings.
$job->translator = 'example';
$job->translator_context = $job->getTranslator()->getController()->defaultCheckoutSettings();
}
}
/**
* Allows to alter job checkout workflow after the default behavior.
*
* @param $redirects
* List of redirects the user is supposed to be redirected to.
* @param $jobs
* Array with the translation jobs to be checked out.
*/
function hook_tmgmt_ui_job_checkout_after_alter(&$redirects, &$jobs) {
// Redirect to custom multi-checkout form if there are multple redirects.
if (count($redirects) > 2) {
$redirects = array('/my/custom/checkout/form/' . implode(',', array_keys($jobs)));
}
}

View File

@@ -0,0 +1,24 @@
name = Translation Management UI
description = User interface.
package = Translation Management
core = 7.x
dependencies[] = tmgmt
dependencies[] = views_bulk_operations
dependencies[] = rules
test_dependencies[] = sharemessage
files[] = includes/tmgmt_ui.controller.job.inc
files[] = includes/tmgmt_ui.controller.job_item.inc
files[] = includes/tmgmt_ui.controller.translator.inc
files[] = includes/tmgmt_ui.cart.inc
files[] = tmgmt_ui.test
files[] = tmgmt_ui_job.test
; Information added by Drupal.org packaging script on 2016-09-21
version = "7.x-1.0-rc2+1-dev"
core = "7.x"
project = "tmgmt"
datestamp = "1474446494"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
<?php
/**
* @file
* Rules integration.
*/
/**
* {@inheritdoc}
*/
function tmgmt_ui_rules_action_info() {
$info['tmgmt_ui_rules_source_add_item_to_cart'] = array(
'label' => t('Add to cart'),
'group' => t('Translation Management'),
'parameter' => array(
'plugin' => array(
'type' => 'token',
'label' => t('Source plugin'),
'description' => t('The source plugin of this item'),
),
'item_type' => array(
'type' => 'token',
'label' => t('Item type'),
'description' => t('The item type'),
),
'item_id' => array(
'type' => 'text',
'label' => t('Item ID'),
'description' => t('ID of the referenced item'),
),
),
);
return $info;
}
/**
* Rules callback to add a job item into the cart.
*/
function tmgmt_ui_rules_source_add_item_to_cart($plugin, $item_type, $item_id) {
tmgmt_ui_cart_get()->addJobItem($plugin, $item_type, $item_id);
}

View File

@@ -0,0 +1,67 @@
<?php
/*
* @file
* Contains default rules.
*/
/**
* Implements hook_default_rules_configuration().
*/
function tmgmt_ui_default_rules_configuration() {
$data = '{ "rules_tmgmt_job_accept_translation" : {
"LABEL" : "Accept Translation",
"PLUGIN" : "rule",
"REQUIRES" : [ "tmgmt" ],
"USES VARIABLES" : { "job" : { "label" : "Job", "type" : "tmgmt_job" } },
"DO" : [ { "tmgmt_rules_job_accept_translation" : { "job" : [ "job" ] } } ]
}
}';
$rule = rules_import($data);
$configs[$rule->name] = $rule;
$data = '{ "rules_tmgmt_job_abort_translation" : {
"LABEL" : "Abort Translation",
"PLUGIN" : "rule",
"REQUIRES" : [ "tmgmt" ],
"USES VARIABLES" : { "job" : { "label" : "Job", "type" : "tmgmt_job" } },
"DO" : [ { "tmgmt_rules_job_abort_translation" : { "job" : [ "job" ] } } ]
}
}';
$rule = rules_import($data);
$configs[$rule->name] = $rule;
$data = '{ "rules_tmgmt_job_delete" : {
"LABEL" : "Delete Job",
"PLUGIN" : "rule",
"REQUIRES" : [ "tmgmt" ],
"USES VARIABLES" : { "job" : { "label" : "Job", "type" : "tmgmt_job" } },
"DO" : [ { "tmgmt_rules_job_delete" : { "job" : [ "job" ] } } ]
}
}';
$rule = rules_import($data);
$configs[$rule->name] = $rule;
$data = '{ "tmgmt_node_ui_tmgmt_nodes_add_items_to_cart" : {
"LABEL" : "Add to cart",
"PLUGIN" : "rule",
"REQUIRES" : [ "tmgmt", "rules", "tmgmt_ui" ],
"USES VARIABLES" : { "nodes" : { "label" : "Nodes", "type" : "list\u003Cnode\u003E" } },
"DO" : [
{ "tmgmt_get_first_from_node_list" : {
"USING" : { "list" : [ "nodes" ] },
"PROVIDE" : { "first_node" : { "first_node" : "Node" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "nodes" ] },
"ITEM" : { "node" : "Node" },
"DO" : [
{ "tmgmt_ui_rules_source_add_item_to_cart" : { "plugin" : "node", "item_type" : "node", "item_id" : "[node:nid]" } }
]
}
}
]
}
}';
$rule = rules_import($data);
$configs[$rule->name] = $rule;
return $configs;
}

View File

@@ -0,0 +1,619 @@
<?php
/*
* @file
* Contains tests for the default user interface.
*/
/**
* Test the UI of tmgmt, for example the checkout form.
*/
class TMGMTUITestCase extends TMGMTBaseTestCase {
static function getInfo() {
return array(
'name' => 'UI tests',
'description' => 'Verifies basic functionality of the user interface',
'group' => 'Translation Management',
);
}
function setUp() {
parent::setup(array('tmgmt_ui'));
parent::createLanguagesLoginTranslator();
}
/**
* Test the page callbacks to create jobs and check them out.
*/
function testCheckoutForm() {
// Add a first item to the job. This will auto-create the job.
$job = tmgmt_job_match_item('en', '');
$job->addItem('test_source', 'test', 1);
// Go to checkout form.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->drupalGet(reset($redirects));
// Check checkout form.
$this->assertText('test_source:test:1');
// Add two more job items.
$job->addItem('test_source', 'test', 2);
$job->addItem('test_source', 'test', 3);
// Go to checkout form.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->drupalGet(reset($redirects));
// Check checkout form.
$this->assertText('test_source:test:1');
$this->assertText('test_source:test:2');
$this->assertText('test_source:test:3');
// @todo: Test ajax functionality.
// Attempt to translate into greek.
$edit = array(
'target_language' => 'el',
'settings[action]' => 'translate',
);
$this->drupalPost(NULL, $edit, t('Submit to translator'));
$this->assertText(t('@translator can not translate from @source to @target.', array('@translator' => 'Test translator (auto created)', '@source' => 'English', '@target' => 'Greek')));
// Job still needs to be in state new.
$job = entity_load_unchanged('tmgmt_job', $job->tjid);
$this->assertTrue($job->isUnprocessed());
$edit = array(
'target_language' => 'es',
'settings[action]' => 'translate',
);
$this->drupalPost(NULL, $edit, t('Submit to translator'));
// Job needs to be in state active.
$job = entity_load_unchanged('tmgmt_job', $job->tjid);
$this->assertTrue($job->isActive());
foreach ($job->getItems() as $job_item) {
/* @var $job_item TMGMTJobItem */
$this->assertTrue($job_item->isNeedsReview());
}
$this->assertText(t('Test translation created'));
$this->assertNoText(t('Test translator called'));
// Test redirection.
$this->assertText(t('Job overview'));
// Another job.
$previous_tjid = $job->tjid;
$job = tmgmt_job_match_item('en', '');
$job->addItem('test_source', 'test', 1);
$this->assertNotEqual($job->tjid, $previous_tjid);
// Go to checkout form.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->drupalGet(reset($redirects));
// Check checkout form.
$this->assertText('You can provide a label for this job in order to identify it easily later on.');
$this->assertText('test_source:test:1');
$edit = array(
'target_language' => 'es',
'settings[action]' => 'submit',
);
$this->drupalPost(NULL, $edit, t('Submit to translator'));
$this->assertText(t('Test submit'));
$job = entity_load_unchanged('tmgmt_job', $job->tjid);
$this->assertTrue($job->isActive());
// Another job.
$job = tmgmt_job_match_item('en', 'es');
$job->addItem('test_source', 'test', 1);
// Go to checkout form.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->drupalGet(reset($redirects));
// Check checkout form.
$this->assertText('You can provide a label for this job in order to identify it easily later on.');
$this->assertText('test_source:test:1');
$edit = array(
'settings[action]' => 'reject',
);
$this->drupalPost(NULL, $edit, t('Submit to translator'));
$this->assertText(t('This is not supported'));
$job = entity_load_unchanged('tmgmt_job', $job->tjid);
$this->assertTrue($job->isRejected());
// Check displayed job messages.
$args = array('@view' => 'view-tmgmt-ui-job-messages');
$this->assertEqual(2, count($this->xpath('//div[contains(@class, @view)]//tbody/tr', $args)));
// Check that the author for each is the current user.
$message_authors = $this->xpath('////div[contains(@class, @view)]//td[contains(@class, @field)]/span', $args + array('@field' => 'views-field-name'));
$this->assertEqual(2, count($message_authors));
foreach ($message_authors as $message_author) {
$this->assertEqual((string)$message_author, $this->translator_user->name);
}
// Make sure that rejected jobs can be re-submitted.
$this->assertTrue($job->isSubmittable());
$edit = array(
'settings[action]' => 'translate',
);
$this->drupalPost(NULL, $edit, t('Submit to translator'));
$this->assertText(t('Test translation created'));
// Another job.
$job = tmgmt_job_match_item('en', 'es');
$job->addItem('test_source', 'test', 1);
// Go to checkout form.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->drupalGet(reset($redirects));
// Check checkout form.
$this->assertText('You can provide a label for this job in order to identify it easily later on.');
$this->assertText('test_source:test:1');
$edit = array(
'settings[action]' => 'fail',
);
$this->drupalPost(NULL, $edit, t('Submit to translator'));
$this->assertText(t('Service not reachable'));
$job = entity_load_unchanged('tmgmt_job', $job->tjid);
$this->assertTrue($job->isUnprocessed());
// Verify that we are still on the form.
$this->assertText('You can provide a label for this job in order to identify it easily later on.');
// Another job.
$job = tmgmt_job_match_item('en', 'es');
$job->addItem('test_source', 'test', 1);
// Go to checkout form.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->drupalGet(reset($redirects));
// Check checkout form.
$this->assertText('You can provide a label for this job in order to identify it easily later on.');
$this->assertText('test_source:test:1');
$edit = array(
'settings[action]' => 'not_translatable',
);
$this->drupalPost(NULL, $edit, t('Submit to translator'));
// @todo Update to correct failure message.
$this->assertText(t('Fail'));
$job = entity_load_unchanged('tmgmt_job', $job->tjid);
$this->assertTrue($job->isUnprocessed());
// Test default settings.
$this->default_translator->settings['action'] = 'reject';
$this->default_translator->save();
$job = tmgmt_job_match_item('en', 'es');
$job->addItem('test_source', 'test', 1);
// Go to checkout form.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->drupalGet(reset($redirects));
// Check checkout form.
$this->assertText('You can provide a label for this job in order to identify it easily later on.');
$this->assertText('test_source:test:1');
// The action should now default to reject.
$this->drupalPost(NULL, array(), t('Submit to translator'));
$this->assertText(t('This is not supported.'));
$job = entity_load_unchanged('tmgmt_job', $job->tjid);
$this->assertTrue($job->isRejected());
}
/**
* Tests the tmgmt_ui_job_checkout() function.
*/
function testCheckoutFunction() {
$job = $this->createJob();
// Check out a job when only the test translator is available. That one has
// settings, so a checkout is necessary.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$uri = $job->uri();
$this->assertEqual($uri['path'], $redirects[0]);
$this->assertTrue($job->isUnprocessed());
$job->delete();
// Hide settings on the test translator.
$default_translator = tmgmt_translator_load('test_translator');
$default_translator->settings = array(
'expose_settings' => FALSE,
);
$job = $this->createJob();
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->assertFalse($redirects);
$this->assertTrue($job->isActive());
// A job without target language needs to be checked out.
$job = $this->createJob('en', '');
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$uri = $job->uri();
$this->assertEqual($uri['path'], $redirects[0]);
$this->assertTrue($job->isUnprocessed());
// Create a second file translator. This should check
// out immediately.
$job = $this->createJob();
$second_translator = $this->createTranslator();
$second_translator->settings = array(
'expose_settings' => FALSE,
);
$second_translator->save();
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$uri = $job->uri();
$this->assertEqual($uri['path'], $redirects[0]);
$this->assertTrue($job->isUnprocessed());
}
/**
* Tests of the job item review process.
*/
public function testReview() {
$job = $this->createJob();
$job->translator = $this->default_translator->name;
$job->settings = array();
$job->save();
$item = $job->addItem('test_source', 'test', 1);
$data = tmgmt_flatten_data($item->getData());
$keys = array_keys($data);
$key = $keys[0];
$this->drupalGet('admin/tmgmt/items/' . $item->tjiid);
// Testing the result of the
// TMGMTTranslatorUIControllerInterface::reviewDataItemElement()
$this->assertText(t('Testing output of review data item element @key from the testing translator.', array('@key' => $key)));
// Test the review tool source textarea.
$this->assertFieldByName('dummy|deep_nesting[source]', $data[$key]['#text']);
// Save translation.
$this->drupalPost(NULL, array('dummy|deep_nesting[translation]' => $data[$key]['#text'] . 'translated'), t('Save'));
$this->drupalGet('admin/tmgmt/items/' . $item->tjiid);
// Check if translation has been saved.
$this->assertFieldByName('dummy|deep_nesting[translation]', $data[$key]['#text'] . 'translated');
}
/**
* Tests the UI of suggestions.
*/
public function testSuggestions() {
// Prepare a job and a node for testing.
$job = $this->createJob();
$job->addItem('test_source', 'test', 1);
$job->addItem('test_source', 'test', 7);
// Go to checkout form.
$redirects = tmgmt_ui_job_checkout_multiple(array($job));
$this->drupalGet(reset($redirects));
$this->assertRaw('20');
// Load all suggestions.
$commands = $this->drupalPostAJAX(NULL, array(), array('op' => t('Load suggestions')));
$this->assertEqual(count($commands), 4, 'Found 4 commands in AJAX-Request.');
// Check each command for success.
foreach ($commands as $command) {
// No checks against the settings because we not use ajax to save.
if ($command['command'] == 'settings') {
}
// Other commands must be from type "insert".
else if ($command['command'] == 'insert') {
// This should be the tableselect javascript file for the header.
if (($command['method'] == 'prepend') && ($command['selector'] == 'head')) {
$this->assertTrue(substr_count($command['data'], 'misc/tableselect.js'), 'Javascript for Tableselect found.');
}
// Check for the main content, the tableselect with the suggestions.
else if (($command['method'] == NULL) && ($command['selector'] == NULL)) {
$this->assertTrue(substr_count($command['data'], '</th>') == 5, 'Found five table header.');
$this->assertTrue(substr_count($command['data'], '</tr>') == 3, 'Found two suggestion and one table header.');
$this->assertTrue(substr_count($command['data'], '<td>11</td>') == 2, 'Found 10 words to translate per suggestion.');
$this->assertTrue(substr_count($command['data'], 'value="Add suggestions"'), 'Found add button.');
}
// Nothing to prepend...
else if (($command['method'] == 'prepend') && ($command['selector'] == NULL)) {
$this->assertTrue(empty($command['data']), 'No content will be prepended.');
}
else {
$this->fail('Unknown method/selector combination.');
debug($command);
}
}
else {
$this->fail('Unknown command.');
debug($command);
}
}
$this->assertText('test_source:test_suggestion:1');
$this->assertText('test_source:test_suggestion:7');
$this->assertText('Test suggestion for test source 1');
$this->assertText('Test suggestion for test source 7');
// Add the second suggestion.
$edit = array('suggestions_table[2]' => TRUE);
$this->drupalPost(NULL, $edit, t('Add suggestions'));
// Total word count should now include the added job.
$this->assertRaw('31');
// The suggestion for 7 was added, so there should now be a suggestion
// or the suggestion instead.
$this->assertNoText('Test suggestion for test source 7');
$this->assertText('test_source:test_suggestion_suggestion:7');
}
/**
* Test the process of aborting and resubmitting the job.
*/
function testAbortJob() {
$job = $this->createJob();
$job->addItem('test_source', 'test', 1);
$job->addItem('test_source', 'test', 2);
$job->addItem('test_source', 'test', 3);
$edit = array(
'target_language' => 'es',
'settings[action]' => 'translate',
);
$this->drupalPost('admin/tmgmt/jobs/' . $job->tjid, $edit, t('Submit to translator'));
// Abort job.
$this->drupalPost('admin/tmgmt/jobs/' . $job->tjid, array(), t('Abort job'));
$this->drupalPost(NULL, array(), t('Confirm'));
// Reload job and check its state.
entity_get_controller('tmgmt_job')->resetCache();
/** @var TMGMTJob $job */
$job = tmgmt_job_load($job->tjid);
$this->assertTrue($job->isAborted());
foreach ($job->getItems() as $item) {
$this->assertTrue($item->isAborted());
}
// Resubmit the job.
$this->drupalPost('admin/tmgmt/jobs/' . $job->tjid, array(), t('Resubmit'));
$this->drupalPost(NULL, array(), t('Confirm'));
// Test for the log message.
$this->assertRaw(t('This job is a duplicate of the previously aborted job <a href="@url">#@id</a>',
array('@url' => url('admin/tmgmt/jobs/' . $job->tjid), '@id' => $job->tjid)));
// Load the resubmitted job and check for its status and values.
$url_parts = explode('/', $this->getUrl());
$resubmitted_job = tmgmt_job_load(array_pop($url_parts));
$this->assertTrue($resubmitted_job->isUnprocessed());
$this->assertEqual($job->translator, $resubmitted_job->translator);
$this->assertEqual($job->source_language, $resubmitted_job->source_language);
$this->assertEqual($job->target_language, $resubmitted_job->target_language);
$this->assertEqual($job->settings, $resubmitted_job->settings);
// Test if job items were duplicated correctly.
/** @var TMGMTJobItem $item */
foreach ($job->getItems() as $item) {
// We match job items based on "id #" string. This is not that straight
// forward, but it works as the test source text is generated as follows:
// Text for job item with type #type and id #id.
$_items = $resubmitted_job->getItems(array('data' => array('value' => '%id ' . $item->item_id . '%', 'operator' => 'LIKE')));
$_item = reset($_items);
/** @var TMGMTJobItem $_item */
$this->assertNotEqual($_item->tjid, $item->tjid);
$this->assertEqual($_item->plugin, $item->plugin);
$this->assertEqual($_item->item_id, $item->item_id);
$this->assertEqual($_item->item_type, $item->item_type);
// Make sure counts have been recalculated.
$this->assertTrue($_item->word_count > 0);
$this->assertTrue($_item->count_pending > 0);
$this->assertEqual($_item->count_translated, 0);
$this->assertEqual($_item->count_accepted, 0);
$this->assertEqual($_item->count_reviewed, 0);
}
// Navigate back to the aborted job and check for the log message.
$this->drupalGet('admin/tmgmt/jobs/' . $job->tjid);
$this->assertRaw(t('Job has been duplicated as a new job <a href="@url">#@id</a>.',
array('@url' => url('admin/tmgmt/jobs/' . $resubmitted_job->tjid), '@id' => $resubmitted_job->tjid)));
$this->drupalGet('admin/tmgmt/jobs');
$elements = $this->xpath('//table[contains(@class, @view)]//td[contains(., @text)]',
array('@view' => 'views-table', '@text' => t('N/A')));
$status = $elements[0];
$this->assertEqual(trim((string)$status), t('N/A'));
}
/**
* Test the cart functionality.
*/
function testCart() {
$this->setEnvironment('fr');
$job_items = array();
// Create a few job items and add them to the cart.
for ($i = 1; $i < 6; $i++) {
$job_item = tmgmt_job_item_create('test_source', 'test', $i);
$job_item->save();
$job_items[$i] = $job_item;
}
$this->loginAsTranslator();
foreach ($job_items as $job_item) {
$this->drupalGet('tmgmt-add-to-cart/' . $job_item->tjiid);
}
// Check if the items are displayed in the cart.
$this->drupalGet('admin/tmgmt/cart');
foreach ($job_items as $job_item) {
$this->assertText($job_item->label());
}
// Test the remove items from cart functionality.
$this->drupalPost(NULL, array('items[1]' => TRUE, 'items[4]' => TRUE), t('Remove selected'));
$this->assertText($job_items[2]->label());
$this->assertText($job_items[3]->label());
$this->assertText($job_items[5]->label());
$this->assertNoText($job_items[1]->label());
$this->assertNoText($job_items[4]->label());
$this->assertText(t('Job items were removed from the cart.'));
// Test that removed job items from cart were deleted as well.
$existing_items = tmgmt_job_item_load_multiple(NULL);
$this->assertTrue(!isset($existing_items[$job_items[1]->tjiid]));
$this->assertTrue(!isset($existing_items[$job_items[4]->tjiid]));
$this->drupalPost(NULL, array(), t('Empty cart'));
$this->assertNoText($job_items[2]->label());
$this->assertNoText($job_items[3]->label());
$this->assertNoText($job_items[5]->label());
$this->assertText(t('All job items were removed from the cart.'));
// No remaining job items.
$existing_items = tmgmt_job_item_load_multiple(NULL);
$this->assertTrue(empty($existing_items));
$language_sequence = array('en', 'en', 'fr', 'fr', 'de', 'de');
for ($i = 1; $i < 7; $i++) {
$job_item = tmgmt_job_item_create('test_source', 'test', $i);
$job_item->save();
$job_items[$i] = $job_item;
$languages[$job_items[$i]->tjiid] = $language_sequence[$i - 1];
}
variable_set('tmgmt_test_source_languages', $languages);
foreach ($job_items as $job_item) {
$this->drupalGet('tmgmt-add-to-cart/' . $job_item->tjiid);
}
$this->drupalPost('admin/tmgmt/cart', array(
'items[' . $job_items[1]->tjiid . ']' => TRUE,
'items[' . $job_items[2]->tjiid . ']' => TRUE,
'items[' . $job_items[3]->tjiid . ']' => TRUE,
'items[' . $job_items[4]->tjiid . ']' => TRUE,
'items[' . $job_items[5]->tjiid . ']' => TRUE,
'target_language[]' => array('en', 'de'),
), t('Request translation'));
$this->assertText(t('@count jobs need to be checked out.', array('@count' => 4)));
// We should have four jobs with following language combinations:
// [fr, fr] => [en]
// [de] => [en]
// [en, en] => [de]
// [fr, fr] => [de]
$jobs = entity_load('tmgmt_job', FALSE, array('source_language' => 'fr', 'target_language' => 'en'));
$job = reset($jobs);
$this->assertEqual(count($job->getItems()), 2);
$jobs = entity_load('tmgmt_job', FALSE, array('source_language' => 'de', 'target_language' => 'en'));
$job = reset($jobs);
$this->assertEqual(count($job->getItems()), 1);
$jobs = entity_load('tmgmt_job', FALSE, array('source_language' => 'en', 'target_language' => 'de'));
$job = reset($jobs);
$this->assertEqual(count($job->getItems()), 2);
$jobs = entity_load('tmgmt_job', FALSE, array('source_language' => 'fr', 'target_language' => 'de'));
$job = reset($jobs);
$this->assertEqual(count($job->getItems()), 2);
$this->drupalGet('admin/tmgmt/cart');
// Both fr and one de items must be gone.
$this->assertNoText($job_items[1]->label());
$this->assertNoText($job_items[2]->label());
$this->assertNoText($job_items[3]->label());
$this->assertNoText($job_items[4]->label());
$this->assertNoText($job_items[5]->label());
// One de item is in the cart as it was not selected for checkout.
$this->assertText($job_items[6]->label());
}
/**
* Test if the source is able to pull content in requested language.
*/
function testCartEnforceSourceLanguage() {
$this->setEnvironment('sk');
$this->setEnvironment('cs');
module_enable(array('tmgmt_node'));
$content_type = $this->drupalCreateContentType();
$node_sk = $this->drupalCreateNode(array(
'title' => $this->randomName(),
'language' => 'sk',
'body' => array('sk' => array(array($this->randomName()))),
'type' => $content_type->type,
));
$this->drupalCreateNode(array(
'title' => $this->randomName(),
'language' => 'en',
'tnid' => $node_sk->nid,
'body' => array('en' => array(array($this->randomName()))),
'type' => $content_type->type,
));
$node_cs = $this->drupalCreateNode(array(
'title' => $this->randomName(),
'language' => 'cs',
'body' => array('cs' => array(array($this->randomName()))),
'type' => $content_type->type,
));
$this->loginAsTranslator();
$job_item_sk = tmgmt_job_item_create('node', 'node', $node_sk->nid);
$job_item_sk->save();
$this->drupalGet('tmgmt-add-to-cart/' . $job_item_sk->tjiid);
$job_items_data[$job_item_sk->item_id] = $job_item_sk->item_type;
$job_item_cs = tmgmt_job_item_create('node', 'node', $node_cs->nid);
$job_item_cs->save();
$this->drupalGet('tmgmt-add-to-cart/' . $job_item_cs->tjiid);
$job_items_data[$job_item_cs->item_id] = $job_item_cs->item_type;
$this->drupalPost('admin/tmgmt/cart', array(
'enforced_source_language' => TRUE,
'source_language' => 'en',
'items[' . $job_item_cs->tjiid .']' => TRUE,
'items[' . $job_item_sk->tjiid .']' => TRUE,
'target_language[]' => array('es')
), t('Request translation'));
$this->assertText(t('One job needs to be checked out.'));
$this->assertRaw(t('One item skipped. @language translation unavailable.', array('@language' => 'English')));
$args = explode('/', $this->getUrl());
$tjid = array_pop($args);
$this->drupalPost(NULL, array(), t('Submit to translator'));
// We cannot test for the item data as items without a job are not able to
// get the data in case the source language is overridden. Therefore only
// testing for item_id and item_type values.
foreach (tmgmt_job_load($tjid)->getItems() as $job_item) {
$this->assertEqual($job_items_data[$job_item->item_id], $job_item->item_type);
}
$this->drupalGet('admin/tmgmt/cart');
$this->assertText($node_cs->title);
$this->assertNoText($node_sk->title);
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* @file
* Contains TMGMTSharemessageIntegrationTestCase.
*/
/**
* Tests integration with the sharemessage module.
*/
class TMGMTSharemessageIntegrationTestCase extends TMGMTBaseTestCase {
static function getInfo() {
return array(
'name' => 'Sharemessage translation',
'description' => 'Checks entity translation for an entity without a URL',
'group' => 'Translation Management',
'dependencies' => array('sharemessage', 'entity_translation'),
);
}
function setUp() {
// Sharemessage is an entity that doesn't provide entity URLs, necessary for
// testReviewForm().
$modules = array(
'tmgmt_ui',
'tmgmt_entity_ui',
'tmgmt_file',
'image',
'block',
'sharemessage',
);
parent::setUp($modules);
parent::createLanguagesLoginTranslator(array(
'administer sharemessage entities',
'view sharemessage entities',
'administer entity translation',
'translate any entity',
));
}
/**
* Test whether the review form is accessible.
*/
function testReviewForm() {
// First create a sharemessage.
$sharemessage = array(
'label' => 'ShareMessage Test Label',
'name' => 'sharemessage_test_label',
'sharemessage_title[en][0][value]' => 'Test title',
'sharemessage_long[en][0][value]' => 'Test description long',
'block' => 1,
);
$this->drupalPost('admin/config/services/sharemessage/add', $sharemessage, t('Save share message'));
$this->assertText(t('Message @label saved.', array('@label' => $sharemessage['label'])));
// Enable translation for sharemessage entities.
$edit = array(
'entity_translation_entity_types[sharemessage]' => TRUE,
);
$this->drupalPost('admin/config/regional/entity_translation', $edit, t('Save configuration'));
// Create a corresponding translation job via the UI (spanish translation).
$this->drupalPost('admin/config/services/sharemessage/manage/' . $sharemessage['name'] . '/translate', array('languages[es]' => TRUE), t('Request translation'));
// Submit the job to the file translator.
$this->drupalPost('admin/tmgmt/jobs/1', array('translator' => 'file'), t('Submit to translator'));
// Make sure the job status is on "In progress" after submission.
$this->drupalGet('admin/config/services/sharemessage/manage/' . $sharemessage['name'] . '/translate');
$this->assertText(t('In progress'));
// Check that the entity label is there even though there is no entity uri
// available.
$this->drupalGet('admin/tmgmt/items/1');
$this->assertText('ShareMessage');
}
}

View File

@@ -0,0 +1,115 @@
<?php
$view = new view();
$view->name = 'tmgmt_ui_job_item_messages';
$view->description = 'Lists the messages that are related to a job item.';
$view->tag = 'Translation Management';
$view->base_table = 'tmgmt_message';
$view->human_name = 'Translation Job Item Messages';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Messages';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['grouping'] = '';
$handler->display->display_options['style_options']['columns'] = array(
'created' => 'created',
'message' => 'message',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'created' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'message' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['content'] = 'There are no messages attached to this translation job item.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Relationship: Translation Management Message: Uid */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'tmgmt_message';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Field: Created */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'tmgmt_message';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['ui_name'] = 'Created';
$handler->display->display_options['fields']['created']['date_format'] = 'short';
/* Field: Message */
$handler->display->display_options['fields']['message']['id'] = 'message';
$handler->display->display_options['fields']['message']['table'] = 'tmgmt_message';
$handler->display->display_options['fields']['message']['field'] = 'message';
$handler->display->display_options['fields']['message']['ui_name'] = 'Message';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
/* Sort criterion: Created */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'tmgmt_message';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['ui_name'] = 'Created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Job Item */
$handler->display->display_options['arguments']['tjiid']['id'] = 'tjiid';
$handler->display->display_options['arguments']['tjiid']['table'] = 'tmgmt_message';
$handler->display->display_options['arguments']['tjiid']['field'] = 'tjiid';
$handler->display->display_options['arguments']['tjiid']['ui_name'] = 'Job Item';
$handler->display->display_options['arguments']['tjiid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['tjiid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['tjiid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['tjiid']['summary_options']['items_per_page'] = '25';
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$translatables['tmgmt_ui_job_item_messages'] = array(
t('Master'),
t('Messages'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Items per page'),
t('- All -'),
t('Offset'),
t('« first'),
t(' previous'),
t('next '),
t('last »'),
t('There are no messages attached to this translation job item.'),
t('User'),
t('Created'),
t('Message'),
t('Name'),
t('All'),
t('Block'),
);

View File

@@ -0,0 +1,167 @@
<?php
$view = new view();
$view->name = 'tmgmt_ui_job_items';
$view->description = 'Displays all job items that belong to a job.';
$view->tag = 'Translation Management';
$view->base_table = 'tmgmt_job_item';
$view->human_name = 'Translation Job Items';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Job Items';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'label' => 'label',
'plugin' => 'plugin',
'state' => 'state',
'changed' => 'changed',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'label' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'plugin' => array(
'sortable' => 1,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'state' => array(
'sortable' => 1,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'changed' => array(
'sortable' => 1,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['content'] = 'There are no items attached to this translation job.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Field: Label */
$handler->display->display_options['fields']['label']['id'] = 'label';
$handler->display->display_options['fields']['label']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['label']['field'] = 'label';
$handler->display->display_options['fields']['label']['ui_name'] = 'Label';
/* Field: Translation Management Job Item: Type */
$handler->display->display_options['fields']['type']['id'] = 'type';
$handler->display->display_options['fields']['type']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['type']['field'] = 'type';
/* Field: State */
$handler->display->display_options['fields']['state']['id'] = 'state';
$handler->display->display_options['fields']['state']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['state']['field'] = 'state';
$handler->display->display_options['fields']['state']['ui_name'] = 'State';
/* Field: Progress */
$handler->display->display_options['fields']['progress']['id'] = 'progress';
$handler->display->display_options['fields']['progress']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['progress']['field'] = 'progress';
$handler->display->display_options['fields']['progress']['ui_name'] = 'Progress';
/* Field: Translation Management Job Item: Word count */
$handler->display->display_options['fields']['word_count_1']['id'] = 'word_count_1';
$handler->display->display_options['fields']['word_count_1']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['word_count_1']['field'] = 'word_count';
/* Field: Changed */
$handler->display->display_options['fields']['changed']['id'] = 'changed';
$handler->display->display_options['fields']['changed']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['changed']['field'] = 'changed';
$handler->display->display_options['fields']['changed']['ui_name'] = 'Changed';
$handler->display->display_options['fields']['changed']['date_format'] = 'short';
/* Field: Operations */
$handler->display->display_options['fields']['operations']['id'] = 'operations';
$handler->display->display_options['fields']['operations']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['operations']['field'] = 'operations';
$handler->display->display_options['fields']['operations']['ui_name'] = 'Operations';
$handler->display->display_options['fields']['operations']['element_label_colon'] = FALSE;
/* Contextual filter: Job Item */
$handler->display->display_options['arguments']['tjid']['id'] = 'tjid';
$handler->display->display_options['arguments']['tjid']['table'] = 'tmgmt_job_item';
$handler->display->display_options['arguments']['tjid']['field'] = 'tjid';
$handler->display->display_options['arguments']['tjid']['ui_name'] = 'Job Item';
$handler->display->display_options['arguments']['tjid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['tjid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['tjid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['tjid']['summary_options']['items_per_page'] = '25';
/* Display: Submit list */
$handler = $view->new_display('block', 'Submit list', 'submit');
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Label */
$handler->display->display_options['fields']['label']['id'] = 'label';
$handler->display->display_options['fields']['label']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['label']['field'] = 'label';
$handler->display->display_options['fields']['label']['ui_name'] = 'Label';
/* Field: Translation Management Job Item: Type */
$handler->display->display_options['fields']['type']['id'] = 'type';
$handler->display->display_options['fields']['type']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['type']['field'] = 'type';
/* Field: Translation Management Job Item: Word count */
$handler->display->display_options['fields']['word_count_1']['id'] = 'word_count_1';
$handler->display->display_options['fields']['word_count_1']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['word_count_1']['field'] = 'word_count';
/* Field: Operations */
$handler->display->display_options['fields']['operations']['id'] = 'operations';
$handler->display->display_options['fields']['operations']['table'] = 'tmgmt_job_item';
$handler->display->display_options['fields']['operations']['field'] = 'operations';
$handler->display->display_options['fields']['operations']['ui_name'] = 'Operations';
$handler->display->display_options['fields']['operations']['element_label_colon'] = FALSE;
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
$translatables['tmgmt_ui_job_items'] = array(
t('Master'),
t('Job Items'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Items per page'),
t('- All -'),
t('Offset'),
t('« first'),
t(' previous'),
t('next '),
t('last »'),
t('There are no items attached to this translation job.'),
t('Label'),
t('Type'),
t('State'),
t('Progress'),
t('Word count'),
t('.'),
t(','),
t('Changed'),
t('Operations'),
t('All'),
t('Submit list'),
t('Block'),
);

View File

@@ -0,0 +1,143 @@
<?php
$view = new view();
$view->name = 'tmgmt_ui_job_messages';
$view->description = 'Lists the messages that are related to a job.';
$view->tag = 'Translation Management';
$view->base_table = 'tmgmt_message';
$view->human_name = 'Translation Job Messages';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Messages';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['grouping'] = '';
$handler->display->display_options['style_options']['columns'] = array(
'created' => 'created',
'message' => 'message',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'created' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'message' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['content'] = 'There are no messages attached to this translation job.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Relationship: Job Item */
$handler->display->display_options['relationships']['tjiid']['id'] = 'tjiid';
$handler->display->display_options['relationships']['tjiid']['table'] = 'tmgmt_message';
$handler->display->display_options['relationships']['tjiid']['field'] = 'tjiid';
$handler->display->display_options['relationships']['tjiid']['ui_name'] = 'Job Item';
$handler->display->display_options['relationships']['tjiid']['label'] = 'Job Item';
/* Relationship: Translation Management Message: Uid */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'tmgmt_message';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Field: Created */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'tmgmt_message';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['ui_name'] = 'Created';
$handler->display->display_options['fields']['created']['date_format'] = 'short';
/* Field: Message */
$handler->display->display_options['fields']['message']['id'] = 'message';
$handler->display->display_options['fields']['message']['table'] = 'tmgmt_message';
$handler->display->display_options['fields']['message']['field'] = 'message';
$handler->display->display_options['fields']['message']['ui_name'] = 'Message';
/* Field: Job Item */
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_tmgmt_job_item';
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['relationship'] = 'tjiid';
$handler->display->display_options['fields']['rendered_entity']['ui_name'] = 'Job Item';
$handler->display->display_options['fields']['rendered_entity']['label'] = 'Related item';
$handler->display->display_options['fields']['rendered_entity']['empty'] = 'None';
$handler->display->display_options['fields']['rendered_entity']['hide_alter_empty'] = FALSE;
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
/* Sort criterion: Created */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'tmgmt_message';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['ui_name'] = 'Created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Job */
$handler->display->display_options['arguments']['tjid']['id'] = 'tjid';
$handler->display->display_options['arguments']['tjid']['table'] = 'tmgmt_message';
$handler->display->display_options['arguments']['tjid']['field'] = 'tjid';
$handler->display->display_options['arguments']['tjid']['ui_name'] = 'Job';
$handler->display->display_options['arguments']['tjid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['tjid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['tjid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['tjid']['summary_options']['items_per_page'] = '25';
/* Contextual filter: Job Item */
$handler->display->display_options['arguments']['tjiid']['id'] = 'tjiid';
$handler->display->display_options['arguments']['tjiid']['table'] = 'tmgmt_message';
$handler->display->display_options['arguments']['tjiid']['field'] = 'tjiid';
$handler->display->display_options['arguments']['tjiid']['ui_name'] = 'Job Item';
$handler->display->display_options['arguments']['tjiid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['tjiid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['tjiid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['tjiid']['summary_options']['items_per_page'] = '25';
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$translatables['tmgmt_ui_job_messages'] = array(
t('Master'),
t('Messages'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Items per page'),
t('- All -'),
t('Offset'),
t('« first'),
t(' previous'),
t('next '),
t('last »'),
t('There are no messages attached to this translation job.'),
t('Job Item'),
t('User'),
t('Created'),
t('Message'),
t('Related item'),
t('None'),
t('Name'),
t('All'),
t('Block'),
);

View File

@@ -0,0 +1,321 @@
<?php
$view = new view();
$view->name = 'tmgmt_ui_job_overview';
$view->description = 'Gives a bulk operation overview of translation jobs in the system.';
$view->tag = 'Translation Management';
$view->base_table = 'tmgmt_job';
$view->human_name = 'Translation Job Overview';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Job overview';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'tmgmt_views_job_access';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'views_bulk_operations' => 'views_bulk_operations',
'label' => 'label',
'source_language' => 'source_language',
'target_language' => 'target_language',
'label_1' => 'label_1',
'state' => 'state',
'created' => 'created',
'changed' => 'changed',
'operations' => 'operations',
);
$handler->display->display_options['style_options']['default'] = 'changed';
$handler->display->display_options['style_options']['info'] = array(
'views_bulk_operations' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'label' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'source_language' => array(
'sortable' => 1,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'target_language' => array(
'sortable' => 1,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'label_1' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'state' => array(
'sortable' => 1,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'created' => array(
'sortable' => 1,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'changed' => array(
'sortable' => 1,
'default_sort_order' => 'desc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'operations' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['content'] = 'There are no translation jobs that match the specified filter criteria.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Relationship: Translator */
$handler->display->display_options['relationships']['translator']['id'] = 'translator';
$handler->display->display_options['relationships']['translator']['table'] = 'tmgmt_job';
$handler->display->display_options['relationships']['translator']['field'] = 'translator';
$handler->display->display_options['relationships']['translator']['ui_name'] = 'Translator';
$handler->display->display_options['relationships']['translator']['label'] = 'Translator';
/* Field: Bulk operations */
$handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations';
$handler->display->display_options['fields']['views_bulk_operations']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations';
$handler->display->display_options['fields']['views_bulk_operations']['ui_name'] = 'Bulk operations';
$handler->display->display_options['fields']['views_bulk_operations']['label'] = '';
$handler->display->display_options['fields']['views_bulk_operations']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '0';
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
'rules_component::rules_tmgmt_job_accept_translation' => array(
'selected' => 1,
'postpone_processing' => 0,
'skip_confirmation' => 1,
'override_label' => 0,
'label' => '',
),
'rules_component::rules_tmgmt_job_abort_translation' => array(
'selected' => 1,
'postpone_processing' => 0,
'skip_confirmation' => 1,
'override_label' => 0,
'label' => '',
),
'action::views_bulk_operations_delete_item' => array(
'selected' => 0,
'postpone_processing' => 0,
'skip_confirmation' => 0,
'override_label' => 1,
'label' => 'Delete Job',
),
'rules_component::rules_tmgmt_job_delete' => array(
'selected' => 1,
'postpone_processing' => 0,
'skip_confirmation' => 0,
'override_label' => 0,
'label' => '',
),
'action::views_bulk_operations_script_action' => array(
'selected' => 0,
'postpone_processing' => 0,
'skip_confirmation' => 0,
'override_label' => 0,
'label' => '',
),
'action::views_bulk_operations_modify_action' => array(
'selected' => 0,
'postpone_processing' => 0,
'skip_confirmation' => 0,
'override_label' => 0,
'label' => '',
'settings' => array(
'show_all_tokens' => 1,
'display_values' => array(
'_all_' => '_all_',
),
),
),
'action::views_bulk_operations_argument_selector_action' => array(
'selected' => 0,
'skip_confirmation' => 0,
'override_label' => 0,
'label' => '',
'settings' => array(
'url' => '',
),
),
'action::system_send_email_action' => array(
'selected' => 0,
'postpone_processing' => 0,
'skip_confirmation' => 0,
'override_label' => 0,
'label' => '',
),
);
/* Field: Label */
$handler->display->display_options['fields']['label']['id'] = 'label';
$handler->display->display_options['fields']['label']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['label']['field'] = 'label';
$handler->display->display_options['fields']['label']['ui_name'] = 'Label';
/* Field: From */
$handler->display->display_options['fields']['source_language']['id'] = 'source_language';
$handler->display->display_options['fields']['source_language']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['source_language']['field'] = 'source_language';
$handler->display->display_options['fields']['source_language']['ui_name'] = 'From';
$handler->display->display_options['fields']['source_language']['label'] = 'From';
/* Field: To */
$handler->display->display_options['fields']['target_language']['id'] = 'target_language';
$handler->display->display_options['fields']['target_language']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['target_language']['field'] = 'target_language';
$handler->display->display_options['fields']['target_language']['ui_name'] = 'To';
$handler->display->display_options['fields']['target_language']['label'] = 'To';
/* Field: State */
$handler->display->display_options['fields']['state']['id'] = 'state';
$handler->display->display_options['fields']['state']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['state']['field'] = 'state';
$handler->display->display_options['fields']['state']['ui_name'] = 'State';
/* Field: Translator */
$handler->display->display_options['fields']['translator']['id'] = 'translator';
$handler->display->display_options['fields']['translator']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['translator']['field'] = 'translator';
$handler->display->display_options['fields']['translator']['ui_name'] = 'Translator';
/* Field: Progress */
$handler->display->display_options['fields']['progress']['id'] = 'progress';
$handler->display->display_options['fields']['progress']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['progress']['field'] = 'progress';
$handler->display->display_options['fields']['progress']['ui_name'] = 'Progress';
/* Field: Translation Management Job: Word count */
$handler->display->display_options['fields']['word_count']['id'] = 'word_count';
$handler->display->display_options['fields']['word_count']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['word_count']['field'] = 'word_count';
/* Field: Changed */
$handler->display->display_options['fields']['changed']['id'] = 'changed';
$handler->display->display_options['fields']['changed']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['changed']['field'] = 'changed';
$handler->display->display_options['fields']['changed']['ui_name'] = 'Changed';
$handler->display->display_options['fields']['changed']['date_format'] = 'short';
/* Field: Operations */
$handler->display->display_options['fields']['operations']['id'] = 'operations';
$handler->display->display_options['fields']['operations']['table'] = 'tmgmt_job';
$handler->display->display_options['fields']['operations']['field'] = 'operations';
$handler->display->display_options['fields']['operations']['ui_name'] = 'Operations';
/* Sort criterion: Changed */
$handler->display->display_options['sorts']['changed']['id'] = 'changed';
$handler->display->display_options['sorts']['changed']['table'] = 'tmgmt_job';
$handler->display->display_options['sorts']['changed']['field'] = 'changed';
$handler->display->display_options['sorts']['changed']['ui_name'] = 'Changed';
$handler->display->display_options['sorts']['changed']['order'] = 'DESC';
/* Filter criterion: State */
$handler->display->display_options['filters']['state']['id'] = 'state';
$handler->display->display_options['filters']['state']['table'] = 'tmgmt_job';
$handler->display->display_options['filters']['state']['field'] = 'state';
$handler->display->display_options['filters']['state']['ui_name'] = 'State';
$handler->display->display_options['filters']['state']['exposed'] = TRUE;
$handler->display->display_options['filters']['state']['expose']['operator_id'] = 'state_op';
$handler->display->display_options['filters']['state']['expose']['label'] = 'State';
$handler->display->display_options['filters']['state']['expose']['operator'] = 'state_op';
$handler->display->display_options['filters']['state']['expose']['identifier'] = 'state';
/* Filter criterion: From */
$handler->display->display_options['filters']['source_language']['id'] = 'source_language';
$handler->display->display_options['filters']['source_language']['table'] = 'tmgmt_job';
$handler->display->display_options['filters']['source_language']['field'] = 'source_language';
$handler->display->display_options['filters']['source_language']['ui_name'] = 'From';
$handler->display->display_options['filters']['source_language']['exposed'] = TRUE;
$handler->display->display_options['filters']['source_language']['expose']['operator_id'] = 'source_language_op';
$handler->display->display_options['filters']['source_language']['expose']['label'] = 'From';
$handler->display->display_options['filters']['source_language']['expose']['operator'] = 'source_language_op';
$handler->display->display_options['filters']['source_language']['expose']['identifier'] = 'from';
/* Filter criterion: To */
$handler->display->display_options['filters']['target_language']['id'] = 'target_language';
$handler->display->display_options['filters']['target_language']['table'] = 'tmgmt_job';
$handler->display->display_options['filters']['target_language']['field'] = 'target_language';
$handler->display->display_options['filters']['target_language']['ui_name'] = 'To';
$handler->display->display_options['filters']['target_language']['exposed'] = TRUE;
$handler->display->display_options['filters']['target_language']['expose']['operator_id'] = 'target_language_op';
$handler->display->display_options['filters']['target_language']['expose']['label'] = 'To';
$handler->display->display_options['filters']['target_language']['expose']['operator'] = 'target_language_op';
$handler->display->display_options['filters']['target_language']['expose']['identifier'] = 'to';
/* Filter criterion: Translator */
$handler->display->display_options['filters']['translator']['id'] = 'translator';
$handler->display->display_options['filters']['translator']['table'] = 'tmgmt_job';
$handler->display->display_options['filters']['translator']['field'] = 'translator';
$handler->display->display_options['filters']['translator']['ui_name'] = 'Translator';
$handler->display->display_options['filters']['translator']['exposed'] = TRUE;
$handler->display->display_options['filters']['translator']['expose']['operator_id'] = 'translator_op';
$handler->display->display_options['filters']['translator']['expose']['label'] = 'Translator';
$handler->display->display_options['filters']['translator']['expose']['operator'] = 'translator_op';
$handler->display->display_options['filters']['translator']['expose']['identifier'] = 'translator';
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'admin/tmgmt/overview';
$handler->display->display_options['menu']['type'] = 'default tab';
$handler->display->display_options['menu']['title'] = 'Jobs';
$handler->display->display_options['menu']['weight'] = '-1';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['tab_options']['type'] = 'normal';
$handler->display->display_options['tab_options']['title'] = 'Translation';
$handler->display->display_options['tab_options']['description'] = 'Translation overview';
$handler->display->display_options['tab_options']['weight'] = -9;
$handler->display->display_options['tab_options']['name'] = 'management';
$translatables['tmgmt_ui_job_overview'] = array(
t('Master'),
t('Job overview'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Items per page'),
t('- All -'),
t('Offset'),
t('« first'),
t(' previous'),
t('next '),
t('last »'),
t('There are no translation jobs that match the specified filter criteria.'),
t('Translator'),
t('Label'),
t('From'),
t('To'),
t('State'),
t('Progress'),
t('Word count'),
t('Changed'),
t('Operations'),
t('Page'),
);