### Eclipse Workspace Patch 1.0
#P drupal-contrib-cvs
Index: modules/sections/sections.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sections/sections.module,v
retrieving revision 1.16
diff -u -r1.16 sections.module
--- modules/sections/sections.module	8 Dec 2006 23:46:52 -0000	1.16
+++ modules/sections/sections.module	30 Apr 2007 21:25:00 -0000
@@ -17,6 +17,85 @@
 }
 
 /**
+ * Implementation of hook_perm().
+ *
+ * Since the access to our new custom pages will be granted based on
+ * special permissions, we need to define what those permissions are here.
+ * This ensures that they are available to enable on the user role
+ * administration pages.
+ */
+function sections_perm() {
+  return array('administer sections');
+}
+
+/**
+ * Implementation of hook_menu().
+ */
+function sections_menu($may_cache) {
+  global $custom_theme;
+  $items = array();
+
+  /*
+  * admin/build/sections/ show the summary
+  * admin/build/sections/list show the summary
+  * admin/build/sections/add show an empty form
+  * admin/build/sections/edit/XX show edit form for XX
+  */
+
+  if ($may_cache) {
+    $access = user_access('administer sections');
+
+    // This is the minimum information you can provide for a menu item.
+    $items[] = array(
+      'path' => 'admin/build/sections', 
+      'title' => t('Sections'),
+      'description' => t('Define sections of your site and apply themes to them.'),
+      'callback' => 'sections_list',
+      'access' => $access
+    );
+    $items[] = array(
+      'path' => 'admin/build/sections/list', 
+      'title' => t('List'),
+      'callback' => 'sections_list',
+      'access' => $access,
+      'type' => MENU_DEFAULT_LOCAL_TASK
+    );
+    $items[] = array(
+      'path' => 'admin/build/sections/add', 
+      'title' => t('Add section'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('sections_admin_settings_form'),
+      'access' => $access,
+      'type' => MENU_LOCAL_TASK
+    );
+
+    foreach (_sections_load() as $section) {
+      $items[] = array(
+        'path' => 'admin/build/sections/edit/'.$section->sid, 
+        'title' => t('Edit @name', array('@name' => $section->name)),
+        'callback' => 'drupal_get_form',
+        'callback arguments' => array('sections_admin_settings_form', NULL, $section),
+        'access' => $access,
+        'type' => MENU_CALLBACK
+      );
+      $items[] = array(
+        'path' => 'admin/build/sections/delete/'.$section->sid, 
+        'title' => t('Delete %name', array('%name'=>$section->name)),
+        'callback' => '_sections_delete',
+        'callback arguments' => array($section),
+        'access' => $access,
+        'type' => MENU_CALLBACK
+      );
+    }
+  }
+  else if ($section = sections_in_section()) {
+    $custom_theme = $section->template;
+  }
+
+  return $items;
+}
+
+/**
  * Declare administrative settings for a module.
  *
  * This hook provides an administrative interface for controlling various
@@ -34,34 +113,41 @@
  * define your own administration page and link to it using hook_menu().
  */
 function sections_list() {
-  $header = array(t('Section'), t('Enabled'), t('Template'), t('Weight'), array('data' => t('Operations')) );
+  $header = array(
+    t('Section'), 
+    t('Enabled'), 
+    t('Template'), 
+    t('Weight'), 
+    array('data' => t('Operations'))
+  );
 
   foreach(_sections_load() as $section) {
-     $rows[] = array(
-        $section->name,
-        $section->status ?  t('enabled') : t('disabled'),
-        $section->template,
-        $section->weight,
-        l(t('edit'),'admin/settings/sections/edit/'.$section->sid) ." ".
-        l(t('delete'),'admin/settings/sections/delete/'.$section->sid));
+    $rows[] = array(
+      $section->name,
+      $section->status ?  t('enabled') : t('disabled'),
+      $section->template,
+      $section->weight,
+      l(t('edit'),'admin/build/sections/edit/'.$section->sid) ." | ". l(t('delete'),'admin/build/sections/delete/'.$section->sid)
+    );
   }
-
+  
   $output = theme('table', $header, $rows);
-  return $output;}
+  return $output;
+}
 
