summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimBrandin2013-01-19 00:19:49 (GMT)
committer emattias2013-01-19 00:19:49 (GMT)
commite938cc4cbbb6115a445078ec48819e6310b7eba9 (patch)
tree975adc9fa4e6738493d5381cbee56dd6f5c967fc
parent7f6538bf1cf3eb28cb4c62cf9b55a95520b63955 (diff)
Issue #1892430 by TimBrandin | Integrated patch in #1 into the generalized thinking in the module
-rw-r--r--plugins/styles/semantic_panels.inc42
-rw-r--r--semantic_panels.module27
2 files changed, 66 insertions, 3 deletions
diff --git a/plugins/styles/semantic_panels.inc b/plugins/styles/semantic_panels.inc
index c0d83e9..aab9428 100644
--- a/plugins/styles/semantic_panels.inc
+++ b/plugins/styles/semantic_panels.inc
@@ -16,6 +16,7 @@ $plugin = array(
'render pane' => 'semantic_panels_render_pane',
'pane settings form' => 'semantic_panels_pane_settings_form',
'pane settings form submit' => 'semantic_panels_pane_settings_form_submit',
+ 'all contexts' => TRUE,
);
/**
@@ -95,7 +96,7 @@ function theme_semantic_panels_render_region($vars) {
/**
* Pane settings form.
*/
-function semantic_panels_pane_settings_form($settings) {
+function semantic_panels_pane_settings_form($settings, $display) {
$elements = _semantic_panels_get_elements();
$form = array();
@@ -160,8 +161,46 @@ function semantic_panels_pane_settings_form($settings) {
),
'#fieldset' => 'element_content',
);
+
_semantic_panels_get_attributes_fieldset($form, $settings, 'element_content');
+ $form['element_content']['link_enable'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Output this content as a link'),
+ '#default_value' => !empty($settings['element_content']['link']),
+ '#fieldset' => 'element_content',
+ );
+
+ $form['element_content']['link'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Output this content as a link'),
+ '#dependency' => array(
+ 'edit-settings-element-content-link-enable' => array(TRUE),
+ ),
+ );
+ $form['element_content']['link']['path'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Link path'),
+ '#default_value' => $settings['element_content']['link']['path'],
+ '#description' => t('The Drupal path or absolute URL for this link. You may enter data from the context keywords as per the "Substitutions" below.'),
+ '#fieldset' => 'element_content',
+ );
+ $form['element_content']['link']['contexts'] = array(
+ '#title' => t('Substitutions'),
+ '#type' => 'fieldset',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#fieldset' => 'element_content',
+ );
+ $form['element_content']['link']['contexts']['tokens']['help'] = array(
+ '#theme' => 'token_tree',
+ '#token_types' => array_map('_semantic_panels_context_token_types_map', $display->context),
+ '#recursion_limit' => 2,
+ '#fieldset' => 'element_content',
+ );
+
+ _semantic_panels_get_attributes_fieldset($form, $settings, array('element_content', 'link'));
+
// Element wrapper.
$form['element_wrapper'] = array(
'#type' => 'fieldset',
@@ -300,6 +339,7 @@ function template_preprocess_semantic_panels_pane(&$vars) {
'content' => $vars['content'],
'default_type' => 'div',
'default_classes' => 'pane-content',
+ 'context' => $vars['display']->context,
);
$vars['content_html'] = _semantic_panels_get_html('element_content', $element_data, $pane_semantic_settings);
diff --git a/semantic_panels.module b/semantic_panels.module
index bb47256..1b6ff12 100644
--- a/semantic_panels.module
+++ b/semantic_panels.module
@@ -85,6 +85,28 @@ function _semantic_panels_get_attributes() {
function _semantic_panels_get_html($element_key, $element_data, $pane_semantic_settings) {
$element_settings = $pane_semantic_settings[$element_key];
+ $element_output = render($element_data['content']);
+
+ if (isset($element_settings['link_enable']) && $element_settings['link_enable'] && $element_settings['link']['path']) {
+ $tokens = current($element_data['context']);
+ $token_content = token_replace($element_settings['link']['path'], array($tokens->keyword => $tokens->data));
+ $matches = array();
+ // If token outputs a link (like the Link field) lets parse out the url.
+ if (preg_match('/<a.*\s+href="(?<url>[^"]*)"[>]*>/i', $token_content, $matches)) {
+ $path = $matches['url'];
+ }
+ else {
+ $path = $token_content;
+ }
+
+ $options = array(
+ 'html' => TRUE,
+ 'attributes' => $element_settings['link']['attributes_array']
+ );
+
+ $element_output = l($element_output, $path, $options);
+ }
+
$element_settings['type'] = _semantic_panels_get_type($element_settings['type'], $element_data['default_type']);
if ($element_settings['type']) {
@@ -109,11 +131,12 @@ function _semantic_panels_get_html($element_key, $element_data, $pane_semantic_s
$pre .= ' ' . drupal_attributes($element_settings['attributes_array']);
}
$pre .= '>';
+ $suf = '</' . $element_settings['type'] . '>';
- return $pre . render($element_data['content']) . '</' . $element_settings['type'] . '>';
+ return $pre . $element_output . $suf;
}
- return render($element_data['content']);
+ return $element_output;
}
/**