function widgets_set_form_data_fields in Widgets 7
Parameters
$data:
$set:
$editable:
Return value
array
1 call to widgets_set_form_data_fields()
- widgets_set_form in ./
widgets.admin.inc - Form builder; Edit an widget set name and elements order.
File
- ./
widgets.admin.inc, line 211 - Administration pages for widget settings.
Code
function widgets_set_form_data_fields($data, $set, $editable) {
$form = array();
$options = array(
'' => t('None'),
'plain-linebreaks' => t('Plain with linebreaks'),
'plain-spaces' => t('Plain with spaces'),
'verticle' => t('Verticle'),
'horizontal' => t('Horizontal'),
);
if ($editable) {
$form['style'] = array(
'#type' => 'select',
'#title' => t('Style'),
'#default_value' => isset($data['style']) && $data['style'] ? $data['style'] : '',
'#options' => $options,
);
}
else {
$form['style'] = array(
'#type' => 'item',
'#title' => t('Style'),
'#markup' => $options[isset($set['style']) && $set['style'] ? $set['style'] : ''],
);
}
$form['visibility'] = array(
'#type' => 'fieldset',
'#title' => t('Visibility'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['visibility']['token'] = array(
'#type' => 'checkbox',
'#title' => t('Token'),
'#description' => t('Create a token to display this widget.'),
'#default_value' => isset($data['visibility']['token']) ? $data['visibility']['token'] : 1,
);
$form['visibility']['block'] = array(
'#type' => 'checkbox',
'#title' => t('Block'),
'#description' => t('Enable widget to be displayed as a block.'),
'#default_value' => isset($data['visibility']['block']) ? $data['visibility']['block'] : 1,
);
if (!$editable) {
$form['visibility']['token']['#type'] = 'item';
$form['visibility']['token']['#markup'] = isset($data['visibility']['token']) && !$data['visibility']['token'] ? 'No' : 'Yes';
$form['visibility']['block']['#type'] = 'item';
$form['visibility']['block']['#markup'] = isset($data['visibility']['block']) && !$data['visibility']['block'] ? 'No' : 'Yes';
}
$types = node_type_get_types();
$form['visibility']['content_types'] = array(
'#type' => 'fieldset',
'#title' => t('Content types'),
'#description' => t('Check the below boxes to display widgets in node links by content types.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$options = array(
'links_full' => 'Full content',
'links_teaser' => 'Teaser',
);
foreach ($types as $typename => $type) {
$form['visibility']['content_types'][$typename] = array(
'#type' => 'checkboxes',
'#title' => $type->name,
'#options' => $options,
'#default_value' => isset($data['visibility']['content_types'][$typename]) ? $data['visibility']['content_types'][$typename] : array(),
);
if (!$editable) {
$form['visibility']['content_types'][$typename]['#type'] = 'item';
$form['visibility']['content_types'][$typename]['#markup'] = isset($data['visibility']['content_types'][$typename]) && count($data['visibility']['content_types'][$typename]) ? implode(', ', $data['visibility']['content_types'][$typename]) : 'No';
}
}
$form['cache'] = array(
'#type' => 'fieldset',
'#title' => t('Cache'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$options = array(
'' => t("Don't cache"),
'site' => t('Cache site wide'),
'author' => t('Cache by node author and user page account'),
'page' => t('Cache by page'),
'user' => t('Cache by logged in user'),
);
$default = isset($scope['cache']['scope']) ? $scope['cache']['scope'] : '';
$form['cache']['scope'] = array(
'#type' => 'radios',
'#title' => t('Scope'),
'#description' => t('Caching improves the speed widget sets are loaded. Cache scope should be based on the scope of the tokens used by the widget elements. Use <em>Cache site wide</em> unless your widget elements have tokens that are page, author or user specific.'),
'#options' => $options,
'#default_value' => isset($data['cache']['scope']) ? $data['cache']['scope'] : $default,
);
// Save existing scope to flush if changed.
$cid0 = '';
if (isset($set['data']['cache']['scope'])) {
$cid0 = widgets_build_cache_cid($set['name'], $set['data']['cache']['scope']);
}
$form['cache']['cid0'] = array(
'#type' => 'value',
'#value' => $cid0,
);
$vars = array(
'set' => $set,
'process_tokens' => FALSE,
);
$text = theme_widgets_set_view($vars);
$tokens = token_scan($text);
$form['tokens'] = array(
'#type' => 'fieldset',
'#title' => t('Tokens'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
if (!is_array($tokens) || count($tokens) == 0) {
$form['tokens']['tokens'] = array(
'#markup' => t('This widget set does not contain any tokens.'),
);
}
else {
$items = array();
$count = 0;
foreach ($tokens as $key => $type) {
if (is_array($type)) {
foreach ($type as $k => $token) {
$items[] = $token;
$count++;
}
}
}
$form['tokens']['tokens'] = array(
'#markup' => t('This widget set contains the following !count tokens:', array(
'!count' => $count,
)) . theme('item_list', array(
'items' => $items,
)),
);
}
return $form;
}