? d7.patch
Index: faq.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/Attic/faq.admin.inc,v
retrieving revision 1.1.2.22
diff -u -p -r1.1.2.22 faq.admin.inc
--- faq.admin.inc	30 Nov 2009 20:57:00 -0000	1.1.2.22
+++ faq.admin.inc	5 Apr 2010 05:36:40 -0000
@@ -37,14 +37,17 @@ function faq_general_settings_form() {
     '#default_value' => variable_get('faq_title', 'Frequently Asked Questions'),
   );
 
-  $form['body_filter']['faq_description'] = array(
-    '#type' => 'textarea',
+  $edit['format'] = variable_get('faq_description_format', '');
+
+  $form['faq_description'] = array(
+    '#type' => 'text_format'
+    '#base_type' => 'textarea',
     '#title' => t('FAQ Description'),
     '#default_value' => variable_get('faq_description', ''),
     '#description' => t('Your FAQ description.  This will be placed at the top of the page, above the questions and can serve as an introductory text.'),
     '#rows' => 5,
+    '#format' => isset($edit['format']) ? $edit['format'] : NULL,
   );
-  $form['body_filter']['faq_description_format'] = filter_form(variable_get('faq_description_format', ''), NULL, array('faq_description_format'));
 
   return system_settings_form($form);
 }
@@ -59,7 +62,7 @@ function faq_questions_settings_form() {
 
   drupal_add_js(array('faq' => array('faq_hide_qa_accordion' => variable_get('faq_hide_qa_accordion', FALSE))), 'setting');
   drupal_add_js(array('faq' => array('faq_category_hide_qa_accordion' => variable_get('faq_category_hide_qa_accordion', FALSE))), 'setting');
-  drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');
+  drupal_add_js(drupal_get_path('module', 'faq') . '/faq.js', 'module');
 
   $display_options['questions_inline'] = t('Questions inline');
   $display_options['questions_top'] = t('Clicking on question takes user to answer further down the page');
@@ -182,7 +185,7 @@ function faq_categories_settings_form() 
   }
   drupal_add_js(array('faq' => array('faq_hide_qa_accordion' => variable_get('faq_hide_qa_accordion', FALSE))), 'setting');
   drupal_add_js(array('faq' => array('faq_category_hide_qa_accordion' => variable_get('faq_category_hide_qa_accordion', FALSE))), 'setting');
