Index: directory.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/directory/directory.module,v
retrieving revision 1.11
diff -u -p -r1.11 directory.module
--- directory.module	28 Dec 2006 03:03:45 -0000	1.11
+++ directory.module	4 Apr 2007 20:35:49 -0000
@@ -45,30 +45,28 @@ function _directory_wd($message, $level=
  ********************************************************************/
 
 /**
- * Implementation of hook_help().
- */
-function directory_help($section = 'admin/help#directory') {
-  switch ($section) {
-    case 'admin/modules#description':
-      return t('Create a directory of resources based on taxonomy (<strong>requires taxonomy.module</strong>)');
-  }
-}
-
-/**
  * Implementation of hook_menu().
  */
 function directory_menu($may_cache) {
   $items = array();
 
   if (!$may_cache) {
-    // inject our css per http://api.drupal.org/api/HEAD/function/hook_init and http://api.drupal.org/api/HEAD/function/hook_menu
-    drupal_set_html_head(theme('stylesheet_import', base_path() . drupal_get_path('module', 'directory') .'/directory.css'));
+    drupal_add_css(drupal_get_path('module', 'directory') .'/directory.css');
   }
 
   if ($may_cache) {
     $items[] = array('path' => 'directory', 'title' => t('directory'), 'callback' => 'directory_page', 'access' => user_access('access content'));
     $items[] = array('path' => 'directory/term', 'title' => t('Advanced directory search'), 'callback' => 'directory_term_page', 'access' => user_access('access content'), 'type' => MENU_CALLBACK);
     $items[] = array('path' => 'directory/random', 'title' => t('Random directory link'), 'callback' => 'directory_random', 'access' => user_access('access content'), 'type' => MENU_CALLBACK);
+    $items[] = array(
+      'path' => 'admin/settings/directory',
+      'title' => t('Directory Settings'),
+      'description' => t('Set which node types and which vocabularies to include, the depth to display on the directory page, etc.'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('directory_admin_settings'),
+      'access' => user_access('administer site configuration'),
+      'type' => MENU_NORMAL_ITEM
+    );
   }
 
   return $items;
@@ -81,7 +79,7 @@ function directory_menu($may_cache) {
 /**
  * Implementation of hook_settings().
  */
-function directory_settings() {
+function directory_admin_settings() {
   $output = '';
 
   if (function_exists('taxonomy_help')) {
@@ -91,8 +89,9 @@ function directory_settings() {
     }
   }
 
-  foreach (node_get_types() as $type => $name) {
-    $nodetypes[$type] = $name;
+  $nodetypes = array();
+  foreach (node_get_types() AS $type) {
+    $nodetypes[$type->type] = $type->name;
   }
 
   $form['module_banner'] = array('#type' => 'markup', 
@@ -105,7 +104,6 @@ function directory_settings() {
   	'#default_value' => variable_get('directory_no_nodes', array()),
   	'#options' => $nodetypes,
   	'#description' => t('<em><strong>Please note:</strong> Any node types that are checked here will <strong>NOT be included</strong> in the directory listings.  All other types will be included.</em>'),
-  	'#attributes' => NULL,
   	'#required' => FALSE,
   );
   $form['directory_vocabularies_root'] = array(
@@ -158,7 +156,7 @@ function directory_settings() {
   	'#description' => t('This text will be displayed at the top of the directory pages.  It is useful for helping or instructing your users.'),
   );
 
-  return $form;
+  return system_settings_form($form);
 }
 
 /********************************************************************
@@ -322,7 +320,7 @@ function directory_select_nodes_query_bu
     if ($operator == 'or') {
       $str_tids = implode(',', call_user_func_array('array_merge', $descendant_tids));
       $sql_fetch = db_rewrite_sql('SELECT DISTINCT(n.nid), n.* FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 ORDER BY n.sticky DESC, n.title ASC');
-      $sql_count = db_rewrite_sql('SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND AND n.status = 1 ORDER BY n.sticky DESC, n.title ASC');
+      $sql_count = db_rewrite_sql('SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 ORDER BY n.sticky DESC, n.title ASC');
     }
     else {
       $joins = '';
@@ -331,7 +329,7 @@ function directory_select_nodes_query_bu
         $joins .= ' INNER JOIN {term_node} tn'. $index .' ON n.nid = tn'. $index .'.nid';
         $wheres .= ' AND tn'. $index .'.tid IN ('. implode(',', $tids) .')';
       }
-      $sql_fetch = db_rewrite_sql('SELECT DISTINCT(n.nid), n.* {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' ORDER BY n.sticky DESC, n.title ASC');
+      $sql_fetch = db_rewrite_sql('SELECT DISTINCT(n.nid), n.* FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' ORDER BY n.sticky DESC, n.title ASC');
       $sql_count = db_rewrite_sql('SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' ORDER BY n.sticky DESC, n.title ASC');
     }
 
@@ -461,7 +459,7 @@ function directory_display_home_category
       }
       // if desired, exclude items 
       if ((!$hideempty) || $nodecount>0) {
-        $items[] = $item_span . l(_taxonomy_depth($term->depth) . ' '. $term->name, "directory/$term->tid", (($term->description) ? array('title' => $term->description) : array())) 
+        $items[] = $item_span . l(str_repeat('-', $term->depth) .' '. $term->name, "directory/$term->tid", (($term->description) ? array('title' => $term->description) : array())) 
            . $nodecount_span . '</span>';
       }
     }
@@ -511,16 +509,16 @@ function directory_get_nodes_by_term($ti
   }
 
   if ($tid == 'alpha') {
-    $sql = db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} t ON t.nid = n.nid WHERE 1 '. $where ." AND n.status = 1");
+    $sql = db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} t ON t.nid = n.nid WHERE 1 '. $where ." AND n.status = 1 ORDER BY n.sticky DESC, n.title ASC");
   }
   elseif ($tid == '0-9') {
-    $sql = db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} t ON t.nid = n.nid WHERE 1 '. $where ." AND n.status = 1 AND n.title REGEXP '^[0-9]'");
+    $sql = db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} t ON t.nid = n.nid WHERE 1 '. $where ." AND n.status = 1 AND n.title REGEXP '^[0-9]' ORDER BY n.sticky DESC, n.title ASC");
   }
   elseif (preg_match('/^[a-zA-z]$/', $tid)) {
-    $sql = db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} t ON t.nid = n.nid WHERE 1 '. $where ." AND n.status = 1 AND n.title LIKE '". db_escape_string($tid) ."%'");
+    $sql = db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} t ON t.nid = n.nid WHERE 1 '. $where ." AND n.status = 1 AND n.title LIKE '". db_escape_string($tid) ."%' ORDER BY n.sticky DESC, n.title ASC");
   }
   else {
-    $sql = db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} t ON t.nid = n.nid WHERE 1 '. $where .' AND n.status = 1 AND t.tid = '. db_escape_string($tid));
+    $sql = db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} t ON t.nid = n.nid WHERE 1 '. $where .' AND n.status = 1 AND t.tid = '. db_escape_string($tid) .' ORDER BY n.sticky DESC, n.title ASC');
   }
   if (DIRECTORY_MODULE_DEBUG) ed_module_support_vd($sql, 'get_nodes_by_term');
   if ($pager) {
