You are here

function view_mode_page_remove_pattern in View Mode Page 7.2

Same name and namespace in other branches
  1. 8.2 view_mode_page.module \view_mode_page_remove_pattern()

Form for removing the pattern

1 string reference to 'view_mode_page_remove_pattern'
view_mode_page_menu in ./view_mode_page.module
Implements hook_menu().

File

./view_mode_page.module, line 780
View Mode Page module allows users to add a page for a specific view mode.

Code

function view_mode_page_remove_pattern($form, &$form_state) {
  $hash = arg(4);

  // find the pattern matching the hash
  $patterns = view_mode_page_get_entity_patterns();
  $found = FALSE;
  foreach ($patterns as $pattern) {
    if (view_mode_page_pattern_hash($pattern) == $hash) {
      $found = TRUE;
      break;
    }
  }
  if (!$found) {
    drupal_not_found();
    exit;
  }
  return array(
    'confirm' => array(
      '#markup' => '<p>' . t('Do you really want to remove this pattern?') . '</p>',
    ),
    'confirm_button' => array(
      '#type' => 'submit',
      '#value' => 'Remove',
    ),
    'pattern' => array(
      '#type' => 'hidden',
      '#value' => drupal_json_encode($pattern),
    ),
  );
}