function joomla_myblog_map_form in Joomla to Drupal 7.2
Same name and namespace in other branches
- 6 joomla_myblog.module \joomla_myblog_map_form()
- 7 joomla_myblog.module \joomla_myblog_map_form()
1 string reference to 'joomla_myblog_map_form'
- joomla_myblog_menu in ./
joomla_myblog.module - Implements hook_menu().
File
- ./
joomla_myblog.module, line 22
Code
function joomla_myblog_map_form($form, &$form_state) {
$vid = variable_get('joomla_myblog_vocabulary', 0);
joomla_database_init();
$vname = db_query('SELECT name FROM {taxonomy_vocabulary} WHERE vid = :vid', array(
':vid' => $vid,
))
->fetchField();
if (!joomla_database_test()) {
$form['error'] = array(
'#markup' => '<p>' . t('The joomla database settings are not currently valid. Please set the correct database settings at <a href="@url">Joomla to Drupal settings</a> page', array(
'@url' => url('admin/config/content/joomla'),
)) . '</p>',
);
return $form;
}
$map = joomla_myblog_map();
if ($vid == 0) {
$form['error'] = array(
'#markup' => '<p>' . t('To use this page, an existing vocabulary must be set under <em>Vocabulary for MyBlog tags</em> on the <a href="@url">Joomla to Drupal settings</a> page', array(
'@url' => url('admin/config/content/joomla'),
)) . '</p>',
);
return $form;
}
$term_select_options = array();
$tree = taxonomy_get_tree($vid);
if ($tree) {
foreach ($tree as $term) {
$choice = new stdClass();
$choice->option = array(
$term->tid => str_repeat('-', $term->depth) . $term->name,
);
$term_select_options[] = $choice;
}
}
$term_select = array(
'#type' => 'select',
'#title' => check_plain($vname),
'#options' => $term_select_options,
'#multiple' => 0,
'#size' => 0,
'#weight' => -15,
);
$form['joomla_myblog_map'] = array(
'#type' => 'fieldset',
'#title' => t('Tag mappings'),
'#description' => t('It is possible to map each myblog category to an existing term in the vocabulary select for MyBlog tags.'),
'#tree' => TRUE,
);
$tags = joomla_myblog_tags();
foreach ($tags as $tag) {
$form['joomla_myblog_map'][$tag->id] = $term_select;
$form['joomla_myblog_map'][$tag->id]['#title'] = $tag->name;
if (array_key_exists($tag->id, $map)) {
$form['joomla_myblog_map'][$tag->id]['#default_value'] = $map[$tag->id];
}
}
$form['joomla_myblog_map_submit'] = array(
'#type' => 'submit',
);
return $form;
}