function globallink_locale in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.7 globallink_locale_mapping.inc \globallink_locale()
- 7.5 globallink_locale_mapping.inc \globallink_locale()
Renders form for globallink_locale.
10 string references to 'globallink_locale'
- globallink_beans_active_form in globallink_beans/
globallink_beans_active_submissions.inc - Builds form to show all active beans submissions.
- globallink_block_active_form in globallink_block/
globallink_block_active_submissions.inc - Builds form to show all active block submissions.
- globallink_dashboard_active in ./
globallink_active_submissions.inc - Builds form to show all active GlobalLink submissions.
- globallink_entity_active_form in globallink_entity/
globallink_entity_active_submissions.inc - Builds form to show all active entity submissions.
- globallink_fieldable_panels_active_form in globallink_fieldable_panels/
globallink_fieldable_panels_active_submissions.inc - Builds form to show all active fieldable panels submissions.
File
- ./
globallink_locale_mapping.inc, line 19 - globallink_locale_mapping.inc is a file that contains most functions needed on the Locale Mapping UI.
Code
function globallink_locale() {
$form = array();
$languages = language_list('language', TRUE);
$mapped_languages = globallink_get_mapped_locale_codes();
if (sizeof($mapped_languages) > 0) {
foreach ($mapped_languages as $mlang) {
foreach ($languages as $language) {
if ($language->language == $mlang) {
unset($languages[$mlang]);
break;
}
}
}
}
$drupal_list = array();
foreach ($languages as $language) {
if ($language->enabled == 1) {
$drupal_list[$language->language . '|' . $language->name] = $language->name;
}
}
$tpt_list = globallink_get_tpt_list();
$header = array(
'drupal_locale_code' => array(
'field' => 'tl.drupal_locale_desc',
'data' => t('Drupal Site Locales'),
),
'locale_code' => array(
'field' => 'tl.locale_desc',
'data' => t('GlobalLink Locales'),
),
);
$query = db_select('globallink_locale', 'tl')
->isNotNull('drupal_locale_code')
->fields('tl')
->extend('PagerDefault')
->limit(TPT_PAGER_LIMIT)
->extend('TableSort')
->orderByHeader($header);
$results = $query
->execute();
$count = 0;
$rows = array();
foreach ($results as $item) {
$count++;
$rows[$item->locale_code] = array(
'drupal_locale_code' => $item->drupal_locale_desc,
'locale_code' => $item->locale_desc,
);
}
$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#empty' => t('No items available'),
);
$form['pager'] = array(
'#markup' => theme('pager'),
);
if ($count > 0) {
$form['submit_locale_delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
}
$form['locale_mapping'] = array(
'#title' => t('Locale Mapping'),
'#type' => 'fieldset',
'#description' => t('Map the Drupal locales with GlobalLink locales'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
if (sizeof($drupal_list) > 0) {
$form['locale_mapping']['drupal_locale_list'] = array(
'#title' => t('Drupal Locale'),
'#type' => 'select',
'#options' => $drupal_list,
);
$form['locale_mapping']['tpt_locale_list'] = array(
'#title' => t('GlobalLink Locale'),
'#type' => 'select',
'#options' => $tpt_list,
);
$form['locale_mapping']['submit_locale_add'] = array(
'#type' => 'submit',
'#value' => t('Add'),
);
}
else {
$form['locale_mapping']['no_mapping'] = array(
'#type' => 'markup',
'#prefix' => '<br/><b><i>',
'#markup' => t('Nothing to Map'),
'#suffix' => '</i></b>',
);
}
return $form;
}