function panels_page_admin_view in Panels 5.2
Same name and namespace in other branches
- 6.2 panels_page/panels_page.admin.inc \panels_page_admin_view()
1 string reference to 'panels_page_admin_view'
- panels_page_view_page in panels_page/
panels_page.module - Page callback to view a panel page.
File
- panels_page/
panels_page.admin.inc, line 878 - panels_page.admin.inc
Code
function panels_page_admin_view($panel_page, $args) {
$form = array();
$form['fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Administrative view: enter arguments'),
'#collapsible' => TRUE,
);
$required_args = strpos($panel_page->path, '%') === false ? 0 : count(split($panel_page->path, '%'));
$url = panels_page_get_url($panel_page, $args);
if ($args_missing = max($required_args - count($args), 0)) {
$value = $url;
$description = format_plural($args_missing, '1 argument is missing to generate a valid URL.', '@count arguments are missing to generate a valid URL.');
}
else {
$value = l($url, $url);
$description = t('Click to see the real panel page.');
}
$form['fieldset']['url'] = array(
'#type' => 'item',
'#title' => t('Real panel URL'),
'#value' => $value,
'#description' => $description,
);
$contexts = panels_context_load_contexts($panel_page);
$count = 0;
foreach ($contexts as $id => $context) {
if (substr($id, 0, 8) == 'argument') {
$required = $count + 1 <= $required_args ? TRUE : FALSE;
$description = $required ? t('Required argument (occupies %-placeholder number !position)', array(
'!position' => $count + 1,
)) : t('Optional argument');
$form['fieldset']["arg{$count}"] = array(
'#type' => 'textfield',
'#title' => check_plain($context->identifier),
'#default_value' => isset($args[$count]) ? $args[$count] : '',
'#required' => $required,
'#description' => $description,
);
}
if (isset($args[$count])) {
unset($args[$count]);
}
$count++;
}
$add = '';
if ($args) {
$add = implode('/', $args);
}
$form['fieldset']['additional'] = array(
'#type' => 'textfield',
'#title' => t('Additional arguments'),
'#description' => t('Separated by /'),
'#default_value' => $add,
);
$form['fieldset']['submit'] = array(
'#type' => 'submit',
'#value' => t('Change arguments'),
);
$form['panel_page'] = array(
'#type' => 'value',
'#value' => $panel_page,
);
$form['contexts'] = array(
'#type' => 'value',
'#value' => $contexts,
);
return $form;
}