-  drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');
+  drupal_add_js(drupal_get_path('module', 'faq') . '/faq.js', 'module');
 
   // Set up a hidden variable.
   $form['faq_display'] = array(
@@ -314,8 +317,8 @@ function faq_order_settings_form($form_s
 
   drupal_add_js(array('faq' => array('faq_hide_qa_accordion' => variable_get('faq_hide_qa_accordion', FALSE))), 'setting');
   drupal_add_js(array('faq' => array('faq_category_hide_qa_accordion' => variable_get('faq_category_hide_qa_accordion', FALSE))), 'setting');
-  drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');
-  drupal_add_css(drupal_get_path('module', 'faq') .'/faq.css');
+  drupal_add_js(drupal_get_path('module', 'faq') . '/faq.js', 'module');
+  drupal_add_css(drupal_get_path('module', 'faq') . '/faq.css');
 
   $use_categories = variable_get('faq_use_categories', FALSE);
   if (!$use_categories) {
@@ -364,10 +367,11 @@ function faq_order_settings_form($form_s
   }
 
   else {
-    $default_sorting = variable_get('faq_default_sorting', 'DESC');
+    $sorting = variable_get('faq_default_sorting', 'DESC');
     $default_weight = 0;
-    if ($default_sorting != 'DESC') {
+    if ($sorting != 'DESC') {
       $default_weight = 1000000;
+      $sorting = 'ASC';
     }
 
     $options = array();
@@ -375,32 +379,30 @@ function faq_order_settings_form($form_s
       $category = $form_state['values']['faq_category'];
     }
 
+    $query = db_select('node', 'n')
+      ->fields('n', array('nid', 'title', 'sticky', 'created'))
+      ->addExpression('if((w.weight IS NULL), :weight, w.weight)', 'weight', array(':weight' => $default_weight))
+      ->condition('type', 'faq')
+      ->condition('status', 1)
+      ->orderBy('weight', 'ASC')
+      ->orderBy('sticky', 'DESC')
+      ->orderBy('created', $sorting);
+
     // Uncategorized ordering.
     if (empty($category)) {
       $category = 0;
-      // Descending.
-      if ($default_sorting == 'DESC') {
-        $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = '%d' WHERE n.type='faq' AND n.status = 1 ORDER BY weight ASC, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $category);
-      }
-      // Ascending.
-      else {
-        $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = '%d' WHERE n.type='faq' AND n.status = 1 ORDER BY weight ASC, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $category);
-      }
     }
     // Categorized ordering.
     else {
-      // Descending.
-      if ($default_sorting == 'DESC') {
-        $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = '%d' WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight ASC, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $category, $category);
-      }
-      // Ascending.
-      else {
-        $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = '%d' WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight ASC, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $category, $category);
-      }
+      $tn_alias = $query->innerJoin('term_node', 'tn', 'n.nid = tn.nid AND n.vid = tn.vid');
+      $query->condition('tn.tid', $category);
     }
 
+    $w_alias = $query->leftJoin('faq_weights', 'w', 'n.nid = w.nid  AND w.tid = :tid', array(':tid' => $category));
+
+    $result = $query->execute();
 
-    while ($node = db_fetch_object($result)) {
+    foreach ($result as $node) {
       $options[$node->nid] = $node->title;
     }
 
Index: faq.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/faq.info,v
retrieving revision 1.1.2.3.2.1
diff -u -p -r1.1.2.3.2.1 faq.info
--- faq.info	5 Sep 2007 14:05:48 -0000	1.1.2.3.2.1
+++ faq.info	5 Apr 2010 05:36:40 -0000
@@ -1,4 +1,5 @@
 ; $Id: faq.info,v 1.1.2.3.2.1 2007/09/05 14:05:48 snpower Exp $
 name = Frequently Asked Questions
 description = "Manages configuration of questions for a FAQ page."
-core = 6.x
+core = 7.x
+files[] = 'faq.module'
\ No newline at end of file
Index: faq.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/Attic/faq.install,v
retrieving revision 1.1.4.16.2.28
diff -u -p -r1.1.4.16.2.28 faq.install
--- faq.install	29 Nov 2009 21:50:34 -0000	1.1.4.16.2.28
+++ faq.install	5 Apr 2010 05:36:40 -0000
@@ -39,7 +39,7 @@ function faq_schema() {
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  *
  * Inserts the FAQ module's schema in the SQL database.
  */
@@ -49,7 +49,7 @@ function faq_install() {
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  *
  * Remove the variables, nodes and schema corresponding to the FAQ module.
  */
Index: faq.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/faq.js,v
retrieving revision 1.1.2.6.2.20
diff -u -p -r1.1.2.6.2.20 faq.js
--- faq.js	20 Nov 2009 02:44:40 -0000	1.1.2.6.2.20
+++ faq.js	5 Apr 2010 05:36:40 -0000
@@ -1,234 +1,240 @@
 /* $Id: faq.js,v 1.1.2.6.2.20 2009/11/20 02:44:40 snpower Exp $ */
 
-function teaser_handler(event) {
-  if ($("input[name=faq_display]:checked").val() != "new_page") {
-    if ($("input[name=faq_use_teaser]:checked").val() == 1) {
+(function ($) {
+
+  function teaser_handler(event) {
+    if ($("input[name=faq_display]:checked").val() != "new_page") {
+      if ($("input[name=faq_use_teaser]:checked").val() == 1) {
+        $("input[name=faq_more_link]").removeAttr("disabled");
+      }
+      else {
+        $("input[name=faq_more_link]").attr("disabled", "disabled");
+      }
+    }
+  }
+  
+  function faq_display_handler(event) {
+    // Enable / disable "questions_inline" and "questions_top" only settings.
+    if ($("input[name=faq_display]:checked").val() == "questions_inline" || $("input[name=faq_display]:checked").val() == "questions_top") {
+      $("input[name=faq_back_to_top]").removeAttr("disabled");
+    }
+    else {
+      $("input[name=faq_back_to_top]").attr("disabled", "disabled");
+    }
+  
+    // Enable / disable "hide_answer" only settings.
+    if ($("input[name=faq_display]:checked").val() != "hide_answer") {
+      $("input[name=faq_hide_qa_accordion]").attr("disabled", "disabled");
+    }
+    else {
+      $("input[name=faq_hide_qa_accordion]").removeAttr("disabled");
+    }
+  
+    // Enable / disable "new_page" only settings.
+    if ($("input[name=faq_display]:checked").val() != "new_page") {
+      $("input[name=faq_use_teaser]").removeAttr("disabled");
       $("input[name=faq_more_link]").removeAttr("disabled");
+      $("input[name=faq_disable_node_links]").removeAttr("disabled");
     }
     else {
+      $("input[name=faq_use_teaser]").attr("disabled", "disabled");
       $("input[name=faq_more_link]").attr("disabled", "disabled");
+      $("input[name=faq_disable_node_links]").attr("disabled", "disabled");
     }
-  }
-}
-
-function faq_display_handler(event) {
-  // Enable / disable "questions_inline" and "questions_top" only settings.
-  if ($("input[name=faq_display]:checked").val() == "questions_inline" || $("input[name=faq_display]:checked").val() == "questions_top") {
-    $("input[name=faq_back_to_top]").removeAttr("disabled");
-  }
-  else {
-    $("input[name=faq_back_to_top]").attr("disabled", "disabled");
-  }
-
-  // Enable / disable "hide_answer" only settings.
-  if ($("input[name=faq_display]:checked").val() != "hide_answer") {
-    $("input[name=faq_hide_qa_accordion]").attr("disabled", "disabled");
-  }
-  else {
-    $("input[name=faq_hide_qa_accordion]").removeAttr("disabled");
-  }
-
-  // Enable / disable "new_page" only settings.
-  if ($("input[name=faq_display]:checked").val() != "new_page") {
-    $("input[name=faq_use_teaser]").removeAttr("disabled");
-    $("input[name=faq_more_link]").removeAttr("disabled");
-    $("input[name=faq_disable_node_links]").removeAttr("disabled");
-  }
-  else {
-    $("input[name=faq_use_teaser]").attr("disabled", "disabled");
-    $("input[name=faq_more_link]").attr("disabled", "disabled");
-    $("input[name=faq_disable_node_links]").attr("disabled", "disabled");
-  }
-  teaser_handler(event);
-
-  // Enable / disable "new_page" and "questions_top" only settings.
-  if ($("input[name=faq_display]:checked").val() == "new_page" ||
-    $("input[name=faq_display]:checked").val() == "questions_top") {
-    $("select[name=faq_question_listing]").removeAttr("disabled");
-  }
-  else {
-    $("select[name=faq_question_listing]").attr("disabled", "disabled");
-  }
-
-  // Enable / disable "questions_inline" only settings.
-  if ($("input[name=faq_display]:checked").val() == "questions_inline") {
-    $("input[name=faq_qa_mark]").removeAttr("disabled");
-    // Enable / disable label settings according to "qa_mark" setting.
-    if ($("input[name=faq_qa_mark]:checked").val() == 1) {
-      $("input[name=faq_question_label]").removeAttr("disabled");
-      $("input[name=faq_answer_label]").removeAttr("disabled");
+    teaser_handler(event);
+  
+    // Enable / disable "new_page" and "questions_top" only settings.
+    if ($("input[name=faq_display]:checked").val() == "new_page" ||
+      $("input[name=faq_display]:checked").val() == "questions_top") {
+      $("select[name=faq_question_listing]").removeAttr("disabled");
     }
     else {
-      $("input[name=faq_question_label]").attr("disabled", "disabled");
-      $("input[name=faq_answer_label]").attr("disabled", "disabled");
+      $("select[name=faq_question_listing]").attr("disabled", "disabled");
     }
-  }
-  else {
-    $("input[name=faq_qa_mark]").attr("disabled", "disabled");
-    $("input[name=faq_question_label]").attr("disabled", "disabled");
-    $("input[name=faq_answer_label]").attr("disabled", "disabled");
-  }
-}
-
-function qa_mark_handler(event) {
-  if ($("input[name=faq_display]:checked").val() == "questions_inline") {
-    // Enable / disable label settings according to "qa_mark" setting.
-    if ($("input[name=faq_qa_mark]:checked").val() == 1) {
-      $("input[name=faq_question_label]").removeAttr("disabled");
-      $("input[name=faq_answer_label]").removeAttr("disabled");
+  
+    // Enable / disable "questions_inline" only settings.
+    if ($("input[name=faq_display]:checked").val() == "questions_inline") {
+      $("input[name=faq_qa_mark]").removeAttr("disabled");
+      // Enable / disable label settings according to "qa_mark" setting.
+      if ($("input[name=faq_qa_mark]:checked").val() == 1) {
+        $("input[name=faq_question_label]").removeAttr("disabled");
+        $("input[name=faq_answer_label]").removeAttr("disabled");
+      }
+      else {
+        $("input[name=faq_question_label]").attr("disabled", "disabled");
+        $("input[name=faq_answer_label]").attr("disabled", "disabled");
+      }
     }
     else {
+      $("input[name=faq_qa_mark]").attr("disabled", "disabled");
       $("input[name=faq_question_label]").attr("disabled", "disabled");
       $("input[name=faq_answer_label]").attr("disabled", "disabled");
     }
   }
-}
-
-function questions_top_handler(event) {
-  $("input[name=faq_display]").val() == "questions_top" ?
-    $("input[name=faq_group_questions_top]").removeAttr("disabled"):
-    $("input[name=faq_group_questions_top]").attr("disabled", "disabled");
-
-  $("input[name=faq_display]").val() == "questions_top" ?
-    $("input[name=faq_answer_category_name]").removeAttr("disabled"):
-    $("input[name=faq_answer_category_name]").attr("disabled", "disabled");
-}
-
-
-function child_term_handler(event) {
-  if ($("input[name=faq_hide_child_terms]:checked").val() == 1) {
-    $("input[name=faq_show_term_page_children]").attr("disabled", "disabled");
-  }
-  else if ($("input[name=faq_category_display]:checked").val() != "categories_inline") {
-    $("input[name=faq_show_term_page_children]").removeAttr("disabled");
-  }
-}
-
-
-function categories_handler(event) {
-  if ($("input[name=faq_display]").val() == "questions_top") {
-    $("input[name=faq_category_display]:checked").val() == "categories_inline" ?
+  
+  function qa_mark_handler(event) {
+    if ($("input[name=faq_display]:checked").val() == "questions_inline") {
+      // Enable / disable label settings according to "qa_mark" setting.
+      if ($("input[name=faq_qa_mark]:checked").val() == 1) {
+        $("input[name=faq_question_label]").removeAttr("disabled");
+        $("input[name=faq_answer_label]").removeAttr("disabled");
+      }
+      else {
+        $("input[name=faq_question_label]").attr("disabled", "disabled");
+        $("input[name=faq_answer_label]").attr("disabled", "disabled");
+      }
+    }
+  }
+  
+  function questions_top_handler(event) {
+    $("input[name=faq_display]").val() == "questions_top" ?
       $("input[name=faq_group_questions_top]").removeAttr("disabled"):
       $("input[name=faq_group_questions_top]").attr("disabled", "disabled");
-    $("input[name=faq_category_display]:checked").val() == "new_page" ?
-      $("input[name=faq_answer_category_name]").attr("disabled", "disabled"):
-      $("input[name=faq_answer_category_name]").removeAttr("disabled");
-  }
-  else {
-    $("input[name=faq_group_questions_top]").attr("disabled", "disabled");
-  }
-
-  // Enable / disable "hide_qa" only settings.
-  if ($("input[name=faq_category_display]:checked").val() != "hide_qa") {
-    $("input[name=faq_category_hide_qa_accordion]").attr("disabled", "disabled");
-  }
-  else {
-    $("input[name=faq_category_hide_qa_accordion]").removeAttr("disabled");
-  }
-
-  $("input[name=faq_category_display]:checked").val() == "categories_inline" ?
-    $("input[name=faq_hide_child_terms]").attr("disabled", "disabled"):
-    $("input[name=faq_hide_child_terms]").removeAttr("disabled");
-  $("input[name=faq_category_display]:checked").val() == "categories_inline" ?
-    $("input[name=faq_show_term_page_children]").attr("disabled", "disabled"):
-    $("input[name=faq_show_term_page_children]").removeAttr("disabled");
-  $("input[name=faq_category_display]:checked").val() == "new_page" ?
-    $("select[name=faq_category_listing]").removeAttr("disabled"):
-    $("select[name=faq_category_listing]").attr("disabled", "disabled");
-
-  child_term_handler();
-}
-
-Drupal.behaviors.initFaqModule = function (context) {
-  // Hide/show answer for a question.
-  var faq_hide_qa_accordion = Drupal.settings.faq.faq_hide_qa_accordion;
-  if (faq_hide_qa_accordion) {
-    $('div.faq-dd-hide-answer').addClass("collapsible collapsed");
-  }
-  else {
-    $('div.faq-dd-hide-answer').hide();
-  }
-  $('div.faq-dt-hide-answer').click(function() {
-    $(this).toggleClass('faq-qa-visible');
-    if (faq_hide_qa_accordion) {
-      $('div.faq-dd-hide-answer').not($(this).next('div.faq-dd-hide-answer')).addClass("collapsed");
-      $(this).next('div.faq-dd-hide-answer').toggleClass("collapsed");
+  
+    $("input[name=faq_display]").val() == "questions_top" ?
+      $("input[name=faq_answer_category_name]").removeAttr("disabled"):
+      $("input[name=faq_answer_category_name]").attr("disabled", "disabled");
+  }
+  
+  
+  function child_term_handler(event) {
+    if ($("input[name=faq_hide_child_terms]:checked").val() == 1) {
+      $("input[name=faq_show_term_page_children]").attr("disabled", "disabled");
+    }
+    else if ($("input[name=faq_category_display]:checked").val() != "categories_inline") {
+      $("input[name=faq_show_term_page_children]").removeAttr("disabled");
+    }
+  }
+  
+  
+  function categories_handler(event) {
+    if ($("input[name=faq_display]").val() == "questions_top") {
+      $("input[name=faq_category_display]:checked").val() == "categories_inline" ?
+        $("input[name=faq_group_questions_top]").removeAttr("disabled"):
+        $("input[name=faq_group_questions_top]").attr("disabled", "disabled");
+      $("input[name=faq_category_display]:checked").val() == "new_page" ?
+        $("input[name=faq_answer_category_name]").attr("disabled", "disabled"):
+        $("input[name=faq_answer_category_name]").removeAttr("disabled");
     }
     else {
-      $(this).next('div.faq-dd-hide-answer').slideToggle('fast', function() {
-        $(this).parent().toggleClass('expanded');
-      });
+      $("input[name=faq_group_questions_top]").attr("disabled", "disabled");
     }
-    return false;
-  });
-
-
-  // Hide/show q/a for a category.
-  var faq_category_hide_qa_accordion = Drupal.settings.faq.faq_category_hide_qa_accordion;
-  if (faq_category_hide_qa_accordion) {
-    $('div.faq-qa-hide').addClass("collapsible collapsed");
-  }
-  else {
-    $('div.faq-qa-hide').hide();
-  }
-  $('div.faq-qa-header .faq-header').click(function() {
-    $(this).toggleClass('faq-category-qa-visible');
-    if (faq_category_hide_qa_accordion) {
-      $('div.faq-qa-hide').not($(this).parent().next('div.faq-qa-hide')).addClass("collapsed");
-      $(this).parent().next('div.faq-qa-hide').toggleClass("collapsed");
+  
+    // Enable / disable "hide_qa" only settings.
+    if ($("input[name=faq_category_display]:checked").val() != "hide_qa") {
+      $("input[name=faq_category_hide_qa_accordion]").attr("disabled", "disabled");
     }
     else {
-      $(this).parent().next('div.faq-qa-hide').slideToggle('fast', function() {
-        $(this).parent().toggleClass('expanded');
-      });
+      $("input[name=faq_category_hide_qa_accordion]").removeAttr("disabled");
+    }
+  
+    $("input[name=faq_category_display]:checked").val() == "categories_inline" ?
+      $("input[name=faq_hide_child_terms]").attr("disabled", "disabled"):
+      $("input[name=faq_hide_child_terms]").removeAttr("disabled");
+    $("input[name=faq_category_display]:checked").val() == "categories_inline" ?
+      $("input[name=faq_show_term_page_children]").attr("disabled", "disabled"):
+      $("input[name=faq_show_term_page_children]").removeAttr("disabled");
+    $("input[name=faq_category_display]:checked").val() == "new_page" ?
+      $("select[name=faq_category_listing]").removeAttr("disabled"):
+      $("select[name=faq_category_listing]").attr("disabled", "disabled");
+  
+    child_term_handler();
+  }
+  
+  Drupal.behaviors.initFaqModule = {
+    attach: function (context) {
+      // Hide/show answer for a question.
+      var faq_hide_qa_accordion = Drupal.settings.faq.faq_hide_qa_accordion;
+      if (faq_hide_qa_accordion) {
+        $('div.faq-dd-hide-answer').addClass("collapsible collapsed");
+      }
+      else {
+        $('div.faq-dd-hide-answer').hide();
+      }
+      $('div.faq-dt-hide-answer').click(function() {
+        $(this).toggleClass('faq-qa-visible');
+        if (faq_hide_qa_accordion) {
+          $('div.faq-dd-hide-answer').not($(this).next('div.faq-dd-hide-answer')).addClass("collapsed");
+          $(this).next('div.faq-dd-hide-answer').toggleClass("collapsed");
+        }
+        else {
+          $(this).next('div.faq-dd-hide-answer').slideToggle('fast', function() {
+            $(this).parent().toggleClass('expanded');
+          });
+        }
+        return false;
+      });
+    
+    
+      // Hide/show q/a for a category.
+      var faq_category_hide_qa_accordion = Drupal.settings.faq.faq_category_hide_qa_accordion;
+      if (faq_category_hide_qa_accordion) {
+        $('div.faq-qa-hide').addClass("collapsible collapsed");
+      }
+      else {
+        $('div.faq-qa-hide').hide();
+      }
+      $('div.faq-qa-header .faq-header').click(function() {
+        $(this).toggleClass('faq-category-qa-visible');
+        if (faq_category_hide_qa_accordion) {
+          $('div.faq-qa-hide').not($(this).parent().next('div.faq-qa-hide')).addClass("collapsed");
+          $(this).parent().next('div.faq-qa-hide').toggleClass("collapsed");
+        }
+        else {
+          $(this).parent().next('div.faq-qa-hide').slideToggle('fast', function() {
+            $(this).parent().toggleClass('expanded');
+          });
+        }
+        return false;
+      });
+    
+    
+      // Show expand all link. 
+      if (!faq_hide_qa_accordion && !faq_category_hide_qa_accordion) {
+        $('#faq-expand-all').show();
+        $('#faq-expand-all a.faq-expand-all-link').show();
+    
+        // Add collapse link click event.
+        $('#faq-expand-all a.faq-collapse-all-link').click(function () {
+          $(this).hide();
+          $('#faq-expand-all a.faq-expand-all-link').show();
+          $('div.faq-qa-hide').slideUp('slow', function() {
+            $(this).removeClass('expanded');
+          });
+          $('div.faq-dd-hide-answer').slideUp('slow', function() {
+            $(this).removeClass('expanded');
+          });
+        });
+    
+        // Add expand link click event.
+        $('#faq-expand-all a.faq-expand-all-link').click(function () {
+          $(this).hide();
+          $('#faq-expand-all a.faq-collapse-all-link').show();
+          $('div.faq-qa-hide').slideDown('slow', function() {
+            $(this).addClass('expanded');
+          });
+          $('div.faq-dd-hide-answer').slideDown('slow', function() {
+            $(this).addClass('expanded');
+          });
+        });
+      }
+    
+    
+    
+      // Handle faq_category_settings_form.
+      faq_display_handler();
+      questions_top_handler();
+      categories_handler();
+      teaser_handler();
+      $("input[name=faq_display]").bind("click", faq_display_handler);
+      $("input[name=faq_qa_mark]").bind("click", qa_mark_handler);
+      $("input[name=faq_use_teaser]").bind("click", teaser_handler);
+      $("input[name=faq_category_display]").bind("click", categories_handler);
+      $("input[name=faq_hide_child_terms]").bind("click", child_term_handler);
+    
     }
-    return false;
-  });
-
-
-  // Show expand all link. 
-  if (!faq_hide_qa_accordion && !faq_category_hide_qa_accordion) {
-    $('#faq-expand-all').show();
-    $('#faq-expand-all a.faq-expand-all-link').show();
-
-    // Add collapse link click event.
-    $('#faq-expand-all a.faq-collapse-all-link').click(function () {
-      $(this).hide();
-      $('#faq-expand-all a.faq-expand-all-link').show();
-      $('div.faq-qa-hide').slideUp('slow', function() {
-        $(this).removeClass('expanded');
-      });
-      $('div.faq-dd-hide-answer').slideUp('slow', function() {
-        $(this).removeClass('expanded');
-      });
-    });
-
-    // Add expand link click event.
-    $('#faq-expand-all a.faq-expand-all-link').click(function () {
-      $(this).hide();
-      $('#faq-expand-all a.faq-collapse-all-link').show();
-      $('div.faq-qa-hide').slideDown('slow', function() {
-        $(this).addClass('expanded');
-      });
-      $('div.faq-dd-hide-answer').slideDown('slow', function() {
-        $(this).addClass('expanded');
-      });
-    });
   }
 
-
-
-  // Handle faq_category_settings_form.
-  faq_display_handler();
-  questions_top_handler();
-  categories_handler();
-  teaser_handler();
-  $("input[name=faq_display]").bind("click", faq_display_handler);
-  $("input[name=faq_qa_mark]").bind("click", qa_mark_handler);
-  $("input[name=faq_use_teaser]").bind("click", teaser_handler);
-  $("input[name=faq_category_display]").bind("click", categories_handler);
-  $("input[name=faq_hide_child_terms]").bind("click", child_term_handler);
-
-}
+})(jQuery);
 
 
Index: faq.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/faq.module,v
retrieving revision 1.1.4.52.2.128
diff -u -p -r1.1.4.52.2.128 faq.module
--- faq.module	23 Dec 2009 18:13:12 -0000	1.1.4.52.2.128
+++ faq.module	5 Apr 2010 05:36:42 -0000
@@ -8,7 +8,7 @@
  */
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function faq_help($path, $arg) {
 
@@ -16,10 +16,10 @@ function faq_help($path, $arg) {
 
   switch ($path) {
     case "admin/help#faq":
-      $output .= '<p>'. t("This module allows users with the 'administer faq' permission to create question and answer pairs which will be displayed on the 'faq' page.  The 'faq' page is automatically generated from the FAQ nodes configured and the layout of this page can be modified on the settings page.  Users will need the 'view faq page' permission in order to view the 'faq' page.") .'</p>'.
-        '<p>'. t("To create a question and answer, the user must create a 'FAQ' node (Create content >> FAQ).  This screen allows the user to edit the question and answer text.  If the 'Taxonomy' module is enabled and there are some terms configured for the FAQ node type, it will also be possible to put the questions into different categories when editing.") .'</p>'.
-        '<p>'. t("The 'Frequently Asked Questions' settings configuration screen will allow users with 'administer faq' permissions to specify different layouts of the questions and answers.") .'</p>'.
-        '<p>'. t("All users with 'view faq page' permissions will be able to view the generated FAQ page at 'www.example.com/faq'.") .'</p>';
+      $output .= '<p>' . t("This module allows users with the 'administer faq' permission to create question and answer pairs which will be displayed on the 'faq' page.  The 'faq' page is automatically generated from the FAQ nodes configured and the layout of this page can be modified on the settings page.  Users will need the 'view faq page' permission in order to view the 'faq' page.") . '</p>' .
+        '<p>' . t("To create a question and answer, the user must create a 'FAQ' node (Create content >> FAQ).  This screen allows the user to edit the question and answer text.  If the 'Taxonomy' module is enabled and there are some terms configured for the FAQ node type, it will also be possible to put the questions into different categories when editing.") . '</p>' .
+        '<p>' . t("The 'Frequently Asked Questions' settings configuration screen will allow users with 'administer faq' permissions to specify different layouts of the questions and answers.") . '</p>' .
+        '<p>' . t("All users with 'view faq page' permissions will be able to view the generated FAQ page at 'www.example.com/faq'.") . '</p>';
       return $output;
     case "admin/modules#description":
       return t("Allows the user to configure the layout of questions and answers on a FAQ page.");
@@ -30,17 +30,42 @@ function faq_help($path, $arg) {
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_permission().
  */
-function faq_perm() {
-  return array('administer faq', 'view faq page', 'edit own faq', 'edit faq', 'create faq', 'administer faq order');
+function faq_permission() {
+  return array(
+    'administer faq' => array(
+      'title' => t('Administer FAQ'),
+      'description' => t('Administer Frequently Asked Questions')
+    ),
+    'view faq page' => array(
+      'title' => t('View FAQ Page'),
+      'description' => t('View Frequently Asked Questions Page')
+    ),
+    'edit own faq' => array(
+      'title' => t('Edit Own FAQ'),
+      'description' => t('Edit Own Frequently Asked Questions')
+    ),
+    'edit faq' => array(
+      'title' => t('Edit FAQ'),
+      'description' => t('Edit Frequently Asked Questions')
+    ),
+    'create faq' => array(
+      'title' => t('Create FAQ'),
+      'description' => t('Create Frequently Asked Questions')
+    ),
+    'administer faq order' => array(
+      'title' => t('Administer FAQ Order'),
+      'description' => t('Administer Frequently Asked Questions Order')
+    ),
+  );
 }
 
 
 /**
- * Implementation of hook_access().
+ * Implements hook_node_access().
  */
-function faq_access($op, $node, $account = NULL) {
+function faq_node_access($node, $op, $account) {
   global $user;
   if (empty($account)) {
     $account = $user;
@@ -65,7 +90,7 @@ function faq_access($op, $node, $account
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function faq_menu() {
   $items = array();
@@ -175,7 +200,7 @@ function faq_menu() {
 }
 
 /**
- * Implementation of hook_node_info().
+ * Implements hook_node_info().
  *
  * Defines the FAQ node/content type.
  * @return
@@ -185,7 +210,7 @@ function faq_node_info() {
   return array(
     'faq' => array(
       'name' => t('FAQ'),
-      'module' => 'faq',
+      'base' => 'faq',
       'description' => t('A frequently asked question and its answer.'),
       'title_label' => t('Question'),
       'body_label' => t('Answer'),
@@ -205,7 +230,7 @@ function faq_node_info() {
  *   The form elements in the $form array.
  */
 function faq_form(&$node, &$param) {
-  $type = node_get_types('type', $node);
+  $type = node_type_get_type($node);
 
   // Short question.
   $form['title'] = array(
@@ -221,7 +246,7 @@ function faq_form(&$node, &$param) {
   $form['detailed_question'] = array(
     '#type' => 'textarea',
     '#title' => t('Question details (optional)'),
-    '#default_value' => $node->detailed_question,
+    '#default_value' => (isset($node->detailed_question)) ? $node->detailed_question : '',
     '#weight' => -1,
     '#rows' => 3,
     '#description' => t('Longer question text.  This will be displayed in all layouts where the answer appears, in addition to the shorter question text.'),
@@ -229,8 +254,10 @@ function faq_form(&$node, &$param) {
 
   // Answer.
   if (!empty($type->body_label)) {
+/*
     $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
     $form['body_field']['body']['#description'] = t('This is that answer to the question.  It will be filtered according to the input format.');
+*/
   }
 
   return $form;
@@ -244,7 +271,14 @@ function faq_form(&$node, &$param) {
  *   The node object.
  */
 function faq_insert($node) {
-  $ret = db_query("INSERT INTO {faq_questions} (nid, vid, question, detailed_question) VALUES(%d, %d, '%s', '%s')", $node->nid, $node->vid, $node->title, $node->detailed_question);
+  db_insert('faq_questions')
+    ->fields(array(
+      'nid' => $node->nid,
+      'vid' => $node->vid,
+      'question' => $node->title,
+      'detailed_question' => $node->detailed_question,
+    ))
+    ->execute();
 }
 
 /**
@@ -258,8 +292,16 @@ function faq_update($node) {
     faq_insert($node);
   }
   else {
-    db_query("UPDATE {faq_questions} SET question = '%s', detailed_question = '%s' WHERE nid = %d AND vid = %d", $node->title, $node->detailed_question, $node->nid, $node->vid);
-    if (!db_affected_rows()) {
+    $affected = db_update('faq_questions')
+      ->fields(array(
+        'question' => $node->title,
+         'detailed_question' => $node->detailed_question,
+      ))
+      ->condition('nid', $node->nid)
+      ->condition('vid', $node->vid)
+      ->execute();
+  
+    if (!$affected) {
       faq_insert($node);
     }
   }
@@ -272,46 +314,64 @@ function faq_update($node) {
  *   Which node to delete.
  */
 function faq_delete(&$node) {
-  db_query("DELETE FROM {faq_weights} WHERE nid = '%d'", $node->nid);
-  db_query("DELETE FROM {faq_questions} WHERE nid = '%d'", $node->nid);
+  db_delete('faq_weights')
+    ->condition('nid', $node->nid)
+    ->execute();
+  db_delete('faq_questions')
+    ->condition('nid', $node->nid)
+    ->execute();
 }
 
 /**
- * Implementation of hook_load().
+ * Implements hook_load().
  *
  * Initialises $node->question using the value in the 'faq_questions' table.
  *
- * @param $node
- *   The node object.
+ * @param $nodes
+ *   The nodes array.
  */
-function faq_load($node) {
-  $result = db_fetch_object(db_query('SELECT question, detailed_question FROM {faq_questions} WHERE nid = %d AND vid = %d', $node->nid, $node->vid));
-  if ($result && !drupal_match_path($_GET['q'], 'node/'. $node->nid .'/edit')) {
-    $question_length = variable_get('faq_question_length', 'short');
-    if ($question_length == 'long' && !empty($result->detailed_question)) {
-      $result->title = $result->detailed_question;
-    }
-    else {
-      $result->title = $result->question;
+function faq_load(&$nodes) {
+
+  foreach ($nodes as $nid => $node) {
+
+    $result = db_select('faq_questions', 'fq')
+      ->fields('fq', array('question', 'detailed_question'))
+      ->condition('nid', $node->nid)
+      ->condition('vid', $node->vid)
+      ->execute()
+      ->fetchObject();
+
+    if ($result) {
+    
+      $nodes[$nid]->detailed_question = $result->detailed_question;
+    
+      if (!drupal_match_path($_GET['q'], 'node/' . $node->nid . '/edit')) {
+        $question_length = variable_get('faq_question_length', 'short');
+        if ($question_length == 'long' && !empty($result->detailed_question)) {
+          $nodes[$nid]->title = $result->detailed_question;
+        }
+        else {
+          $nodes[$nid]->title = $result->question;
+        }
+      }
+      
     }
-  }
-  return $result;
+  
+  } // foreach
 }
 
 /**
- * Implementation of hook_nodeapi().
+ * Implements hook_node_delete().
  */
-function faq_nodeapi(&$node, $op, $teaser, $page) {
-  switch ($op) {
-    case 'delete revision':
-      db_query('DELETE FROM {faq_questions} WHERE nid = %d AND vid = %d', $node->nid, $node->vid);
-      break;
-  }
+function faq_node_delete($node) {
+  db_delete('faq_questions')
+    ->condition('nid', $node->nid)
+    ->condition('vid', $node->vid)
+    ->execute();
 }
 
-
 /**
- * Implementation of hook_view().
+ * Implements hook_view().
  *
  * @param $node
  *   Which node to show.
@@ -324,13 +384,13 @@ function faq_nodeapi(&$node, $op, $tease
  *   The node object.
  */
 function faq_view($node, $teaser = FALSE, $page = FALSE) {
-  drupal_add_css(drupal_get_path('module', 'faq') .'/faq.css');
-  $node = node_prepare($node, $teaser);
+  drupal_add_css(drupal_get_path('module', 'faq') . '/faq.css');
+  //$node = node_prepare($node, $teaser);
   $node->detailed_question = check_markup($node->detailed_question, $node->format, FALSE);
   $content = $node->content['body']['#value'];
 
   if (!empty($node->detailed_question) && variable_get('faq_question_length', 'short') == 'both' && (variable_get('faq_display', 'questions_top') == 'hide_answer' || drupal_match_path($_GET['q'], 'node/' . $node->nid))) {
-    $node->content['body']['#value'] = '<div class="faq-detailed-question">'. $node->detailed_question .'</div>'. $content;
+    $node->content['body']['#value'] = '<div class="faq-detailed-question">' . $node->detailed_question . '</div>' . $content;
   }
 
   return $node;
@@ -359,19 +419,19 @@ function faq_page($tid = 0, $faq_display
   $default_values = array(t('Frequently Asked Questions'), t('Back to Top'), t('Q:'), t('A:'));
 
   $output = $output_answers = '';
-  drupal_add_css(drupal_get_path('module', 'faq') .'/faq.css');
+  drupal_add_css(drupal_get_path('module', 'faq') . '/faq.css');
   if (arg(0) == 'faq') {
-    drupal_set_title(check_plain(variable_get('faq_title', 'Frequently Asked Questions')));
+    drupal_set_title(variable_get('faq_title', 'Frequently Asked Questions'));
   }
   if (!module_exists("taxonomy")) {
     $tid = 0;
   }
 
   // Configure the breadcrumb trail.
-  if (!empty($tid) && $current_term = taxonomy_get_term($tid)) {
-    if (!drupal_lookup_path('alias', arg(0) .'/'. arg(1)) && module_exists('pathauto')) {
-      $placeholders = pathauto_get_placeholders('taxonomy', taxonomy_get_term($tid));
-      if ($alias = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) .'/'. arg(1), arg(1))) {
+  if (!empty($tid) && $current_term = taxonomy_term_load($tid)) {
+    if (!drupal_lookup_path('alias', arg(0) . '/' . arg(1)) && module_exists('pathauto')) {
+      $placeholders = pathauto_get_placeholders('taxonomy', taxonomy_term_load($tid));
+      if ($alias = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) . '/' . arg(1), arg(1))) {
         drupal_goto($alias);
       }
     }
@@ -395,12 +455,12 @@ function faq_page($tid = 0, $faq_display
     $use_categories = FALSE;
   }
 
-  $faq_path = drupal_get_path('module', 'faq') .'/includes';
+  $faq_path = drupal_get_path('module', 'faq') . '/includes';
 
   if (($use_categories && $category_display == 'hide_qa') || $faq_display == 'hide_answer') {
     drupal_add_js(array('faq' => array('faq_hide_qa_accordion' => variable_get('faq_hide_qa_accordion', FALSE))), 'setting');
     drupal_add_js(array('faq' => array('faq_category_hide_qa_accordion' => variable_get('faq_category_hide_qa_accordion', FALSE))), 'setting');
-    drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');
+    drupal_add_js(drupal_get_path('module', 'faq') . '/faq.js', 'module');
   }
 
   // Non-categorized questions and answers.
@@ -409,41 +469,59 @@ function faq_page($tid = 0, $faq_display
       drupal_not_found();
       return;
     }
-    $default_sorting = variable_get('faq_default_sorting', 'DESC');
+    $sorting = variable_get('faq_default_sorting', 'DESC');
     $default_weight = 0;
-    if ($default_sorting != 'DESC') {
+    if ($sorting != 'DESC') {
       $default_weight = 1000000;
-      $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight);
+      $sorting = 'ASC';
     }
-    else {
-      $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight);
-    }
-    $data = array();
-    while ($row = db_fetch_object($result)) {
+
+    $query = db_select('node', 'n')
+      ->fields('n', array('nid', 'title', 'sticky', 'created'));
+      
+    $w_alias = $query->leftJoin('faq_weights', 'w', 'w.nid = n.nid');
+    $weight_alias = $query->addExpression('if((' . $w_alias . '.weight IS NULL), :weight, ' . $w_alias . '.weight)', 'weight', array(':weight' => $default_weight));
+
+    $query
+      ->condition('type', 'faq')
+      ->condition('status', 1)
+      ->condition(
+        db_or()
+          ->condition($w_alias . '.tid', 0)
+          ->isNull($w_alias . '.tid')
+        )
+      ->orderBy($weight_alias, 'ASC')
+      ->orderBy('sticky', 'DESC')
+      ->orderBy('created', $sorting);
+
+    $result = $query->execute();
+
+    $data = array('data' => array());
+    foreach ($result as $row) {
       $node = node_load($row->nid);
       if (node_access("view", $node)) {
-        $data[] = $node;
+        $data['data'][] = $node;
       }
     }
 
     switch ($faq_display) {
       case 'questions_top':
-        include_once($faq_path .'/faq.questions_top.inc');
+        include_once($faq_path . '/faq.questions_top.inc');
         $output = theme('faq_questions_top', $data);
         break;
 
       case 'hide_answer':
-        include_once($faq_path .'/faq.hide_answer.inc');
+        include_once($faq_path . '/faq.hide_answer.inc');
         $output = theme('faq_hide_answer', $data);
         break;
 
       case 'questions_inline':
-        include_once($faq_path .'/faq.questions_inline.inc');
+        include_once($faq_path . '/faq.questions_inline.inc');
         $output = theme('faq_questions_inline', $data);
         break;
 
       case 'new_page':
-        include_once($faq_path .'/faq.new_page.inc');
+        include_once($faq_path . '/faq.new_page.inc');
         $output = theme('faq_new_page', $data);
         break;
 
@@ -458,10 +536,10 @@ function faq_page($tid = 0, $faq_display
 
     // If we're viewing a specific category/term.
     if (!empty($tid)) {
-      if ($term = taxonomy_get_term($tid)) {
+      if ($term = taxonomy_term_load($tid)) {
         $title = variable_get('faq_title', 'Frequently Asked Questions');
         if (arg(0) == 'faq' && is_numeric(arg(1))) {
-          drupal_set_title(check_plain($title . ($title ? ' - ' : '') . faq_tt("taxonomy:term:$term->tid:name", $term->name)));
+          drupal_set_title($title . ($title ? ' - ' : '') . faq_tt("taxonomy:term:$term->tid:name", $term->name));
         }
         _display_faq_by_category($faq_display, $category_display, $term, 0, $output, $output_answers);
         return theme('faq_page', $output, $output_answers);
@@ -491,7 +569,7 @@ function faq_page($tid = 0, $faq_display
       // Not a new page.
       else {
         if ($hide_child_terms && $category_display == 'hide_qa') {
-          $tree = taxonomy_get_tree($vid, 0, -1, 1);
+          $tree = taxonomy_get_tree($vid, 0, 1, -1);
         }
         else {
           $tree = taxonomy_get_tree($vid);
@@ -521,7 +599,7 @@ function faq_page($tid = 0, $faq_display
   $faq_description = variable_get('faq_description', '');
   $format = variable_get('faq_description_format', 0);
   if ($format) {
-    $faq_description = check_markup($faq_description, $format, FALSE);
+    $faq_description = check_markup($faq_description, $format, '');
   }
   return theme('faq_page', $output, $output_answers, $faq_description);
 }
@@ -546,24 +624,38 @@ function faq_page($tid = 0, $faq_display
  */
 function _display_faq_by_category($faq_display, $category_display, $term, $display_header, &$output, &$output_answers) {
 
-  $default_sorting = variable_get('faq_default_sorting', 'DESC');
+  $sorting = variable_get('faq_default_sorting', 'DESC');
   $default_weight = 0;
-  if ($default_sorting != 'DESC') {
+  if ($sorting != 'DESC') {
     $default_weight = 1000000;
-    $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $term->tid);
-  }
-  else {
-    $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $term->tid);
+    $sorting = 'ASC';
   }
+
+  $query = db_select('node', 'n')
+    ->fields('n', array('nid', 'title', 'sticky', 'created'));
+  
+  $tn_alias = $query->innerJoin('term_node', 'tn', 'n.nid = tn.nid AND n.vid = tn.vid');
+  $w_alias = $query->leftJoin('faq_weights', 'w', 'n.nid = w.nid  AND w.tid = tn.tid');
+  $weight_alias = $query->addExpression('if((' . $w_alias .'.weight IS NULL), :weight, ' . $w_alias . '.weight)', 'weight', array(':weight' => $default_weight));
+  
+  $query
+    ->condition('type', 'faq')
+    ->condition('status', 1)
+    ->condition($tn_alias . '.tid', $term->tid)
+    ->orderBy($weight_alias, 'ASC')
+    ->orderBy('sticky', 'DESC')
+    ->orderBy('created', $sorting);
+
+  $result = $query->execute();
+
   $data = array();
-  while ($row = db_fetch_object($result)) {
+  foreach ($result as $row) {
     $node = node_load($row->nid);
     if (node_access("view", $node)) {
       $data[] = $node;
     }
   }
 
-
   // Handle indenting of categories.
   $depth = 0;
   if (!isset($term->depth)) $term->depth = 0;
@@ -580,12 +672,12 @@ function _display_faq_by_category($faq_d
     $faq_class = "faq-qa-hide";
   }
 
-  $faq_path = drupal_get_path('module', 'faq') .'/includes';
+  $faq_path = drupal_get_path('module', 'faq') . '/includes';
 
   switch ($faq_display) {
 
     case 'questions_top':
-      include_once($faq_path .'/faq.questions_top.inc');
+      include_once($faq_path . '/faq.questions_top.inc');
       // @todo fix workaround: have to share result.
       $output .= theme('faq_category_questions_top', $data, $display_header, $category_display, $term, $faq_class, $term);
       $output_answers .= theme('faq_category_questions_top_answers', $data, $display_header, $category_display, $term, $faq_class, $term);
@@ -593,19 +685,19 @@ function _display_faq_by_category($faq_d
 
 
     case 'hide_answer':
-      include_once($faq_path .'/faq.hide_answer.inc');
+      include_once($faq_path . '/faq.hide_answer.inc');
       $output .= theme('faq_category_hide_answer', $data, $display_header, $category_display, $term, $faq_class, $term);
       break;
 
 
     case 'questions_inline':
-      include_once($faq_path .'/faq.questions_inline.inc');
+      include_once($faq_path . '/faq.questions_inline.inc');
       $output .= theme('faq_category_questions_inline', $data, $display_header, $category_display, $term, $faq_class, $term);
       break;
 
 
     case 'new_page':
-      include_once($faq_path .'/faq.new_page.inc');
+      include_once($faq_path . '/faq.new_page.inc');
       $output .= theme('faq_category_new_page', $data, $display_header, $category_display, $term, $faq_class, $term);
       break;
 
@@ -621,10 +713,10 @@ function _display_faq_by_category($faq_d
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function faq_theme() {
-  $path = drupal_get_path('module', 'faq') .'/includes';
+  $path = drupal_get_path('module', 'faq') . '/includes';
   return array(
     'faq_draggable_question_order_table' => array(
       'arguments' => array('form' => NULL),
@@ -690,117 +782,125 @@ function faq_theme() {
 }
 
 /**
- * Implementation of hook_block().
- *
- * Create the code of the FAQ page providing three block types: FAQ Categories,
- * Recent FAQs and Random FAQs.
+ * Implements hook_block_list().
  */
-function faq_block($op = 'list', $delta = 0, $edit = array()) {
-  static $vocabularies, $terms;
+function faq_block_list() {
 
-  switch ($op) {
+  $blocks[0]['info'] = t('FAQ Categories');
+  $blocks[1]['info'] = t('Recent FAQs');
+  $blocks[2]['info'] = t('Random FAQs');
+  return $blocks;
 
-    case 'list':
-      $blocks[0]['info'] = t('FAQ Categories');
-      $blocks[1]['info'] = t('Recent FAQs');
-      $blocks[2]['info'] = t('Random FAQs');
-      return $blocks;
-
-    case 'view':
-      $block = array();
-      switch ($delta) {
-        case 0:
-          // FAQ Categories.
-          if (module_exists('taxonomy')) {
-            if (!isset($terms)) {
-              $terms = array();
-              $vocabularies = taxonomy_get_vocabularies('faq');
-              $vocab_omit = array_flip(variable_get('faq_omit_vocabulary', array()));
-              $vocabularies = array_diff_key($vocabularies, $vocab_omit);
-              foreach ($vocabularies as $vocab) {
-                foreach (taxonomy_get_tree($vocab->vid) as $term) {
-                  if (taxonomy_term_count_nodes($term->tid, 'faq')) {
-                    $terms[$term->name] = $term->tid;
-                  }
-                }
-              }
-            }
-            if (count($terms) > 0) {
-              $block['subject'] = t('FAQ Categories');
-              $items = array();
-              foreach ($terms as $name => $tid) {
-                $items[] = l(faq_tt("taxonomy:term:$tid:name", $name), 'faq/'. $tid);
+} // faq_block_list
+
+/**
+ * Implements hook_block_view().
+ */
+function faq_block_view($delta = '') {
+
+  $block = array();
+  switch ($delta) {
+    case 0:
+      // FAQ Categories.
+      if (module_exists('taxonomy')) {
+        if (!isset($terms)) {
+          $terms = array();
+          $vocabularies = taxonomy_get_vocabularies('faq');
+          $vocab_omit = array_flip(variable_get('faq_omit_vocabulary', array()));
+          $vocabularies = array_diff_key($vocabularies, $vocab_omit);
+          foreach ($vocabularies as $vocab) {
+            foreach (taxonomy_get_tree($vocab->vid) as $term) {
+              if (taxonomy_term_count_nodes($term->tid, 'faq')) {
+                $terms[$term->name] = $term->tid;
               }
-              $list_style = variable_get('faq_category_listing', 'ul');
-              $block['content'] = theme('item_list', $items, NULL, $list_style);
             }
           }
-          break;
+        }
+        if (count($terms) > 0) {
+          $block['subject'] = t('FAQ Categories');
+          $items = array();
+          foreach ($terms as $name => $tid) {
+            $items[] = l(faq_tt("taxonomy:term:$tid:name", $name), 'faq/' . $tid);
+          }
+          $list_style = variable_get('faq_category_listing', 'ul');
+          $block['content'] = theme('item_list', $items, NULL, $list_style);
+        }
+      }
+      break;
 
 
-        case 1:
-          // Recent FAQs.
-          $block['subject'] = t('Recent FAQs');
-          $block['content'] = faq_highlights_block(variable_get('faq_block_recent_faq_count', 5));
-          break;
+    case 1:
+      // Recent FAQs.
+      $block['subject'] = t('Recent FAQs');
+      $block['content'] = faq_highlights_block_content(variable_get('faq_block_recent_faq_count', 5));
+      break;
 
-        case 2:
-          // Random FAQs.
-          $block['subject'] = t('Random FAQs');
-          $block['content'] = faq_random_highlights_block(variable_get('faq_block_random_faq_count', 5));
-          break;
+    case 2:
+      // Random FAQs.
+      $block['subject'] = t('Random FAQs');
+      $block['content'] = faq_random_highlights_block_content(variable_get('faq_block_random_faq_count', 5));
+      break;
 
-      } // End switch($delta).
+  } // End switch($delta).
 
-      return $block;
+  return $block;
 
+} // faq_block_view
 
-    case 'configure':
-      switch ($delta) {
-        case 0:
-          return;
-
-        case 1:
-          // Recent FAQs.
-          $form['faq_block_recent_faq_count'] = array(
-            '#type' => 'textfield',
-            '#title' => t('Number of FAQs to show'),
-            '#description' => t("This controls the number of FAQs that appear in the 'Recent FAQs' block"),
-            '#default_value' => variable_get('faq_block_recent_faq_count', 5),
-          );
-          break;
+/**
+ * Implements hook_block_save().
+ */
+function faq_block_save($delta = '', $edit = array()) {
 
-        case 2:
-          // Random FAQs.
-          $form['faq_block_random_faq_count'] = array(
-            '#type' => 'textfield',
-            '#title' => t('Number of FAQs to show'),
-            '#description' => t("This controls the number of FAQs that appear in the 'Random FAQs' block"),
-            '#default_value' => variable_get('faq_block_random_faq_count', 5),
-          );
-          break;
-      } // End switch($delta).
+  switch ($delta) {
+    case 0:
+      break;
 
-      return $form;
+    case 1:
+      variable_set('faq_block_recent_faq_count', $edit['faq_block_recent_faq_count']);
+      break;
 
-    case 'save':
-      switch ($delta) {
-        case 0:
-          break;
+    case 2:
+      variable_set('faq_block_random_faq_count', $edit['faq_block_random_faq_count']);
+      break;
+  } // End switch($delta).
+  return;
 
-        case 1:
-          variable_set('faq_block_recent_faq_count', $edit['faq_block_recent_faq_count']);
-          break;
+} // faq_block_save
 
-        case 2:
-          variable_set('faq_block_random_faq_count', $edit['faq_block_random_faq_count']);
-          break;
-      } // End switch($delta).
+/**
+ * Implements hook_block_configure().
+ */
+function faq_block_configure($delta = '') {
+
+  switch ($delta) {
+    case 0:
       return;
 
-  } // End switch($op).
+    case 1:
+      // Recent FAQs.
+      $form['faq_block_recent_faq_count'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Number of FAQs to show'),
+        '#description' => t("This controls the number of FAQs that appear in the 'Recent FAQs' block"),
+        '#default_value' => variable_get('faq_block_recent_faq_count', 5),
+      );
+      break;
+
+    case 2:
+      // Random FAQs.
+      $form['faq_block_random_faq_count'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Number of FAQs to show'),
+        '#description' => t("This controls the number of FAQs that appear in the 'Random FAQs' block"),
+        '#default_value' => variable_get('faq_block_random_faq_count', 5),
+      );
+      break;
+  } // End switch($delta).
+
+  return $form;
 
-}
+} // faq_block_configure
 
 /**
  * Create the HTML output for the Recent FAQs block.
@@ -810,27 +910,34 @@ function faq_block($op = 'list', $delta 
  * @return
  *   The HTML-formatted code displaying the Recent FAQs.
  */
-function faq_highlights_block($num = 5) {
+function faq_highlights_block_content($num = 5) {
   $disable_node_links = variable_get('faq_disable_node_links', FALSE);
 
-  $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type='faq' AND n.status = 1 ORDER BY n.created DESC", "n", "nid"), 0, $num);
+  $query = db_select('node', 'n')
+    ->fields('n', array('nid', 'created'))
+    ->condition('type', 'faq')
+    ->condition('status', 1)
+    ->orderBy('created', 'DESC')
+    ->range(0, $num);
+
+  $result = $query->execute();
 
   $items = array();
-  while ($row = db_fetch_object($result)) {
-    $node = node_load(array('nid' => $row->nid));
+  foreach ($result as $row) {
+    $node = node_load($row->nid);
     $node = node_prepare($node);
     if (node_access("view", $node)) {
       if ($disable_node_links) {
         $items[] = check_plain($node->question);
       }
       else {
-        $items[] = l($node->question, 'node/'. $node->nid);
+        $items[] = l($node->question, 'node/' . $node->nid);
       }
     }
   }
   $list_style = variable_get('faq_question_listing', 'ul');
   $output = theme('item_list', $items, NULL, $list_style);
-  $output .= '<div class="faq-all-faqs-link">'. l(t('All FAQs'), 'faq') .'</div>';
+  $output .= '<div class="faq-all-faqs-link">' . l(t('All FAQs'), 'faq') . '</div>';
 
   return $output;
 }
@@ -843,27 +950,34 @@ function faq_highlights_block($num = 5) 
  * @return
  *   The HTML-formatted code displaying the Random FAQs.
  */
-function faq_random_highlights_block($num = 5) {
+function faq_random_highlights_block_content($num = 5) {
   $disable_node_links = variable_get('faq_disable_node_links', FALSE);
 
-  $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type='faq' AND n.status = 1 ORDER BY RAND()", "n", "nid"), 0, $num);
+  $query = db_select('node', 'n')
+    ->fields('n', array('nid'))
+    ->condition('type', 'faq')
+    ->condition('status', 1)
+    ->orderRandom()
+    ->range(0, $num);
+
+  $result = $query->execute();
 
   $items = array();
   while ($row = db_fetch_object($result)) {
-    $node = node_load(array('nid' => $row->nid));
+    $node = node_load($row->nid);
     $node = node_prepare($node);
     if (node_access("view", $node)) {
       if ($disable_node_links) {
         $items[] = check_plain($node->question);
       }
       else {
-        $items[] = l($node->question, 'node/'. $node->nid);
+        $items[] = l($node->question, 'node/' . $node->nid);
       }
     }
   }
   $list_style = variable_get('faq_question_listing', 'ul');
   $output = theme('item_list', $items, NULL, $list_style);
-  $output .= '<div class="faq-all-faqs-link">'. l(t('All FAQs'), 'faq') .'</div>';
+  $output .= '<div class="faq-all-faqs-link">' . l(t('All FAQs'), 'faq') . '</div>';
 
   return $output;
 }
@@ -887,7 +1001,7 @@ function _get_indented_faq_terms($vid, $
   $hide_child_terms = variable_get('faq_hide_child_terms', FALSE);
 
   $items = array();
-  $tree = taxonomy_get_tree($vid, $tid, -1, 1);
+  $tree = taxonomy_get_tree($vid, $tid, 1, -1);
 
   foreach ($tree as $term) {
 
@@ -904,27 +1018,36 @@ function _get_indented_faq_terms($vid, $
       $desc = '';
       if (!empty($term->description)) {
         $desc = '<div class="faq-qa-description">';
-        $desc .= check_markup(faq_tt("taxonomy:term:$term->tid:description", $term->description)) ."</div>";
+        $desc .= check_markup(faq_tt("taxonomy:term:$term->tid:description", $term->description)) . '</div>';
       }
 
       // See if this term has any nodes itself, should it be a link?
-      $result = db_query(db_rewrite_sql("SELECT COUNT(n.nid) AS c FROM {term_node} tn INNER JOIN {node} n ON (n.nid = tn.nid AND n.vid = tn.vid) WHERE n.status = 1 AND n.type = 'faq' AND tn.tid = '%d' ", "n", "nid"), $term->tid);
-      $term_node_count = db_fetch_object($result);
 
-      if ($term_node_count->c > 0) {
+      $query = db_select('taxonomy_term_node', 'tn');
+      $n_alias = $query->innerJoin('node', 'n', 'n.nid = tn.nid AND n.vid = tn.vid');
+
+      $query
+        ->fields($n_alias, array('nid'))
+        ->condition('type', 'faq')
+        ->condition('status', 1)
+        ->condition('tn.tid', $term->tid);
+
+      $term_node_count = $query->countQuery()->execute()->fetchField();
+
+      if ($term_node_count > 0) {
         $path = "faq/$term->tid";
 
-        if (!drupal_lookup_path('alias', arg(0) .'/'. $term->tid) && module_exists('pathauto')) {
+        if (!drupal_lookup_path('alias', arg(0) . '/' . $term->tid) && module_exists('pathauto')) {
           $placeholders = pathauto_get_placeholders('taxonomy', $term);
-          $path = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) .'/'. $term->tid, $term->tid);
+          $path = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) . '/' . $term->tid, $term->tid);
         }
 
         if ($display_faq_count) {
-          $count = $term_node_count->c;
+          $count = $term_node_count;
           if ($hide_child_terms) {
             $count = $tree_count;
           }
-          $cur_item = $term_image . l(faq_tt("taxonomy:term:$term->tid:name", $term->name), $path) ." ($count) ". $desc;
+          $cur_item = $term_image . l(faq_tt("taxonomy:term:$term->tid:name", $term->name), $path) . " ($count) " . $desc;
         }
         else {
           $cur_item = $term_image . l(faq_tt("taxonomy:term:$term->tid:name", $term->name), $path) . $desc;
@@ -983,16 +1106,34 @@ function faq_get_faq_list() {
 
   // Otherwise return list of weighted FAQ nodes.
   $items = array();
-  $default_sorting = variable_get('faq_default_sorting', 'DESC');
+  $result = variable_get('faq_default_sorting', 'DESC');
   $default_weight = 0;
   if ($default_sorting != 'DESC') {
     $default_weight = 1000000;
-    $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight);
+    $sorting = 'ASC';
   }
-  else {
-    $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight);
-  }
-  while ($row = db_fetch_object($result)) {
+
+  $query = db_select('node', 'n')
+    ->fields('n', array('nid', 'title', 'sticky', 'created'));
+
+  $w_alias = $query->leftJoin('faq_weights', 'w', 'n.nid = w.nid');
+  $weight_alias = $query->addExpression('if((' . $w_alias . '.weight IS NULL), :weight, ' . $w_alias . '.weight)', 'weight', array(':weight' => $default_weight));
+
+  $query
+    ->condition('type', 'faq')
+    ->condition('status', 1)
+    ->condition(
+      db_or()
+        ->condition($w_alias . '.tid', 0)
+        ->isNull($w_alias . '.tid')
+      )
+    ->orderBy($weight_alias, 'ASC')
+    ->orderBy('sticky', 'DESC')
+    ->orderBy('created', $sorting);
+
+  $result = $query->execute();
+
+  foreach ($result as $row) {
     $node = node_load($row->nid);
     if (node_access("view", $node)) {
       $items[] = l($node->question, "node/$node->nid");
@@ -1003,7 +1144,7 @@ function faq_get_faq_list() {
 }
 
 /**
- * Implementation of hook_site_map().
+ * Implements hook_site_map().
  *
  * Not needed by the latest site_map module as it implements a _site_map_faq()
  * function itself.  Leaving this code here for now in case things change again.
@@ -1023,7 +1164,7 @@ function faq_site_map() {
  */
 
 /**
- * Implementation of hook_link_alter().
+ * Implements hook_link_alter().
  *
  * Change the term links on a node to point at the appropriate faq page.
  */
@@ -1043,7 +1184,7 @@ function faq_link_alter(&$links, $node) 
       // Link back to the faq and not the taxonomy term page. We'll only
       // do this if the taxonomy term in question belongs to faq vocab.
       $tid = str_replace('taxonomy/term/', '', $link['href']);
-      $term = taxonomy_get_term($tid);
+      $term = taxonomy_term_load($tid);
       if (!is_object($term)) continue;
       foreach ($vocabularies as $vid => $vobj) {
         if ($term->vid == $vid && taxonomy_term_count_nodes($term->tid, 'faq')) {
@@ -1071,10 +1212,10 @@ if (!function_exists('array_diff_key')) 
 }
 
 /**
- * Implementation of hook_term_path().
+ * Implements hook_term_path().
  */
 function faq_term_path($term) {
-  return 'faq/'. $term->tid;
+  return 'faq/' . $term->tid;
 }
 
 /**
@@ -1101,7 +1242,7 @@ function faq_view_question(&$data, $node
     elseif (empty($path)) {
       // Can't seem to use l() function with empty string as screen-readers
       // don't like it, so create anchor name manually.
-      $question = '<a name="' . $anchor . '" id="' . $anchor . '">' . check_plain($node->title) .'</a>';
+      $question = '<a name="' . $anchor . '" id="' . $anchor . '">' . check_plain($node->title) . '</a>';
     }
     else {
       $question = l($node->title, $path);
@@ -1119,7 +1260,7 @@ function faq_view_question(&$data, $node
   }
 
   if (variable_get('faq_display', 'questions_top') != 'hide_answer' && !empty($node->detailed_question) && variable_get('faq_question_length', 'short') == 'both') {
-    $question .= '<div class="faq-detailed-question">'. $node->detailed_question .'</div>';
+    $question .= '<div class="faq-detailed-question">' . $node->detailed_question . '</div>';
   }
   $data['question'] = $question;
 }
@@ -1146,7 +1287,7 @@ function faq_view_answer(&$data, $node, 
   if ($links) {
     $node->links = module_invoke_all('link', 'node', $node, $teaser);
     foreach (module_implements('link_alter') as $module) {
-      $function = $module .'_link_alter';
+      $function = $module . '_link_alter';
       $function($node->links, $node);
     }
   }
@@ -1167,7 +1308,7 @@ function faq_view_answer(&$data, $node, 
   }
 
   $content = drupal_render($node->content);
-  node_invoke_nodeapi($node, 'alter', $teaser, 0);
+  module_invoke_all('node_alter', $node);
 
   // Unset unused $node text so that a bad theme can not open a security hole.
   // $node->body = NULL;
@@ -1225,7 +1366,7 @@ function faq_init_back_to_top($path) {
  * @param $parent_term
  *   The original, top-level, term we're displaying FAQs for.
  */
-function faq_get_child_categories_faqs($term, $theme_function, $default_weight, $default_sorting, $category_display, $class, $parent_term = NULL) {
+function faq_get_child_categories_faqs($term, $theme_function, $default_weight, $sorting, $category_display, $class, $parent_term = NULL) {
   $output = array();
 
   $list = taxonomy_get_children($term->tid);
@@ -1234,15 +1375,30 @@ function faq_get_child_categories_faqs($
     $child_term->depth = $term->depth + 1;
 
     if (taxonomy_term_count_nodes($child_term->tid, 'faq')) {
-      if ($default_sorting == 'DESC') {
-        $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $child_term->tid);
-      }
-      else {
-        $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $child_term->tid);
+
+      if ($sorting != 'DESC') {
+        $sorting = 'ASC';
       }
 
+      $query = db_select('node', 'n')
+        ->fields('n', array('nid', 'title', 'sticky', 'created'));
+      
+      $tn_alias = $query->innerJoin('term_node', 'tn', 'n.nid = tn.nid AND n.vid = tn.vid');
+      $w_alias = $query->leftJoin('faq_weights', 'w', 'w.tid = tn.tid AND n.nid = w.nid');
+      $weight_alias = $query->addExpression('if((' . $w_alias . '.weight IS NULL), :weight, ' . $w_alias . '.weight)', 'weight', array(':weight' => $default_weight));
+
+      $query
+        ->condition('type', 'faq')
+        ->condition('status', 1)
+        ->condition($tn_alias . '.tid', $child_term->tid)
+        ->orderBy($weight_alias, 'ASC')
+        ->orderBy('sticky', 'DESC')
+        ->orderBy('created', $sorting);
+
+      $result = $query->execute();
+
       $data = array();
-      while ($row = db_fetch_object($result)) {
+      foreach ($result as $row) {
         $node = node_load($row->nid);
         if (node_access("view", $node)) {
           $data[] = $node;
@@ -1290,7 +1446,7 @@ function faq_view_child_category_headers
 }
 
 /**
- * Implementation of hook_pathauto().
+ * Implements hook_pathauto().
  */
 function faq_pathauto($op) {
   switch ($op) {
@@ -1306,7 +1462,7 @@ function faq_pathauto($op) {
       foreach ($patterns as $type => $pattern_set) {
         if ($type != 'global') {
           foreach ($pattern_set as $pattern => $description) {
-            $settings['placeholders']['['. $pattern .']'] = $description;
+            $settings['placeholders']['[' . $pattern . ']'] = $description;
           }
         }
       }
@@ -1326,10 +1482,10 @@ function faq_set_breadcrumb($term = NULL
   $breadcrumb = array();
 
   if (module_exists("taxonomy") && $term) {
-    $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), 'faq/'. $term->tid);
+    $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), 'faq/' . $term->tid);
     while ($parents = taxonomy_get_parents($term->tid)) {
       $term = array_shift($parents);
-      $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), 'faq/'. $term->tid);
+      $breadcrumb[] = l(faq_tt("taxonomy:term:$term->tid:name", $term->name), 'faq/' . $term->tid);
     }
   }
   $breadcrumb[] = l(variable_get('faq_title', 'Frequently Asked Questions'), 'faq');
@@ -1339,7 +1495,7 @@ function faq_set_breadcrumb($term = NULL
 }
 
 /**
- * Implementation of template_preprocess_page().
+ * Implements template_preprocess_page().
  *
  * Override the breadcrumbs for faq nodes.
  */
@@ -1365,51 +1521,33 @@ function faq_tt($string_id, $default, $l
 }
 
 /**
- * Implementation of hook_filter().
+ * Implements hook_filter_info().
  */
-function faq_filter($op, $delta = 0, $format = -1, $text = '', $cache_id = 0) {
-  switch ($op) {
-    case 'list':
-      return array(
-        0 => t('Embed FAQ page'),
-      );
+function faq_filter_info() {
 
-    case 'no cache':
-      switch ($delta) {
-        case 0:
-          return TRUE;
-      }
-
-    case 'description':
-      switch ($delta) {
-        case 0:
-          return t('Embed FAQ page using [faq] type tags.  Disables filter caching so not recommended for all input formats.');
-      }
-
-    case "process":
-      switch ($delta) {
-        case 0:
-          $text = preg_replace_callback('/\[faq:?([^\]]*)\]/', '_faq_faq_page_filter_replacer', $text);
-          // Remove comments, as they're not supported by all input formats.
-          $text = preg_replace('/<!--.*?-->/', '', $text);
-          return $text;
-      }
-      return $text;
+  $filters['faq_page'] = array(
+    'name' => t('Embed FAQ page'),
+    'description' => t('Embed FAQ page using [faq] type tags.  Disables filter caching so not recommended for all input formats.'),
+    'process callback' => '_filter_faq_process',
+    'tips callback' => '_filter_faq_tips',
+  );
 
-    default:
-      return $text;
-  }
-}
+  return $filters;
 
-/**
- * Implementation of hook_filter_tips().
- */
-function faq_filter_tips($delta, $format, $long = FALSE) {
-  switch ($delta) {
-    case 0:
-      return t('[faq] or [faq:123,questions_inline,categories_inline] - insert FAQ content based on the optional category, question style and category style.');
-  }
-}
+} // faq_filter_info
+
+function _filter_faq_process($text, $format) {
+
+  $text = preg_replace_callback('/\[faq:?([^\]]*)\]/', '_faq_faq_page_filter_replacer', $text);
+  // Remove comments, as they're not supported by all input formats.
+  $text = preg_replace('/<!--.*?-->/', '', $text);
+  return $text;
+
+} // _faq_filter_process
+
+function _filter_faq_tips($format, $long = FALSE) {
+  return t('[faq] or [faq:123,questions_inline,categories_inline] - insert FAQ content based on the optional category, question style and category style.');
+} // _faq_filter_tips
 
 /**
  * Helper function for faq input filter.
@@ -1419,7 +1557,7 @@ function _faq_faq_page_filter_replacer($
   $faq_display = '';
   $category_display = '';
   if (drupal_strlen($matches[1])) {
-    list ($tid, $faq_display, $category_display) = explode(',', $matches[1] .',,');
+    list ($tid, $faq_display, $category_display) = explode(',', $matches[1] . ',,');
     $tid = (int) trim($tid);
     $faq_display = trim($faq_display);
     $category_display = trim($category_display);
@@ -1442,7 +1580,7 @@ function _faq_faq_page_filter_replacer($
 function theme_faq_page($content = '', $answers = '', $description = NULL) {
   $output = '<div class="faq-content"><div class="faq">';
   if (!empty($description)) {
-    $output .= '<div class="faq-description">'. $description ."</div>\n";
+    $output .= '<div class="faq-description">' . $description . "</div>\n";
   }
   if (variable_get('faq_show_expand_all', FALSE)) {
     $output .= '<div id="faq-expand-all">';
@@ -1452,7 +1590,7 @@ function theme_faq_page($content = '', $
   }
 
   $output .= $content;
-  $output .= $answers ."</div></div>\n";
+  $output .= $answers . "</div></div>\n";
   return $output;
 }
 
Index: includes/faq.questions_top.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/includes/Attic/faq.questions_top.inc,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 faq.questions_top.inc
--- includes/faq.questions_top.inc	17 Nov 2009 23:00:52 -0000	1.1.2.7
+++ includes/faq.questions_top.inc	5 Apr 2010 05:36:42 -0000
@@ -31,7 +31,7 @@ function template_preprocess_faq_questio
   $answers = array();
   $key = 0;
   foreach ($data as $node) {
-    $anchor = "n". $node->nid;
+    $anchor = "n" . $node->nid;
     $questions[$key] = l($node->title, $this_page, array('fragment' => $anchor));
     faq_view_question($answers[$key], $node, '', $anchor);
     faq_view_answer($answers[$key], $node, $back_to_top, $teaser, $links);
@@ -153,7 +153,7 @@ function template_preprocess_faq_categor
     if (!$hide_child_terms) {
       $count++;
     }
-    $anchor = $term->tid ."n". $node->nid;
+    $anchor = $term->tid . "n" . $node->nid;
     $node_var = array();
     faq_view_question($node_var, $node, '', $anchor);
     if ($group_questions_top || $category_display == 'hide_qa') {
@@ -248,7 +248,7 @@ function template_preprocess_faq_categor
 
   $nodes = array();
   foreach ($data as $node) {
-    $anchor = $term->tid ."n". $node->nid;
+    $anchor = $term->tid . "n" . $node->nid;
     $node_var = array();
     faq_view_question($node_var, $node, '', $anchor);
     faq_view_answer($node_var, $node, $back_to_top, $teaser, $links);
