Index: sites/all/modules/quicktabs-HEAD/quicktabs.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quicktabs/quicktabs.info,v
retrieving revision 1.3
diff -u -p -r1.3 quicktabs.info
--- sites/all/modules/quicktabs-HEAD/quicktabs.info	17 Apr 2008 22:59:23 -0000	1.3
+++ sites/all/modules/quicktabs-HEAD/quicktabs.info	24 Aug 2009 02:46:22 -0000
@@ -1,4 +1,7 @@
 ; $Id: quicktabs.info,v 1.3 2008/04/17 22:59:23 katbailey Exp $
 name = Quick Tabs
 description = Create blocks of tabbed views and blocks.
-core = 6.x
\ No newline at end of file
+core = 7.x
+
+files[] = quicktabs.module
+files[] = quicktabs.install
\ No newline at end of file
Index: sites/all/modules/quicktabs-HEAD/quicktabs.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quicktabs/quicktabs.module,v
retrieving revision 1.10
diff -u -p -r1.10 quicktabs.module
--- sites/all/modules/quicktabs-HEAD/quicktabs.module	3 Nov 2008 03:31:29 -0000	1.10
+++ sites/all/modules/quicktabs-HEAD/quicktabs.module	24 Aug 2009 02:46:23 -0000
@@ -1,10 +1,13 @@
 <?php
-
 // $Id: quicktabs.module,v 1.10 2008/11/03 03:31:29 katbailey Exp $ 
 
