diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 559d237..6461559 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,8 +1,3 @@ -Panopoly Magic 7.x-1.14, 2014-11-19 ----------------------------- -- Have Panopoly Theme depend on Radix Layouts (rather than providing it's own). -- Added Can't turn off previews on Panels Add Content modal. - Panopoly Magic 7.x-1.13, 2014-10-17 ---------------------------- - No changes since last release. diff --git a/css/panopoly-magic.css b/css/panopoly-magic.css index 683cb96..5d62396 100644 --- a/css/panopoly-magic.css +++ b/css/panopoly-magic.css @@ -63,6 +63,10 @@ div.ctools-modal-content div.form-item-categories label { width: auto; } +#panels-layout-category-Panopoly { + margin: 3% 6%; +} + div.ctools-modal-content .panels-choose-layout .dependent-options { padding-left: 0px; } @@ -72,6 +76,27 @@ div.modal-content-preview-button { text-align: center; } +#panels-layout-category-Panopoly-wrapper .panels-layouts-category, +#panels-layout-category-Panopoly-wrapper .layout-link div { + display: none; +} + +#panels-layout-category-Panopoly-wrapper .layout-link { + float: left; + height: 68px; + padding: 1.25em; + text-align: center; + width: 68px; +} + +#panels-layout-category-Panopoly-wrapper .layout-link:hover { + background-color: #BBB; +} + +#panels-layout-category-Panopoly-wrapper .current-layout { + background-color: #DDD; +} + /** * Custom styling for exposed views filter options */ diff --git a/panopoly_magic.module b/panopoly_magic.module index c5f15b0..e0eaac0 100644 --- a/panopoly_magic.module +++ b/panopoly_magic.module @@ -1,10 +1,14 @@ 'select', '#required' => TRUE, '#options' => array( - PANOPOLY_ADD_PREVIEW_AUTOMATIC => 'Automatic', - PANOPOLY_ADD_PREVIEW_MANUAL => 'Manual', - PANOPOLY_ADD_PREVIEW_DISABLED => 'Disabled', + '1' => t('Enabled'), + '0' => t('Disabled'), ), - '#default_value' => variable_get('panopoly_magic_pane_add_preview', PANOPOLY_ADD_PREVIEW_DEFAULT), + '#default_value' => variable_get('panopoly_magic_pane_add_preview', 1), '#description' => t('Do you want to automatically generate previews when adding existing panels panes through the IPE?'), ); @@ -246,11 +249,6 @@ function panopoly_magic_form_alter(&$form, &$form_state, $form_id) { $clicked_button = empty($form_state['triggering_element']['#value']) ? '' : $form_state['triggering_element']['#value']; if ($form_id == 'fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form' && ($clicked_button == 'Update Preview' || ($form_state['op'] == 'add' && empty($form_state['input']['form_build_id'])))) { - // Determine the current VID for the element - if (!empty($form_state['entity']->fpid)) { - $current_vid = db_query("SELECT vid FROM {fieldable_panels_panes} WHERE fpid = :fpid", array(':fpid' => $form_state['entity']->fpid))->fetchField(); - } - // Run entity information through standard submission form if this is a new or updated object // Update the pane settngs with the VID afterwards if (!$form_state['entity']->reusable || $form_state['op'] != 'add' || $form_state['rebuild'] == TRUE) { @@ -275,15 +273,14 @@ function panopoly_magic_form_alter(&$form, &$form_state, $form_id) { $form_state['values'] = $default_values; } + // Attach fields in the form state so they can be rendered in preview. + field_attach_submit('fieldable_panels_pane', $form_state['entity'], $form, $form_state); - fieldable_panels_panes_entity_edit_form_submit($form, $form_state); - $preview_subtype = 'vid:' . $form_state['entity']->vid; - $pane->subtype = 'fpid:' . $form_state['entity']->fpid; - } + // Define the content type plugin to use for rendering the preview. + $preview_type = 'fieldable_panels_pane_preview'; - // Properly adjust the VID if we are dealing with an existing object - if (!empty($current_vid)) { - db_query("UPDATE {fieldable_panels_panes} SET vid = :vid WHERE fpid = :fpid", array(':vid' => $current_vid, ':fpid' => $form_state['entity']->fpid)); + // Stash the entity stub for the preview content type. + $pane->configuration['fieldable_panels_pane'] = $form_state['entity']; } } @@ -331,7 +328,7 @@ function panopoly_magic_form_alter(&$form, &$form_state, $form_id) { // inside form and double rendering. $form['#post_render'][] = 'panopoly_magic_form_post_render_preview'; $form['#panopoly_magic_preview_info'] = array( - 'preview_subtype' => isset($preview_subtype) ? $preview_subtype : NULL, + 'preview_type' => isset($preview_type) ? $preview_type : NULL, 'pane' => $pane, 'configuration' => $configuration, 'keywords' => $keywords, @@ -470,7 +467,16 @@ function panopoly_magic_ajax_update_preview($form, $form_state) { */ function panopoly_magic_form_post_render_preview($output, $form) { extract($form['#panopoly_magic_preview_info']); - $content = (empty($preview_subtype)) ? ctools_content_render($pane->type, $pane->subtype, $configuration, $keywords, $args, $context) : ctools_content_render($pane->type, $preview_subtype, $configuration, $keywords, $args, $context); + + // If no preview type was specified, render the pane as normal. + if (empty($preview_type)) { + $content = ctools_content_render($pane->type, $pane->subtype, $configuration, $keywords, $args, $context); + } + // If a preview type was specified, use that to render the preview. + else { + $content = ctools_content_render($preview_type, $pane->subtype, $configuration, $keywords, $args, $context); + } + // Create the fieldset with appropriate content $preview = array( @@ -1235,7 +1241,7 @@ function panopoly_magic_preprocess_panels_add_content_modal(&$vars) { // Generate the pane preview if (!empty($vars['categories'][$vars['category']]['content'])) { foreach ($vars['categories'][$vars['category']]['content'] as &$plugin) { - $use_preview = (variable_get('panopoly_magic_pane_add_preview', PANOPOLY_ADD_PREVIEW_DEFAULT) == PANOPOLY_ADD_PREVIEW_AUTOMATIC); + $use_preview = variable_get('panopoly_magic_pane_add_preview', 1); $strip_js = variable_get('panopoly_magic_strip_js_from_preview', 0); $query = drupal_get_query_parameters(); $preview_panes = (!empty($query['preview_panes'])) ? explode(',', $query['preview_panes']) : array(); @@ -1273,10 +1279,6 @@ function panopoly_magic_preprocess_panels_add_content_modal(&$vars) { * Process the panels_add_content_modal() to adjust the markup to present the preview */ function panopoly_magic_process_panels_add_content_modal(&$vars) { - if (variable_get('panopoly_magic_pane_add_preview', PANOPOLY_ADD_PREVIEW_DEFAULT) == PANOPOLY_ADD_PREVIEW_DISABLED) { - return; - } - $content = !empty($vars['categories'][$vars['category']]['content']) ? $vars['categories'][$vars['category']]['content'] : array(); // If no category is selected or the category is empty or our special empty diff --git a/plugins/content_types/fieldable_panels_pane_preview.inc b/plugins/content_types/fieldable_panels_pane_preview.inc new file mode 100644 index 0000000..6228c67 --- /dev/null +++ b/plugins/content_types/fieldable_panels_pane_preview.inc @@ -0,0 +1,48 @@ + t('Fielded custom content (preview)'), + 'no title override' => TRUE, + 'description' => t('Preview for created custom panels pane with fields'), + 'category' => t('Fielded panes'), + 'all contexts' => TRUE, + 'defaults' => array( + 'view_mode' => 'full', + ), + ); +} + +/** + * Callback to render our content type preview. + * + * Render FPP based on entity stashed in configuration for the preview. + * + * @see fieldable_panels_panes_fieldable_panels_pane_content_type_render(). + */ +function panopoly_magic_fieldable_panels_pane_preview_content_type_render($subtype, $conf, $panel_args = array(), $context = array()) { + $entity = $conf['fieldable_panels_pane']; + $view_mode = isset($conf['view_mode']) ? $conf['view_mode'] : 'full'; + if ($entity && !empty($entity->fpid) && fieldable_panels_panes_access('view', $entity)) { + $settings = field_bundle_settings('fieldable_panels_pane', $entity->bundle); + $block = new stdClass(); + $block->title = ''; + if (empty($settings['extra_fields']['display']) || !empty($settings['extra_fields']['display']['title']['default']['visible'])) { + $block->title = !empty($entity->title) ? filter_xss_admin($entity->title) : ''; + } + $block->content = fieldable_panels_panes_view($entity, $view_mode); + return $block; + } +}