function globallink_entity_receive_form in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.5 globallink_entity/globallink_entity_receive.inc \globallink_entity_receive_form()
Builds form to receive an entity submission.
1 string reference to 'globallink_entity_receive_form'
- globallink_entity_receive_submissions in globallink_entity/
globallink_entity_receive.inc - Builds forms on entity receive dashboard.
File
- globallink_entity/
globallink_entity_receive.inc, line 265
Code
function globallink_entity_receive_form() {
module_load_include('inc', 'globallink', 'globallink_settings');
module_load_include('inc', 'globallink', 'gl_ws/gl_ws_receive_translations');
$form = array();
if (!empty($_SESSION['transpefect_entity_receive_type'])) {
$type = $_SESSION['transpefect_entity_receive_type'];
$globallink_arr = array();
if (!empty($_SESSION['globallink_globalLink_entity_arr'])) {
$globallink_arr = unserialize($_SESSION['globallink_globalLink_entity_arr']);
}
$header = array(
'submissionName' => t('Submission'),
'sourceLocale' => t('Source Language'),
'targetLocale' => t('Target Language'),
'title' => t('Title'),
'status' => t('Status'),
);
if (variable_get('globallink_enable_preview', 1)) {
$header['preview'] = '';
}
$rows = array();
$count = 1;
$filter_lang = '[any]';
if (!empty($_SESSION['globallink_entity_receive_filter_language'])) {
$filter_lang = $_SESSION['globallink_entity_receive_filter_language'];
}
if (isset($globallink_arr) && is_array($globallink_arr)) {
foreach ($globallink_arr as $key => &$globallink) {
if ($filter_lang != '[any]' && $globallink->targetLocale != $filter_lang) {
unset($globallink_arr[$key]);
}
}
}
if (isset($globallink_arr) && is_array($globallink_arr)) {
$filter_status = '[any]';
if (!empty($_SESSION['globallink_entity_receive_filter_status'])) {
$filter_status = $_SESSION['globallink_entity_receive_filter_status'];
}
$rid_arr = array();
foreach ($globallink_arr as $key => &$globallink) {
if ($globallink->type != 'entity') {
continue;
}
$source_xml = '';
$status = 'Translation Completed';
$title = globallink_entity_get_title($globallink);
if (!$title) {
$title = $globallink->title;
$status = 'Source Deleted';
$source_xml = 'Source Deleted';
$globallink->status = 'Source Deleted';
$globallink->sourceDeleted = TRUE;
}
if ($globallink->status == 'Error') {
$status = 'Error';
}
if ($filter_status != '[any]' && $status != $filter_status) {
unset($globallink_arr[$key]);
continue;
}
$filter_submission = '[any]';
if (!empty($_SESSION['globallink_entity_receive_filter_submission'])) {
$filter_submission = $_SESSION['globallink_entity_receive_filter_submission'];
}
if ($filter_submission != '[any]' && $globallink->submissionTicket != $filter_submission) {
unset($globallink_arr[$key]);
continue;
}
$tpt_row_id = globallink_entity_get_row_id_from_submission($globallink->submissionTicket, $globallink->documentTicket, $globallink->targetLocale);
if ($tpt_row_id) {
$rid_arr['tpt_content_div_' . $key] = $tpt_row_id;
}
$source_name = globallink_get_drupal_locale_name($globallink->sourceLocale);
$target_name = globallink_get_drupal_locale_name($globallink->targetLocale);
$rows[$key] = array(
'submissionName' => $globallink->submissionName,
'sourceLocale' => $source_name,
'targetLocale' => $target_name,
'title' => $title,
'status' => $status,
);
if (variable_get('globallink_enable_preview', 1)) {
$rows[$key]['preview'] = $source_xml != 'Source Deleted' ? l(t('Preview Translations'), 'javascript:void(0)', array(
'fragment' => '',
'external' => TRUE,
'attributes' => array(
'title' => 'Click to Preview',
'id' => 'tpt_content_link_' . $key,
),
)) : '';
}
$count++;
}
}
$page_count = isset($_SESSION['globallink_receive_entity_page_count']) ? $_SESSION['globallink_receive_entity_page_count'][0] : TPT_PAGER_LIMIT;
$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => globallink_pager_array_splice($rows, $page_count),
'#empty' => t('No items available'),
);
$form['pager'] = array(
'#markup' => theme('pager'),
);
if (variable_get('globallink_enable_preview', 1)) {
$lcount = 1;
$div_arr = array();
foreach ($rid_arr as $key => $rid) {
if (isset($rid)) {
$lcount = str_replace('tpt_content_div_', '', $key);
$form['tpt_content_div_' . $lcount] = array(
'#type' => 'markup',
'#markup' => '',
'#prefix' => '<div id="tpt_content_div_' . $lcount . '" style="display: none;">',
'#suffix' => '</div>',
);
$div_arr['tpt_content_link_' . $lcount] = 'tpt_content_div_' . $lcount;
}
}
drupal_add_js(array(
'globallink' => array(
'popup' => $div_arr,
'previewpath' => base_path() . 'admin/globallink-translations/receiveTranslation/entity/preview',
'rids' => $rid_arr,
),
), 'setting');
}
if ($count > 1) {
$form['submit_update_selected'] = array(
'#type' => 'submit',
'#value' => t('Update Selected'),
);
$form['submit_update_all'] = array(
'#type' => 'submit',
'#value' => t('Update All'),
);
$form['submit_clear_deleted_hidden'] = array(
'#type' => 'submit',
'#value' => t('Clear Deleted Records'),
'#attributes' => array(
'style' => 'display:none;',
'disabled' => 'true',
),
);
$form['submit_clear_deleted'] = array(
'#type' => 'submit',
'#value' => t('Clear Deleted Records'),
);
}
$last_refreshed = '';
if (isset($_SESSION['globallink_globalLink_entity_arr_last_refreshed'])) {
$last_refreshed = $_SESSION['globallink_globalLink_entity_arr_last_refreshed'];
}
$form['submit_refresh_hidden'] = array(
'#type' => 'submit',
'#value' => t('Refresh Page'),
'#prefix' => '<BR/>',
'#attributes' => array(
'style' => 'display:none;',
'disabled' => 'true',
),
);
$form['submit_refresh'] = array(
'#type' => 'submit',
'#value' => t('Refresh Page'),
);
$form['markup'] = array(
'#type' => 'markup',
'#markup' => 'Last refreshed : ' . $last_refreshed,
);
}
drupal_add_js('jQuery(document).ready(function(){jQuery("#edit-submit-refresh").click(function(){jQuery("#edit-submit-refresh").hide();jQuery("#edit-submit-refresh-hidden").css("display","inline");});});', 'inline');
drupal_add_js('jQuery(document).ready(function(){jQuery("#edit-submit-clear-deleted").click(function(){jQuery("#edit-submit-clear-deleted").hide();jQuery("#edit-submit-clear-deleted-hidden").css("display","inline");});});', 'inline');
drupal_add_library('system', 'ui.dialog');
$module_path = drupal_get_path('module', 'globallink');
drupal_add_css($module_path . '/css/globallink.css');
drupal_add_js($module_path . '/globallink_entity/js/globallink_entity_receive.js');
return $form;
}