*** delete_orphaned_terms.module.old	Fri Mar  5 05:54:38 2010
--- delete_orphaned_terms.module	Fri May 28 08:54:03 2010
***************
*** 42,47 ****
--- 42,53 ----
    case 'delete_orphaned_terms_enablecron':
      return FALSE;
      break;
+   case 'delete_orphaned_terms_maxwords':
+     return 0;
+     break;
+   case 'delete_orphaned_terms_minwords':
+     return 0;
+     break;
    default:
      DIE('Don\'t know this option');
    }
***************
*** 170,175 ****
--- 176,183 ----
      variable_set('delete_orphaned_terms_vocabs', $form_state['values']['delete_orphaned_terms_vocabs']);
    }
    $thres = _dot_get('delete_orphaned_terms_threshold');
+   $maxwords = _dot_get('delete_orphaned_terms_maxwords');
+   $minwords = _dot_get('delete_orphaned_terms_minwords');
  
    // assemble the terms to process and generate output
    $prune = array();
***************
*** 198,203 ****
--- 206,243 ----
            }
          }
        }
+       if (($maxwords >0) && (str_word_count($term->name) > $maxwords)){
+         $prune_local[] = $term->tid;
+         $del_term++;
+         if ($sim) {
+           drupal_set_message(t('Would delete term #!tid: !name (!vname)', array('!tid' => $term->tid,
+                                                                                 '!name' => $term->name,
+                                                                                 '!vname' => $vocab->name)));
+         }
+         else {
+           if (!$cron) {
+             drupal_set_message(t('Deleting term #!tid: !name (!vname)', array('!tid' => $term->tid,
+                                                                               '!name' => $term->name,
+                                                                               '!vname' => $vocab->name)));
+           }
+         }
+       }
+       if (($minwords >0 ) && (str_word_count($term->name) < $minwords)){
+         $prune_local[] = $term->tid;
+         $del_term++;
+         if ($sim) {
+           drupal_set_message(t('Would delete term #!tid: !name (!vname)', array('!tid' => $term->tid,
+                                                                                 '!name' => $term->name,
+                                                                                 '!vname' => $vocab->name)));
+         }
+         else {
+           if (!$cron) {
+             drupal_set_message(t('Deleting term #!tid: !name (!vname)', array('!tid' => $term->tid,
+                                                                               '!name' => $term->name,
+                                                                               '!vname' => $vocab->name)));
+           }
+         }
+       }
      }
      // issue an error to the log if the configured failsafe (any) is out of bounds
      if (count($terms) > 0 && count($prune)/count($terms)*100 > _dot_get('delete_orphaned_terms_failsafe')) {
***************
*** 454,459 ****
--- 494,519 ----
      '#type' => 'textfield',
    );
  
+   $form['dot_param']['delete_orphaned_terms_maxwords'] = array(
+     '#description' => t('Number of words in a term <em>over</em> to which it is considered as Too-Long-Tail-Term (Should be deleted). Leave 0 this setting will be ignored.'),
+     '#default_value' => _dot_get('delete_orphaned_terms_maxwords'),
+     '#element_validate' => array('_delete_orphaned_terms_element_validate_threshold'),
+     '#maxlength' => 2,
+     '#size' => 2,
+     '#title' => t('Max words of a Long-Tail-Term'),
+     '#type' => 'textfield',
+   );
+ 
+   $form['dot_param']['delete_orphaned_terms_minwords'] = array(
+     '#description' => t('Number of words in a term <em>less</em> to which it is considered as Too-Short-Term (Should be deleted). Leave 0 this setting will be ignored.'),
+     '#default_value' => _dot_get('delete_orphaned_terms_minwords'),
+     '#element_validate' => array('_delete_orphaned_terms_element_validate_threshold'),
+     '#maxlength' => 1,
+     '#size' => 1,
+     '#title' => t('Min words a term should include'),
+     '#type' => 'textfield',
+   );
+ 
    return system_settings_form($form);
  }
  
***************
*** 519,522 ****
    );
  
    return $items;
! }
--- 579,582 ----
    );
  
    return $items;
! }
\ No newline at end of file
