from = $from; $this->to = $to; } function editInput($table, $field, $attrs, $value) { static $slugify; if (!$_GET["select"] && !$_GET["where"]) { if ($slugify === null) { $slugify = array(); $prev = null; foreach (fields($table) as $name => $val) { if ($prev && preg_match('~(^|_)slug(_|$)~', $name)) { $slugify[$prev] = $name; } $prev = $name; } } $slug = $slugify[$field["field"]]; if ($slug !== null) { return "" . script("qsl('input').onchange = function () { var find = '$this->from'; var repl = '$this->to'; this.form['fields[$slug]'].value = this.value.toLowerCase() .replace(new RegExp('[' + find + ']', 'g'), function (str) { return repl[find.indexOf(str)]; }) .replace(/[^a-z0-9_]+/g, '-') .replace(/^-|-\$/g, '') .substr(0, $field[length]); };"); } } } }