From 4df7b4151c4192aa595e3741b0ebaabcc97287c4 Mon Sep 17 00:00:00 2001
From: Jakob Perry <japerry@45640.no-reply.drupal.org>
Date: Fri, 29 Jul 2016 21:37:11 -0700
Subject: [PATCH] Reroll against head

---
 includes/display-edit.inc | 11 +++++++++++
 panels.install            | 33 ++++++++++++++++++++++++++++++++-
 panels.module             |  9 ++++++++-
 3 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/includes/display-edit.inc b/includes/display-edit.inc
index 4e28292..377027b 100644
--- a/includes/display-edit.inc
+++ b/includes/display-edit.inc
@@ -246,6 +246,16 @@ function panels_edit_display_settings_form($form, &$form_state) {
       '#maxlength' => 255,
     );
 
+    $form['display_title']['title_url'] = array(
+      '#type' => 'textfield',
+      '#default_value' => $display->title_url,
+      '#title' => t('Title URL'),
+      '#description' => t('The URL for the title of this panel. If left blank, no link will be generated.'),
+      '#process' => array('ctools_dependent_process'),
+      '#dependency' => array('edit-display-title-hide-title' => array(PANELS_TITLE_FIXED)),
+      '#maxlength' => 255,
+    );
+
     if (!empty($display->context)) {
       $form['display_title']['title']['#description'] .= ' ' . t('You may use substitutions in this title.');
 
@@ -324,5 +334,6 @@ function panels_edit_display_settings_form_submit($form, &$form_state) {
   if (isset($form_state['values']['display_title']['title'])) {
     $display->title = $form_state['values']['display_title']['title'];
     $display->hide_title = $form_state['values']['display_title']['hide_title'];
+    $display->title_url = $form_state['values']['display_title']['title_url'];
   }
 }
diff --git a/panels.install b/panels.install
index 7a9e7f7..05edd20 100644
--- a/panels.install
+++ b/panels.install
@@ -47,7 +47,19 @@ function panels_requirements_install() {
 function panels_schema() {
   // This should always point to our 'current' schema. This makes it relatively
   // easy to keep a record of schema as we make changes to it.
-  return panels_schema_7();
+  return panels_schema_8();
+}
+
+function panels_schema_8() {
+  $schema = panels_schema_7();
+
+  $schema['panels_display']['fields']['title_url'] = array(
+    'type' => 'varchar',
+    'length' => '255',
+    'default' => '',
+  );
+
+  return $schema;
 }
 
 function panels_schema_7() {
@@ -520,3 +532,22 @@ function panels_update_7304() {
     }
   }
 }
+
+/**
+ * Add panels_display.title_url field.
+ */
+function panels_update_7306() {
+  // Load the schema.
+  $schema = panels_schema_8();
+  $table = 'panels_display';
+  $field = 'title_url';
+  $spec = $schema[$table]['fields'][$field];
+
+  if (!db_field_exists($table, $field)) {
+    // Re-define the column.
+    db_add_field($table, $field, $spec);
+    return t('Added panels_display.title_url field.');
+  }
+
+  return t('panels_pane.title_url field already existed, update skipped.');
+}
diff --git a/panels.module b/panels.module
index 3f243eb..c01cb8d 100644
--- a/panels.module
+++ b/panels.module
@@ -720,7 +720,14 @@ class panels_display {
 
       case PANELS_TITLE_FIXED:
       case FALSE; // For old exported panels that are not in the database.
-        if (!empty($this->title)) {
+        if (!empty($this->title) && !empty($this->title_url)) {
+          return l(
+            filter_xss_admin(ctools_context_keyword_substitute($this->title, array(), $this->context)),
+            filter_xss_admin(ctools_context_keyword_substitute($this->title_url, array(), $this->context)),
+            array('attributes' => array('class' => 'title-link'))
+          );
+        }
+        elseif (!empty($this->title)) {
           return filter_xss_admin(ctools_context_keyword_substitute($this->title, array(), $this->context));
         }
         return NULL;
-- 
2.6.4 (Apple Git-63)