-function sections_settings_form($edit = NULL, $section = NULL) {
+function sections_admin_settings_form($edit = NULL, $section = NULL) {
   if ($section) {
     $edit = (array)$section;
   }
   $access = user_access('use PHP for block visibility');
   $form = array();
-
+  
   $options = array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.'));
-  $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '%blog' for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => theme('placeholder', 'blog'), '%blog-wildcard' =>  theme('placeholder', 'blog/*'), '%front' => theme('placeholder', '<front>')));
+  $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
 
   if ($access) {
     $options[] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
-    $description .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => theme('placeholder', '<?php ?>')));
+    $description .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
   }
 
   $form['section_settings'] = array(
@@ -72,7 +158,7 @@
   $form['section_settings']['name'] = array(
     '#type' => 'textfield',
     '#title' => t('Name'),
-    '#default_value' =>  $edit['name'],
+    '#default_value' => $edit['name'],
     '#size' => 40,
     '#maxlength' => 64,
     '#description' => t('Give the name of the section'),
@@ -88,7 +174,7 @@
   $form['section_settings']['path'] = array(
     '#type' => 'textarea',
     '#title' => t('Pages'),
-    '#default_value' =>  $edit['path'],
+    '#default_value' => $edit['path'],
     '#cols' => 40,
     '#rows' => 5,
     '#description' => $description,
@@ -125,25 +211,24 @@
     $form['submit'] = array('#type' => 'submit', '#value' => t('Add section'));
   }
 
-  print theme('page', drupal_get_form('section_settings', $form));
+  return $form;
 }
 
-
-function section_settings_submit($id, $edit) {
+function sections_admin_settings_form_submit($id, $edit) {
   switch ($_POST['op']) {
     case t('Save section'):
       db_query("UPDATE {sections_data} SET name = '%s', status = '%d', visibility = '%d', template = '%s', path = '%s', weight = %d WHERE sid = '%d'", $edit['name'], $edit['status'], $edit['visibility'], $edit['template'], $edit['path'], $edit['weight'], $edit['sid']);
-      drupal_set_message('The sections configuration has been saved.');
+      drupal_set_message(t('The sections configuration has been saved.'));
       cache_clear_all();
       menu_rebuild();
-      drupal_goto('admin/settings/sections/');
+      drupal_goto('admin/build/sections/');
     case t('Add section'):
       $edit['sid'] = db_next_id('{sections_id}');
       db_query("INSERT INTO {sections_data} SET sid = '%d', name = '%s', status = '%d', visibility = '%d', path = '%s', template = '%s', weight = %d", $edit['sid'], $edit['name'], $edit['status'], $edit['visibility'], $edit['path'], $edit['template'], $edit['weight']);
-      drupal_set_message('The sections configuration has been saved.');
+      drupal_set_message(t('The sections configuration has been saved.'));
       cache_clear_all();
       menu_rebuild();
-      drupal_goto('admin/settings/sections/');
+      drupal_goto('admin/build/sections/');
       break;
   }
 }
@@ -153,94 +238,36 @@
 
   switch ($op) {
     case t('Delete'):
-      db_query('DELETE FROM {sections_data} WHERE sid = %d', $section->sid);
-      drupal_set_message(t('The section %name has been deleted.', array('%name' => '<em>'. $section->name .'</em>')));
+      db_query("DELETE FROM {sections_data} WHERE sid = %d", $section->sid);
+      drupal_set_message(t('The section %name has been deleted.', array('%name' => $section->name)));
       cache_clear_all();
-      drupal_goto('admin/settings/sections');
+      drupal_goto('admin/build/sections');
       break;
 
     default:
-      $output = confirm_form(
-                    'comment_confirm_delete',
-                    array(),
-                    t('Are you sure you want to delete the section %name?', array('%name' => '<em>'. $section->name .'</em>')),
-                    'admin/settings/sections/',
-                    '',
-                    t('Delete'),
-                    t('Cancel'));
+      $output = drupal_get_form('_sections_delete_confirm', $section);
       break;
   }
 
-  print theme('page', $output);
+  return $output;
 }
 
-/**
- * Implementation of hook_perm().
- *
- * Since the access to our new custom pages will be granted based on
- * special permissions, we need to define what those permissions are here.
- * This ensures that they are available to enable on the user role
- * administration pages.
- */
-function sections_perm() {
-  return array('adminster sections');
-}
-
-/**
- * Implementation of hook_menu().
- */
-function sections_menu($may_cache) {
-  global $custom_theme;
-  $items = array();
-
-  /*
-  * admin/settings/sections/ show the summary
-  * admin/settings/sections/list show the summary
-  * admin/settings/sections/add show an empty form
-  * admin/settings/sections/edit/XX show edit form for XX
-  */
-
-  if ($may_cache) {
-    $access = user_access('adminster sections');
-
-    // This is the minimum information you can provide for a menu item.
-    $items[] = array('path' => 'admin/settings/sections', 'title' => t('sections'),
-      'callback' => 'sections_list',
-      'access' => $access);
-
-    $items[] = array('path' => 'admin/settings/sections/list', 'title' => t('list'),
-      'callback' => 'sections_list',
-      'access' => $access,
-      'type' => MENU_DEFAULT_LOCAL_TASK);
-    $items[] = array('path' => 'admin/settings/sections/add', 'title' => t('add'),
-      'callback' => 'sections_settings_form',
-      'access' => $access,
-      'type' => MENU_LOCAL_TASK);
 
-    foreach (_sections_load() as $section) {
-       $items[] = array('path' => 'admin/settings/sections/edit/'.$section->sid, 'title' => t('edit %name', array('%name'=>$section->name)),
-        'callback' => 'sections_settings_form',
-        'callback arguments' => array(NULL,$section),
-        'access' => $access,
-        'type' => MENU_CALLBACK);
-       $items[] = array('path' => 'admin/settings/sections/delete/'.$section->sid, 'title' => t('edit %name', array('%name'=>$section->name)),
-        'callback' => '_sections_delete',
-        'callback arguments' => array($section),
-        'access' => $access,
-        'type' => MENU_CALLBACK);
-    }
-  }
-  else if ($section = sections_in_section()) {
-    $custom_theme = $section->template;
-  }
-
-  return $items;
+function _sections_delete_confirm($section) {
+  return confirm_form(
+    array(),
+    t('Delete section %name', array('%name' => $section->name)),
+    'admin/build/sections/', 
+    t('<p>Are you sure you want to delete the section %name?</p>', array('%name' => $section->name)),
+    t('Delete'),
+    t('Cancel')
+  );
 }
 
 function _sections_load() {
   $sections = array();
 
-  $res = db_query('SELECT * FROM {sections_data}');
+  $res = db_query("SELECT * FROM {sections_data}");
 
   while ($row = db_fetch_object($res)) {
     $sections[] = $row;
@@ -253,7 +280,7 @@
  */
 
 function _section_load($section_name) {
-  return db_fetch_object(db_query('SELECT * FROM {sections_data} WHERE n.name = %s ORDER BY weight', $section_name));
+  return db_fetch_object(db_query("SELECT * FROM {sections_data} WHERE n.name = '%s' ORDER BY weight", $section_name));
 }
 
 /**
@@ -288,16 +315,14 @@
   if (is_string($section)) {
     //caller wants to know if shes in the section she provided.
     if($section == sections_in_section()) {
-     return TRUE;
+      return TRUE;
     }
   }
   else {
     //caller wants to know in which section she is.
-
     $res = db_query("SELECT path, status, visibility, template, weight FROM {sections_data} WHERE status=1 ORDER BY weight");
     while ($row = db_fetch_object($res)) {
       if ($row->visibility == 1) {
-
         // This bizarre bit of magic courtesy of block.module
         $path = drupal_get_path_alias($_GET['q']);
         $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($row->path, '/')) .')$/';
Index: modules/sections/sections.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sections/sections.install,v
retrieving revision 1.5
diff -u -r1.5 sections.install
--- modules/sections/sections.install	12 Jul 2006 17:41:36 -0000	1.5
+++ modules/sections/sections.install	30 Apr 2007 21:24:59 -0000
@@ -13,9 +13,7 @@
                 `template` text,
                 `visibility` smallint(1) default '0',
                 `weight` int(10) default NULL
-                ) ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      $id = db_next_id('sections_id');
-      db_query("INSERT INTO {sections_data} VALUES (%d,'Admin',1,'admin\nadmin/*','bluemarine',1,-10);", $id);
+                ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
       break;
     case 'pgsql':
       break;
Index: modules/sections/sections.info
===================================================================
RCS file: modules/sections/sections.info
diff -N modules/sections/sections.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/sections/sections.info	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,4 @@
+; $Id$
+name = Sections
+description = "Allows you to define sections of your site and apply themes to those sections."
+version = "$Name: $"
