/**
  * Add the panelizer settings form to a single entity bundle config form.
  *
  * @param &$form
  *   The form array.
  * @param &$form_state
  *   The form state array.
  * @param $bundle
  *   The machine name of the bundle this form is for.
  * @param $type_location
  *   The location in the form state values that the bundle name will be;
  *   this is used so that if a machine name of a bundle is changed, Panelizer
  *   can update as much as possible.
  */
 public function add_bundle_setting_form(&$form, &$form_state, $bundle, $type_location)
 {
     $settings = !empty($this->plugin['bundles'][$bundle]) ? $this->plugin['bundles'][$bundle] : array('status' => FALSE, 'choice' => FALSE);
     $entity_info = entity_get_info($this->entity_type);
     $perms_url = url('admin/people/permissions');
     $form['panelizer'] = array('#type' => 'fieldset', '#title' => t('Panelizer'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#group' => 'additional_settings', '#attributes' => array('class' => array('panelizer-entity-bundle')), '#bundle' => $bundle, '#location' => $type_location, '#tree' => TRUE, '#access' => panelizer_administer_entity_bundle($this, $bundle), '#attached' => array('js' => array(ctools_attach_js('panelizer-entity-bundle', 'panelizer'))));
     $form['panelizer']['status'] = array('#title' => t('Panelize'), '#type' => 'checkbox', '#default_value' => !empty($settings['status']), '#id' => 'panelizer-status', '#description' => t('Allow content of this type to have its display controlled by Panelizer. Once enabled, each individual view mode will have further options.<br />Enabling a view mode adds adds <a href="!perm_url">several new permissions</a> for it.', array('!perm_url' => $perms_url)));
     foreach ($this->plugin['view modes'] as $view_mode => $view_mode_info) {
         if (isset($this->plugin['view mode status'][$bundle][$view_mode]) && empty($this->plugin['view mode status'][$bundle][$view_mode])) {
             continue;
         }
         $form['panelizer']['view modes'][$view_mode] = array('#type' => 'item', '#title' => $view_mode_info['label'], '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE))));
         $form['panelizer']['view modes'][$view_mode]['status'] = array('#title' => t('Panelize'), '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['status']), '#id' => 'panelizer-' . $view_mode . '-status', '#attributes' => array('title' => $view_mode_info['label']), '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE))), '#description' => t('Allow entities of this type to have this view mode controlled by Panelizer.'));
         $form['panelizer']['view modes'][$view_mode]['default'] = array('#title' => t('Provide initial display'), '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['status']) && !empty($settings['view modes'][$view_mode]['default']), '#id' => 'panelizer-' . $view_mode . '-initial', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE))), '#description' => t('If checked, a panel will be provided named "Default", which will be used as the default display, unless another one is created & selected below.'));
         // Obtain a list of all available panels for this view mode / bundle.
         $panelizers = $this->get_default_panelizer_objects($bundle . '.' . $view_mode);
         $options = array();
         if (!empty($panelizers)) {
             foreach ($panelizers as $name => $panelizer) {
                 // Don't show disabled displays.
                 if (empty($panelizer->disabled)) {
                     $options[$name] = $panelizer->title;
                 }
             }
         }
         if (!empty($options)) {
             ksort($options);
         }
         // The default display to be used if nothing found.
         $default_name = implode(':', array($this->entity_type, $bundle, 'default'));
         $variable_name = 'panelizer_' . $this->entity_type . ':' . $bundle . ':' . $view_mode . '_selection';
         if ($view_mode != 'page_manager') {
             $default_name .= ':' . $view_mode;
         }
         // If this has not been set previously, use the 'default' as the default
         // selection.
         $default_value = variable_get($variable_name, FALSE);
         if ($default_value === FALSE) {
             $default_value = $default_name;
         }
         // Indicate which item is actually the default.
         if (count($options) > 1 && isset($options[$default_value])) {
             $options[$default_value] .= ' (' . t('default') . ')';
         }
         $form['panelizer']['view modes'][$view_mode]['selection'] = array('#title' => t('Default panel'), '#type' => 'select', '#options' => $options, '#default_value' => $default_value, '#id' => 'panelizer-' . $view_mode . '-default', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE))), '#required' => count($options), '#disabled' => count($options) == 0, '#description' => t('The default panel to be used for new %bundle records. If "Allow panel choice" is not enabled, the item selected will be used for any new %bundle record. All existing %bundle records will have to be manually updated to the new selection.', array('%bundle' => $bundle)));
         $form['panelizer']['view modes'][$view_mode]['default revert'] = array('#type' => 'checkbox', '#title' => t('Update existing entities to use this display'), '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE))), '#description' => t('Will update all %bundle records to use the newly selected display, unless they have been customized. Note: only takes effect when the display is changed, and will not work if the default was not assigned previously.', array('%bundle' => $bundle)), '#field_prefix' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
         // First time this is displayed there won't be any defaults assigned, so
         // show a placeholder indicating the page needs to be saved before they
         // will show.
         if (count($options) == 0) {
             $form['panelizer']['view modes'][$view_mode]['selection']['#options'] = array('' => '* ' . t('No displays available yet') . ' *');
             $form['panelizer']['view modes'][$view_mode]['selection']['#description'] .= '<br />' . '<em>' . t('No displays have been created yet, the default may not be assigned.') . '</em>';
         }
         // Control whether the default can be selected.
         $form['panelizer']['view modes'][$view_mode]['choice'] = array('#title' => t('Allow panel choice'), '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['status']) && !empty($settings['view modes'][$view_mode]['choice']), '#id' => 'panelizer-' . $view_mode . '-choice', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE))), '#description' => t('Allows multiple panels to be created for this view mode. Once created, a selector will be provided on the @bundle edit form allowing the display of this view mode to be chosen. Additionally, any customizations made will be based upon the selected display. Note: the selector will not be shown if there is only one display, instead the default will be automatically selected.', array('@bundle' => $bundle)));
         if (!empty($bundle)) {
             $form['panelizer']['view modes'][$view_mode]['choice']['#description'] .= '<br />' . t('This option adds a <a href="!perm_url">new permission</a>: !perm', array('!perm_url' => $perms_url, '!perm' => t('%entity_name %bundle_name: Choose panels', array('%entity_name' => $entity_info['label'], '%bundle_name' => $entity_info['bundles'][$bundle]['label']))));
         }
     }
     array_unshift($form['#submit'], 'panelizer_entity_default_bundle_form_submit');
     $form_state['panelizer_entity_handler'] = $this;
 }
 /**
  * Add the panelizer settings form to a single entity bundle config form.
  *
  * @param &$form
  *   The form array.
  * @param &$form_state
  *   The form state array.
  * @param $bundle
  *   The machine name of the bundle this form is for.
  * @param $type_location
  *   The location in the form state values that the bundle name will be;
  *   this is used so that if a machine name of a bundle is changed, Panelizer
  *   can update as much as possible.
  */
 public function add_bundle_setting_form(&$form, &$form_state, $bundle, $type_location)
 {
     $settings = !empty($this->plugin['bundles'][$bundle]) ? $this->plugin['bundles'][$bundle] : array('status' => FALSE, 'choice' => FALSE);
     $entity_info = entity_get_info($this->entity_type);
     $perms_url = url('admin/people/permissions');
     $manage_display = t('Manage Display');
     $bundle_info = array();
     if (isset($entity_info['bundles'][$bundle])) {
         $bundle_info = $entity_info['bundles'][$bundle];
         if (!empty($bundle_info['admin']['real path'])) {
             $manage_display = l($manage_display, $bundle_info['admin']['real path'] . '/display');
         }
     }
     $view_mode_settings = array();
     if (!empty($bundle)) {
         $view_mode_settings = field_view_mode_settings($this->entity_type, $bundle);
     }
     $form['panelizer'] = array('#type' => 'fieldset', '#title' => t('Panelizer'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#group' => 'additional_settings', '#attributes' => array('class' => array('panelizer-entity-bundle')), '#bundle' => $bundle, '#location' => $type_location, '#tree' => TRUE, '#access' => panelizer_administer_entity_bundle($this, $bundle), '#attached' => array('js' => array(ctools_attach_js('panelizer-entity-bundle', 'panelizer'))));
     // The master checkbox.
     $form['panelizer']['status'] = array('#title' => t('Panelize'), '#type' => 'checkbox', '#default_value' => !empty($settings['status']), '#id' => 'panelizer-status', '#description' => t('Allow content of this type to have its display controlled by Panelizer. Once enabled, each individual view mode will have further options and will add <a href="!perm_url">several new permissions</a>.', array('!perm_url' => $perms_url)) . '<br />' . t('Other than "Full page override" and "Default", only view modes enabled through the Custom Display Settings section of the !manage_display tab will be available for use.', array('!manage_display' => $manage_display)) . '<br />' . t('Once enabled, a new tab named "Customize display" will show on pages for this content.'));
     // Help, I need somebody.
     $form['panelizer']['help'] = array('#title' => t('Optional help message to show above the display selector, if applicable'), '#type' => 'textarea', '#rows' => 3, '#default_value' => !empty($settings['help']) ? $settings['help'] : '', '#id' => 'panelizer-help', '#description' => t('Only used if one or more of the view modes has a display that allows multiple values and the "Customize display" tab is to be shown on the entity edit form. Allows HTML.'), '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE))));
     $view_modes = $this->get_available_view_modes($bundle);
     foreach ($view_modes as $view_mode => $view_mode_label) {
         $view_mode_info = $this->plugin['view modes'][$view_mode];
         $form['panelizer']['view modes'][$view_mode] = array('#type' => 'item', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE))));
         // Show the optional view mode description.
         $pm_links = array('!pm' => l('Page Manager', 'admin/structure/pages'), '!panels' => l('Panels', 'admin/structure/panels'), '!entity_type' => $this->entity_type, '!task_name' => $this->get_page_manager_task_name());
         $description = '';
         if ($view_mode == 'default') {
             $description = t('If a requested view mode for an entity was not enabled in the !manage_display tab page, this view mode will be used as a failover. For example, if "Teaser" was being used but it was not enabled.', array('!manage_display' => $manage_display));
         } elseif ($view_mode == 'page_manager') {
             $description = t("A custom view mode only used when !pm/!panels is used to control this entity's full page display, i.e. the '!task_name' display is enabled. Unlike the \"!full\" view mode, this one allows customization of the page title.", $pm_links + array('!full' => !empty($entity_info['view modes']['full']['label']) ? $entity_info['view modes']['full']['label'] : 'Full'));
         } elseif ($view_mode == 'full') {
             $description = t('Used when viewing !entity_type entities on their standalone page, does not allow customization of the page title.', array('!entity_type' => $this->entity_type));
         } elseif ($view_mode == 'teaser') {
             $description = t('Used in content lists by default, e.g. on the default homepage and on taxonomy term pages.');
         } elseif ($view_mode == 'rss') {
             $description = t('Used by the default RSS content lists.');
         }
         $form['panelizer']['view modes'][$view_mode]['status'] = array('#title' => $view_mode_info['label'], '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['status']), '#id' => 'panelizer-' . $view_mode . '-status', '#prefix' => '<hr />', '#description' => $description, '#attributes' => array('title' => $view_mode_info['label']), '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE))));
         if ($view_mode == 'page_manager') {
             if (!$this->is_page_manager_enabled()) {
                 $form['panelizer']['view modes'][$view_mode]['status']['#title'] .= ' (<em>' . t('!pm is enabled correctly', $pm_links) . '</em>)';
             } else {
                 $form['panelizer']['view modes'][$view_mode]['status']['#title'] .= ' (<em>' . t('"!task_name" must be enabled in !pm', $pm_links) . '</em>)';
                 // Only display this message if the form has not been submitted, the
                 // bundle has been panelized and the view mode is panelized.
                 if (empty($form_state['input']) && !empty($settings['status']) && !empty($settings['view modes'][$view_mode]['status'])) {
                     drupal_set_message(t('Note: "!task_name" display must be enabled in !pm in order for the !entity_type full page display ("Full page override") to work correctly.', $pm_links), 'warning', FALSE);
                 }
             }
         }
         $options = array('' => t('- Ignore this option -')) + $view_modes;
         unset($options[$view_mode]);
         $form['panelizer']['view modes'][$view_mode]['substitute'] = array('#title' => t('Substitute a different view mode in place of this one'), '#description' => t("Allows this view mode to be enabled but for the actual display to be handled by another view mode. This can save on configuration effort should multiple view modes need to look the same."), '#type' => 'select', '#options' => $options, '#default_value' => $this->get_substitute($view_mode, $bundle), '#id' => 'panelizer-' . $view_mode . '-substitute', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE))));
         $form['panelizer']['view modes'][$view_mode]['default'] = array('#title' => t('Provide an initial display named "Default"'), '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['status']) && !empty($settings['view modes'][$view_mode]['default']), '#id' => 'panelizer-' . $view_mode . '-initial', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-substitute' => array('value' => ''))));
         // Obtain a list of all available panels for this view mode / bundle.
         $panelizers = $this->get_default_panelizer_objects($bundle . '.' . $view_mode);
         $options = array();
         if (!empty($panelizers)) {
             foreach ($panelizers as $name => $panelizer) {
                 // Don't show disabled displays.
                 if (empty($panelizer->disabled)) {
                     $options[$name] = $panelizer->title;
                 }
             }
         }
         if (!empty($options)) {
             ksort($options);
         }
         // The default display to be used if nothing found.
         $default_name = implode(':', array($this->entity_type, $bundle, 'default'));
         $variable_name = 'panelizer_' . $this->entity_type . ':' . $bundle . ':' . $view_mode . '_selection';
         if ($view_mode != 'page_manager') {
             $default_name .= ':' . $view_mode;
         }
         // If this has not been set previously, use the 'default' as the default
         // selection.
         $default_value = variable_get($variable_name, FALSE);
         if (empty($default_value)) {
             $default_value = $default_name;
         }
         // Indicate which item is actually the default.
         if (count($options) > 1 && isset($options[$default_value])) {
             $options[$default_value] .= ' (' . t('default') . ')';
         }
         if (!empty($bundle_info) && count($options) > 0) {
             $form['panelizer']['view modes'][$view_mode]['selection'] = array('#title' => t('Default panel'), '#type' => 'select', '#options' => $options, '#default_value' => $default_value, '#id' => 'panelizer-' . $view_mode . '-default', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-substitute' => array('value' => ''))), '#required' => count($options), '#disabled' => count($options) == 0, '#description' => t('The default display to be used for new %bundle records. If "Allow panel choice" is not enabled, the item selected will be used for any new %bundle record. All existing %bundle records will have to be manually updated to the new selection.', array('%bundle' => $bundle)));
             $form['panelizer']['view modes'][$view_mode]['default revert'] = array('#type' => 'checkbox', '#title' => t('Update existing entities to use this display'), '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-substitute' => array('value' => ''))), '#description' => t('Will update all %bundle records to use the newly selected display, unless they have been customized. Note: only takes effect when the display is changed, and will not work if the default was not assigned previously.', array('%bundle' => $bundle)), '#field_prefix' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
         }
         // Control whether the default can be selected.
         $form['panelizer']['view modes'][$view_mode]['choice'] = array('#title' => t('Allow per-record display choice'), '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['status']) && !empty($settings['view modes'][$view_mode]['choice']), '#id' => 'panelizer-' . $view_mode . '-choice', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-substitute' => array('value' => ''))), '#description' => t("Allows multiple displays to be created for this view mode. Once created, a selector will be provided on the %bundle record's edit form allowing the display of this view mode to be chosen. Additionally, any customizations made will be based upon the selected display. Note: the selector will not be shown if there is only one display, instead the default will be automatically selected.", array('%bundle' => $bundle)));
         if (!empty($bundle)) {
             $form['panelizer']['view modes'][$view_mode]['choice']['#description'] .= '<br />' . t('This option adds a <a href="!perm_url">new permission</a>: !perm', array('!perm_url' => $perms_url, '!perm' => t('%entity_name %bundle_name: Choose panels', array('%entity_name' => $entity_info['label'], '%bundle_name' => $entity_info['bundles'][$bundle]['label']))));
         }
     }
     array_unshift($form['#submit'], 'panelizer_entity_default_bundle_form_submit');
     $form_state['panelizer_entity_handler'] = $this;
 }
 public function hook_page_alter(&$page)
 {
     // Add an extra "Panelizer" action on the content types admin page.
     if ($_GET['q'] == 'admin/structure/types') {
         // This only works with some themes.
         if (!empty($page['content']['system_main']['node_table'])) {
             // Shortcut.
             $table =& $page['content']['system_main']['node_table'];
             // Operations column should always be the last column in header.
             // Increase its colspan by one to include possible panelizer link.
             $operationsCol = end($table['#header']);
             if (!empty($operationsCol['colspan'])) {
                 $operationsColKey = key($table['#header']);
                 $table['#header'][$operationsColKey]['colspan']++;
             }
             // Since we can't tell what row a type is for, but we know that they
             // were generated in this order, go through the original types list.
             $types = node_type_get_types();
             $names = node_type_get_names();
             $row_index = 0;
             foreach ($names as $bundle => $name) {
                 $type = $types[$bundle];
                 if (node_hook($type->type, 'form')) {
                     $type_url_str = str_replace('_', '-', $type->type);
                     if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
                         $table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer'));
                     } else {
                         $table['#rows'][$row_index][] = array('data' => '');
                     }
                     // Update row index for next pass.
                     $row_index++;
                 }
             }
         }
     }
 }
 /**
  * Implements hook_page_alter().
  */
 public function hook_page_alter(&$page)
 {
     // Add an extra "Panelizer" action on the paragraphs bundles admin page.
     if (current_path() == 'admin/structure/paragraphs') {
         // This only works with some themes.
         if (!empty($page['content']['system_main']['paragraphs_bundle_table'])) {
             // Shortcut.
             $table =& $page['content']['system_main']['paragraphs_bundle_table'];
             // Operations column should always be the last column in header.
             // Increase its colspan by one to include possible panelizer link.
             $operationsCol = end($table['#header']);
             if (!empty($operationsCol['colspan'])) {
                 $operationsColKey = key($table['#header']);
                 $table['#header'][$operationsColKey]['colspan']++;
             }
             foreach ($table['#rows'] as $bundle => &$row) {
                 $bundle_url_str = str_replace('_', '-', $bundle);
                 if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
                     $row[] = array('data' => l(t('panelizer'), 'admin/structure/paragraphs/' . $bundle_url_str . '/panelizer'));
                 } else {
                     $row[] = array('data' => '');
                 }
             }
         }
     }
 }
 public function hook_page_alter(&$page)
 {
     if ($_GET['q'] == 'admin/structure/types' && !empty($page['content']['system_main']['node_table'])) {
         // shortcut
         $table =& $page['content']['system_main']['node_table'];
         // Modify the header.
         $table['#header'][1]['colspan'] = 5;
         // Since we can't tell what row a type is for, but we know that they
         // were generated in this order, go through the original types
         // list:
         $types = node_type_get_types();
         $names = node_type_get_names();
         $row_index = 0;
         foreach ($names as $bundle => $name) {
             $type = $types[$bundle];
             if (node_hook($type->type, 'form')) {
                 $type_url_str = str_replace('_', '-', $type->type);
                 if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
                     $table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer'));
                 } else {
                     $table['#rows'][$row_index][] = array('data' => '');
                 }
                 // Update row index for next pass:
                 $row_index++;
             }
         }
     }
 }
 /**
  * Add the panelizer settings form to a single entity bundle config form.
  *
  * @param &$form
  *   The form array.
  * @param &$form_state
  *   The form state array.
  * @param $bundle
  *   The machine name of the bundle this form is for.
  * @param $type_location
  *   The location in the form state values that the bundle name will be;
  *   this is used so that if a machine name of a bundle is changed, Panelizer
  *   can update as much as possible.
  */
 public function add_bundle_setting_form(&$form, &$form_state, $bundle, $type_location)
 {
     $settings = !empty($this->plugin['bundles'][$bundle]) ? $this->plugin['bundles'][$bundle] : array('status' => FALSE, 'default' => FALSE, 'choice' => FALSE);
     $form['panelizer'] = array('#type' => 'fieldset', '#title' => t('Panelizer'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#group' => 'additional_settings', '#attributes' => array('class' => array('panelizer-node-type-settings-form')), '#bundle' => $bundle, '#location' => $type_location, '#tree' => TRUE, '#access' => panelizer_administer_entity_bundle($this, $bundle));
     $form['panelizer']['status'] = array('#title' => t('Panelize'), '#type' => 'checkbox', '#default_value' => !empty($settings['status']), '#id' => 'panelizer-status');
     foreach ($this->plugin['view modes'] as $view_mode => $view_mode_info) {
         $form['panelizer']['view modes'][$view_mode] = array('#type' => 'item', '#title' => $view_mode_info['label'], '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE))));
         $form['panelizer']['view modes'][$view_mode]['status'] = array('#title' => t('Panelize'), '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['status']), '#id' => 'panelizer-' . $view_mode . '-status', '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE))));
         $form['panelizer']['view modes'][$view_mode]['default'] = array('#title' => t('Provide default panel'), '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['default']), '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE))), '#description' => t('If checked, a default panel will be utilized for all existing and new entities.'));
         $form['panelizer']['view modes'][$view_mode]['choice'] = array('#title' => t('Allow panel choice'), '#type' => 'checkbox', '#default_value' => !empty($settings['view modes'][$view_mode]['choice']), '#states' => array('visible' => array('#panelizer-status' => array('checked' => TRUE), '#panelizer-' . $view_mode . '-status' => array('checked' => TRUE))), '#description' => t('If checked multiple panels can be created and each entity will get a selector to choose which panel to use.'));
     }
     array_unshift($form['#submit'], 'panelizer_entity_default_bundle_form_submit');
     $form_state['panelizer_entity_handler'] = $this;
 }
 /**
  * Implements a delegated hook_page_alter.
  *
  * Add panelizer links to the block types page.
  */
 public function hook_page_alter(&$page)
 {
     if ($_GET['q'] == 'admin/structure/block-types' && !empty($page['content']['system_main']['bean_table'])) {
         // shortcut
         $table =& $page['content']['system_main']['bean_table'];
         // Modify the header.
         $table['#header'][2]['colspan'] = 5;
         $bean_info = bean_entity_info();
         $names = $bean_info['bean']['bundles'];
         foreach ($names as $bundle => $name) {
             // @see bean_admin_ui_admin_page() for information on why we have to
             // append '_0'.
             $type_url_str = str_replace(' ', '', $name['label'] . '_0');
             if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
                 $table['#rows'][$type_url_str][] = array('data' => l(t('panelizer'), 'admin/structure/block-types/manage/' . $bundle . '/panelizer'));
             } else {
                 $table['#rows'][$type_url_str][] = array('data' => '');
             }
         }
     }
 }