You are here

function _modules_weight_prepare_delta in Modules weight 7

Prepares the delta for the weight field on the administration form.

If a module has a weight higher then 100 (or lower than 100), it will use that value as delta and the '#weight' field will turn into a textfield most likely.

Parameters

int $weight: The weight.

Return value

int The weight.

1 call to _modules_weight_prepare_delta()
modules_weight_admin_config_page_form in ./modules_weight.admin.inc
Form constructor for Module Weight form.

File

./modules_weight.helpers.inc, line 21
Helper functions.

Code

function _modules_weight_prepare_delta($weight) {
  $delta = 100;

  // Typecasting to int.
  $weight = (int) $weight;
  if ($weight > $delta) {
    return $weight;
  }
  if ($weight < -100) {
    return $weight * -1;
  }
  return $delta;
}