function msnf_steps in Multistep Nodeform 7
Same name and namespace in other branches
- 6 includes/msnf.steps.inc \msnf_steps()
Returns all steps for a content type.
Return value
<array> All steps including associated fields in a structured array.
3 calls to msnf_steps()
- msnf_save_step in includes/
msnf.steps.inc - Saves a step for a content-type.
- msnf_step_validate_name in includes/
msnf.steps.inc - API for step name validation.
- _msnf_steps_label in includes/
msnf.steps.inc - Provide labels for all steps.
2 string references to 'msnf_steps'
- msnf_info_steps in ./
msnf.module - Get all form steps.
- msnf_step_export_delete in ./
msnf.module - Delete a single step.
File
- includes/
msnf.steps.inc, line 14 - Step crud functions.
Code
function msnf_steps($content_type = '', $sorted = FALSE, $reset = FALSE) {
global $language;
static $steps, $steps_sorted;
if (!isset($steps) || $reset) {
if (($cached = cache_get('msnf_step_data:' . $language->language)) !== 0 && !empty($cached->data) && time() < $cached->expire) {
$data = $cached->data;
$steps = $data['steps'];
$steps_sorted = $data['steps_sorted'];
}
else {
$result = db_query('SELECT * FROM {msnf_step} ORDER BY weight, step_name');
$steps = array();
$steps_sorted = array();
while ($step = db_fetch_array($result)) {
$step['settings'] = unserialize($step['settings']);
$step['fields'] = array();
$step['groups'] = array();
// Allow external modules to translate field step strings.
$step_strings = array(
'label' => $step['label'],
'form_description' => $step['settings']['form']['description'],
'form_button_label_previous' => $step['settings']['form']['button_label']['previous'],
'form_button_label_next' => $step['settings']['form']['button_label']['next'],
'form_description' => $step['settings']['form']['description'],
);
drupal_alter('msnf_step_strings', $step_strings, $step['type_name'], $step['step_name']);
$step['label'] = $step_strings['label'];
$step['settings']['form']['description'] = $step_strings['form_description'];
$step['settings']['form']['button_label']['previous'] = $step_strings['form_button_label_previous'];
$step['settings']['form']['button_label']['next'] = $step_strings['form_button_label_next'];
// Load non-CCK fields and add them to the list.
$extra_fields = msnf_extra_fields($step['type_name']);
$step_fields = msnf_step_get_fields($step['type_name'], $step['step_name']);
foreach ($extra_fields as $field_name => $field) {
if (isset($step_fields[$field_name])) {
// We do not have a real widget here but this doesn't matter.
$field_strings = array(
'widget_label' => $field['label'],
'widget_description' => $field['description'],
);
// Allow external modules to translate field strings
// (using hook_content_field_strings()!).
drupal_alter('content_field_strings', $field_strings, $field['type_name'], $field_name);
$field['label'] = $field_strings['widget_label'];
$field['description'] = $field_strings['widget_description'];
$step['fields'][$field_name] = $field;
}
}
$steps[$step['type_name']][$step['step_name']] = $step;
$steps_sorted[$step['type_name']][] =& $steps[$step['type_name']][$step['step_name']];
}
// Load fields from content.module (if installed).
if (module_exists('content')) {
$result = db_query('SELECT nfi.*, ms.step_name FROM {msnf_step} ms ' . 'INNER JOIN {msnf_step_fields} msf ON msf.type_name = ms.type_name AND msf.step_name = ms.step_name ' . 'INNER JOIN {' . content_instance_tablename() . '} nfi ON nfi.field_name = msf.field_name AND nfi.type_name = msf.type_name ' . 'WHERE nfi.widget_active = 1 ORDER BY nfi.weight');
while ($field = db_fetch_array($result)) {
$field_strings = array(
'widget_label' => $field['label'],
'widget_description' => $field['description'],
);
// Allow external modules to translate field strings
// (using hook_content_field_strings()!).
drupal_alter('content_field_strings', $field_strings, $field['type_name'], $field['field_name']);
$field['label'] = $field_strings['widget_label'];
$field['description'] = $field_strings['widget_description'];
$steps[$field['type_name']][$field['step_name']]['fields'][$field['field_name']] = $field;
}
}
// Load fieldgroups from fieldgroup.module (if installed).
if (module_exists('fieldgroup')) {
$result = db_query('SELECT cg.*, ms.step_name FROM {msnf_step} ms ' . 'INNER JOIN {msnf_step_fields} msf ON msf.type_name = ms.type_name AND msf.step_name = ms.step_name ' . 'INNER JOIN {' . fieldgroup_tablename() . '} cg ON cg.group_name = msf.field_name AND cg.type_name = msf.type_name ' . 'ORDER BY cg.weight');
while ($group = db_fetch_array($result)) {
$group_strings = array(
'widget_label' => $group['label'],
'widget_description' => $group['description'],
);
// Allow external modules to translate field strings
// (using hook_content_field_strings()!).
drupal_alter('content_field_strings', $group_strings, $group['type_name'], $group['group_name']);
$group['label'] = $group_strings['widget_label'];
$group['description'] = $group_strings['widget_description'];
$steps[$group['type_name']][$group['step_name']]['groups'][$group['group_name']] = $group;
}
}
cache_set('msnf_step_data:' . $language->language, array(
'steps' => $steps,
'steps_sorted' => $steps_sorted,
));
}
}
if (empty($content_type)) {
return $steps;
}
elseif (empty($steps) || empty($steps[$content_type])) {
return array();
}
return $sorted ? $steps_sorted[$content_type] : $steps[$content_type];
}