function panelizer_settings_page_form in Panelizer 6
Same name and namespace in other branches
- 7.3 includes/admin.inc \panelizer_settings_page_form()
- 7 includes/admin.inc \panelizer_settings_page_form()
- 7.2 includes/admin.inc \panelizer_settings_page_form()
Primary settings page.
This settings page allows the administrator to select which node types can be panelized, whether they have a default, and provides links to edit those defaults.
1 string reference to 'panelizer_settings_page_form'
- panelizer_menu in ./
panelizer.module - Implementation of hook_menu().
File
- includes/
admin.inc, line 15 - Contains administrative forms and settings.
Code
function panelizer_settings_page_form(&$form_state) {
ctools_include('dependent');
$form = array();
$form['warnings'] = array();
$task = page_manager_get_task('node_view');
if (!empty($task->disabled)) {
$form['warning']['task'] = array(
'#prefix' => '<div class="messages warning">',
'#value' => t('The node template page is currently not enabled in page manager. You must enable this for Panelizer to be able to panelize nodes.'),
'#suffix' => '</div>',
);
}
$handler = page_manager_load_task_handler($task, '', 'node_view_panelizer');
if (!empty($handler->disabled)) {
$form['warning']['handler'] = array(
'#prefix' => '<div class="messages warning">',
'#value' => t('The panelizer variant on the node template page is currently not enabled in page manager. You must enable this for Panelizer to be able to panelize nodes.'),
'#suffix' => '</div>',
);
}
$form['types'] = array(
'#tree' => TRUE,
);
// Add 'node' settings
$form['types']['node'] = array(
'#theme' => 'panelizer_node_settings_page_form',
);
$types = node_get_types('names');
drupal_alter('panelizer_default_types', $types, 'node');
$settings = variable_get('panelizer_defaults', array());
foreach ($types as $type => $title) {
$base_id = str_replace(array(
'][',
'_',
' ',
), '-', 'edit-types-node-' . $type);
$form['types']['node'][$type]['title'] = array(
'#value' => $title,
);
$form['types']['node'][$type]['status'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($settings['node'][$type]['status']),
);
$form['types']['node'][$type]['default'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($settings['node'][$type]['default']),
'#process' => array(
'ctools_dependent_process',
),
'#dependency' => array(
$base_id . '-status' => array(
TRUE,
),
),
);
$form['types']['node'][$type]['choice'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($settings['node'][$type]['choice']),
'#process' => array(
'ctools_dependent_process',
),
'#dependency' => array(
$base_id . '-status' => array(
TRUE,
),
),
'#access' => FALSE,
);
$base_url = 'admin/settings/panelizer/node/' . $type;
$form['types']['node'][$type]['links'] = array(
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
if (!empty($settings['node'][$type]['status'])) {
// add links
$links = array(
'settings' => array(
'title' => t('allowed content'),
'href' => $base_url . '/allowed',
),
);
$form['types']['node'][$type]['links']['basic'] = array(
'#type' => 'item',
'#input' => TRUE,
// necessary to fake the #process
'#value' => theme('links', $links, array(
'class' => 'links inline',
)),
'#id' => $base_id . '-links-basic',
'#process' => array(
'ctools_dependent_process',
),
'#dependency' => array(
$base_id . '-status' => array(
TRUE,
),
),
);
}
if (!empty($settings['node'][$type]['default'])) {
// add links
$links = array(
'settings' => array(
'title' => t('settings'),
'href' => $base_url . '/settings',
),
'context' => array(
'title' => t('context'),
'href' => $base_url . '/context',
),
'layout' => array(
'title' => t('layout'),
'href' => $base_url . '/layout',
),
'content' => array(
'title' => t('content'),
'href' => $base_url . '/content',
),
);
$form['types']['node'][$type]['links']['default'] = array(
'#type' => 'item',
'#input' => TRUE,
// necessary to fake the #process
'#value' => theme('links', $links, array(
'class' => 'links inline',
)),
'#id' => $base_id . '-links-default',
'#process' => array(
'ctools_dependent_process',
),
'#dependency_count' => 2,
'#dependency' => array(
$base_id . '-default' => array(
TRUE,
),
$base_id . '-status' => array(
TRUE,
),
),
);
$links = array(
'list' => array(
'title' => t('list'),
'href' => $base_url . '/list',
),
);
$form['types']['node'][$type]['links']['default2'] = array(
'#type' => 'item',
'#input' => TRUE,
// necessary to fake the #process
'#value' => theme('links', $links, array(
'class' => 'links inline',
)),
'#id' => $base_id . '-links-default2',
'#process' => array(
'ctools_dependent_process',
),
'#dependency_count' => 2,
'#dependency' => array(
$base_id . '-default' => array(
TRUE,
),
$base_id . '-choice' => array(
TRUE,
),
),
);
}
}
// Add 'user' settings
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}