Conditions | 8 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | function editInput($table, $field, $attrs, $value) { |
||
23 | static $slugify; |
||
24 | if (!$_GET['select'] && !$_GET['where']) { |
||
25 | if ($slugify === null) { |
||
26 | $slugify = array(); |
||
27 | $prev = null; |
||
28 | foreach (fields($table) as $name => $val) { |
||
29 | if ($prev && preg_match('~(^|_)slug(_|$)~', $name)) { |
||
30 | $slugify[$prev] = $name; |
||
31 | } |
||
32 | $prev = $name; |
||
33 | } |
||
34 | } |
||
35 | $slug = $slugify[$field['field']]; |
||
36 | if ($slug !== null) { |
||
37 | return "<input value='" . h($value) . "' maxlength='$field[length]' size='40'$attrs onchange=\"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]);\">"; |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | |||
43 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.