Index: edge.info
===================================================================
RCS file: edge.info
diff -N edge.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ edge.info	1 Oct 2010 23:16:44 -0000
@@ -0,0 +1,6 @@
+; $Id$
+name = Edge
+description = Provides cutting edge functionality for Drupal core.
+package = Core - Cutting Edge
+core = 7.x
+files[] = edge.module
Index: edge.module
===================================================================
RCS file: edge.module
diff -N edge.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ edge.module	1 Oct 2010 23:10:28 -0000
@@ -0,0 +1,25 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Cutting Edge functionality.
+ */
+
+/**
+ * Implements hook_theme_registry_alter().
+ */
+function edge_theme_registry_alter(&$callbacks) {
+  $path = drupal_get_path('module', 'edge');
+
+  // Apply replacement theme callbacks, but only if they have not been
+  // overridden.
+  $edge_theme = array('links');
+  foreach ($edge_theme as $callback) {
+    if (isset($callbacks[$callback]) && $callbacks[$callback]['function'] == 'theme_' . $callback) {
+      $callbacks[$callback]['function'] = 'theme_edge_' . $callback;
+      $callbacks[$callback]['includes'][] = $path . '/edge.theme.inc';
+      $callbacks[$callback]['file'] = 'edge.theme.inc';
+    }
+  }
+}
Index: edge.theme.inc
===================================================================
RCS file: edge.theme.inc
diff -N edge.theme.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ edge.theme.inc	1 Oct 2010 23:13:10 -0000
@@ -0,0 +1,123 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Cutting Edge theme functions.
+ */
+
+/**
+ * Returns HTML for a set of links.
+ *
+ * @param $variables
+ *   An associative array containing:
+ *   - links: A keyed array of links to be themed. The key for each link is used
+ *     as its css class. Each link should be itself an array, with the following
+ *     keys:
+ *     - title: the link text
+ *     - href: the link URL. If omitted, the 'title' is shown as a plain text
+ *       item in the links list.
+ *     - html: (optional) set this to TRUE if 'title' is HTML so it will be
+ *       escaped.
+ *     Array items are passed on to the l() function's $options parameter when
+ *     creating the link.
+ *   - attributes: A keyed array of attributes.
+ *   - heading: An optional keyed array or a string for a heading to precede the
+ *     links. When using an array the following keys can be used:
+ *     - text: the heading text
+ *     - level: the heading level (e.g. 'h2', 'h3')
+ *     - class: (optional) an array of the CSS classes for the heading
+ *     When using a string it will be used as the text of the heading and the
+ *     level will default to 'h2'.
+ *
+ *     Headings should be used on navigation menus and any list of links that
+ *     consistently appears on multiple pages. To make the heading invisible
+ *     use the 'element-invisible' CSS class. Do not use 'display:none', which
+ *     removes it from screen-readers and assistive technology. Headings allow
+ *     screen-reader and keyboard only users to navigate to or skip the links.
+ *     See http://juicystudio.com/article/screen-readers-display-none.php
+ *     and http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
+ */
+function theme_edge_links($variables) {
+  global $language_url;
+
+  $links = $variables['links'];
+  $attributes = $variables['attributes'];
+  $heading = $variables['heading'];
+  $output = '';
+
+  if ($links) {
+    // Prepend the heading to the list, if any.
+    if ($heading) {
+      // Convert a string heading into an array, using a H2 tag by default.
+      if (is_string($heading)) {
+        $heading = array('text' => $heading);
+      }
+      // Merge in default array properties into $heading.
+      $heading += array(
+        'level' => 'h2',
+        'attributes' => array(),
+      );
+      // @todo D8: Remove backwards compatibility for $heading['class'].
+      if (isset($heading['class'])) {
+        $heading['attributes']['class'] = $heading['class'];
+      }
+
+      $output .= '<' . $heading['level'] . drupal_attributes($heading['attributes']) . '>';
+      $output .= check_plain($heading['text']);
+      $output .= '</' . $heading['level'] . '>';
+    }
+
+    $output .= '<ul' . drupal_attributes($attributes) . '>';
+
+    $num_links = count($links);
+    $i = 0;
+    foreach ($links as $key => $link) {
+      $i++;
+
+      $class = array();
+      // Use the array key as class name.
+      $class[] = drupal_html_class($key);
+      // Add odd/even, first, and last classes.
+      $class[] = ($i % 2 ? 'odd' : 'even');
+      if ($i == 1) {
+        $class[] = 'first';
+      }
+      if ($i == $num_links) {
+        $class[] = 'last';
+      }
+      $item = '';
+
+      // Handle links.
+      if (isset($link['href'])) {
+        $is_current_path = ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()));
+        $is_current_language = (empty($link['language']) || $link['language']->language == $language_url->language);
+        if ($is_current_path && $is_current_language) {
+          $class[] = 'active';
+        }
+        // Pass in $link as $options, they share the same keys.
+        $item = l($link['title'], $link['href'], $link);
+      }
+      // Handle title-only text items.
+      else {
+        // Merge in default array properties into $link.
+        $link += array(
+          'html' => FALSE,
+          'attributes' => array(),
+        );
+        $item .= '<span' . drupal_attributes($link['attributes']) . '>';
+        $item .= ($link['html'] ? $link['title'] : check_plain($link['title']));
+        $item .= '</span>';
+      }
+
+      $output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
+      $output .= $item;
+      $output .= '</li>';
+    }
+
+    $output .= '</ul>';
+  }
+
+  return $output;
+}
+
