function globallink_block_receive_form in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.5 globallink_block/globallink_block_receive.inc \globallink_block_receive_form()
Builds form to receive a block submission.
1 string reference to 'globallink_block_receive_form'
- globallink_block_receive_submissions in globallink_block/
globallink_block_receive.inc - Builds forms on block receive dashboard.
File
- globallink_block/
globallink_block_receive.inc, line 273
Code
function globallink_block_receive_form() {
module_load_include('inc', 'globallink', 'gl_ws/gl_ws_receive_translations');
$form = array();
if (!empty($_SESSION['transpefect_block_receive_type'])) {
$type = $_SESSION['transpefect_block_receive_type'];
}
$globallink_arr = array();
if (!empty($_SESSION['globallink_block_globalLink_arr'])) {
$globallink_arr = unserialize($_SESSION['globallink_block_globalLink_arr']);
}
$page_count = isset($_SESSION['globallink_block_receive_page_count']) ? $_SESSION['globallink_block_receive_page_count'][0] : TPT_PAGER_LIMIT;
$rows = array();
$filter_lang = '[any]';
if (!empty($_SESSION['globallink_block_receive_filter_language'])) {
$filter_lang = $_SESSION['globallink_block_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)) {
$strings = globallink_block_get_strings(NULL, 'blocks');
$filter_status = '[any]';
if (!empty($_SESSION['globallink_block_receive_filter_status'])) {
$filter_status = $_SESSION['globallink_block_receive_filter_status'];
}
$header = array(
'submissionName' => t('Submission'),
'sourceLocale' => t('Source Language'),
'targetLocale' => t('Target Language'),
'title' => t('Block Info'),
'status' => t('Status'),
);
if (variable_get('globallink_enable_preview', 1)) {
$header['preview'] = '';
}
$count = 1;
$rid_arr = array();
foreach ($globallink_arr as $key => &$globallink) {
if ($globallink->type != 'block') {
continue;
}
$pd4 = globallink_get_project_director_details();
$target_xml = globallink_download_target_resource($pd4, $globallink->targetTicket);
$block_arr = globallink_block_get_translated_items($target_xml);
if (count($block_arr) > 0) {
$bid = $block_arr['bid'];
$title = '';
$status = globallink_block_get_translation_status($bid, $globallink->targetLocale, $title);
if ($status == 'Source Deleted') {
$globallink->sourceDeleted = TRUE;
}
if ($filter_status != '[any]' && $status != $filter_status) {
unset($globallink_arr[$key]);
continue;
}
$filter_submission = '[any]';
if (!empty($_SESSION['globallink_block_receive_filter_submission'])) {
$filter_submission = $_SESSION['globallink_block_receive_filter_submission'];
}
if ($filter_submission != '[any]' && $globallink->submissionName != $filter_submission) {
unset($globallink_arr[$key]);
continue;
}
if (variable_get('globallink_enable_preview', 1)) {
if ($status != 'Source Deleted') {
$tpt_row_id = globallink_block_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'] = $status != 'Source Deleted' ? l(t('Preview Translations'), 'javascript:void(0)', array(
'fragment' => '',
'external' => TRUE,
'attributes' => array(
'id' => 'tpt_content_link_' . $key,
),
)) : '';
}
$count++;
}
}
$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/block/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_block_globalLink_arr_last_refreshed'])) {
$last_refreshed = $_SESSION['globallink_block_globalLink_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-clear-deleted").click(function(){jQuery("#edit-submit-clear-deleted").hide();jQuery("#edit-submit-clear-deleted-hidden").css("display","inline");});});', 'inline');
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_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_block/js/globallink_block_receive.js');
return $form;
}