diff --git a/sites/all/modules/contrib/signwriter/color.js b/sites/all/modules/contrib/signwriter/color.js
index bb6042b..6cb4be9 100644
--- a/sites/all/modules/contrib/signwriter/color.js
+++ b/sites/all/modules/contrib/signwriter/color.js
@@ -1,6 +1,7 @@
 /* $Id $ */
-$(function() {
-  if (Drupal.jsEnabled) {
+(function ($) {
+
+  $(function() {
     farbify($('#edit-background'), '#background-farb');
     farbify($('#edit-hov-background'), '#hov_background-farb');
     farbify($('#edit-act-background'), '#act_background-farb');
@@ -16,23 +17,23 @@ $(function() {
     farbify($('#edit-border-color'), '#border-color-farb');
     farbify($('#edit-hov-border-color'), '#hov_border-color-farb');
     farbify($('#edit-act-border-color'), '#act_border-color-farb');
+  });
+  
+  function updateColor(elt, farb) {
+    var text = elt.val();
+    if (text.length == 6)
+      farb.setColor('#' + text);
   }
-});
-
-function updateColor(elt, farb) {
-  var text = elt.val();
-  if (text.length == 6)
-    farb.setColor('#' + text);
-}
-
-function farbify(elt, wrapper) {
-  var farb = $.farbtastic(wrapper);
-  farb.linkTo(function(color) {
-      elt
-        .css('background-color', color)
-        .css('color', this.hsl[2] > 0.5 ? '#000' : '#fff')
-        .val(color.substring(1));
-    });
-  farb.setColor('#' + elt.val());
-  elt.bind('keyup', function(){ updateColor(elt, farb); });
-}
+  
+  function farbify(elt, wrapper) {
+    var farb = $.farbtastic(wrapper);
+    farb.linkTo(function(color) {
+        elt
+          .css('background-color', color)
+          .css('color', this.hsl[2] > 0.5 ? '#000' : '#fff')
+          .val(color.substring(1));
+      });
+    farb.setColor('#' + elt.val());
+    elt.bind('keyup', function(){ updateColor(elt, farb); });
+  }
+})(jQuery);
diff --git a/sites/all/modules/contrib/signwriter/signwriter.admin.inc b/sites/all/modules/contrib/signwriter/signwriter.admin.inc
index adc77c5..62f8fbd 100644
--- a/sites/all/modules/contrib/signwriter/signwriter.admin.inc
+++ b/sites/all/modules/contrib/signwriter/signwriter.admin.inc
@@ -1,5 +1,10 @@
 <?php
+// $Id$
 
+/**
+ * @file
+ * Admin section for Signwriter.
+ */
 
 /**
  * adds the signwriter profiles to the settings form
@@ -8,22 +13,42 @@ function _signwriter_add_profiles_to_form(&$form, $formtag = "profiles") {
   $profiles = signwriter_load_profiles();
   $rows = array();
   foreach ($profiles as $profile) {
-    $links[] = l($profile->name, 'admin/settings/signwriter/profile/'. $profile->id);
+    $links[] = l($profile->name, 'admin/config/signwriter/signwriter/profile/' . $profile->id);
+    $variables = array(
+      'text' => $profile->name,
+      'profile' => $profile,
+      'attributes' => array('style' => 'vertical-align:middle'),
+    );
     $rows[] = array(
-      'name' => l(theme_signwriter_text($profile->name, $profile, array('style' => 'vertical-align:middle')),
-                    'admin/settings/signwriter/profile/'. $profile->id,
-    array('html' => TRUE)),
-      'edit' => l(t('edit'), 'admin/settings/signwriter/profile/'. $profile->id),
-      'delete' => l(t('delete'), "admin/settings/signwriter/profile/$profile->id/delete"));
+      'name' => l(theme('signwriter_text', $variables), 'admin/config/signwriter/signwriter/profile/'. $profile->id, array('html' => TRUE)),
+      'edit' => l(t('edit'), 'admin/config/signwriter/signwriter/profile/' . $profile->id),
+      'delete' => l(t('delete'), "admin/config/signwriter/signwriter/profile/$profile->id/delete"),
+    );
   }
   if (empty($rows)) {
-    $rows[] = array(array('data' => t('No profiles'), 'colspan' => '3', 'class' => 'message'));
+    $rows[] = array(
+      array(
+        'data' => t('No profiles'),
+        'colspan' => '3',
+        'class' => 'message',
+      ),
+    );
   }
 
-  $rows[] = array(array('data' => l(t('Add a profile'), 'admin/settings/signwriter/profile/add'), 'colspan' => '3'));
-  $header = array(array('data' => t('Profiles'), 'colspan' => '3'));
+  $rows[] = array(
+    array(
+      'data' => l(t('Add a profile'), 'admin/config/signwriter/signwriter/profile/add'),
+      'colspan' => '3',
+    ),
+  );
+  $header = array(
+    array(
+      'data' => t('Profiles'),
+      'colspan' => '3',
+    ),
+  );
   $form[$formtag] = array(
-    '#value' => theme('table', $header, $rows), 
+    '#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
   );
 }
 /**
@@ -33,7 +58,11 @@ function _signwriter_add_profiles_to_form(&$form, $formtag = "profiles") {
  *   The profile object to delete.
  */
 function _signwriter_delete_profile($profile) {
-  if (db_query('DELETE FROM {signwriter} WHERE id = %d', $profile->id)) {
+  // TODO Please review the conversion of this statement to the D7 database API syntax.
+  /* db_query('DELETE FROM {signwriter} WHERE id = %d', $profile->id) */
+  if (db_delete('signwriter')
+  ->condition('id', $profile->id)
+  ->execute()) {
     drupal_set_message(t("Deleted the '@name' profile.", array('@name' => $profile->name)));
   }
   else {
@@ -47,10 +76,8 @@ function _signwriter_delete_profile($profile) {
  * @param $profile
  *   The profile object to save
  */
-function signwriter_save_profile($profile, $update) {
-  $s = drupal_write_record('signwriter', $profile, $update ? "id" : NULL);
-  //  drupal_set_message('signwriter_save_profile::drupal_write_record = <pre>'.print_r($s, TRUE).'</pre>');
-  //  drupal_set_message('signwriter_save_profile::$profile = <pre>'.print_r($profile, TRUE).'</pre>');
+function signwriter_save_profile($profile, $update = FALSE) {
+  drupal_write_record('signwriter', $profile, ($update ? 'id' : array()));
   return $profile->id;
 }
 
@@ -63,31 +90,34 @@ function _signwriter_add_menuprofiles_to_form(&$form, $formtag = "menuprofiles")
   $rows = array();
   foreach ($profiles as $profile) {
     $rows[] = array(
-            'name' => $profile->name,
-    //'sample' => theme_signwriter_text($profile->name, $profile, array('style' => 'vertical-align:middle')),
-    //'sample' => _signwritermenu_overview($profile),
-            'sample' => $profile->name,
-            'edit' => l(t('edit'), 'admin/settings/signwriter/menuprofile/'. $profile->id),
-            'delete' => l(t('delete'), "admin/settings/signwriter/menuprofile/$profile->id/delete")
+      'name' => $profile->name,
+      'sample' => $profile->name,
+      'edit' => l(t('edit'), 'admin/config/signwriter/signwriter/menuprofile/' . $profile->id),
+      'delete' => l(t('delete'), "admin/config/signwriter/signwriter/menuprofile/$profile->id/delete"),
     );
   }
   if (empty($rows)) {
-    $rows[] = array(array('data' => t('No profiles'), 'colspan' => '4', 'class' => 'message'));
+    $rows[] = array(array(
+      'data' => t('No profiles'),
+      'colspan' => '4',
+      'class' => 'message',
+    ));
   }
   $rows[] = array(
-  array('data' => l(t('Add a menu profile'), 'admin/settings/signwriter/menuprofile/add'),
-              'colspan' => '4'
-              ),
-              );
-              $header = array(
+    array(
+      'data' => l(t('Add a menu profile'), 'admin/config/signwriter/signwriter/menuprofile/add'),
+      'colspan' => '4',
+    ),
+  );
+  $header = array(
     'name' => t('Profile'),
     'sample' => t('Sample'),
     'actions' => t('Actions'),
-              //'actions2' => "",
-              );
-              $form[$formtag] = array(
-    '#value' => theme('table', $header, $rows)
-              );
+    //'actions2' => "",
+  );
+  $form[$formtag] = array(
+    '#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
+  );
 }
 
 /**
@@ -97,7 +127,9 @@ function _signwriter_add_menuprofiles_to_form(&$form, $formtag = "menuprofiles")
  *   The profile object to delete.
  */
 function _signwriter_delete_menuprofile($profile) {
-  if (db_query("DELETE FROM {signwriter_menu} WHERE id = %d", $profile->id)) {
+  // TODO Please review the conversion of this statement to the D7 database API syntax.
+  /* db_query("DELETE FROM {signwriter_menu} WHERE id = %d", $profile->id) */
+  if (db_delete('signwriter_menu')->condition('id', $profile->id)->execute()) {
     drupal_set_message(t("Deleted the '@name' profile.", array('@name' => $profile->name)));
   }
   else {
@@ -114,11 +146,24 @@ function _signwriter_delete_menuprofile($profile) {
 function _signwriter_save_menuprofile($profile, $update) {
   $values = serialize($profile->data);
   if (empty($profile->id)) {
-    db_query("INSERT INTO {signwriter_menu} (name,data) VALUES ('%s','%s')", $profile->name, $values);
-    return db_result(db_query("SELECT LAST_INSERT_ID()"));
+    // TODO Please review the conversion of this statement to the D7 database API syntax.
+    /* db_query("INSERT INTO {signwriter_menu} (name,data) VALUES ('%s','%s')", $profile->name, $values) */
+    $id = db_insert('signwriter_menu')->fields(array(
+      'name' => $profile->name,
+      'data' => $values,
+    ))->execute();
+    return db_query("SELECT LAST_INSERT_ID()")->fetchField();
   }
   else {
-    db_query("UPDATE {signwriter_menu} SET name='%s', data='%s' WHERE id=%d", $profile->name, $values, $profile->id);
+    // TODO Please review the conversion of this statement to the D7 database API syntax.
+    /* db_query("UPDATE {signwriter_menu} SET name='%s', data='%s' WHERE id=%d", $profile->name, $values, $profile->id) */
+    db_update('signwriter_menu')
+    ->fields(array(
+      'name' => $profile->name,
+      'data' => $values,
+    ))
+    ->condition('id', $profile->id)
+    ->execute();
     return $profile->id;
   }
 }
@@ -128,31 +173,37 @@ function _signwriter_save_menuprofile($profile, $update) {
 /**
  * The main admin>>settings>>signwriter page
  */
-function signwriter_settings_form($form_state) {
+function signwriter_settings_form($form, $form_state) {
   $form = array();
   if (!function_exists('imagetypes')) {
-    $form['error'] = array(
-      '#value' => theme('page', t('It appears that you do not have the GD image library installed. GD is enabled by default in PHP >= 4.3, but can be enabled at compile time in earlier versions. If your php installation is on windows, try uncommenting the line which reads \'extension=php_gd2.dll\' in your php.ini. For more information see the !phpimagedoc', array('!phpimagedoc' => l('PHP Image library documentation.', 'http://php.net/image')))),
-    );
+    // TODO Please change this theme call as discussed at http://drupal.org/node/224333#theme_page.
+    // $form['error'] = array(
     return $form;
   }
-  else
-  {
+  else {
     _signwriter_add_profiles_to_form($form);
-     
-    $form['paths'] = array('#type' => 'fieldset', '#title' => t('Paths'), '#collapsible' => TRUE, '#collapsed' => FALSE);
+    $form['paths'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Paths'),
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+    );
     $form['paths']['signwriter_cachedir'] = array(
       '#type' => 'textfield',
       '#title' => t('Cache Directory'),
       '#description' => t('This is the directory that signwriter will store its generated images in. It must be publicly accessible; the default is \'files/signwriter-cache\'. Make sure that your webserver process is able to create and write to this directory. Files can be deleted from this directory at any time.'),
-      '#default_value' => variable_get('signwriter_cachedir', file_directory_path() .'/signwriter'),
+      '#default_value' => variable_get('signwriter_cachedir', file_directory_path() . '/signwriter'),
     );
     $form['paths']['signwriter_cachecleanperiod'] = array(
       '#type' => 'radios',
       '#title' => t('Cache cleanup period'),
       '#description' => t('Choose how often the images in the signwriter cache directory should be purged.'),
       '#default_value' => variable_get('signwriter_cachecleanperiod', '100 years'),
-      '#options' => array('1 day' => t('Daily'), '1 week' => t('Weekly'), '100 years' => t('Never')),
+      '#options' => array(
+        '1 day' => t('Daily'),
+        '1 week' => t('Weekly'),
+        '100 years' => t('Never'),
+      ),
     );
     $form['paths']['signwriter_cachecleannow'] = array(
       '#type' => 'submit',
@@ -165,13 +216,18 @@ function signwriter_settings_form($form_state) {
       '#default_value' => variable_get('signwriter_fontpath', ''),
     );
 
-    $form['pages'] = array('#type' => 'fieldset', '#title' => t('Pages'), '#collapsible' => TRUE, '#collapsed' => FALSE);
+    $form['pages'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Pages'),
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+    );
     $options = array(t('Use on every page except the listed pages.'), t('Use 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' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
     $access = user_access('use PHP for signwriter pages');
     if ($access) {
       $options[] = t('Use 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' => '<?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['pages']['signwriter_pages_type'] = array(
       '#type' => 'radios',
@@ -195,7 +251,11 @@ function signwriter_settings_form($form_state) {
     $titleoptions = array('disabled' => t('Disabled (headers unchanged)'));
     $profiles = signwriter_load_profiles();
     foreach ($profiles as $profile) {
-      $titleoptions[$profile->id] = theme_signwriter_text($profile->name, $profile, array('style' => 'vertical-align:middle'));
+      $titleoptions[$profile->id] = theme('signwriter_text', array(
+        'text' => $profile->name,
+        'profile' => $profile,
+        'attributes' => array('style' => 'vertical-align:middle'),
+      ));
     }
 
     $form['hooks'] = array(
@@ -203,7 +263,7 @@ function signwriter_settings_form($form_state) {
       '#title' => t('Template Hooks'),
       '#description' => t('Choose a profile for each specific signwriter_preprocess hook to replace normal /text) headers with signwritten versions.'),
       '#collapsible' => TRUE,
-      '#collapsed' => FALSE
+      '#collapsed' => FALSE,
     );
     $form['hooks']['signwriter_pagehookprofile'] = array(
       '#type' => 'radios',
@@ -232,8 +292,9 @@ function signwriter_settings_form($form_state) {
     //.... Build profile popup menu
     $menuprofiles = signwriter_load_menuprofiles();
     $menuoptions = array(false => t("Standard (not signwriter enhanced)"));
-    foreach ($menuprofiles as $menuprofile)
-    $menuoptions[$menuprofile->id] = $menuprofile->name;
+    foreach ($menuprofiles as $menuprofile) {
+      $menuoptions[$menuprofile->id] = $menuprofile->name;
+    }
 
     //.... Build settings for earch menu
     $form['signwritermenu'] = array(
@@ -241,7 +302,7 @@ function signwriter_settings_form($form_state) {
       '#title' => t('Menu Settings'),
       '#description' => t('Choose a profile for each menu that should use Signwritermenu for drawing menu items.'),
       '#collapsible' => TRUE,
-      '#collapsed' => FALSE
+      '#collapsed' => FALSE,
     );
     $form['signwritermenu']['signwriter_menulevels'] = array(
       '#type' => 'textfield',
@@ -250,15 +311,15 @@ function signwriter_settings_form($form_state) {
       '#default_value' => variable_get('signwriter_menulevels', '3'),
       '#size' => 2,
     );
-     
+
     $menusettings = variable_get("signwriter_menusettings", array());
     $menus = menu_get_menus();
     foreach ($menus as $key => $title) {
-      $form['signwritermenu']['swm_'.$key] = array(
+      $form['signwritermenu']['swm_' . $key] = array(
         '#type' => 'select',
         '#title' => $title,
         '#descripion' => t(""),
-        '#default_value' => $menusettings[$key],
+        '#default_value' => (isset($menusettings[$key]) ? $menusettings[$key] : ''),
         '#options' => $menuoptions,
       );
     }
@@ -268,6 +329,10 @@ function signwriter_settings_form($form_state) {
   }
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function signwriter_settings_form_validate($form, &$form_state) {
   if ($form_state['clicked_button']['#value'] == t('Clean signwriter cache now')) {
     signwriter_cron(TRUE);
@@ -284,55 +349,57 @@ function signwriter_settings_form_submit($form, &$form_state) {
   $menus = menu_get_menus();
   $menusettings = array();
   foreach ($menus as $key => $title) {
-    $value = $form_state['values']['swm_'.$key];
+    $value = $form_state['values']['swm_' . $key];
     if ($value) {
       $menusettings[$key] = intval($value);
     }
-    unset($form_state['values']['swm_'.$key]);
+    unset($form_state['values']['swm_' . $key]);
   }
   unset($form_state['values']['signwriter_cachecleannow']);
 
   if ($op == t('Reset to defaults')) {
     variable_del('signwriter_menusettings');
-  } else {
+  }
+  else {
     variable_set('signwriter_menusettings', $menusettings);
   }
 
   system_settings_form_submit($form, $form_state);
   cache_clear_all();
-  drupal_rebuild_theme_registry();
+  drupal_theme_rebuild();
 }
 
-
-
-
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function _signwriter_profile_font($p, $fontoptions, $state = "") {
   $fieldset = array();
   $fieldset['fontfile'] = array(
     '#type' => 'select',
     '#title' => t('Font'),
-    '#description' => t('These fonts have been found on the host system. The directories searched for fonts were @fontsearch. To change the font search path, go to !signwriter_admin.', array('@fontsearch' => implode(', ', _signwriter_get_fontpaths()), '!signwriter_admin' => l('the signwriter settings page', 'admin/settings/signwriter'))),
+    '#description' => t('These fonts have been found on the host system. The directories searched for fonts were @fontsearch. To change the font search path, go to !signwriter_admin.', array('@fontsearch' => implode(', ', _signwriter_get_fontpaths()), '!signwriter_admin' => l(t('the signwriter settings page'), 'admin/config/signwriter/signwriter'))),
     '#options' => $fontoptions,
-    '#default_value' => _signwriter_get_val($p, $state.'fontfile'),
+    '#default_value' => _signwriter_get_val($p, $state . 'fontfile'),
     '#prefix' => '<td>',
   );
   $fieldset['fontsize'] = array(
     '#type' => 'textfield',
     '#title' => t('Font Size'),
     '#description' => t("If you define 'Max Width' below then this size may be overridden in order to fit the text within the given width. Defaults to 20."),
-    '#default_value' => _signwriter_get_val($p, $state.'fontsize'),
+    '#default_value' => _signwriter_get_val($p, $state . 'fontsize'),
     '#size' => 4,
   );
   $fieldset['foreground'] = array(
     '#type' => 'textfield',
     '#title' => t('Font Colour'),
     '#description' => t('This should be six hexadecimal digits, such as ff0000 for red, 00ff00 for green, or 0000ff for blue.'),
-    '#default_value' => _signwriter_get_val($p, $state.'foreground'),
+    '#default_value' => _signwriter_get_val($p, $state . 'foreground'),
     '#size' => 6,
     '#maxlength' => 6,
   );
   $fieldset['foreground-farb'] = array(
-    '#value' => '<div id="' . $state . 'foreground-farb"></div>',
+    '#markup' => '<div id="' . $state . 'foreground-farb"></div>',
   );
   return $fieldset;
 }
@@ -343,97 +410,108 @@ function _signwriter_profile_shadow_settings($p, $fontoptions, $state = "") {
     '#type' => 'checkbox',
     '#title' => t('Drop Shadow'),
     '#description' => t('If enabled, the text will cast a shadow.'),
-    '#default_value' => _signwriter_get_val($p, $state.'drop_shadow', FALSE),
+    '#default_value' => _signwriter_get_val($p, $state . 'drop_shadow', FALSE),
   );
   $fieldset['shadow_color'] = array(
     '#type' => 'textfield',
     '#title' => t('Shadow Colour'),
     '#description' => t('This should be six hexadecimal digits, such as ff0000 for red, 00ff00 for green, or 0000ff for blue.'),
-    '#default_value' => _signwriter_get_val($p, $state.'shadow_color'),
+    '#default_value' => _signwriter_get_val($p, $state . 'shadow_color'),
     '#size' => 6,
     '#maxlength' => 6,
   );
   $fieldset['shadow_color-farb'] = array(
-    '#value' => '<div id="' . $state . 'shadow-color-farb"></div>'
-    );
-    $fieldset['shadow_xoffset'] = array(
+    '#markup' => '<div id="' . $state . 'shadow-color-farb"></div>',
+  );
+  $fieldset['shadow_xoffset'] = array(
     '#type' => 'textfield',
     '#title' => t('Shadow X Offset'),
     '#description' => t('The horizontal distance of the shadow from the actual text. A negative value will put the shadow to the left of the text.'),
-    '#default_value' => _signwriter_get_val($p, $state.'shadow_xoffset', $state == "" ? 5 : NULL),
+    '#default_value' => _signwriter_get_val($p, $state . 'shadow_xoffset', $state == "" ? 5 : NULL),
     '#size' => 4,
-    );
-    $fieldset['shadow_yoffset'] = array(
+  );
+  $fieldset['shadow_yoffset'] = array(
     '#type' => 'textfield',
     '#title' => t('Shadow Y Offset'),
     '#description' => t('The vertical distance of the shadow from the actual text. A negative value will put the shadow above the text.'),
-    '#default_value' => _signwriter_get_val($p, $state.'shadow_yoffset', $state == "" ? 5 : NULL),
+    '#default_value' => _signwriter_get_val($p, $state . 'shadow_yoffset', $state == "" ? 5 : NULL),
     '#size' => 4,
-    );
-    return $fieldset;
+  );
+  return $fieldset;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function _signwriter_profile_background_settings($p, $fontoptions, $state = "") {
   $fieldset = array();
   $fieldset['transparent'] = array(
     '#type' => 'checkbox',
     '#title' => t('Transparent'),
     '#description' => t('If enabled, then the background colour selected below will be made transparent in the generated image.'),
-    '#default_value' => _signwriter_get_val($p, $state.'transparent', TRUE),
-    'single' => true,
+    '#default_value' => _signwriter_get_val($p, $state . 'transparent', TRUE),
+    'single' => TRUE,
   );
   $fieldset['background'] = array(
     '#type' => 'textfield',
     '#title' => t('Background Colour'),
     '#description' => t('This should be six hexadecimal digits, such as ff0000 for red, 00ff00 for green, or 0000ff for blue. To avoid jagged fonts when using transparency, make sure that this colour is the same as the page background colour. If you are using a background image and transparency then this colour will be made transparent in the source background image.'),
-    '#default_value' => _signwriter_get_val($p, $state.'background'),
+    '#default_value' => _signwriter_get_val($p, $state . 'background'),
     '#size' => 6,
     '#maxlength' => 6,
   );
   $fieldset['background-farb'] = array(
-    '#value' => '<div id="' . $state . 'background-farb"></div>'
-    );
-    $fieldset['bgimage'] = array(
+    '#markup' => '<div id="' . $state . 'background-farb"></div>',
+  );
+  $fieldset['bgimage'] = array(
     '#type' => 'textfield',
     '#title' => t('Background Image'),
     '#description' => t('Path to the background image to use, relative to your drupal directory. Leave blank to not use a background image.'),
-    '#default_value' => _signwriter_get_val($p, $state.'bgimage'),
+    '#default_value' => _signwriter_get_val($p, $state . 'bgimage'),
     '#size' => 40,
-    );
-    return $fieldset;
+  );
+  return $fieldset;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function _signwriter_profile_border_settings($p, $fontoptions, $state = "") {
   $fieldset = array();
   $fieldset['border'] = array(
     '#type' => 'checkbox',
     '#title' => t('Border'),
     '#description' => t('If enabled, the text will be surrounded by a border.'),
-    '#default_value' => _signwriter_get_val($p, $state.'border', FALSE),
+    '#default_value' => _signwriter_get_val($p, $state . 'border', FALSE),
   );
   $fieldset['border_color'] = array(
     '#type' => 'textfield',
     '#title' => t('Border Colour'),
     '#description' => t('This should be six hexadecimal digits, such as ff0000 for red, 00ff00 for green, or 0000ff for blue.'),
-    '#default_value' => _signwriter_get_val($p, $state.'border_color'),
+    '#default_value' => _signwriter_get_val($p, $state . 'border_color'),
     '#size' => 6,
     '#maxlength' => 6,
   );
   $fieldset['border_color-farb'] = array(
-    '#value' => '<div id="' . $state . 'border-color-farb"></div>'
-    );
-    $fieldset['border_radius'] = array(
+    '#markup' => '<div id="' . $state . 'border-color-farb"></div>',
+  );
+  $fieldset['border_radius'] = array(
     '#type' => 'textfield',
     '#title' => t('Border Radius'),
     '#description' => t('The radius of the border. Use only small values.'),
-    '#default_value' => _signwriter_get_val($p, $state.'border_radius', 1),
+    '#default_value' => _signwriter_get_val($p, $state . 'border_radius', 1),
     '#size' => 4,
-    );
-    return $fieldset;
+  );
+  return $fieldset;
 }
 
-function _signwriter_profile_onestate(&$v, $prefix, $suffix)
-{
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function _signwriter_profile_onestate(&$v, $prefix, $suffix) {
   $desc = NULL;
   if (isset($v['#description'])) {
     $desc = $v['#description'];
@@ -444,6 +522,10 @@ function _signwriter_profile_onestate(&$v, $prefix, $suffix)
   return $desc;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function _signwriter_profile_threestate(&$form, $p, $fontoptions, $fieldset, $title) {
   $function = '_signwriter_profile_' . $fieldset;
   $form[$fieldset] = array(
@@ -454,64 +536,70 @@ function _signwriter_profile_threestate(&$form, $p, $fontoptions, $fieldset, $ti
   );
 
   $header = "";
-  foreach (array('Normal' => '', 'Hover' => 'hov_', 'Active' => 'act_') as $headinfo => $style) {
-    $header .= '<th class="signwriter_'.$style.'style">' . t($headinfo) . '</th>';
+  foreach (array(
+    'Normal' => '',
+    'Hover' => 'hov_',
+    'Active' => 'act_',
+  ) as $headinfo => $style) {
+    $header .= '<th class="signwriter_' . $style . 'style">' . t($headinfo) . '</th>';
   }
 
   $form[$fieldset]['starttable'] = array(
-    '#value' => '<table class="signwriter-pref"><tbody><tr>' . $header . '</tr>',
+    '#markup' => '<table class="signwriter-pref"><tbody><tr>' . $header . '</tr>',
   );
 
   $f1 = call_user_func_array($function, array($p, $fontoptions, ""));
   $f2 = call_user_func_array($function, array($p, $fontoptions, "hov_"));
   $f3 = call_user_func_array($function, array($p, $fontoptions, "act_"));
 
-  foreach (array_keys($f1) as $key)
-  {
+  foreach (array_keys($f1) as $key) {
     $v1 = $f1[$key];
     $v2 = $f2[$key];
     $v3 = $f3[$key];
-    if ($single =isset($v1['single'])) {
+    if ($single = isset($v1['single'])) {
       unset($v1['single']);
     }
 
-    $desc = _signwriter_profile_onestate($v1,$single ? '<tr><td colspan="3">' : '<tr><td class="signwriter_style">', $single ? '</td></tr>' : '</td>');
+    $desc = _signwriter_profile_onestate($v1, $single ? '<tr><td colspan="3">' : '<tr><td class="signwriter_style">', $single ? '</td></tr>' : '</td>');
     $form[$fieldset][$key] = $v1;
 
     if (!$single) {
-      _signwriter_profile_onestate($v2,'<td class="signwriter_hov_style">','</td>');
-      _signwriter_profile_onestate($v3,'<td class="signwriter_act_style">','</td></tr>');
-      $form[$fieldset]['hov_'.$key] = $v2;
-      $form[$fieldset]['act_'.$key] = $v3;
+      _signwriter_profile_onestate($v2, '<td class="signwriter_hov_style">', '</td>');
+      _signwriter_profile_onestate($v3, '<td class="signwriter_act_style">', '</td></tr>');
+      $form[$fieldset]['hov_' . $key] = $v2;
+      $form[$fieldset]['act_' . $key] = $v3;
     }
     if ($desc) {
-      $form[$fieldset][$key.'_desc'] = array(
-          '#value' => $desc,
-          '#prefix' => '<tr><td colspan="3">', 
-          '#suffix' => '</td></tr>',
+      $form[$fieldset][$key . '_desc'] = array(
+        '#value' => $desc,
+        '#prefix' => '<tr><td colspan="3">',
+        '#suffix' => '</td></tr>',
       );
     }
   }
   $form[$fieldset]['endtable'] = array(
-    '#value' => '</tbody></table>'
-    );
+    '#markup' => '</tbody></table>',
+  );
 }
 
-function signwriter_profile_form(&$form_state, $p = NULL) {
-  drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
-  drupal_add_js('misc/farbtastic/farbtastic.js');
-  drupal_add_js(drupal_get_path('module', 'signwriter') .'/color.js');
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function signwriter_profile_form($form, &$form_state, $p = NULL) {
+  drupal_add_library('system', 'farbtastic');
+  drupal_add_js(drupal_get_path('module', 'signwriter') . '/color.js');
 
   // TODO: add a preview,
   $profileid = _signwriter_get_val($p, 'id');
   $profilename = _signwriter_get_val($p, 'name');
 
-  drupal_set_title(t('Editing signwriter profile @profilename', array('@profilename' => $profilename)));
+  drupal_set_title(t('Editing signwriter profile @profilename', array('@profilename' => $profilename)), PASS_THROUGH);
 
   $form = array();
   $form['id'] = array(
     '#type' => 'value',
-    '#value' => $profileid
+    '#value' => $profileid,
   );
   $form['name'] = array(
     '#type' => 'textfield',
@@ -535,8 +623,11 @@ function signwriter_profile_form(&$form_state, $p = NULL) {
 
     $rows[] = array(
       'name' => $fontname,
-      'sample' => theme_signwriter_text("$fontname - Sample text (0123456789)", 
-    $preview_profile, array('style' => 'vertical-align:middle')),
+      'sample' => theme('signwriter_text', array(
+        'text' =>"$fontname - Sample text (0123456789)",
+        'profile' => $preview_profile,
+        'attributes' => array('style' => 'vertical-align:middle'),
+      )),
     );
   }
   $header = array(
@@ -544,14 +635,14 @@ function signwriter_profile_form(&$form_state, $p = NULL) {
     'sample' => t("Sample"),
   );
   $form['fontpreview'] = array(
-    '#value' => theme('table', $header, $rows)
+    '#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
   );
 
   $form['general'] = array(
     '#type' => 'fieldset',
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
-    '#title' => t('General settings')
+    '#title' => t('General settings'),
   );
   $form['general']['allowed_nonasciichars'] = array(
     '#type' => 'textfield',
@@ -594,17 +685,17 @@ function signwriter_profile_form(&$form_state, $p = NULL) {
     '#type' => 'fieldset',
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
-    '#title' => t('Image Layout')
-  );
-/*
-  $form['layout']['angle'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Angle'),
-    '#description' => t("Set the angle of the image in degrees."),
-    '#default_value' => _signwriter_get_val($p, 'angle', 0),
-    '#size' => 4,
-  );
-*/   
+    '#title' => t('Image Layout'),
+  );
+  /*
+   $form['layout']['angle'] = array(
+   '#type' => 'textfield',
+   '#title' => t('Angle'),
+   '#description' => t("Set the angle of the image in degrees."),
+   '#default_value' => _signwriter_get_val($p, 'angle', 0),
+   '#size' => 4,
+   );
+   */
   $form['layout']['width'] = array(
     '#type' => 'textfield',
     '#title' => t('Width'),
@@ -631,7 +722,11 @@ function signwriter_profile_form(&$form_state, $p = NULL) {
     '#title' => t('Text Align'),
     '#description' => t('Text Align only makes sense if your image is wider than the text. To make this happen either assign a background image, or set the width.'),
     '#default_value' => _signwriter_get_val($p, 'textalign'),
-    '#options' => array('left' => 'left', 'center' => 'center', 'right' => 'right'),
+    '#options' => array(
+      'left' => 'left',
+      'center' => 'center',
+      'right' => 'right',
+    ),
   );
   $form['layout']['xoffset'] = array(
     '#type' => 'textfield',
@@ -660,21 +755,34 @@ function signwriter_profile_form(&$form_state, $p = NULL) {
     '#type' => 'textfield',
     '#title' => t('Input Filter Pattern'),
     '#default_value' => _signwriter_get_val($p, 'pattern'),
-    '#description' => t("If this pattern is defined then this profile will be available as an input filter which you can enable on the <a href='@input-formats-url'>%inputformats</a> page. When the filter is enabled, anything matching this pattern will be replaced with a signwriter image. The pattern should be a perl regular expression. For example, to replace all headings, use: <code>/&lt;h.*?&gt;.*?&lt;\/h.*?&gt;/</code>. To replace only h1 headings, use <code>/&lt;h1.*&gt;.*?&lt;\/h1&gt;/</code>. To define a custom pseudo-html tag (such as &lt;signwriter&gt;), use: <code>/&lt;signwriter&gt;.*?&lt;\/signwriter&gt;/</code>", array('@input-formats-url' => url('admin/settings/filters'), '%inputformats' => 'Administer >> Site configuration >> Input formats')),
+    '#description' => t("If this pattern is defined then this profile will be available as an input filter which you can enable on the <a href='@input-formats-url'>%inputformats</a> page. When the filter is enabled, anything matching this pattern will be replaced with a signwriter image. The pattern should be a perl regular expression. For example, to replace all headings, use: <code>/&lt;h.*?&gt;.*?&lt;\/h.*?&gt;/</code>. To replace only h1 headings, use <code>/&lt;h1.*&gt;.*?&lt;\/h1&gt;/</code>. To define a custom pseudo-html tag (such as &lt;signwriter&gt;), use: <code>/&lt;signwriter&gt;.*?&lt;\/signwriter&gt;/</code>", array('@input-formats-url' => url('admin/config/content/formats'), '%inputformats' => 'Administer >> Site configuration >> Input formats')),
     '#size' => 20,
   );
 
-  $form['save'] = array('#type' => 'submit', '#value' => t('Save'));
-  $form['submit'] = array('#type' => 'submit', '#value' => t('Save and edit'));
+  $form['save'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save and edit'),
+  );
   // Don't add the delete button if they are on the add new profile page
   // Otherwise clicking the button will return page not found due to there not being a profile to delete.
   if ($p) {
-    $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
+    $form['delete'] = array(
+      '#type' => 'submit',
+      '#value' => t('Delete'),
+    );
   }
 
   return $form;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function signwriter_profile_form_validate($form, $form_state) {
   $shadow_error = t('If using a drop shadow, the Shadow X Offset and Shadow Y Offset values must not both be zero.');
   if ($form_state['values']['drop_shadow']) {
@@ -687,36 +795,40 @@ function signwriter_profile_form_validate($form, $form_state) {
   if (!is_numeric($form_state['values']['fontsize']) && $form_state['values']['fontsize']) {
     form_set_error('fontsize', 'Font size must be numeric.');
   }
-/*
+  /*
   if (!is_numeric($form_state['values']['angle']) && $form_state['values']['angle']) {
-    form_set_error('angle', 'Angle must be numeric.');
+     form_set_error('angle', 'Angle must be numeric.');
   }
-*/
+  */
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function signwriter_profile_form_submit($form, &$form_state) {
-  $profile = (object)$form_state['values'];
+  $profile = (object) $form_state['values'];
 
   // To allow for font size default of 20.
   if (!$profile->fontsize) {
     $profile->fontsize = 20;
   }
-/*
-  if (!$profile->angle) {
-    $profile->angle = 0;
-  }
-*/
+  /*
+   if (!$profile->angle) {
+   $profile->angle = 0;
+   }
+   */
 
   $clicked_button = $form_state['clicked_button']['#value'];
   if ($clicked_button == t('Delete')) {
-    $form_state['redirect'] = 'admin/settings/signwriter/profile/'. $profile->id .'/delete';
+    $form_state['redirect'] = 'admin/config/signwriter/signwriter/profile/' . $profile->id . '/delete';
   }
   else {
     $id = signwriter_save_profile($profile, $form_state['values']['id']);
     $message = t("Profile '@name' saved.", array('@name' => $profile->name));
     //drupal_set_message(theme('signwriter_text', $message, $profile));
     drupal_set_message($message);
-    $form_state['redirect'] = ($clicked_button == 'Save and edit') ? 'admin/settings/signwriter/profile/'. $id : 'admin/settings/signwriter';
+    $form_state['redirect'] = ($clicked_button == 'Save and edit') ? 'admin/config/signwriter/signwriter/profile/' . $id : 'admin/config/signwriter/signwriter';
   }
 }
 
@@ -726,12 +838,15 @@ function signwriter_profile_form_submit($form, &$form_state) {
  * @param $profile
  *   The profile object to delete.
  */
-function signwriter_confirm_delete_profile_form(&$form_state, $profile) {
+function signwriter_confirm_delete_profile_form($form, &$form_state, $profile) {
   $form = array();
-  $form['id'] = array('#type' => 'value', '#value' => $profile->id);
+  $form['id'] = array(
+    '#type' => 'value',
+    '#value' => $profile->id,
+  );
   return confirm_form($form,
   t("Are you sure you want to delete the '%title' profile?", array('%title' => $profile->name)),
-      'admin/settings/signwriter',
+      'admin/config/signwriter/signwriter',
   t('Deleting a profile cannot be undone.'),
   t('Delete'),
   t('Cancel'));
@@ -744,14 +859,13 @@ function signwriter_confirm_delete_profile_form(&$form_state, $profile) {
 function signwriter_confirm_delete_profile_form_submit($form, &$form_state) {
   $profile = signwriter_load_profile($form_state['values']['id']);
   _signwriter_delete_profile($profile);
-  $form_state['redirect'] = 'admin/settings/signwriter';
+  $form_state['redirect'] = 'admin/config/signwriter/signwriter';
 }
 
-
 /**
  *	Edit signwritermenu profile
  */
-function signwriter_menuprofile_form(&$form_state, $p = NULL) {
+function signwriter_menuprofile_form($form, &$form_state, $p = NULL) {
   //	drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
   //	drupal_add_js('misc/farbtastic/farbtastic.js');
   //	drupal_add_js(drupal_get_path('module', 'signwritermenu') .'/color.js');
@@ -762,7 +876,13 @@ function signwriter_menuprofile_form(&$form_state, $p = NULL) {
   $menuoptions = array(false => t("Unused"));
   foreach ($swprofiles as $swprofile) {
     $menuoptions[$swprofile->id] = $swprofile->name;
-    $rows[] = array('name' => theme_signwriter_text($swprofile->name, $swprofile, array('style' => 'vertical-align:middle')));
+    $rows[] = array(
+      'name' => theme('signwriter_text', array(
+        'text' => $swprofile->name,
+        'profile' => $swprofile,
+        'attributes' => array('style' => 'vertical-align:middle'),
+      )),
+    );
   }
   $header = array(array('data' => t('Signwriter samples')));
 
@@ -770,15 +890,15 @@ function signwriter_menuprofile_form(&$form_state, $p = NULL) {
   $profilename = _signwriter_get_val($p, 'name');
   $values = _signwriter_get_val($p, 'data');
 
-  drupal_set_title(t('Editing signwritermenu profile @profilename', array('@profilename' => $profilename)));
+  drupal_set_title(t('Editing signwritermenu profile @profilename', array('@profilename' => $profilename)), PASS_THROUGH);
 
   $form = array();
   $form['samples'] = array(
-    '#value' => theme('table', $header, $rows),
+    '#value' => theme('table', array('header' => $header, 'rows' => $rows)),
   );
   $form['id'] = array(
     '#type' => 'value',
-    '#value' => $profileid
+    '#value' => $profileid,
   );
   $form['name'] = array(
     '#type' => 'textfield',
@@ -789,15 +909,14 @@ function signwriter_menuprofile_form(&$form_state, $p = NULL) {
   );
 
   $levels = variable_get('signwriter_menulevels', '3');
-  for ($i=1;$i<=$levels;$i++)
-  {
-    $form['set'.$i] = array(
+  for ($i = 1; $i <= $levels; $i++) {
+    $form['set' . $i] = array(
       '#type' => 'fieldset',
       '#collapsible' => TRUE,
       '#collapsed' => FALSE,
-      '#title' => t('Settings for Menu Items level '.$i)
+      '#title' => t('Settings for Menu Items level ' . $i),
     );
-    $form['set'.$i]['item-'.$i] = array(
+    $form['set' . $i]['item-' . $i] = array(
       '#type' => 'select',
       '#title' => t("Signwriter Profile"),
       '#descripion' => t("Signwriter profile to be used to display regular menu items"),
@@ -806,36 +925,49 @@ function signwriter_menuprofile_form(&$form_state, $p = NULL) {
     );
   }
 
-  $form['save'] = array('#type' => 'submit', '#value' => t('Save'));
-  $form['submit'] = array('#type' => 'submit', '#value' => t('Save and edit'));
+  $form['save'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save and edit'),
+  );
   // Don't add the delete button if they are on the add new profile page
   // Otherwise clicking the button will return page not found due to there not being a profile to delete.
   if ($p) {
-    $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
+    $form['delete'] = array(
+      '#type' => 'submit',
+      '#value' => t('Delete'),
+    );
   }
 
   return $form;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function signwriter_menuprofile_form_submit($form, &$form_state) {
   $profile->id = $form_state['values']['id'];
   $profile->name = $form_state['values']['name'];
   $profile->data = array();
 
   $levels = variable_get('signwriter_menulevels', '3');
-  for ($i=1;$i<=$levels;$i++) {
-    $item = intval($form_state['values']['item-'.$i]);
+  for ($i = 1; $i <= $levels; $i++) {
+    $item = intval($form_state['values']['item-' . $i]);
     $profile->data[$i] = $item;
   }
 
   $clicked_button = $form_state['clicked_button']['#value'];
   if ($clicked_button == t('Delete')) {
-    $form_state['redirect'] = 'admin/settings/signwriter/menuprofile/'. $profile->id .'/delete';
+    $form_state['redirect'] = 'admin/config/signwriter/signwriter/menuprofile/' . $profile->id . '/delete';
   }
   else {
     $id = _signwriter_save_menuprofile($profile, $form_state['values']['id']);
     $message = t("Profile '@name' saved.", array('@name' => $profile->name));
-    $form_state['redirect'] = ($clicked_button == 'Save and edit') ? 'admin/settings/signwriter/menuprofile/'. $id : 'admin/settings/signwriter';
+    $form_state['redirect'] = ($clicked_button == 'Save and edit') ? 'admin/config/signwriter/signwriter/menuprofile/' . $id : 'admin/config/signwriter/signwriter';
   }
 }
 
@@ -845,12 +977,15 @@ function signwriter_menuprofile_form_submit($form, &$form_state) {
  * @param $profile
  *   The profile object to delete.
  */
-function signwriter_confirm_delete_menuprofile_form(&$form_state, $profile) {
+function signwriter_confirm_delete_menuprofile_form($form, &$form_state, $profile) {
   $form = array();
-  $form['id'] = array('#type' => 'value', '#value' => $profile->id);
+  $form['id'] = array(
+    '#type' => 'value',
+    '#value' => $profile->id,
+  );
   return confirm_form($form,
   t("Are you sure you want to delete the '%title' profile?", array('%title' => $profile->name)),
-            'admin/settings/signwriter',
+            'admin/config/signwriter/signwriter',
   t('Deleting a profile cannot be undone.'),
   t('Delete'),
   t('Cancel'));
@@ -863,5 +998,5 @@ function signwriter_confirm_delete_menuprofile_form(&$form_state, $profile) {
 function signwriter_confirm_delete_menuprofile_form_submit($form, &$form_state) {
   $profile = signwriter_load_menuprofile($form_state['values']['id']);
   _signwriter_delete_menuprofile($profile);
-  $form_state['redirect'] = 'admin/settings/signwriter';
+  $form_state['redirect'] = 'admin/config/signwriter/signwriter';
 }
diff --git a/sites/all/modules/contrib/signwriter/signwriter.info b/sites/all/modules/contrib/signwriter/signwriter.info
index 14a63a7..b047dbc 100644
--- a/sites/all/modules/contrib/signwriter/signwriter.info
+++ b/sites/all/modules/contrib/signwriter/signwriter.info
@@ -1,12 +1,16 @@
 ; $Id: signwriter.info,v 1.2.2.2.2.3 2009/10/01 02:02:58 agileware Exp $
 name = Signwriter
 description = Allows you to use custom truetype fonts for headings.
-core = 6.x
+core = 7.x
 php = 5.0
 
 ; Information added by drupal.org packaging script on 2010-02-02
 version = "6.x-2.0-beta2"
-core = "6.x"
+core = 7.x
 project = "signwriter"
 datestamp = "1265151907"
 
+
+files[] = signwriter.admin.inc
+files[] = signwriter.install
+files[] = signwriter.module
diff --git a/sites/all/modules/contrib/signwriter/signwriter.install b/sites/all/modules/contrib/signwriter/signwriter.install
index 16c039a..6ed2a64 100644
--- a/sites/all/modules/contrib/signwriter/signwriter.install
+++ b/sites/all/modules/contrib/signwriter/signwriter.install
@@ -7,14 +7,15 @@
  */
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  */
 function signwriter_install() {
-  drupal_install_schema('signwriter');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_install_schema('signwriter')
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function signwriter_uninstall() {
   variable_del('signwriter_cachedir');
@@ -31,15 +32,16 @@ function signwriter_uninstall() {
   cache_clear_all("signwriter_menu", "cache");
   cache_clear_all("signwriter_menucss", "cache");
 
-  drupal_uninstall_schema('signwriter');
+  // TODO The drupal_(un)install_schema functions are called automatically in D7.
+  // drupal_uninstall_schema('signwriter')
 }
 
 /**
- * Implementation of hook_schema().
+ * Implements hook_schema().
  */
 function signwriter_schema() {
   $schema['signwriter'] = array(
-    'description' => t('signwriter table'),
+    'description' => 'signwriter table',
     'fields' => array(
       'id' => array(
         'description' => 'the primary identifier of the schema',
@@ -128,7 +130,7 @@ function signwriter_schema() {
   signwriter_imgstate_schema($schema, "act_");
 
   $schema['signwriter_menu'] = array(
-    'description' => t('signwriter menu profile table'),
+    'description' => 'signwriter menu profile table',
     'fields' => array(
       'id' => array(
         'description' => 'the primary identifier of the profile',
@@ -145,7 +147,7 @@ function signwriter_schema() {
         'description' => 'The value of the variable.',
         'type' => 'text',
         'not null' => TRUE,
-        'size' => 'big'
+        'size' => 'big',
       ),
     ),
     'indexes' => array(
@@ -242,57 +244,73 @@ function signwriter_imgstate_schema(&$schema, $state = "") {
  * Provides update for additional signwriter fields for different menu states
  */
 function _signwriter_update_imgstate(&$ret, $state) {
-  db_add_field($ret, 'signwriter', "${state}fontfile", array('description' => 'the name of the font, without ttf', 'type' => 'varchar', 'length' => 128,  ));
-  db_add_field($ret, 'signwriter', "${state}fontsize", array('description' => 'the size of the font', 'type' => 'int','unsigned' => TRUE, 'default' => 20,));
-  db_add_field($ret, 'signwriter', "${state}background", array('description' => 'background color', 'type' => 'varchar', 'length' => 6, 'default' => 'ffffff'));
-  db_add_field($ret, 'signwriter', "${state}foreground", array('description' => 'foreground color', 'type' => 'varchar', 'length' => 6, 'default' => '000000'));
-  db_add_field($ret, 'signwriter', "${state}bgimage", array('description' => 'background image', 'type' => 'varchar', 'length' => 128));
-  db_add_field($ret, 'signwriter', "${state}xoffset", array('description' => 'x offset of the text within the image', 'type' => 'int'));
-  db_add_field($ret, 'signwriter', "${state}yoffset", array('description' => 'y offset of the text within the image', 'type' => 'int'));
-  db_add_field($ret, 'signwriter', "${state}drop_shadow", array('description' => 'are drop shadows on or off', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
-  db_add_field($ret, 'signwriter', "${state}shadow_color", array('description' => 'are drop shadows on or off', 'type' => 'varchar', 'length' => 6, 'default' => 'd2d2d2'));
-  db_add_field($ret, 'signwriter', "${state}shadow_xoffset", array('description' => 'x offset of shadow from actual text', 'type' => 'int', 'default' => 5));
-  db_add_field($ret, 'signwriter', "${state}shadow_yoffset", array('description' => 'y offset of shadow from actual text', 'type' => 'int'));
-  db_add_field($ret, 'signwriter', "${state}border", array('description' => 'are borders on or off', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
-  db_add_field($ret, 'signwriter', "${state}border_color", array('description' => 'border color', 'type' => 'varchar', 'length' => 6, 'default' => 'e2e2e2'));
-  db_add_field($ret, 'signwriter', "${state}border_radius", array('description' => 'radius of border', 'type' => 'int', 'default' => 1));
+  db_add_field('signwriter', "${state}fontfile", array('description' => 'the name of the font, without ttf', 'type' => 'varchar', 'length' => 128));
+  db_add_field('signwriter', "${state}fontsize", array('description' => 'the size of the font', 'type' => 'int', 'unsigned' => TRUE, 'default' => 20));
+  db_add_field('signwriter', "${state}background", array('description' => 'background color', 'type' => 'varchar', 'length' => 6, 'default' => 'ffffff'));
+  db_add_field('signwriter', "${state}foreground", array('description' => 'foreground color', 'type' => 'varchar', 'length' => 6, 'default' => '000000'));
+  db_add_field('signwriter', "${state}bgimage", array('description' => 'background image', 'type' => 'varchar', 'length' => 128));
+  db_add_field('signwriter', "${state}xoffset", array('description' => 'x offset of the text within the image', 'type' => 'int'));
+  db_add_field('signwriter', "${state}yoffset", array('description' => 'y offset of the text within the image', 'type' => 'int'));
+  db_add_field('signwriter', "${state}drop_shadow", array('description' => 'are drop shadows on or off', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
+  db_add_field('signwriter', "${state}shadow_color", array('description' => 'are drop shadows on or off', 'type' => 'varchar', 'length' => 6, 'default' => 'd2d2d2'));
+  db_add_field('signwriter', "${state}shadow_xoffset", array('description' => 'x offset of shadow from actual text', 'type' => 'int', 'default' => 5));
+  db_add_field('signwriter', "${state}shadow_yoffset", array('description' => 'y offset of shadow from actual text', 'type' => 'int'));
+  db_add_field('signwriter', "${state}border", array('description' => 'are borders on or off', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
+  db_add_field('signwriter', "${state}border_color", array('description' => 'border color', 'type' => 'varchar', 'length' => 6, 'default' => 'e2e2e2'));
+  db_add_field('signwriter', "${state}border_radius", array('description' => 'radius of border', 'type' => 'int', 'default' => 1));
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function signwriter_update_6000() {
   $ret = array();
   variable_del('cachedir');
   variable_del('fontpath');
-  $ret[] = update_sql("ALTER TABLE {signwriter} CHANGE fontsize fontsize int unsigned default '20'");
-  $ret[] = update_sql("ALTER TABLE {signwriter} CHANGE background background varchar(6) default 'ffffff'");
-  $ret[] = update_sql("ALTER TABLE {signwriter} CHANGE foreground foreground varchar(6) default '000000'");
-  $ret[] = update_sql("ALTER TABLE {signwriter} CHANGE shadow_color shadow_color varchar(6) default 'd2d2d2'");
-  $ret[] = update_sql("ALTER TABLE {signwriter} ADD allowed_nonasciichars varchar(255) AFTER fontsize");
+  // TODO update_sql has been removed. Use the database API for any schema or data changes.
+  $ret[] = array() /* update_sql("ALTER TABLE {signwriter} CHANGE fontsize fontsize int unsigned default '20'") */;
+  // TODO update_sql has been removed. Use the database API for any schema or data changes.
+  $ret[] = array() /* update_sql("ALTER TABLE {signwriter} CHANGE background background varchar(6) default 'ffffff'") */;
+  // TODO update_sql has been removed. Use the database API for any schema or data changes.
+  $ret[] = array() /* update_sql("ALTER TABLE {signwriter} CHANGE foreground foreground varchar(6) default '000000'") */;
+  // TODO update_sql has been removed. Use the database API for any schema or data changes.
+  $ret[] = array() /* update_sql("ALTER TABLE {signwriter} CHANGE shadow_color shadow_color varchar(6) default 'd2d2d2'") */;
+  // TODO update_sql has been removed. Use the database API for any schema or data changes.
+  $ret[] = array() /* update_sql("ALTER TABLE {signwriter} ADD allowed_nonasciichars varchar(255) AFTER fontsize") */;
   cache_clear_all();
   menu_rebuild();
   drupal_set_message(t('The signwriter module now has an option to clean up the generated image files regularily (off by default). Files generated by previous versions have to be removed manually from the old signwriter cache directory, the new one is located within the files directory.'));
-  return $ret;
+  // hook_update_N() no longer returns a $ret array. Instead, return
+  // nothing or a translated string indicating the update ran successfully.
+  // See http://drupal.org/node/224333#update_sql.
+  return t('TODO Add a descriptive string here to show in the UI.') /* $ret */;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function signwriter_update_6200() {
   $ret = array();
 
   // Need to check this column as it exists in new D5 versions but not old ones
-  if (!db_column_exists('signwriter', 'disable_span')) {
-    db_add_field($ret, 'signwriter', 'disable_span', array('description' => 'Whether or not to disable the hidden span.', 'type' => 'int', 'unsigned' => TRUE, 'default' => 0));
+  if (!db_field_exists('signwriter', 'disable_span')) {
+    db_add_field('signwriter', 'disable_span', array('description' => 'Whether or not to disable the hidden span.', 'type' => 'int', 'unsigned' => TRUE, 'default' => 0));
   }
 
-  db_add_field($ret, 'signwriter', 'threestate', array('description' => 'add hover and active images', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
-  db_add_field($ret, 'signwriter', 'use_title_text', array('description' => 'Whether or not to display title text for images.', 'type' => 'int', 'unsigned' => TRUE, 'default' => 0));
+  db_add_field('signwriter', 'threestate', array('description' => 'add hover and active images', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
+  db_add_field('signwriter', 'use_title_text', array('description' => 'Whether or not to display title text for images.', 'type' => 'int', 'unsigned' => TRUE, 'default' => 0));
 
-  db_add_field($ret, 'signwriter', 'border_radius', array('description' => 'radius of border', 'type' => 'int', 'default' => 1));
-  db_add_field($ret, 'signwriter', 'border_color', array('description' => 'border color', 'type' => 'varchar', 'length' => 6, 'default' => 'e2e2e2'));
-  db_add_field($ret, 'signwriter', 'border', array('description' => 'are borders on or off', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
+  db_add_field('signwriter', 'border_radius', array('description' => 'radius of border', 'type' => 'int', 'default' => 1));
+  db_add_field('signwriter', 'border_color', array('description' => 'border color', 'type' => 'varchar', 'length' => 6, 'default' => 'e2e2e2'));
+  db_add_field('signwriter', 'border', array('description' => 'are borders on or off', 'type' => 'int', 'not null' => TRUE, 'default' => 0));
 
   _signwriter_update_imgstate($ret, "hov_");
   _signwriter_update_imgstate($ret, "act_");
 
   $schema['signwriter_menu'] = array(
-    'description' => t('signwriter menu profile table'),
+    'description' => 'signwriter menu profile table',
     'fields' => array(
       'id' => array(
         'description' => 'the primary identifier of the profile',
@@ -309,16 +327,19 @@ function signwriter_update_6200() {
         'description' => 'The value of the variable.',
         'type' => 'text',
         'not null' => TRUE,
-        'size' => 'big'
+        'size' => 'big',
       ),
     ),
     'indexes' => array(
       'name' => array('name'),
     ),
     'primary key' => array('id'),
-  );
-
-  db_create_table($ret, 'signwriter_menu', $schema['signwriter_menu']);
+  );
+
+  db_create_table('signwriter_menu', $schema['signwriter_menu']);
 
-  return $ret;
+  // hook_update_N() no longer returns a $ret array. Instead, return
+  // nothing or a translated string indicating the update ran successfully.
+  // See http://drupal.org/node/224333#update_sql.
+  return t('TODO Add a descriptive string here to show in the UI.') /* $ret */;
 }
diff --git a/sites/all/modules/contrib/signwriter/signwriter.js b/sites/all/modules/contrib/signwriter/signwriter.js
index 71c1408..453d9a9 100644
--- a/sites/all/modules/contrib/signwriter/signwriter.js
+++ b/sites/all/modules/contrib/signwriter/signwriter.js
@@ -1,37 +1,40 @@
 /* $Id $ */
-
-$(document).ready(function() {
-  // Add signwriter-hover class to the menus that signwriter is being used for.
-  $('img.signwriter-hover')
-        .parents('ul.menu')
-        .addClass('signwriter-hover');
-
-  $('img.signwriter-hover')
-
-  set_signwriter_active_top();
-
-  // Add over class so it will work in IE.
-  $('ul.menu.signwriter-hover li a:not(.active)').hover(function() {
-    $(this).addClass('over');
-    set_signwriter_over_top(this);
-  }, function() {
-    $(this).removeClass('over');
-    $(this).children('img.signwriter-hover').css('top', 0);
+(function ($) {
+
+  $(document).ready(function() {
+    // Add signwriter-hover class to the menus that signwriter is being used for.
+    $('img.signwriter-hover')
+          .parents('ul.menu')
+          .addClass('signwriter-hover');
+  
+    $('img.signwriter-hover')
+  
+    set_signwriter_active_top();
+  
+    // Add over class so it will work in IE.
+    $('ul.menu.signwriter-hover li a:not(.active)').hover(function() {
+      $(this).addClass('over');
+      set_signwriter_over_top(this);
+    }, function() {
+      $(this).removeClass('over');
+      $(this).children('img.signwriter-hover').css('top', 0);
+    });
+  
+    // Set css top values for hover images based on the height of the image
+    function set_signwriter_over_top(elem) {
+      var image_height =  $(elem).height();
+      var over_top = 0 - image_height;
+  
+      $(elem).children('img.signwriter-hover').css('top', over_top);
+    }
+  
+    // Set css top values for active images based on the height of the image
+    function set_signwriter_active_top() {
+      var image_height =  $('a.active img.signwriter-hover').height();
+      var active_top = 0 - ((image_height / 3) * 2);
+  
+      $('ul.menu.signwriter-hover').find('a.active img.signwriter-hover').css('top', active_top);
+    }
   });
 
-  // Set css top values for hover images based on the height of the image
-  function set_signwriter_over_top(elem) {
-    var image_height =  $(elem).height();
-    var over_top = 0 - image_height;
-
-    $(elem).children('img.signwriter-hover').css('top', over_top);
-  }
-
-  // Set css top values for active images based on the height of the image
-  function set_signwriter_active_top() {
-    var image_height =  $('a.active img.signwriter-hover').height();
-    var active_top = 0 - ((image_height / 3) * 2);
-
-    $('ul.menu.signwriter-hover').find('a.active img.signwriter-hover').css('top', active_top);
-  }
-});
\ No newline at end of file
+})(jQuery);
diff --git a/sites/all/modules/contrib/signwriter/signwriter.module b/sites/all/modules/contrib/signwriter/signwriter.module
index 2786837..a1e1c85 100644
--- a/sites/all/modules/contrib/signwriter/signwriter.module
+++ b/sites/all/modules/contrib/signwriter/signwriter.module
@@ -2,15 +2,16 @@
 // $Id: signwriter.module,v 1.17.2.3.2.7 2010/02/02 22:48:15 agileware Exp $
 
 /**
- * Implementation of hook_init().
+ * Implements hook_init().
  */
-function signwriter_init(){
-  drupal_add_js(drupal_get_path('module', 'signwriter') .'/signwriter.js');
-  drupal_add_css(drupal_get_path('module', 'signwriter') .'/signwriter.css');
+function signwriter_init() {
+  $path = drupal_get_path('module', 'signwriter');
+  drupal_add_js("$path/signwriter.js");
+  drupal_add_css("$path/signwriter.css");
 }
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function signwriter_help($path, $arg) {
   switch ($path) {
@@ -21,12 +22,21 @@ function signwriter_help($path, $arg) {
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function signwriter_menu() {
   $items = array();
 
-  $items['admin/settings/signwriter'] = array(
+  $items['admin/config/signwriter'] = array(
+    'title' => 'Signwriter',
+    'description' => 'Manage Signwriter profiles, for custom font headings.',
+    'position' => 'left',
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('access administration pages'),
+    'file' => 'system.admin.inc',
+    'file path' => drupal_get_path('module', 'system'),
+  );
+  $items['admin/config/signwriter/signwriter'] = array(
     'title' => 'Signwriter',
     'description' => 'Manage Signwriter profiles, for custom font headings.',
     'file' => 'signwriter.admin.inc',
@@ -35,8 +45,7 @@ function signwriter_menu() {
     'access arguments' => array('administer signwriter'),
     'type' => MENU_NORMAL_ITEM,
   );
-
-  $items['admin/settings/signwriter/profile/add'] = array(
+  $items['admin/config/signwriter/signwriter/profile/add'] = array(
     'title' => 'Add profile',
     'description' => 'Add a new Signwriter profile.',
     'file' => 'signwriter.admin.inc',
@@ -46,26 +55,25 @@ function signwriter_menu() {
     'type' => MENU_NORMAL_ITEM,
     'weight' => -8,
   );
-  $items['admin/settings/signwriter/profile/%signwriter_profile'] = array(
+  $items['admin/config/signwriter/signwriter/profile/%signwriter_profile'] = array(
     'title' => 'Edit signwriter profile',
-    'description' => t('Edit Signwriter profile.'),
+    'description' => 'Edit Signwriter profile.',
     'file' => 'signwriter.admin.inc',
     'page callback' => 'drupal_get_form',
     'access arguments' => array('administer signwriter'),
-    'page arguments' => array('signwriter_profile_form', 4),
+    'page arguments' => array('signwriter_profile_form', 5),
     'type' => MENU_NORMAL_ITEM,
   );
-  $items['admin/settings/signwriter/profile/%signwriter_profile/delete'] = array(
+  $items['admin/config/signwriter/signwriter/profile/%signwriter_profile/delete'] = array(
     'title' => "Delete signwriter profile",
-    'description' => t('Delete Signwriter profile'),
+    'description' => 'Delete Signwriter profile',
     'file' => 'signwriter.admin.inc',
     'page callback' => 'drupal_get_form',
     'access arguments' => array('administer signwriter'),
-    'page arguments' => array('signwriter_confirm_delete_profile_form', 4),
+    'page arguments' => array('signwriter_confirm_delete_profile_form', 5),
     'type' => MENU_NORMAL_ITEM,
   );
-
-  $items['admin/settings/signwriter/menuprofile/add'] = array(
+  $items['admin/config/signwriter/signwriter/menuprofile/add'] = array(
     'title' => 'Add menu profile',
     'description' => 'Add a new Signwriter menu profile.',
     'file' => 'signwriter.admin.inc',
@@ -75,68 +83,76 @@ function signwriter_menu() {
     'type' => MENU_NORMAL_ITEM,
     'weight' => -8,
   );
-  $items['admin/settings/signwriter/menuprofile/%signwriter_menuprofile'] = array(
+  $items['admin/config/signwriter/signwriter/menuprofile/%signwriter_menuprofile'] = array(
     'title' => 'Edit signwriter menu profile',
-    'description' => t('Edit Signwriter menu profile.'),
+    'description' => 'Edit Signwriter menu profile.',
     'file' => 'signwriter.admin.inc',
     'page callback' => 'drupal_get_form',
     'access arguments' => array('administer signwriter'),
-    'page arguments' => array('signwriter_menuprofile_form', 4),
+    'page arguments' => array('signwriter_menuprofile_form', 5),
     'type' => MENU_NORMAL_ITEM,
   );
-  $items['admin/settings/signwriter/menuprofile/%signwriter_menuprofile/delete'] = array(
+  $items['admin/config/signwriter/signwriter/menuprofile/%signwriter_menuprofile/delete'] = array(
     'title' => "Delete signwriter menu profile",
-    'description' => t('Delete Signwriter menu profile'),
+    'description' => 'Delete Signwriter menu profile',
     'file' => 'signwriter.admin.inc',
     'page callback' => 'drupal_get_form',
     'access arguments' => array('administer signwriter'),
-    'page arguments' => array('signwriter_confirm_delete_menuprofile_form', 4),
+    'page arguments' => array('signwriter_confirm_delete_menuprofile_form', 5),
     'type' => MENU_NORMAL_ITEM,
   );
-
   return $items;
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function signwriter_theme() {
   return array(
     'signwriter_text' => array(
-      'arguments' => array('text', 'signwriter'),
+      'variables' => array('text' => '', 'signwriter' => array(), 'attributes' => array(), 'threestate' => NULL),
     ),
   );
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_permission().
  */
-function signwriter_perm() {
-  return array('administer signwriter', 'use PHP for signwriter pages');
+function signwriter_permission() {
+  return array(
+    'administer signwriter' => array(
+      'title' => t('administer signwriter'),
+      'description' => t('TODO Add a description for \'administer signwriter\''),
+    ),
+    'use PHP for signwriter pages' => array(
+      'title' => t('use PHP for signwriter pages'),
+      'description' => t('TODO Add a description for \'use PHP for signwriter pages\''),
+    ),
+  );
 }
 
 /**
- * Implementation of hook_cron().
+ * Implements hook_cron().
  * Cleans the signwriter cache if called explicitly or enough time has passed.
  */
 function signwriter_cron($now = FALSE) {
   $last_cleanup = variable_get('signwriter_last_cleanup', 0);
   $cachecleanperiod = variable_get('signwriter_cachecleanperiod', '100 years');
   if ($last_cleanup < strtotime("-$cachecleanperiod") || $now) {
-    $cachedir = variable_get('signwriter_cachedir', file_directory_path() .'/signwriter');
+    $cachedir = variable_get('signwriter_cachedir', file_directory_path() . '/signwriter');
     // Prevent removal of files not created by this module.
-    $cached_images = glob($cachedir .'/*-signwriter.*');
-    if (array_walk($cached_images, 'file_delete') && $now) {
+    $cached_images = glob($cachedir . '/*-signwriter.*');
+    if (array_walk($cached_images, 'file_unmanaged_delete') && $now) {
       drupal_set_message(t('!imagenum images have been cleared from the signwriter cache.', array('!imagenum' => count($cached_images))));
     }
   }
-  variable_set('signwriter_last_cleanup', time());
+  variable_set('signwriter_last_cleanup', REQUEST_TIME);
 }
 
 /**
- * Implementation of hook_filter().
+ * Implements hook_filter().
  */
-function signwriter_filter($op, $delta = 0, $format = -1, $text = '') {
+function signwriter_filter_XXX($op, $delta = 0, $format = -1, $text = '') {
   switch ($op) {
     case 'list':
       $profiles = signwriter_load_profiles();
@@ -154,10 +170,10 @@ function signwriter_filter($op, $delta = 0, $format = -1, $text = '') {
 
     case "process":
       // Make the profile global so the preg_replace_callback callback function can access it
-      global $signwriter_filter_profile;
-      $signwriter_filter_profile = signwriter_load_profile($delta);
-      $text = preg_replace_callback($signwriter_filter_profile->pattern, 'signwriter_filter_replace_callback', $text);
-      unset($signwriter_filter_profile);
+      global $_signwriter_filter_profile;
+      $_signwriter_filter_profile = signwriter_load_profile($delta);
+      $text = preg_replace_callback($_signwriter_filter_profile->pattern, 'signwriter_filter_replace_callback', $text);
+      unset($_signwriter_filter_profile);
       return $text;
 
     case 'no cache':
@@ -175,17 +191,17 @@ function signwriter_filter($op, $delta = 0, $format = -1, $text = '') {
  * which would create a security issue
  */
 function signwriter_filter_replace_callback($matches) {
-  global $signwriter_filter_profile;
-  return signwriter_title_convert($matches[0], $signwriter_filter_profile);
+  global $_signwriter_filter_profile;
+  return signwriter_title_convert($matches[0], $_signwriter_filter_profile);
 }
 
 /**
- * Implementation of hook_filter_tips().
+ * Implements hook_filter_tips().
  */
-function signwriter_filter_tips($delta, $format, $long = FALSE) {
+function signwriter_filter_tips_XXX($delta, $format, $long = FALSE) {
   $profile = signwriter_load_profile($delta);
   if ($long) {
-    return t('The signwriter filter will replace headings matching the regular expression %pattern with images according to the settings of <a href="@profile-admin-url">the signwriter profile %profilename</a>.', array('%pattern' => $profile->pattern, '@profile-admin-url' => url('admin/settings/signwriter/profile/'. $profile->id), '%profilename' => $profile->name));
+    return t('The signwriter filter will replace headings matching the regular expression %pattern with images according to the settings of <a href="@profile-admin-url">the signwriter profile %profilename</a>.', array('%pattern' => $profile->pattern, '@profile-admin-url' => url('admin/config/signwriter/signwriter/profile/' . $profile->id), '%profilename' => $profile->name));
   }
   else {
     return t("The signwriter filter '%profilename' is enabled.", array('%profilename' => $profile->name));
@@ -193,7 +209,7 @@ function signwriter_filter_tips($delta, $format, $long = FALSE) {
 }
 
 /**
- * Implementation of hook_theme_registry_alter()
+ * Implements hook_theme_registry_alter().
  *
  * Add other menu module hooks here and provide respective 'signwritermenu_hook
  */
@@ -201,10 +217,11 @@ function signwriter_theme_registry_alter(&$theme_registry) {
   // functions to be intercepted
   //$replace_hooks = array('menu_item_link','menu_item','dhtml_menu_item','nice_menu');
   $replace_hooks = array('menu_item_link');
+
   foreach ($replace_hooks as $hook) {
     // if hook is a function then install my interception proc
     if (isset($theme_registry[$hook]['function'])) {
-      $intercept= 'function';
+      $intercept = 'function';
       if ($theme_registry[$hook]['function'] == 'devel_themer_catch_function') {
         $intercept = 'devel_function_intercept';
       }
@@ -234,7 +251,7 @@ function _signwriter_get_origfunc($origin) {
  * Return path to 'signwriter-dynamic.css'
  */
 function signwriter_dynamiccss_path() {
-  $cachedir = variable_get('signwriter_cachedir', file_directory_path() .'/signwriter');
+  $cachedir = variable_get('signwriter_cachedir', file_directory_path() . '/signwriter');
   return $cachedir . "/signwriter-dynamic.css";
 }
 
@@ -253,7 +270,7 @@ function signwriter_update_menucss($cssfile, $heights) {
 }
 
 /**
- * Implementation of interception hook
+ * Implements interception hook
  */
 function signwriter_menu_item_link($link) {
   // Check that signwriter is to be used on this page.
@@ -308,7 +325,7 @@ function signwriter_menu_item_link($link) {
         $csscache = new stdClass();
         $csscache->data = array();
       }
-      else if (!is_readable($menucss)) {
+      elseif (!is_readable($menucss)) {
         signwriter_update_menucss($menucss, $csscache->data);
       }
     }
@@ -321,9 +338,10 @@ function signwriter_menu_item_link($link) {
       // we don't have heigth in cache?
       if (!isset($heightcache->data[$imageinfo->key])) {
         $size = getimagesize($imageinfo->path);
-        $height = $heightcache->data[$imageinfo->key] = $size[1]/3;
+        $height = $heightcache->data[$imageinfo->key] = $size[1] / 3;
         cache_set("signwriter_menu", $heightcache->data);
-      } else {
+      }
+      else {
         $height = $heightcache->data[$imageinfo->key];
       }
     }
@@ -358,7 +376,7 @@ function signwriter_menu_item_link($link) {
  * Internal: Returns variable if set in object or a default.
  */
 function _signwriter_get_val($object, $variable, $default = NULL) {
-  $var = $object->$variable;
+  $var = ($object && isset($object->$variable) ? $object->$variable : NULL);
   $return = (isset($var) && !is_null($var)) ? $var : $default;
   return $return;
 }
@@ -368,7 +386,7 @@ function _signwriter_get_val($object, $variable, $default = NULL) {
  */
 function _signwriter_get_fontpaths() {
   // search drupal's base dir, files dir, and current theme dir, as well as user-supplied dirs for a font
-  $fontpaths = array('.', file_directory_path(), file_directory_path() .'/fonts', path_to_theme(), path_to_theme() .'/fonts');
+  $fontpaths = array('.', file_directory_path(), file_directory_path() . '/fonts', path_to_theme(), path_to_theme() . '/fonts');
   $userfontpath = variable_get('signwriter_fontpath', '');
   if ($userfontpath != '') {
     array_push($fontpaths, $userfontpath);
@@ -389,7 +407,7 @@ function _signwriter_available_fonts() {
   $fontpath = _signwriter_get_fontpaths();
   $fonts = array();
   foreach ($fontpath as $dir) {
-    $ttfs = glob($dir .'/{*.ttf, *.TTF}', GLOB_BRACE);
+    $ttfs = glob($dir . '/{*.ttf, *.TTF}', GLOB_BRACE);
     if (!empty($ttfs)) {
       foreach ($ttfs as $font) {
         $fonts[$font] = basename($font);
@@ -408,9 +426,15 @@ function _signwriter_available_fonts() {
 function _signwriter_available_image_types() {
   $types = imagetypes();
   $return = array();
-  if ($types & IMG_GIF) $return['gif'] = 'gif';
-  if ($types & IMG_PNG) $return['png'] = 'png';
-  if ($types & IMG_JPG) $return['jpeg'] = 'jpeg';
+  if ($types & IMG_GIF) {
+    $return['gif'] = 'gif';
+  }
+  if ($types & IMG_PNG) {
+    $return['png'] = 'png';
+  }
+  if ($types & IMG_JPG) {
+    $return['jpeg'] = 'jpeg';
+  }
 
   return $return;
 }
@@ -488,11 +512,12 @@ function signwriter_profile_load($pid) {
 function signwriter_load_profile($p) {
   $id = is_numeric($p) ? $p : (!empty($p->id) ? $p->id : 0);
   $name = is_string($p) ? $p : (!empty($p->name) ? $p->name : '');
+
   if ($id) {
-    return db_fetch_object(db_query("SELECT * FROM {signwriter} WHERE id = %d", $id));
+    return db_query("SELECT * FROM {signwriter} WHERE id = :id", array(':id' => $id))->fetchObject();
   }
   else {
-    return db_fetch_object(db_query("SELECT * FROM {signwriter} WHERE name = '%s'", $name));
+    return db_query("SELECT * FROM {signwriter} WHERE name = :name", array(':name' => $name))->fetchObject();
   }
 }
 
@@ -511,7 +536,7 @@ function signwriter_load_profiles($profiles = NULL) {
   if (is_NULL($profiles)) {
     $profiles = array();
     $results = db_query("SELECT * FROM {signwriter}");
-    while ($profile = db_fetch_object($results)) {
+    foreach ($results as $profile) {
       $profiles[] = $profile;
     }
   }
@@ -545,13 +570,13 @@ function signwriter_load_profiles($profiles = NULL) {
  *   false, if the file is not found in the cache
  */
 function signwriter_image_check_cache($text, $profile, &$imagefile, $tag = 'text', &$imageinfo = NULL) {
-  $cachedir = variable_get('signwriter_cachedir', file_directory_path() .'/signwriter');
-  file_check_directory($cachedir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
-  $imagefileid = "$tag:$text-". serialize($profile);
+  $cachedir = variable_get('signwriter_cachedir', file_directory_path() . '/signwriter');
+  file_prepare_directory($cachedir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+  $imagefileid = "$tag:$text-" . serialize($profile);
   $key = md5($imagefileid);
 
   // for shorter filenames that are still unique and repeatable (for caching)
-  $imagefilename = preg_replace('/[^\w\d]/', '', $text) .'-'. $key .'-signwriter.'. $profile->imagetype;
+  $imagefilename = preg_replace('/[^\w\d]/', '', $text) . '-' . $key . '-signwriter.' . $profile->imagetype;
   $imagefile = "$cachedir/$imagefilename";
   if ($imageinfo) {
     $imageinfo->key = $key;
@@ -572,24 +597,26 @@ function signwriter_image_check_cache($text, $profile, &$imagefile, $tag = 'text
  *   Profile to take color info from
  */
 function _signwriter_image_prepare_state($image, $profile, $idx, $state = "") {
-  $image->fontfile[$idx] = _signwriter_get_val($profile, $state.'fontfile', $profile->fontfile);
+  $image->fontfile[$idx] = _signwriter_get_val($profile, $state . 'fontfile', $profile->fontfile);
   $image->fontsize[$idx] = (float) _signwriter_get_val($profile, 'fontsize', $state ? $profile->fontsize : 20);
 
   # shadow, colors, background
-  $image->bg[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state.'background', 'ffffff'));
-  $image->fg[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state.'foreground', '000000'));
-  $image->transparent[$idx] = _signwriter_get_val($profile, $state.'transparent', TRUE);
-  $image->drop_shadow[$idx] = _signwriter_get_val($profile, $state.'drop_shadow', 0);
-  $image->shadow_rgb[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state.'shadow_color', 'd2d2d2'));
-  $image->shadow_xoffset[$idx] = _signwriter_get_val($profile, $state.'shadow_xoffset', 0);
-  $image->shadow_yoffset[$idx] = _signwriter_get_val($profile, $state.'shadow_yoffset', 0);
-  $image->border[$idx] = _signwriter_get_val($profile, $state.'border', 0);
-  $image->border_rgb[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state.'border_color', 'd2d2d2'));
-  $image->border_radius[$idx] = $image->border[$idx] ? _signwriter_get_val($profile, $state.'border_radius', 0) : 0;
-  $image->bgimage[$idx] = _signwriter_get_val($profile, $state.'bgimage');
+  $image->bg[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state . 'background', 'ffffff'));
+  $image->fg[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state . 'foreground', '000000'));
+  $image->transparent[$idx] = _signwriter_get_val($profile, $state . 'transparent', TRUE);
+  $image->drop_shadow[$idx] = _signwriter_get_val($profile, $state . 'drop_shadow', 0);
+  $image->shadow_rgb[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state . 'shadow_color', 'd2d2d2'));
+  $image->shadow_xoffset[$idx] = _signwriter_get_val($profile, $state . 'shadow_xoffset', 0);
+  $image->shadow_yoffset[$idx] = _signwriter_get_val($profile, $state . 'shadow_yoffset', 0);
+  $image->border[$idx] = _signwriter_get_val($profile, $state . 'border', 0);
+  $image->border_rgb[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state . 'border_color', 'd2d2d2'));
+  $image->border_color[$idx] = _signwriter_parse_colour(_signwriter_get_val($profile, $state . 'border_color', 'd2d2d2'));
+  $image->border_radius[$idx] = $image->border[$idx] ? _signwriter_get_val($profile, $state . 'border_radius', 0) : 0;
+  $image->bgimage[$idx] = _signwriter_get_val($profile, $state . 'bgimage');
   $image->bgimagetype[$idx] = _signwriter_get_image_type($image->bgimage[$idx]);
+
   if ($image->bgimage[$idx] && !$image->bgimagetype[$idx]) {
-    drupal_set_message("Signwriter: unsupported image type: {$image->bgimage[$idx]}", 'error');
+    drupal_set_message(t("Signwriter: unsupported image type: {$image->bgimage[$idx]}"), 'error');
   }
 }
 
@@ -613,7 +640,7 @@ function signwriter_image_prepare($profile) {
   $image->imagetype = _signwriter_get_val($profile, 'imagetype', 'gif');
   $image->xoffset = _signwriter_get_val($profile, 'xoffset', 0);
   $image->yoffset = _signwriter_get_val($profile, 'yoffset', 0);
-  $image->multiline = $profile->multiline;
+  $image->multiline = (isset($profile->multiline) ? $profile->multiline : 0);
   _signwriter_image_prepare_state($image, $profile, 0);
   if ($profile->threestate) {
     _signwriter_image_prepare_state($image, $profile, 1, "hov_");
@@ -682,7 +709,7 @@ function signwriter_image_calc_dimension($image, $text) {
             }
             $line = '';
           }
-          $line .= $word .' ';
+          $line .= $word . ' ';
         }
         $lines[] = trim($line);
         $tempbox   = imagettfbbox($image->fontsize[0], $angle, $image->fontfile[0], $line);
@@ -699,11 +726,10 @@ function signwriter_image_calc_dimension($image, $text) {
         $done = FALSE;
       }
     }
-    else{
+    else {
       $image->lines = array($text);
     }
-  }
-  while (!$done);
+  } while (!$done);
 
   if ($maxlinewidth) {
     $image->calcwidth = $image->width ? $image->width : $maxlinewidth;
@@ -734,15 +760,18 @@ function signwriter_image_calc_dimension($image, $text) {
  */
 function signwriter_create_image($image, $profile, $width, $height) {
   // create the image
-  if (!empty($image->bgimage[$idx])) {
-    $imagefunction = 'imagecreatefrom'. $image->bgimagetype[$idx];
-    $image->im = $imagefunction($image->bgimage);
-    $width = imagesx($image->im);
-    $height = imagesy($image->im);
-  }
-  else {
+  // $idx is never set.
+  /*
+    if (!empty($image->bgimage[$idx])) {
+      $imagefunction = 'imagecreatefrom' . $image->bgimagetype[$idx];
+      $image->im = $imagefunction($image->bgimage);
+      $width = imagesx($image->im);
+      $height = imagesy($image->im);
+    }
+    else {
+  */
     $image->im = imagecreate($width, $height);
-  }
+  // }
 
   // pre allocate the colors
   for ($idx = 0; $idx < ($profile->threestate ? 3 : 1); $idx++) {
@@ -798,7 +827,7 @@ function signwriter_render_text($image, $idx, $xofs, $yofs, $width, $height) {
   $box = $image->box;
 
   if (!$image->transparent && empty($image->bgimage[$idx])) {
-    imagefilledrectangle ($image->im, $xofs, $yofs , $xofs + $width, $yofs+ $height, $image->background[$idx]);
+    imagefilledrectangle($image->im, $xofs, $yofs, $xofs + $width, $yofs + $height, $image->background[$idx]);
   }
 
   foreach ($image->lines as $n => $line) {
@@ -821,18 +850,18 @@ function signwriter_render_text($image, $idx, $xofs, $yofs, $width, $height) {
     // This is so that the shadow doesn't go outside of the box.
     if ($image->drop_shadow[$idx]) {
       if ($image->shadow_xoffset[$idx] < 0 && $image->shadow_yoffset[$idx] < 0) {
-        imagettftext($image->im, $image->fontsize[$idx], $angle, $x + abs($box[0]),$y + abs($box[5]), $image->shadow_color[$idx], $image->fontfile[$idx], $line); // Shadow
+        imagettftext($image->im, $image->fontsize[$idx], $angle, $x + abs($box[0]), $y + abs($box[5]), $image->shadow_color[$idx], $image->fontfile[$idx], $line); // Shadow
         signwriter_bordered_text($image->im, $image->fontsize[$idx], $angle, $x + abs($box[0]) - $image->shadow_xoffset[$idx], $y + abs($box[5]) - $image->shadow_yoffset[$idx], $image->foreground[$idx], $image->fontfile[$idx], $line, $image->border_radius[$idx], $image->border_color[$idx]); // Text
       }
-      else if ($image->shadow_xoffset[$idx] > 0 && $image->shadow_yoffset[$idx] > 0) {
+      elseif ($image->shadow_xoffset[$idx] > 0 && $image->shadow_yoffset[$idx] > 0) {
         imagettftext($image->im, $image->fontsize[$idx], $angle, $x + abs($box[0]) + $image->shadow_xoffset[$idx], $y + abs($box[5]) + $image->shadow_yoffset[$idx], $image->shadow_color[$idx], $image->fontfile[$idx], $line); // Shadow
         signwriter_bordered_text($image->im, $image->fontsize[$idx], $angle, $x + abs($box[0]), $y + abs($box[5]), $image->foreground[$idx], $image->fontfile[$idx], $line, $image->border_radius[$idx], $image->border_color[$idx]); // Text
       }
-      else if ($image->shadow_xoffset[$idx] < 0 && $image->shadow_yoffset[$idx] > 0) {
+      elseif ($image->shadow_xoffset[$idx] < 0 && $image->shadow_yoffset[$idx] > 0) {
         imagettftext($image->im, $fontsize, $angle, $x + abs($box[0]), $y + abs($box[5]) + $image->shadow_yoffset[$idx], $image->shadow_color[$idx], $image->fontfile[$idx], $line); // Shadow
         signwriter_bordered_text($image->im, $fontsize, $angle, $x + abs($box[0]) - $shadow_xoffset, $y + abs($box[5]), $image->foreground[$idx], $image->fontfile[$idx], $line, $image->border_radius[$idx], $image->border_color[$idx]); // Text
       }
-      else if ($image->shadow_xoffset[$idx] > 0 && $image->shadow_yoffset[$idx] < 0) {
+      elseif ($image->shadow_xoffset[$idx] > 0 && $image->shadow_yoffset[$idx] < 0) {
         imagettftext($image->im, $fontsize, $angle, $x + abs($box[0]) + $image->shadow_xoffset[$idx], $y + abs($box[5]), $image->shadow_color[$idx], $image->fontfile[$idx], $line); // Shadow
         signwriter_bordered_text($image->im, $fontsize, $angle, $x + abs($box[0]), $y + abs($box[5]) - $shadow_yoffset, $image->foreground[$idx], $image->fontfile[$idx], $line, $image->border_radius[$idx], $image->border_color[$idx]); // Text
       }
@@ -946,13 +975,13 @@ function signwriter_title_convert($title, $signwriter) {
   }
 
   // Remove escapes from single quotes
-  $title =  preg_replace("/\\\'/","'", $title);
+  $title =  preg_replace("/\\\'/", "'", $title);
   $title = _signwriter_strip_tags($title);
   preg_match('/^(<.*?>)*([^<]*)(<.*?>)*($)/s', $title, $matches);
   $openingtags = $matches[1];
   $titletext = $matches[2];
   $closingtags = $matches[3];
-  return $openingtags . theme('signwriter_text', $titletext, $signwriter) . $closingtags;
+  return $openingtags . theme('signwriter_text', array('text' => $titletext, 'profile' => $signwriter)) . $closingtags;
 }
 
 /**
@@ -975,56 +1004,61 @@ function signwriter_theme_text($text, $profile, $attributes = NULL, $threestate
     return $text;
   }
 
-  drupal_add_css(drupal_get_path('module', 'signwriter') .'/signwriter.css');
+  drupal_add_css(drupal_get_path('module', 'signwriter') . '/signwriter.css');
 
   if (empty($profile->fontfile)) {
     $profile = signwriter_load_profile($profile);
   }
+
   $unicode_rest = array();
-  $alttext = '"'. decode_entities($text);
-  preg_match_all('/[^[:print:]'. $profile->allowed_nonasciichars .']/u', $alttext, $unicode_rest);
+  $alttext = '"' . decode_entities($text);
+
+  if (isset($profile->allowed_nonasciichars)) {
+    preg_match_all('/[^[:print:]'. $profile->allowed_nonasciichars .']/u', $alttext, $unicode_rest);
+  }
+
   if (mb_detect_encoding($alttext) === 'UTF-8' && $profile->allowed_nonasciichars !== 'all' && !empty($unicode_rest[0])) {
     if (variable_get('signwriter_specialcharnotice', TRUE) && user_access('administer signwriter')) {
       unset($profile->width);
       unset($profile->maxwidth);
       foreach ($unicode_rest[0] as $num => $character) {
-        $alttext = t($character .'rendered with profile '. $profile->name);
-        $unicode_rest[0][$num] = $character .' ('. theme( 'image', signwriter_image($character, $profile), $alttext, $alttext, array('style' => 'vertical-align:middle')) .')';
+        $alttext = t($character . 'rendered with profile ' . $profile->name);
+        // TODO Please change this theme call to use an associative array for the $variables parameter.
+        $unicode_rest[0][$num] = $character . ' (' . theme( 'image', signwriter_image($character, $profile), $alttext, $alttext, array('style' => 'vertical-align:middle')) . ')';
       }
       drupal_set_message(t("Signwriter notice: The unicode string '$text' will not be replaced by an
-        image because it contains following special characters = ". implode(',', $unicode_rest[0])
-      .'. If your font indeed does include these glyphs, paste them into the <em>allowed characters</em>field on the
-        !profilesettings.', array('!profilesettings' => l("profile's setting page", 'admin/settings/signwriter/profile/'. $profile->id))));
+        image because it contains following special characters = " . implode(',', $unicode_rest[0])
+      . '. If your font indeed does include these glyphs, paste them into the <em>allowed characters</em>field on the
+        !profilesettings.', array('!profilesettings' => l("profile's setting page", 'admin/config/signwriter/signwriter/profile/' . $profile->id))));
     }
     return $text;
   }
 
   $text = _signwriter_strip_tags($text);
-  $alttext= htmlspecialchars($text, ENT_QUOTES);
-  $titletext = $profile->use_title_text ? $alttext : '';
+  $alttext = htmlspecialchars($text, ENT_QUOTES);
+  $titletext = (isset($profile->use_title_text) && $profile->use_title_text ? $alttext : '');
   $imgsrc = signwriter_image($text, $profile, $tag, $imageinfo);
 
   if ($threestate && $profile->threestate) {
     $attributes['class'] = $attributes['class'] ? $attributes['class'] . ' signwriter signwriter-hover' : 'signwriter signwriter-hover';
   }
   else {
-    $attributes['class'] = $attributes['class'] ? $attributes['class'] . ' signwriter' : 'signwriter';
+    $attributes['class'] = (isset($attributes['class']) && !empty($attributes['class']) ? $attributes['class'] . ' signwriter' : 'signwriter');
   }
 
   $output = $text;
   if (!empty($imgsrc)) {
-    if ($profile->disable_span) {
-      $output = theme('image', $imgsrc, $alttext, $titletext, $attributes);
+    if (isset($profile->disable_span) && $profile->disable_span) {
+      $output = theme('image', array('path' => $imgsrc, 'width' => $alttext, 'height' => $titletext, 'alt' => $attributes));
     }
     else {
-      $output = '<span class="sw-hidden">' . $text . '</span>' . theme('image', $imgsrc, $alttext, $titletext, $attributes);
+      $output = '<span class="sw-hidden">' . $text . '</span>' . theme('image', array('path' => $imgsrc, 'width' => $alttext, 'height' => $titletext, 'alt' => $attributes));
     }
   }
 
   return $output;
 }
 
-
 /**
  * Turn text into a signwriter image.
  *
@@ -1039,40 +1073,48 @@ function signwriter_theme_text($text, $profile, $attributes = NULL, $threestate
  * @return
  *   HTML text to replace the input text.
  */
-function theme_signwriter_text($text, $profile, $attributes = NULL, $threestate = TRUE) {
-  return signwriter_theme_text($text, $profile, $attributes, $threestate);
+function theme_signwriter_text($variables) {
+  // TODO Number of parameters in this theme funcion does not match number of parameters found in hook_theme.
+  return signwriter_theme_text($variables['text'], $variables['profile'], $variables['attributes'], $variables['threestate']);
 }
 
 
 /**
- * Implementation of hook_preprocess_page().
+ * Implements hook_preprocess_page().
  */
 function signwriter_preprocess_page(&$variables) {
   $pagehookprofile = variable_get('signwriter_pagehookprofile', 'disabled');
-  $title = &$variables['title'];
 
-  if ($pagehookprofile !== 'disabled' && !empty($title)) {
-    $title = signwriter_title_convert($title, $pagehookprofile);
+  if (isset($variables['title']) && !empty($variables['title'])) {
+    $title = $variables['title'];
+
+    if ($pagehookprofile !== 'disabled' && !empty($title)) {
+      $variables['title'] = signwriter_title_convert($title, $pagehookprofile);
+    }
   }
 }
 
 /**
- * Implementation of hook_preprocess_block().
+ * Implements hook_preprocess_block().
  */
 function signwriter_preprocess_block(&$variables) {
   static $blockhookprofile = NULL;
+  $block = $variables['block'];
 
   if (!$blockhookprofile) {
     $blockhookprofile = variable_get('signwriter_blockhookprofile', 'disabled');
   }
 
-  $subject = &$variables['block']->subject;
-  if ($blockhookprofile !== 'disabled' && !empty($subject)) {
-    $subject = signwriter_title_convert($subject, $blockhookprofile);
+  if ($blockhookprofile !== 'disabled' && !empty($block->subject)) {
+    $block->subject = signwriter_title_convert($block->subject, $blockhookprofile);
   }
 }
 
-function signwriter_panels_pane_content_alter (&$content, $pane, $args, $context) {
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function signwriter_panels_pane_content_alter(&$content, $pane, $args, $context) {
   $panelstitlehookprofile = variable_get('signwriter_panelshooktitleprofile', 'disabled');
 
   if ($panelstitlehookprofile !== 'disabled' && !empty($content->title)) {
@@ -1112,10 +1154,10 @@ function signwriter_load_menuprofile($p) {
   $id = is_numeric($p) ? $p : (!empty($p->id) ? $p->id : 0);
   $name = is_string($p) ? $p : (!empty($p->name) ? $p->name : '');
   if ($id) {
-    return _signwriter_unpack_menuprofile(db_fetch_object(db_query("SELECT * FROM {signwriter_menu} WHERE id = %d", $id)));
+    return _signwriter_unpack_menuprofile(db_query("SELECT * FROM {signwriter_menu} WHERE id = :id", array(':id' => $id)));
   }
   else {
-    return _signwriter_unpack_menuprofile(db_fetch_object(db_query("SELECT * FROM {signwriter_menu} WHERE name = '%s'", $name)));
+    return _signwriter_unpack_menuprofile(db_query("SELECT * FROM {signwriter_menu} WHERE name = :name", array(':name' => $name)));
   }
 }
 
@@ -1134,7 +1176,7 @@ function signwriter_load_menuprofiles($profiles = NULL) {
   if (is_NULL($profiles)) {
     $profiles = array();
     $results = db_query("SELECT * FROM {signwriter_menu}");
-    while ($profile = db_fetch_object($results)) {
+    foreach ($results as $profile) {
       $profiles[$profile->id] = _signwriter_unpack_menuprofile($profile);
     }
   }
@@ -1148,6 +1190,10 @@ function signwriter_load_menuprofiles($profiles = NULL) {
   return $profiles;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function _signwriter_unpack_menuprofile($in) {
   $out = $in;
   $out->data = unserialize($in->data);
@@ -1176,7 +1222,10 @@ function _signwriter_display_on_page() {
       $page_match = !($type xor $page_match);
     }
     else {
-      $page_match = drupal_eval($list);
+      if (module_exists('php')) {
+        $page_match = php_eval($list);
+
+      }
     }
   }
   else {
@@ -1184,6 +1233,3 @@ function _signwriter_display_on_page() {
   }
   return $page_match;
 }
-
-//---------------------------------------------------------
-//>>>> check implementation
