Diff of /plugins/slugify.php [40ad84] .. [6591d4] Maximize Restore

  Switch to unified view

a/plugins/slugify.php b/plugins/slugify.php
...
...
19
    }
19
    }
20
    
20
    
21
    function editInput($table, $field, $attrs, $value) {
21
    function editInput($table, $field, $attrs, $value) {
22
        static $slugify;
22
        static $slugify;
23
        if (!$_GET["select"] && !$_GET["where"]) {
23
        if (!$_GET["select"] && !$_GET["where"]) {
24
          if (!isset($slugify)) {
24
          if ($slugify === null) {
25
                $slugify = array();
25
                $slugify = array();
26
                $prev = null;
26
                $prev = null;
27
                foreach (fields($table) as $name => $val) {
27
                foreach (fields($table) as $name => $val) {
28
                    if ($prev && ereg('(^|_)slug(_|$)', $name)) {
28
                    if ($prev && ereg('(^|_)slug(_|$)', $name)) {
29
                        $slugify[$prev] = $name;
29
                        $slugify[$prev] = $name;
30
                    }
30
                    }
31
                    $prev = $name;
31
                    $prev = $name;
32
                }
32
                }
33
            }
33
            }
34
            $slug = $slugify[$field["field"]];
34
            $slug = $slugify[$field["field"]];
35
          if (isset($slug)) {
35
          if ($slug !== null) {
36
                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]);\">";
36
                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]);\">";
37
            }
37
            }
38
        }
38
        }
39
    }
39
    }
40
    
40