function gathercontent_mapping_form_templates in GatherContent 7.3
GatherContent template import.
In this form, we load templates from Gather Content and create empty Mappings for them.
@inheritdoc
1 string reference to 'gathercontent_mapping_form_templates'
- gathercontent_menu in ./
gathercontent.module - Implements hook_menu().
File
- forms/
gathercontent.mapping-create.inc, line 19 - Multistep mapping form.
Code
function gathercontent_mapping_form_templates($form, &$form_state) {
$pr_obj = new Project();
$projects = $pr_obj
->getProjects();
$template_obj = new Template();
$form = array();
$form['description'] = array(
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => t("Please select the GatherContent Templates you'd like to map. Only Templates you've not selected will be listed."),
'#attributes' => array(
'class' => array(
'description',
),
),
);
$form['projects'] = array(
'#type' => 'vertical_tabs',
);
foreach ($projects as $project_id => $project) {
$remote_templates = $template_obj
->getTemplates($project_id);
$query = db_select('gathercontent_mapping', 'm')
->distinct()
->fields('m', array(
'gathercontent_template',
'gathercontent_template_id',
))
->execute();
$local_templates = $query
->fetchAllKeyed(1, 0);
$templates = array_diff_assoc($remote_templates, $local_templates);
if (empty($templates)) {
continue;
}
$form['p' . $project_id] = array(
'#type' => 'fieldset',
'#title' => $project,
'#group' => 'projects',
'#tree' => TRUE,
);
$form['p' . $project_id]['templates'] = array(
'#type' => 'checkboxes',
'#title' => $project,
'#options' => $templates,
);
}
$form['selected_templates_message'] = array(
'#type' => 'gathercontent_checkboxcounter',
'#counter_message_js_template' => array(
'1 template selected',
'@count templates selected',
),
'#counter_message_default' => format_plural(0, '1 template selected', '@count templates selected'),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Select'),
);
$form['actions']['close'] = array(
'#type' => 'submit',
'#value' => t('Close'),
);
return $form;
}