From 40025d1a756e66498b5cdbdcb3f8b247afcfc59c Tue, 15 Nov 2011 16:24:51 -0300
From: Javier Castro <javier.alejandro.castro@gmail.com>
Date: Tue, 15 Nov 2011 16:22:13 -0300
Subject: [PATCH] Fix couple of errors/warnings Fix node_presave() must look for an existing 'format' array index to work with

Signed-off-by: Javier Castro <javier.alejandro.castro@gmail.com>

diff --git a/tableofcontents.module b/tableofcontents.module
old mode 100644
new mode 100755
index 754c908..fe0ad0e
--- a/tableofcontents.module
+++ b/tableofcontents.module
@@ -53,8 +53,8 @@
 /**
  * Implementation of hook_filter_FILTER_tips().
  */
-function tableofcontents_filter_FILTER_tips($filter, $format, $long = FALSE) {
-  if ( $filter->name == filter_toc ) {
+function tableofcontents_filter_tips($filter, $format, $long = FALSE) {
+  if ( $filter->name == 'filter_toc' ) {
     $delta = 0;
   } else {
     $delta = 1;
@@ -93,6 +93,7 @@
  */
 function tableofcontents_filter_info() {
   module_load_include('admin.inc', 'tableofcontents');
+  $filters = array();
   $filters['filter_toc'] = array(
     'title' => t('Table of contents'),
     'description' => t('Inserts a table of contents in place of [toc ...] tags.'),
@@ -172,7 +173,7 @@
  * Implementation of hook_node_presave
  */
 function tableofcontents_node_presave($node) {
-  if (isset($node->body)) {
+  if (isset($node->body) && array_key_exists('format', $node->body[$node->language][0])) {
     if (variable_get('tableofcontents_remove_teaser_' . $node->body[$node->language][0]['format'], TRUE)) {
       module_load_include('admin.inc', 'tableofcontents');
       _tableofcontents_hide_in_teaser($node);
diff --git a/tableofcontents.pages.inc b/tableofcontents.pages.inc
old mode 100644
new mode 100755
index 55550fa..4b848b6
--- a/tableofcontents.pages.inc
+++ b/tableofcontents.pages.inc
@@ -844,6 +844,7 @@
  * @param $text The text to filter
  */
 function _tableofcontents_process($text, $format, $filter = 0) {
+  $format = is_object($format) ? $format->format : $format;
   return _tableofcontents_replace_toc($text, $format, $filter);
 }
 