Index: tagadelic.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tagadelic/Attic/tagadelic.module,v
retrieving revision 1.36.2.8
diff -u -p -r1.36.2.8 tagadelic.module
--- tagadelic.module	30 Dec 2007 13:54:50 -0000	1.36.2.8
+++ tagadelic.module	17 Apr 2008 19:38:46 -0000
@@ -67,7 +67,8 @@ function tagadelic_nodeapi(&$node, $op, 
  * Menu callback. Admin setting page for tagadelic.
  */
 function tagadelic_settings() {
-  $options = array('weight,asc' => t('by weight, ascending'), 'weight,desc' => t('by weight, descending'), 'title,asc' => t('by title, ascending'), 'title,desc' => t('by title, descending'), 'random,none' => t('random'));
+  $options = array('weight,asc' => t('by weight, ascending'), 'weight,desc' => t('by weight, descending'), 'title,asc' => t('by title, ascending'), 'title,desc' => t('by title, descending'), 'random,none' => t('random'), 'custom,none' => t('custom'));
+  
   $form['tagadelic_sort_order'] = array(
     '#type' => 'radios',
     '#title' => t('Tagadelic sort order'),
@@ -75,6 +76,13 @@ function tagadelic_settings() {
     '#default_value' => variable_get('tagadelic_sort_order', 'title,asc'),
     '#description' => t('Determines the sort order of the tags on the freetagging page.'),
   );
+  $form['tagadelic_custom_sort_order'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Custom Sort Order'),
+    '#default_value' => variable_get('tagadelic_custom_sort_order', ""),
+    '#rows' => 4,
+    '#description' => t('Enter php code to be used in the <a href="http://us2.php.net/usort">usort</a> callback function.  Enclosing <?php ?> tags are not needed.  <br/>Two variables are available, <em>$a</em> and <em>$b</em> as arguments to the sorting function.'),
+  );
   $form['tagadelic_page_amount'] = array(
     '#type' => 'textfield',
     '#size' => 5,
@@ -256,6 +264,9 @@ function tagadelic_sort_tags($tags) {
     case 'random':
       shuffle($tags);
       break;
+    case 'custom':
+      usort($tags, "_tagadelic_sort_custom");
+      break;
   }
   if ($order == 'desc') {
     $tags = array_reverse($tags);
@@ -278,6 +289,13 @@ function _tagadelic_sort_by_weight($a, $
 }
 
 /**
+ * callback for usort, sort by custom 
+ */
+function _tagadelic_sort_custom($a, $b) {
+  return eval(variable_get('tagadelic_custom_sort_order', "FALSE"));
+}
+
+/**
  * theme function that renders the HTML for the tags
  * @ingroup themable
  */
