Skip to content
Snippets Groups Projects
Commit 9619365b authored by Kristof De Jaeger's avatar Kristof De Jaeger
Browse files

Sanitize $_GET['v']

parent 17a9800e
No related branches found
No related tags found
No related merge requests found
......@@ -516,6 +516,25 @@ function ds_extras_get_view_mode() {
return drupal_static('ds_extras_view_mode');
}
/**
* Get view modes for an entity bundle.
*/
function ds_extras_get_bundle_view_modes($type, $bundle) {
$view_modes = array('default' => t('Default'));
$view_mode_settings = field_view_mode_settings($type, $bundle);
$ds_vm = ds_entity_view_modes($type);
foreach ($ds_vm as $key => $item) {
$overriden = (!empty($view_mode_settings[$key]['custom_settings']) ? TRUE : FALSE);
if ($overriden) {
$view_modes[$key] = $item['label'];
}
}
return $view_modes;
}
/**
* Page title options for a full entity page view.
*/
......
......@@ -29,6 +29,12 @@ function ds_extras_node_page_view($node) {
// It's also possible to use $_GET['v'] to switch view modes.
if (isset($_GET['v']) && !empty($_GET['v'])) {
$view_mode = $_GET['v'];
// Check if this is a valid view mode, switch to default otherwise.
$view_modes = ds_extras_get_bundle_view_modes('node', $node->type);
if (!isset($view_modes[$view_mode])) {
$view_mode = 'full';
}
}
drupal_static('ds_extras_view_mode', $view_mode);
return node_view_multiple(array($node->nid => $node), $view_mode);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment