You are here

function _shs_create_hash in Simple hierarchical select 7

Helper function to create a pseudo hash needed for javascript settings.

Parameters

int $length: Lenght of string to return.

Return value

string Random string.

See also

DrupalTestCase::randomName()

3 calls to _shs_create_hash()
shs_field_widget_afterbuild in ./shs.module
Afterbuild callback for widgets of type "taxonomy_shs".
shs_handler_filter_entityreference::value_form in includes/handlers/shs_handler_filter_entityreference.inc
Provide a simple textfield for equality.
shs_handler_filter_term_node_tid::value_form in includes/handlers/shs_handler_filter_term_node_tid.inc
Options form subform for setting options.

File

./shs.module, line 1168
Provides an additional widget for term fields to create hierarchical selects.

Code

function _shs_create_hash($length = 8) {
  $values = array_merge(range(65, 90), range(97, 122), range(48, 57));
  $max = count($values) - 1;
  $hash = chr(mt_rand(97, 122));
  for ($i = 1; $i < $length; $i++) {
    $hash .= chr($values[mt_rand(0, $max)]);
  }
  return $hash;
}