+/**
+ * @file
+ * quicktabs.module
+ */
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function quicktabs_help($path, $arg) {
   switch ($path) {
@@ -15,10 +18,13 @@ function quicktabs_help($path, $arg) {
 <p>Visit the <a href="@configuration">Quick Tabs configuration page</a> to choose a style for your Quick Tabs blocks.</p>
 <p>Click on the "New QT block" tab below to get started.</p>', array('@configuration' => url('admin/settings/quicktabs')));
     case 'admin/build/quicktabs/add':
-      return '<p>'. t('Here you can create a new Quick Tabs block. Once you have created this block you will be taken to the <a href="@overview">blocks</a> page to configure and enable it.', array('@overview' => url('admin/build/block'))) .'</p>';
+      return '<p>' . t('Here you can create a new Quick Tabs block. Once you have created this block you will be taken to the <a href="@overview">blocks</a> page to configure and enable it.', array('@overview' => url('admin/build/block'))) . '</p>';
   }
 }
 
+/**
+ * Implements hook_theme().
+ */
 function quicktabs_theme() {
   return array(
     'quicktabs_settings' => array(
@@ -43,95 +49,104 @@ function quicktabs_theme() {
 }
 
 /** 
- * Implementation of hook_menu(). 
+ * Implements hook_menu(). 
  */ 
 function quicktabs_menu() { 
   $items = array(); 
 
-    $items['admin/build/quicktabs'] = array( 
-      'title' => 'Quick Tabs',
-      'description' => 'Create blocks of tabbed content - content for each tab can be a view or a block',
-      'page callback' => 'quicktabs_list', 
-      'access arguments' => array('administer quicktabs blocks'), 
-    );
-    $items['admin/build/quicktabs/list'] = array(
-      'title' => 'List',
-      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);    
-    $items['admin/build/quicktabs/add'] = array(
-      'title' => 'New QT block',
-      'access arguments' => array('create quicktabs block'),
-      'page callback' => 'quicktabs_new',
-      'weight' => 0,
-      'type' => MENU_LOCAL_TASK);
-    $items['admin/build/quicktabs/ajax/add'] = array(
-      'title' => 'New QT AJAX block',
-      'access arguments' => array('create quicktabs block'),
-      'page callback' => 'quicktabs_new',
-      'page arguments' => array(TRUE),
-      'weight' => 1,
-      'type' => MENU_LOCAL_TASK);
-    $items['admin/build/quicktabs/delete'] = array(
-      'title' => 'Delete QT block',
-      'access arguments' => array('administer blocks'),
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('quicktabs_block_delete'),
-      'type' => MENU_CALLBACK);
-    $items['admin/build/quicktabs/edit'] = array(
-      'title' => 'Edit QT block',
-      'access arguments' => array('administer blocks'),
-      'page callback' => 'quicktabs_block_edit',
-      'type' => MENU_CALLBACK);
-    $items['admin/settings/quicktabs'] = array(
-      'title'    => 'Quick Tabs',
-      'description' => 'Select a style for your Quick Tabs blocks',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('quicktabs_settings'),
-      'type'     => MENU_NORMAL_ITEM,
-      'access arguments'   => array('administer site configuration'),
-    );
-    $items['quicktabs/preview'] = array(
-      'page callback' => 'quicktabs_preview_page',
-      'type'     => MENU_CALLBACK,
-      'access arguments'   => array('administer site configuration'),
-    );
-    $items['quicktabs/ahah'] = array(
-      'page callback' => 'quicktabs_ahah',
-      'type' => MENU_CALLBACK,
-      'access arguments' => array('administer site configuration'),
-    );
-    $items['quicktabs/views/displays'] = array(
-      'page callback' => 'quicktabs_ajax',
-      'type' => MENU_CALLBACK,
-      'access arguments' => array('administer site configuration'),
-    );
-    $items['quicktabs/ajax/views'] = array(
-      'page callback' => 'quicktabs_ajax_views',
-      'type' => MENU_CALLBACK,
-      'access arguments' => array('access content'),
-    );
-    $items['quicktabs/ajax/node'] = array(
-      'page callback' => 'quicktabs_ajax_node',
-      'type' => MENU_CALLBACK,
-      'access arguments' => array('access content'),
-    );
+  $items['admin/build/quicktabs'] = array( 
+    'title' => 'Quick Tabs',
+    'description' => 'Create blocks of tabbed content - content for each tab can be a view or a block',
+    'page callback' => 'quicktabs_list', 
+    'access arguments' => array('administer quicktabs blocks'), 
+  );
+  $items['admin/build/quicktabs/list'] = array(
+    'title' => 'List',
+    'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);    
+  $items['admin/build/quicktabs/add'] = array(
+    'title' => 'New QT block',
+    'access arguments' => array('create quicktabs block'),
+    'page callback' => 'quicktabs_new',
+    'weight' => 0,
+    'type' => MENU_LOCAL_TASK);
+  $items['admin/build/quicktabs/ajax/add'] = array(
+    'title' => 'New QT AJAX block',
+    'access arguments' => array('create quicktabs block'),
+    'page callback' => 'quicktabs_new',
+    'page arguments' => array(TRUE),
+    'weight' => 1,
+    'type' => MENU_LOCAL_TASK);
+  $items['admin/build/quicktabs/delete'] = array(
+    'title' => 'Delete QT block',
+    'access arguments' => array('administer blocks'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('quicktabs_block_delete'),
+    'type' => MENU_CALLBACK);
+  $items['admin/build/quicktabs/edit'] = array(
+    'title' => 'Edit QT block',
+    'access arguments' => array('administer blocks'),
+    'page callback' => 'quicktabs_block_edit',
+    'type' => MENU_CALLBACK);
+  $items['admin/settings/quicktabs'] = array(
+    'title'    => 'Quick Tabs',
+    'description' => 'Select a style for your Quick Tabs blocks',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('quicktabs_settings'),
+    'type'     => MENU_NORMAL_ITEM,
+    'access arguments'   => array('administer site configuration'),
+  );
+  $items['quicktabs/preview'] = array(
+    'page callback' => 'quicktabs_preview_page',
+    'type'     => MENU_CALLBACK,
+    'access arguments'   => array('administer site configuration'),
+  );
+  $items['quicktabs/ahah'] = array(
+    'page callback' => 'quicktabs_ahah',
+    'type' => MENU_CALLBACK,
+    'access arguments' => array('administer site configuration'),
+  );
+  $items['quicktabs/views/displays'] = array(
+    'page callback' => 'quicktabs_ajax',
+    'type' => MENU_CALLBACK,
+    'access arguments' => array('administer site configuration'),
+  );
+  $items['quicktabs/ajax/views'] = array(
+    'page callback' => 'quicktabs_ajax_views',
+    'type' => MENU_CALLBACK,
+    'access arguments' => array('access content'),
+  );
+  $items['quicktabs/ajax/node'] = array(
+    'page callback' => 'quicktabs_ajax_node',
+    'type' => MENU_CALLBACK,
+    'access arguments' => array('access content'),
+  );
   return $items; 
 }
 
 /** 
- * Implementation of hook_perm(). 
+ * Implements hook_permission(). 
  */ 
-function quicktabs_perm() {
-  return array('create quicktabs block', 'administer quicktabs blocks');
+function quicktabs_permission() {
+  return array(
+    'create quicktabs block' => array(
+      'title' => 'Create quicktabs block',
+      'description' => 'Create the quicktabs block.',
+    ),
+    'administer quicktabs blocks' => array(
+      'title' => 'Administer quicktabs blocks',
+      'description' => 'Administer all quicktabs blocks.',
+    ),
+  );
 }
 
 function quicktabs_list() {
   $result = db_query('SELECT qtid, title FROM {quicktabs}');
   $header = array(t('Quick Tabs Block Name'), t('Delete'));
   $rows = array();
-  while ($row = db_fetch_object($result)) {
+  foreach ($result AS $row) {
     $tablerow = array(
-    array('data' => $row->title .' ('. l('edit', 'admin/build/quicktabs/edit/'. $row->qtid) .')'),
-    array('data' => l(t('Delete'), 'admin/build/quicktabs/delete/'. $row->qtid)),
+    array('data' => $row->title . ' (' . l('edit', 'admin/build/quicktabs/edit/' . $row->qtid) . ')'),
+    array('data' => l(t('Delete'), 'admin/build/quicktabs/delete/' . $row->qtid)),
     );
     $rows[] = $tablerow;
   }
@@ -143,15 +158,16 @@ function quicktabs_list() {
 function quicktabs_new($ajax = FALSE) {
   global $base_url;
   $quicktabsForm = array(
-    'ajax_path' => $base_url .'/quicktabs/views/displays'
+    'ajax_path' => $base_url . '/quicktabs/views/displays'
   );
   drupal_add_js('/misc/jquery.form.js');
   drupal_add_js(array('quicktabsForm' => $quicktabsForm), 'setting');
-  drupal_add_js(drupal_get_path('module', 'quicktabs') .'/js/quicktabs_form.js');
-  drupal_add_css(drupal_get_path('module', 'quicktabs') .'/quicktabs.css');
+  drupal_add_js(drupal_get_path('module', 'quicktabs') . '/js/quicktabs_form.js');
+  drupal_add_css(drupal_get_path('module', 'quicktabs') . '/quicktabs.css');
   if (!$ajax) {
     return drupal_get_form('quicktabs_form');
-  } else {
+  }
+  else {
     return drupal_get_form('quicktabs_aj_form');
   }
 }
@@ -197,7 +213,7 @@ function _quicktabs_get_default_view_dis
 function quicktabs_get_views() {
   $result = db_query("SELECT v.name, v.description FROM {views_view} v");
   $views = array();
-  while ($view = db_fetch_object($result)) {
+  foreach ($result AS $view) {
     $views[$view->name] = $view->name;
   }
   $status = variable_get('views_defaults', array());
@@ -218,7 +234,7 @@ function quicktabs_get_blocks() {
   $blocksarray = array();
   foreach ($blocks as $i => $block) {
     if ($block['module'] != 'quicktabs') {
-      $key = $block['module'] .'_delta_'. $block['delta'];
+      $key = $block['module'] . '_delta_' . $block['delta'];
       $blocksarray[$key] = $block['info'];
     }
   }
@@ -226,18 +242,12 @@ function quicktabs_get_blocks() {
 }
 
 function quicktabs_get_nodes() {
-  $nodes = array();
   // TODO: make the allowed node types an admin setting
-  $result = db_query('SELECT nid, title FROM {node} WHERE type in ("page", "story")');
-  while ($row = db_fetch_object($result)) {
-    $key = $row->nid;
-    $nodes[$key] = $row->title;
-  }
-  return $nodes;
+  // Returns an array of nodes: nid => title
+  return db_select('node')->fields(array('nid', 'title'))->condition('type', array('page', 'story'), 'IN')->fetchAllKeyed();
 }
 
 function quicktabs_form(&$form, $form_state = NULL) {
-
   $form = array(
     '#cache' => TRUE,
   );
@@ -312,13 +322,11 @@ function quicktabs_form(&$form, $form_st
       'effect' => 'fade',
     ),
   );
-$form['submit'] = array(
-'#type' => 'submit',
-'#value' => t('Save'),
-); 		
-
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
   return $form;
-
 }
 
 
@@ -350,47 +358,48 @@ function _quicktabs_form($delta, $weight
   if (module_exists('views')) {
     $views = quicktabs_get_views();
     $form['type_options'] = array(
-    '#type' => 'value',
-    '#value' => array(
-    'block' => 'block',
-    'view' => 'view',
-    )
+      '#type' => 'value',
+      '#value' => array(
+        'block' => 'block',
+        'view' => 'view',
+      )
     );        
     $form['tabtype'] = array(
-    '#type' => 'radios',
-    '#options' => $form['type_options']['#value'],
-    '#title' => t('Tab Content'),
-    '#default_value' => $type,
-    '#parents' => array('tabs', $delta, 'tabtype'),
+      '#type' => 'radios',
+      '#options' => $form['type_options']['#value'],
+      '#title' => t('Tab Content'),
+      '#default_value' => $type,
+      '#parents' => array('tabs', $delta, 'tabtype'),
     );
     $views_keys = array_keys($views);
     $selected_view = ($vid ? ($vid == 'default' ? $views_keys[0] : ($type == 'block' ? $views_keys[0] : $vid)) : $views_keys[0]);
     $form['vid'] = array(
-    '#type' => 'select',
-    '#options' => $views,
-    '#default_value' => $selected_view,
-    '#title' => t('Select a view'),
-    '#parents' => array('tabs', $delta, 'vid'),
+      '#type' => 'select',
+      '#options' => $views,
+      '#default_value' => $selected_view,
+      '#title' => t('Select a view'),
+      '#parents' => array('tabs', $delta, 'vid'),
     );
     $form['args'] = array(
-    '#type' => 'textfield',
-    '#title' => 'arguments',
-    '#size' => '10',
-    '#required' => false,
-    '#default_value' => $args,
-    '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
-    '#parents' => array('tabs', $delta, 'args')
+      '#type' => 'textfield',
+      '#title' => 'arguments',
+      '#size' => '10',
+      '#required' => FALSE,
+      '#default_value' => $args,
+      '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
+      '#parents' => array('tabs', $delta, 'args')
     );        
 
     $form['display'] = array(
-    '#type' => 'select',
-    '#title' => 'display',
-    '#options' => _quicktabs_get_views_displays($selected_view),
-    '#default_value' => $display,
-    '#description' => t('Choose a display for your view.'),
-    '#parents' => array('tabs', $delta, 'display')
+      '#type' => 'select',
+      '#title' => 'display',
+      '#options' => _quicktabs_get_views_displays($selected_view),
+      '#default_value' => $display,
+      '#description' => t('Choose a display for your view.'),
+      '#parents' => array('tabs', $delta, 'display')
     );
-  } else {
+  }
+  else {
     $form['tabtype'] = array(
       '#type' => 'hidden',
       '#title' => t('Type for tab @n', array('@n' => ($delta + 1))),
@@ -413,11 +422,11 @@ function _quicktabs_form($delta, $weight
   );
   $form['remove'] = array(
     '#type' => 'submit',
-    '#value' => 'remove_'. $delta,
+    '#value' => 'remove_' . $delta,
     '#attributes' => array('class' => 'delete-tab'),
     '#parents' => array('tabs', $delta, 'remove'),
     '#ahah' => array(
-      'path' => 'quicktabs/ahah/'. $delta,
+      'path' => 'quicktabs/ahah/' . $delta,
       'wrapper' => 'quicktabs-tabs',
       'method' => 'replace',
       'effect' => 'fade',
@@ -429,7 +438,7 @@ function _quicktabs_form($delta, $weight
 function theme_qt_tabs($form) {
   // Change the button title to reflect the behavior when using JavaScript.
   drupal_add_tabledrag('qt-tablist-table', 'order', 'sibling', 'qt-tabs-weight');
-  drupal_add_js('if (Drupal.jsEnabled) { $(document).ready(function() { $("#edit-tabs-more").val("'. t('Add another tab') .'"); }); }', 'inline');
+  drupal_add_js('if (Drupal.jsEnabled) { $(document).ready(function() { $("#edit-tabs-more").val("' . t('Add another tab') . '"); }); }', 'inline');
 
   $rows = array();
   $headers = array(
@@ -475,7 +484,7 @@ function quicktabs_form_validate($form, 
   else {
     foreach ($form_state['values']['tabs'] as $j => $tab) {
       if (empty($tab['tabtext'])) {
-        form_set_error('tabs]['. $j .'][tabtext', t('You must give each tab a title.'));	  
+        form_set_error('tabs][' . $j . '][tabtext', t('You must give each tab a title.'));
       }
     }  
   }
@@ -518,7 +527,6 @@ function quicktabs_form_submit($form, $f
  * ajax version
  */
 function quicktabs_aj_form(&$form, $form_state = NULL) {
-
   $form = array(
     '#cache' => TRUE,
   );
@@ -591,13 +599,11 @@ function quicktabs_aj_form(&$form, $form
       'effect' => 'fade',
     ),
   );
-$form['submit'] = array(
-'#type' => 'submit',
-'#value' => t('Save'),
-); 		
-
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
   return $form;
-
 }
   
 function _quicktabs_aj_form($delta, $weight = -10, $title = '', $type='node', $nid = 0, $vid = 'default', $args = NULL, $display = 'default') {
@@ -628,47 +634,48 @@ function _quicktabs_aj_form($delta, $wei
   if (module_exists('views')) {
     $views = quicktabs_get_views();
     $form['type_options'] = array(
-    '#type' => 'value',
-    '#value' => array(
-    'node' => 'node',
-    'view' => 'view',
-    )
+      '#type' => 'value',
+      '#value' => array(
+        'node' => 'node',
+        'view' => 'view',
+      )
     );        
     $form['tabtype'] = array(
-    '#type' => 'radios',
-    '#options' => $form['type_options']['#value'],
-    '#title' => t('Tab Content'),
-    '#default_value' => $type,
-    '#parents' => array('tabs', $delta, 'tabtype'),
+      '#type' => 'radios',
+      '#options' => $form['type_options']['#value'],
+      '#title' => t('Tab Content'),
+      '#default_value' => $type,
+      '#parents' => array('tabs', $delta, 'tabtype'),
     );
     $views_keys = array_keys($views);
     $selected_view = ($vid ? ($vid == 'default' ? $views_keys[0] : ($type == 'node' ? $views_keys[0] : $vid)) : $views_keys[0]);
     $form['vid'] = array(
-    '#type' => 'select',
-    '#options' => $views,
-    '#default_value' => $selected_view,
-    '#title' => t('Select a view'),
-    '#parents' => array('tabs', $delta, 'vid'),
+      '#type' => 'select',
+      '#options' => $views,
+      '#default_value' => $selected_view,
+      '#title' => t('Select a view'),
+      '#parents' => array('tabs', $delta, 'vid'),
     );
     $form['args'] = array(
-    '#type' => 'textfield',
-    '#title' => 'arguments',
-    '#size' => '10',
-    '#required' => false,
-    '#default_value' => $args,
-    '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
-    '#parents' => array('tabs', $delta, 'args')
+      '#type' => 'textfield',
+      '#title' => 'arguments',
+      '#size' => '10',
+      '#required' => FALSE,
+      '#default_value' => $args,
+      '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
+      '#parents' => array('tabs', $delta, 'args')
     );        
 
     $form['display'] = array(
-    '#type' => 'select',
-    '#title' => 'display',
-    '#options' => _quicktabs_get_views_displays($selected_view),
-    '#default_value' => $display,
-    '#description' => t('Choose a display for your view.'),
-    '#parents' => array('tabs', $delta, 'display')
+      '#type' => 'select',
+      '#title' => 'display',
+      '#options' => _quicktabs_get_views_displays($selected_view),
+      '#default_value' => $display,
+      '#description' => t('Choose a display for your view.'),
+      '#parents' => array('tabs', $delta, 'display')
     );
-  } else {
+  }
+  else {
     $form['tabtype'] = array(
       '#type' => 'hidden',
       '#title' => t('Type for tab @n', array('@n' => ($delta + 1))),
@@ -685,11 +692,11 @@ function _quicktabs_aj_form($delta, $wei
   );
   $form['remove'] = array(
     '#type' => 'submit',
-    '#value' => 'remove_'. $delta,
+    '#value' => 'remove_' . $delta,
     '#attributes' => array('class' => 'delete-tab'),
     '#parents' => array('tabs', $delta, 'remove'),
     '#ahah' => array(
-      'path' => 'quicktabs/ahah/true/'. $delta,
+      'path' => 'quicktabs/ahah/true/' . $delta,
       'wrapper' => 'quicktabs-tabs',
       'method' => 'replace',
       'effect' => 'fade',
@@ -701,7 +708,7 @@ function _quicktabs_aj_form($delta, $wei
 function theme_qtaj_tabs($form) {
   // Change the button title to reflect the behavior when using JavaScript.
   drupal_add_tabledrag('qt-tablist-table', 'order', 'sibling', 'qt-tabs-weight');
-  drupal_add_js('if (Drupal.jsEnabled) { $(document).ready(function() { $("#edit-tabs-more").val("'. t('Add another tab') .'"); }); }', 'inline');
+  drupal_add_js('if (Drupal.jsEnabled) { $(document).ready(function() { $("#edit-tabs-more").val("' . t('Add another tab') . '"); }); }', 'inline');
 
   $rows = array();
   $headers = array(
@@ -747,14 +754,13 @@ function quicktabs_aj_form_validate($for
   else {
     foreach ($form_state['values']['tabs'] as $j => $tab) {
       if (empty($tab['tabtext'])) {
-        form_set_error('tabs]['. $j .'][tabtext', t('You must give each tab a title.'));	  
+        form_set_error('tabs][' . $j . '][tabtext', t('You must give each tab a title.'));
       }
     }  
   }
 }
 
 function quicktabs_aj_form_submit($form, $form_state) {
-
   $formvalues_tabs = array();
   foreach ($form_state['values']['tabs'] as $j => $tab) {
     $formvalues_tabs[] = array(
@@ -812,12 +818,14 @@ function quicktabs_ahah($ajax = FALSE, $
       $form_element = $ajax ? _quicktabs_aj_form($delta, $newweight) : _quicktabs_form($delta, $newweight);
     }
     $form['qt_wrapper']['tabs'][$delta] = $form_element;
-  } else {
+  }
+  else {
     $op = 'remove';
     if (count($form['qt_wrapper']['tabs']) > 2) {
       unset($form['qt_wrapper']['tabs'][$delta]);
-    } else {
-      drupal_set_message('The number of tabs cannot be less than two. Simply change the content of the second tab.');
+    }
+    else {
+      drupal_set_message(t('The number of tabs cannot be less than two. Simply change the content of the second tab.'));
     }
   }
 
@@ -835,7 +843,7 @@ function quicktabs_ahah($ajax = FALSE, $
   unset($qt_form['#prefix'], $qt_form['#suffix']); // Prevent duplicate wrappers.
   if ($op != 'remove') {
     $stripe = $delta % 2 ? 'even' : 'odd';
-    $qt_form[$delta]['#attributes']['class'] = empty($qt_form[$delta]['#attributes']['class']) ? 'draggable ahah-new-content'. $stripe : $qt_form[$delta]['#attributes']['class'] .'draggable ahah-new-content';
+    $qt_form[$delta]['#attributes']['class'] = empty($qt_form[$delta]['#attributes']['class']) ? 'draggable ahah-new-content' . $stripe : $qt_form[$delta]['#attributes']['class'] . 'draggable ahah-new-content';
   }
   $output = theme('status_messages') . drupal_render($qt_form);
 
@@ -844,11 +852,14 @@ function quicktabs_ahah($ajax = FALSE, $
 
 
 function _quicktabs_get_views_displays($view) {
-  $displays = array();
-  $result = db_query('SELECT d.id FROM {views_view} v INNER JOIN {views_display} d ON v.vid = d.vid WHERE v.name = "%s" ORDER BY position ASC', $view);
-  while ($row = db_fetch_object($result)) {
-    $displays[$row->id] = $row->id;
-  }
+  $query = db_select('views_view', 'v')
+    ->join('views_display', 'd', 'v.vid = d.vid');
+  $displays = $query
+    ->fields('d', array('id', 'id'))
+    ->condition('v.name', $view)
+    ->orderBy('position')
+    ->fetchAllKeyed();
+
   if (empty($displays)) {
     $displays = _quicktabs_get_default_view_displays($view);
   }
@@ -858,12 +869,12 @@ function _quicktabs_get_views_displays($
 
 function quicktabs_ajax($view, $delta) {
   $form_element = array(
-  '#name' => 'tabs['. $delta .'][display]',
-  '#type' => 'select',
-  '#title' => 'display',
-  '#options' => _quicktabs_get_views_displays($view),
-  '#description' => t('Choose a display for your view.'),
-  '#parents' => array('tabs', $delta, 'display')
+    '#name' => 'tabs[' . $delta . '][display]',
+    '#type' => 'select',
+    '#title' => 'display',
+    '#options' => _quicktabs_get_views_displays($view),
+    '#description' => t('Choose a display for your view.'),
+    '#parents' => array('tabs', $delta, 'display')
   );
   
   $form_state = array('submitted' => FALSE);
@@ -884,13 +895,24 @@ function quicktabs_ajax($view, $delta) {
 
 
 function quicktabs_createblock($fullcontent, $ajax = FALSE) {
-  $qtid = db_last_insert_id('quicktabs', 'qtid');
   $title = $fullcontent['blocktitle'];
   $tabs = serialize($fullcontent['blockcontent']);
   if (!$ajax) {
-    db_query('INSERT INTO {quicktabs} (qtid, title, tabs) VALUES(%d, "%s", "%s")', $qtid, $title, $tabs);
-  } else {
-    db_query('INSERT INTO {quicktabs} (qtid, ajax, title, tabs) VALUES(%d, 1, "%s", "%s")', $qtid, $title, $tabs);
+    db_insert('quicktabs')
+      ->fields(array(
+        'title' => $title,
+        'tabs' => $tabs,
+      ))
+      ->execute();
+  }
+  else {
+    db_insert('quicktabs')
+      ->fields(array(
+        'ajax' => 1,
+        'title' => $title,
+        'tabs' => $tabs,
+      ))
+      ->execute();
   }
   return; 
 }
@@ -898,158 +920,168 @@ function quicktabs_createblock($fullcont
 function quicktabs_updateblock($qtid, $fullcontent) {
   $title = $fullcontent['blocktitle'];
   $tabs = serialize($fullcontent['blockcontent']);
-  db_query('UPDATE {quicktabs} SET title="%s", tabs="%s" WHERE qtid=%d', $title, $tabs, $qtid);
+  db_update('quicktabs')
+    ->fields(array(
+      'title' => $title,
+      'tabs' => $tabs,
+    ))
+    ->condition('qtid', $qtid)
+    ->execute();
   return; 
 }
 
 /**
- * Implementation of hook_block
+ * Implements hook_block_list
  */
-function quicktabs_block($op = 'list', $delta = 0, $edit = array()) {
+function quicktabs_block_list() {
+  $jqueryblocks = array();
+  $result = db_select('quicktabs')
+    ->fields(array('qtid', 'title'));
+  $jqueryblocks = $result->fetchAllKeyed;
+  foreach ($jqueryblocks as $key => $val) {
+    $blocks[$key]['info'] = t($val);
+  }
+  return $blocks;
+}
 
-  switch ($op) {
-    case 'list':
-      $jqueryblocks = array();
-      $result = db_query('SELECT * FROM {quicktabs}');
-      while ($row = db_fetch_object($result)) {
-        $jqueryblocks[$row->qtid] = $row->title;
+/**
+ * Implements hook_block_view
+ */
+function quicktabs_block_view($delta = '') {
+  if ($qtblock = db_select('quicktabs')->fields(array('qtid', 'ajax', 'title', 'tabs'))->condition('qtid', $delta)->fetchObject()) {
+    quicktabs_add_css();
+    drupal_add_js(drupal_get_path('module', 'quicktabs') . '/js/quicktabs.js');
+    if ($qtblock->ajax == 0) {
+      $mainblock['subject'] = $qtblock->title;
+      $tabs = unserialize($qtblock->tabs);
+      foreach ($tabs as $key => $tab) {
+        $weight[$key]  = $tab['weight'];
       }
-      foreach ($jqueryblocks as $key => $val) {
-	$blocks[$key]['info'] = t($val);
+      array_multisort($weight, SORT_ASC, $tabs);
+      $tabtitles = array();
+      foreach ($tabs as $tab) {
+        $tabtitles[] = $tab['title'];
       }
-      return $blocks;
-      break;
-    case 'view':
-      if ($qtblock = db_fetch_object(db_query('SELECT qtid, ajax, title, tabs FROM {quicktabs} WHERE qtid = %d', $delta))) {
-        quicktabs_add_css();
-        drupal_add_js(drupal_get_path('module', 'quicktabs') .'/js/quicktabs.js');
-        if ($qtblock->ajax == 0) {
-          $mainblock['subject'] = $qtblock->title;
-          $tabs = unserialize($qtblock->tabs);
-          foreach ($tabs as $key => $tab) {
-            $weight[$key]  = $tab['weight'];
-          }
-          array_multisort($weight, SORT_ASC, $tabs);
-          $tabtitles = array();
-          foreach ($tabs as $tab) {
-            $tabtitles[] = $tab['title'];
-          }
-          $output = '<div class="quicktabs_wrapper">';
-          $output .= theme('quicktabs_tabs', $tabtitles);
-          $output .= '<div class="quicktabs_main">';
-          foreach ($tabs as $j => $tab) {
-            $output .= '<div class="quicktabs">';
-            if ($tab['type'] == 'view') {
-              if (module_exists('views')) {
-                $args = array();
-                if ($tab['args'] != '') {
-                  $args_array = explode(',', $tab['args']);
-                  foreach($args_array as $arg) {
-                    $args[] = trim($arg);
-                  }
-                }
-                $func_args = array_merge(array($tab['bvid'], $tab['display']), $args);
-                $output .= call_user_func_array('views_embed_view', $func_args);
-              }
-              else {
-                $output .= 'Views module not enabled, cannot display tab content';
-              }
-            }
-            else {
-              $pos = strpos($tab['bvid'], '_delta_');
-              $blockmodule = substr($tab['bvid'], 0, $pos);
-              $blockdelta = substr($tab['bvid'], $pos+7);
-              $block = (object) module_invoke($blockmodule, 'block', 'view', $blockdelta);
-              $block->module = $blockmodule;
-              $block->delta = $blockdelta;
-              if ($tab['hide_title'] != 1) {
-                $output .= $block->content ? theme('quicktabs_block', $block, TRUE) : '';
-              } else {
-                $output .= $block->content ? theme('quicktabs_block', $block, FALSE) : '';
+      $output = '<div class="quicktabs_wrapper">';
+      $output .= theme('quicktabs_tabs', $tabtitles);
+      $output .= '<div class="quicktabs_main">';
+      foreach ($tabs as $j => $tab) {
+        $output .= '<div class="quicktabs">';
+        if ($tab['type'] == 'view') {
+          if (module_exists('views')) {
+            $args = array();
+            if ($tab['args'] != '') {
+              $args_array = explode(',', $tab['args']);
+              foreach ($args_array as $arg) {
+                $args[] = trim($arg);
               }
             }
-            $output .= '</div>';  
+            $func_args = array_merge(array($tab['bvid'], $tab['display']), $args);
+            $output .= call_user_func_array('views_embed_view', $func_args);
           }
-          $output .= '</div></div>';	
-          $mainblock['content'] = $output;
-        } else {
-          $mainblock['subject'] = $qtblock->title;
-          $tabs = unserialize($qtblock->tabs);
-          foreach ($tabs as $key => $tab) {
-            $weight[$key]  = $tab['weight'];
+          else {
+            $output .= 'Views module not enabled, cannot display tab content';
           }
-          array_multisort($weight, SORT_ASC, $tabs);
-          $fullpath = explode('?', $_SERVER['REQUEST_URI']);
-          $queries = $_GET;
-          unset($queries['quicktabs_'. $delta]);
-          unset($queries['q']);
-          $querystring = '';
-          if (!empty($queries)) {
-            $i = 0;
-            foreach ($queries as $key => $value) {
-              $querystring .= $i > 0 ? '&'. $key .'='. $value : $key .'='. $value;
-              $i++;
-            }
-            $querystring .= '&';
+        }
+        else {
+          $pos = strpos($tab['bvid'], '_delta_');
+          $blockmodule = substr($tab['bvid'], 0, $pos);
+          $blockdelta = substr($tab['bvid'], $pos+7);
+          $block = (object) module_invoke($blockmodule, 'block', 'view', $blockdelta);
+          $block->module = $blockmodule;
+          $block->delta = $blockdelta;
+          if ($tab['hide_title'] != 1) {
+            $output .= $block->content ? theme('quicktabs_block', $block, TRUE) : '';
           }
-          $path = $fullpath[0];
-          $path .= '?'. $querystring;
-          
-          $output = '<div class="quicktabs_wrapper">';
-          $output .= '<ul class="quicktabs_tabs">';
-          foreach ($tabs as $i => $tab) {
-            $qtpath = 'quicktabs_'. $delta . '='. $i;
-            if ($tab['type'] == 'view') {
-              if (module_exists('views')) {              
-                if ($tab['args'] != '') {
-                  $argstring = '-'. str_replace(',', '|', $tab['args']);
-                } else {
-                  $argstring = '';
-                }
-                $id = 'view-'. $delta .'-'. $i .'-'. $tab['bnid'] .'-'. $tab['display'] . $argstring;
-              } else {
-                $output .= 'Views module not enabled, cannot display tab content';
-              }
-            } else {
-              $id = 'node-'. $delta .'-'. $i .'-'. $tab['bnid'];
-            }
-            $output .= '<li><a href="'. $path . $qtpath .'" class="qt_ajax_tabs" id="'. $id .'">'. $tab['title'] .'</a></li>';
+          else {
+            $output .= $block->content ? theme('quicktabs_block', $block, FALSE) : '';
           }
-          $output .= '</ul>';			
-          $output .= '<div class="quicktabs_main">';
-          $output .= '<div id="quicktabs_ajax_container_'. $delta .'">';
-
-          $active_tab = $_GET['quicktabs_'. $delta] ? $_GET['quicktabs_'. $delta] : 0;
-          if ($tabs[$active_tab]['type'] == 'view') {
-            $args = array();
-            if ($tabs[$active_tab]['args'] != '') {
-              $args_array = explode(',', $tabs[$active_tab]['args']);
-              foreach($args_array as $arg) {
-                $args[] = trim($arg);
-              }
+        }
+        $output .= '</div>';  
+      }
+      $output .= '</div></div>';
+      $mainblock['content'] = $output;
+    }
+    else {
+      $mainblock['subject'] = $qtblock->title;
+      $tabs = unserialize($qtblock->tabs);
+      foreach ($tabs as $key => $tab) {
+        $weight[$key]  = $tab['weight'];
+      }
+      array_multisort($weight, SORT_ASC, $tabs);
+      $fullpath = explode('?', request_uri());
+      $queries = $_GET;
+      unset($queries['quicktabs_' . $delta]);
+      unset($queries['q']);
+      $querystring = '';
+      if (!empty($queries)) {
+        $i = 0;
+        foreach ($queries as $key => $value) {
+          $querystring .= $i > 0 ? '&' . $key . '=' . $value : $key . '=' . $value;
+          $i++;
+        }
+        $querystring .= '&';
+      }
+      $path = $fullpath[0];
+      $path .= '?' . $querystring;
+      
+      $output = '<div class="quicktabs_wrapper">';
+      $output .= '<ul class="quicktabs_tabs">';
+      foreach ($tabs as $i => $tab) {
+        $qtpath = 'quicktabs_' . $delta . '=' . $i;
+        if ($tab['type'] == 'view') {
+          if (module_exists('views')) {              
+            if ($tab['args'] != '') {
+              $argstring = '-' . str_replace(',', '|', $tab['args']);
             }
-            $func_args = array_merge(array($tabs[$active_tab]['bnid'], $tabs[$active_tab]['display']), $args);
-            $output .= call_user_func_array('views_embed_view', $func_args);
-          } else {
-            $node = node_load($tabs[$active_tab]['bnid']);
-            $output .= theme('node', $node);
+            else {
+              $argstring = '';
+            }
+            $id = 'view-' . $delta . '-' . $i . '-' . $tab['bnid'] . '-' . $tab['display'] . $argstring;
+          }
+          else {
+            $output .= 'Views module not enabled, cannot display tab content';
           }
-          
-          $output .= '</div>';  
-          $output .= '</div></div>';	
-          $mainblock['content'] = $output;
         }
-      }        
-      return $mainblock;
-    break;
-  }
+        else {
+          $id = 'node-' . $delta . '-' . $i . '-' . $tab['bnid'];
+        }
+        $output .= '<li><a href="' . $path . $qtpath . '" class="qt_ajax_tabs" id="' . $id . '">' . $tab['title'] . '</a></li>';
+      }
+      $output .= '</ul>';
+      $output .= '<div class="quicktabs_main">';
+      $output .= '<div id="quicktabs_ajax_container_' . $delta . '">';
+
+      $active_tab = $_GET['quicktabs_' . $delta] ? $_GET['quicktabs_' . $delta] : 0;
+      if ($tabs[$active_tab]['type'] == 'view') {
+        $args = array();
+        if ($tabs[$active_tab]['args'] != '') {
+          $args_array = explode(',', $tabs[$active_tab]['args']);
+          foreach ($args_array as $arg) {
+            $args[] = trim($arg);
+          }
+        }
+        $func_args = array_merge(array($tabs[$active_tab]['bnid'], $tabs[$active_tab]['display']), $args);
+        $output .= call_user_func_array('views_embed_view', $func_args);
+      }
+      else {
+        $node = node_load($tabs[$active_tab]['bnid']);
+        $output .= theme('node', $node);
+      }
+      
+      $output .= '</div>';  
+      $output .= '</div></div>';
+      $mainblock['content'] = $output;
+    }
+  }        
+  return $mainblock;
 }
 
 function quicktabs_ajax_views($vid, $did, $args = NULL) {
   $args_ar = array();
   if ($args) {
     $args_array = explode('|', $args);
-    foreach($args_array as $arg) {
+    foreach ($args_array as $arg) {
       $args_ar[] = trim($arg);
     }
   }
@@ -1082,15 +1114,14 @@ function theme_quicktabs_block($block, $
 function theme_quicktabs_tabs($tabs) {
   $output .= '<ul class="quicktabs_tabs">';
   foreach ($tabs as $i => $tab) {
-    $output .= '<li><a href="#">'. $tab .'</a></li>';
+    $output .= '<li><a href="#">' . $tab . '</a></li>';
   }
   $output .= '</ul>';
   return $output;
 }
 
 function quicktabs_block_get_name($qtid) {
-  $result = db_result(db_query('SELECT title FROM {quicktabs} WHERE qtid=%d', $qtid));
-  return $result;
+  return db_select('quicktabs')->fields(array('title'))->condition('qtid', $qtid)->fetch();
 }
 
 function quicktabs_block_delete(&$form_state, $qtid =0) {
@@ -1101,7 +1132,8 @@ function quicktabs_block_delete(&$form_s
 }
 
 function quicktabs_block_edit($qtid) {
-  if ($qtblock = db_fetch_object(db_query('SELECT title, tabs, ajax FROM {quicktabs} WHERE qtid = %d', $qtid))) {
+  global $base_url;
+  if ($qtblock = db_select('quicktabs')->fields(array('title', 'tabs', 'ajax'))->condition('qtid', $qtid)->fetchObject()) {
     $tabs = unserialize($qtblock->tabs);
     foreach ($tabs as $key => $tab) {
       $weight[$key]  = $tab['weight'];
@@ -1114,16 +1146,16 @@ function quicktabs_block_edit($qtid) {
       'tabs' => $tabs,
       'formtype' => 'edit',
     );
-    global $base_url;
     $quicktabsForm = array(
-      'ajax_path' => $base_url .'/quicktabs/views/displays'
+      'ajax_path' => $base_url . '/quicktabs/views/displays'
     );
     drupal_add_js(array('quicktabsForm' => $quicktabsForm), 'setting');
-    drupal_add_js(drupal_get_path('module', 'quicktabs') .'/js/quicktabs_form.js');
-    drupal_add_css(drupal_get_path('module', 'quicktabs') .'/quicktabs.css');
+    drupal_add_js(drupal_get_path('module', 'quicktabs') . '/js/quicktabs_form.js');
+    drupal_add_css(drupal_get_path('module', 'quicktabs') . '/quicktabs.css');
     if ($qtblock->ajax == 0) {
       $output = drupal_get_form('quicktabs_form', $form_state);
-    } else {
+    }
+    else {
       $output = drupal_get_form('quicktabs_aj_form', $form_state);
     }
     return $output; 
@@ -1137,7 +1169,7 @@ function quicktabs_block_edit($qtid) {
  * Deletion of Quick Tabs blocks.
  */
 function quicktabs_block_delete_submit($form, $form_state) {
-  db_query('DELETE FROM {quicktabs} WHERE qtid = %d', $form_state['values']['qtid']);
+  db_delete('quicktabs')->condition('qtid', $form_state['values']['qtid'])->execute();
   drupal_set_message(t('The Quick Tabs block %name has been removed.', array('%name' => $form_state['values']['qt_name'])));
   cache_clear_all();
   drupal_goto('admin/build/quicktabs');
@@ -1157,9 +1189,9 @@ function quicktabs_settings() {
     '#attributes' => array('class' => 'quicktabs-tabstyles clear-block'),
   );
   $form['submit'] = array(
-  '#type' => 'submit',
-  '#value' => t('Submit'),
-  ); 		
+    '#type' => 'submit',
+    '#value' => t('Submit'),
+  );
   return $form;
 }
 
@@ -1174,16 +1206,15 @@ function theme_quicktabs_settings($form)
   drupal_set_title(t('Quick Tabs Settings'));
 
   // Default preview.
-  $form['quicktabs_tabstyle']['default']['#description'] = 'Default '. t('Preview') .':<br /><iframe class="quicktabs-preview" scrolling="no" src="'. url('quicktabs/preview') .'"></iframe>';
+  $form['quicktabs_tabstyle']['default']['#description'] = 'Default ' . t('Preview') . ':<br /><iframe class="quicktabs-preview" scrolling="no" src="' . url('quicktabs/preview') . '"></iframe>';
 
   // Preview for each style.
   $tabstyle_number = 0;
   foreach (element_children($form['quicktabs_tabstyle']) as $tabstyle_key) {
     if ($tabstyle_key != 'default') {
-      $form['quicktabs_tabstyle'][$tabstyle_key]['#description'] = $form['quicktabs_tabstyle'][$tabstyle_key]['#title'] .' '. t('Preview') .':<br /><iframe class="quicktabs-preview" scrolling="no" src="'. url('quicktabs/preview/'. $tabstyle_number) .'"></iframe>';
+      $form['quicktabs_tabstyle'][$tabstyle_key]['#description'] = $form['quicktabs_tabstyle'][$tabstyle_key]['#title'] . ' ' . t('Preview') . ':<br /><iframe class="quicktabs-preview" scrolling="no" src="' . url('quicktabs/preview/' . $tabstyle_number) . '"></iframe>';
       $tabstyle_number++;
     }
-    
   }
   return drupal_render($form);
 }
@@ -1200,17 +1231,16 @@ function quicktabs_preview_page($tabstyl
   else {
     quicktabs_add_css('default');
   }
-  drupal_add_js(drupal_get_path('module', 'quicktabs') .'/js/quicktabs.js');
+  drupal_add_js(drupal_get_path('module', 'quicktabs') . '/js/quicktabs.js');
   print theme('quicktabs_preview_page');
   exit;
 }
 
 function theme_quicktabs_preview_page() {
-
   $output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
   $output .= '<html xmlns="http://www.w3.org/1999/xhtml">';
   $output .= '<head>';
-  $output .= ' <title>'. t('Quick Tabs Preview') .'</title>';
+  $output .= ' <title>' . t('Quick Tabs Preview') . '</title>';
   $output .= drupal_get_html_head();
   $output .= drupal_get_css();
   $output .= drupal_get_js();
@@ -1219,9 +1249,7 @@ function theme_quicktabs_preview_page() 
   $output .= '<div class="quicktabs_wrapper">';
   $output .= '<ul class="quicktabs_tabs"><li><a href="#">One</a></li><li><a href="#">Two</a></li></ul>';
   $output .= '<div class="quicktabs_main"><div class="quicktabs"></div><div class="quicktabs"></div></div></div>';
-        
   $output .= '</body></html>';
-
   return $output;
 }
 
@@ -1231,7 +1259,7 @@ function theme_quicktabs_preview_page() 
  */
 function quicktabs_add_css($tabstyle_css = NULL) {
   // Add quicktabs CSS.
-  drupal_add_css(drupal_get_path('module', 'quicktabs') .'/quicktabs.css');
+  drupal_add_css(drupal_get_path('module', 'quicktabs') . '/quicktabs.css');
 
   // Add specific CSS.
   if (!isset($tabstyle_css)) {
@@ -1244,7 +1272,7 @@ function quicktabs_add_css($tabstyle_css
 }
 
 /**
- * Implementation of hook_quicktabs_widgets.
+ * Implements hook_quicktabs_widgets.
  * 
  * This hook allows other modules to create additional tab styles for
  * the quicktabs module.
@@ -1255,8 +1283,8 @@ function quicktabs_add_css($tabstyle_css
  *   file for a quick tabs style. Each value should be the name of the style.
  */
 function quicktabs_quicktabs_tabstyles() {
-  $tabstyles_directory = drupal_get_path('module', 'quicktabs') .'/tabstyles';
-  $files = file_scan_directory($tabstyles_directory, '\.css$');
+  $tabstyles_directory = drupal_get_path('module', 'quicktabs') . '/tabstyles';
+  $files = file_scan_directory($tabstyles_directory, '/\.css$/');
 
   $tabstyles = array();
   foreach ($files as $file) {
