Index: nodewords.module
===================================================================
--- nodewords.module	(revision 776)
+++ nodewords.module	(working copy)
@@ -74,13 +74,18 @@
       'type' => MENU_LOCAL_TASK,
     );
   }
-  else {
+   else {
     $tags = nodewords_get();
     foreach ($tags as $name => $content) {
       if (!empty($content)) {
+        $argument = nodewords_get_arguments();
+        foreach ($argument as $key => $phrase) {
+          $content = str_replace('%'.$key, ucwords($argument[$key]), $content);
+        }
         drupal_set_html_head('<meta name="' . $name . '" content="' . $content . '" />');
       }
     }
+
   }
   return $items;
 }
@@ -142,6 +147,14 @@
     $form['#submit']['nodewords_panels_handler'] = array();
   } else if ($form_id == 'panels_delete_confirm') {
     $form['#submit']['nodewords_panels_handler'] = array();
+  } else if ($form_id == 'panels_page_edit_form') {
+    $panels_page = panels_page_get_current($form);
+    $type = 'panels_page';
+    $id = $panels_page['panel_page']['#value']->did;
+    $form['submit']['#weight'] = 45;
+    $form['#submit']['nodewords_panels_page_handler'] = array();
+  } else if ($form_id == 'panels_page_delete_confirm') {
+    $form['#submit']['nodewords_panels_page_handler'] = array();
   } else if ($form_id == 'views_edit_view') {
     $type = 'views';
     $id = $form['vid']['#value'];
@@ -377,6 +390,25 @@
 }
 
 /**
+ * Handling of edit/delete form for panels 2.
+ */
+function nodewords_panels_page_handler($form_id, $form_values) {
+  switch ($_POST['op']) {
+    case t('Save'):
+      if (isset($form_values['nodewords']) && user_access('administer meta tags')) {
+        _nodewords_set('panels_page', $form_values['panel_page']->did, $form_values['nodewords']);
+      }
+      break;
+
+    case t('Delete'):
+      if ($form_values['confirm']) {
+        _nodewords_delete('panels_page', $form_values['panel_page']->did);
+      }
+      break;
+  }
+}
+
+/**
  * Handling of edit/delete form for views.
  */
 function nodewords_views_handler($form_id, $form_values) {
@@ -461,8 +493,14 @@
  *   An associative array of the defined meta tags.
  */
 function nodewords_get($type = NULL, $ids = NULL, $filtered = TRUE) {
+  /* Panels are tricky so lets do this */
+  if ($type = 'panels' && isset($ids)) {
+    $result = _nodewords_panels_load($ids);
+    $type = $result['type'];
+    $ids = $result['ids'];
+  }
   /* Autodetect if $type and/or $ids is not set */
-  if ($type == NULL || $ids == NULL) {
+  elseif ($type == NULL || $ids == NULL) {
     $result = _nodewords_detect_type_and_ids();
     $type = $result['type'];
     $ids = $result['ids'];
@@ -501,7 +539,6 @@
 
   /* Prepare tags for output */
   $tags = _nodewords_prepare($type, $ids, $tags, $filtered);
-
   return $tags;
 }
 
@@ -707,9 +744,15 @@
         $tags['DC.title'] = $panel->title;
       }
     }
+    else if ($type == 'panels_page') {
+      $panel = db_fetch_object(db_query("SELECT * FROM {panels_page} WHERE did = %d", $ids[0]));
+      if ($panel) {
+        $tags['DC.title'] = $panel->title;
+      }
+    }
     unset($tags['geourl']);
   }
-  
+
   /* Check 'content' of each tag */
   $tags = array_map(_nodewords_check_content, $tags);
 
@@ -811,13 +854,19 @@
       }
       break;
   }
-
-// Not compatible with panels 2.
+//  Panels does not work
 //  if (module_exists('panels')) {
 //    if ($result = db_fetch_array(db_query("SELECT * FROM {panels_info} WHERE path = '%s'", $_GET['q']))) {
 //      return array('type' => 'panels', 'ids' => array($result['did']));
 //    }
 //  }
+//  Panels 2 does not work
+//  if (module_exists('panels_page')) {
+//    print "it exist";
+//    if ($result = db_fetch_array(db_query("SELECT * FROM {panels_page} WHERE path = '%s'", $_GET['q']))) {
+//      return array('type' => 'panels_page', 'ids' => array($result['did']));
+//    }
+//  }
 
   if (module_exists('views')) {
     if (($result = db_fetch_array(db_query("SELECT * FROM {view_view} WHERE url LIKE '%s%%' AND page = 1", $_GET['q'])))) {
@@ -828,3 +877,30 @@
   return array('type' => 'none', 'ids' => array());
 }
 
+function nodewords_get_arguments () {
+  $args = array();
+  $args = explode("/",str_replace("-", " ",$_GET['q']));
+
+  return $args;
+}
+
+function nodewords_panels_pre_render($panel_id = NULL) {
+  $tags = nodewords_get('panels', $panel_id, TRUE);
+  foreach ($tags as $name => $content) {
+    if (!empty($content)) {
+      $argument = nodewords_get_arguments();
+      foreach ($argument as $key => $phrase) {
+        $content = str_replace('%'.$key, ucwords($argument[$key]), $content);
+      }
+      if($name != 'robots'){
+        drupal_set_html_head('<meta name="' . $name . '" content="' . $content . '" />');
+      }
+    }
+  }
+}
+
+function _nodewords_panels_load($panel_id) {
+    if ($result = db_fetch_array(db_query("SELECT * FROM {panels_page} WHERE did = '%d'", $panel_id))) {
+      return array('type' => 'panels_page', 'ids' => array($result['did']));
+    }
+}
\ No newline at end of file
