tmgmt.info.inc in Translation Management Tool 7
Contains the metadata controller classes for the Translation Management Tool
entities.
File
includes/tmgmt.info.inc
View source
<?php
class TMGMTJobMetadataController extends EntityDefaultMetadataController {
public function entityPropertyInfo() {
$info = parent::entityPropertyInfo();
$info = _tmgmt_override_property_description($info, $this->type);
$properties =& $info[$this->type]['properties'];
$properties['changed']['type'] = $properties['created']['type'] = 'date';
$properties['label']['getter callback'] = 'entity_class_label';
foreach (array(
'target_language',
'source_language',
'translator',
) as $property) {
$properties[$property]['setter callback'] = 'entity_property_verbatim_set';
}
$properties['target_language']['options list'] = $properties['source_language']['options list'] = 'entity_metadata_language_list';
$properties['state']['options list'] = 'tmgmt_job_states';
$properties['translator']['type'] = 'tmgmt_translator';
$properties['translator']['options list'] = 'tmgmt_translator_labels';
$properties['author'] = array(
'label' => t('Author'),
'type' => 'user',
'description' => t('The author of the translation job.'),
'setter callback' => 'entity_property_verbatim_set',
'setter permission' => 'administer tmgmt',
'required' => TRUE,
'schema field' => 'uid',
);
return $info;
}
}
class TMGMTJobItemMetadataController extends EntityDefaultMetadataController {
public function entityPropertyInfo() {
$info = parent::entityPropertyInfo();
$info = _tmgmt_override_property_description($info, $this->type);
$properties =& $info[$this->type]['properties'];
$properties['changed']['type'] = 'date';
$properties['state']['options list'] = 'tmgmt_job_item_states';
$properties['tjid'] = array(
'description' => t('Corresponding job entity.'),
'type' => 'tmgmt_job',
) + $properties['tjid'];
$properties['plugin']['options list'] = 'tmgmt_source_plugin_labels';
$properties['word_count']['label'] = t('Word count');
return $info;
}
}
class TMGMTMessageMetadataController extends EntityDefaultMetadataController {
public function entityPropertyInfo() {
$info = parent::entityPropertyInfo();
$info = _tmgmt_override_property_description($info, $this->type);
$properties =& $info[$this->type]['properties'];
$properties['created']['type'] = 'date';
$properties['tjid'] = array(
'description' => t('Corresponding job entity.'),
'type' => 'tmgmt_job',
) + $properties['tjid'];
$properties['tjiid'] = array(
'description' => t('Corresponding job item entity.'),
'type' => 'tmgmt_job_item',
) + $properties['tjiid'];
$properties['uid'] = array(
'type' => 'user',
'description' => t('User associated with TMGMT Job Message entity.'),
) + (isset($properties['uid']) ? $properties['uid'] : array());
return $info;
}
}
class TMGMTTranslatorMetadataController extends EntityDefaultMetadataController {
public function entityPropertyInfo() {
$info = parent::entityPropertyInfo();
$info = _tmgmt_override_property_description($info, $this->type);
$properties =& $info[$this->type]['properties'];
$properties['plugin']['options list'] = 'tmgmt_translator_plugin_labels';
return $info;
}
}
function _tmgmt_override_property_description($info, $entity_type) {
module_load_install('tmgmt');
$entity_info = entity_get_info($entity_type);
$schema = tmgmt_schema();
$fields = $schema[$entity_info['base table']]['fields'];
$properties =& $info[$entity_type]['properties'];
foreach ($properties as $name => $property_info) {
if (isset($fields[$name]['description'])) {
$properties[$name]['description'] = $fields[$name]['description'];
}
}
return $info;
}