Index: page_title.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/page_title/page_title.module,v
retrieving revision 1.18.2.15
diff -u -r1.18.2.15 page_title.module
--- page_title.module	17 Jun 2009 15:03:07 -0000	1.18.2.15
+++ page_title.module	18 Jun 2009 07:35:00 -0000
@@ -317,6 +317,51 @@
     }
   }
 
+  // If we're looking at a panel, emulate delegator_page_execute() to find title
+  $router_item = menu_get_item();
+  if ($router_item['page_callback'] == 'delegator_page_execute') {
+
+    // Find page name (subtask_id) and load page object
+    $subtask_id = $router_item['page_arguments'][0];
+    $page = delegator_page_load($subtask_id);    
+
+    /*
+     * Code to get contexts and args is copied from delegator_page_execute()
+     */     
+    // Turn the contexts into a properly keyed array.
+    $contexts = array();
+    $args = array();
+    foreach (func_get_args() as $count => $arg) {
+      if (is_object($arg) && get_class($arg) == 'ctools_context') {
+        $contexts[$arg->id] = $arg;
+        $args[] = $arg->original_argument;
+      }
+      else if ($count) {
+        $args[] = $arg;
+      }
+    }
+    $count = 0;
+    $names = delegator_page_get_named_arguments($page->path);
+    $bits = explode('/', $page->path);  
+    if ($page->arguments) {
+      foreach ($page->arguments as $name => $argument) {
+        // Optional arguments must be converted to contexts too, if they exist.
+        if ($bits[$names[$name]][0] == '!' && isset($args[$count])) {
+          $argument['keyword'] = $name;
+          ctools_include('context');
+          $context = ctools_context_get_context_from_argument($argument, $args[$count]);
+          $contexts[$context->id] = $context;
+        }
+        $count++;
+      }
+    }
+
+    // Now load and execute the handler to get the title
+    require_once(drupal_get_path('module', 'panels') . '/plugins/task_handlers/panel_context.inc');
+    $info = panels_panel_context_render($page, $contexts, $args, FALSE);
+    $title = $info['title'];
+  }
+
   // If nothing above set a title, give the legacy function a chance to act
   if (empty($title)) {
     $title = check_plain(strip_tags(page_title_set_title()));

