5 class Char extends \Rsi\Fred\Controller\Widget{
38 $config = array_merge(parent::clientConfig(),$this->
get([self::NOTATION,self::TRANSFORM,self::REGEX,self::TRIM]));
45 return $this->local->formatInt($value);
49 return $value && is_string($value) ? $value :
null;
53 return $this->transform && !$this->
nothing($value) ? \Rsi\Str::transform($value,$this->transform) : $value;
57 return $this->trim && is_scalar($value) ? trim($value,$this->trim ===
true ?
" \t\n\r" : $this->trim) : $value;
61 if($this->replace)
foreach($this->replace as $mask =>
$replace) $value = preg_replace($mask,
$replace,$value);
66 return !$this->min || (mb_strlen($value) >=
$this->min);
70 return !$this->max || (mb_strlen($value) <=
$this->max);
74 return !$this->regex || preg_match($this->regex,$value);
78 return !$this->spoof || !\Rsi\Str::spoof($value,$this->spoof ===
true ?
null : $this->spoof);
82 if(is_callable(
$suggest = $this->suggest))
87 elseif(!preg_match(
'/^(\\w+)\\.(\\w+)$/',
$suggest,$match))
89 elseif(($count = count(
$suggest = $this->db->record(
90 $this->db->limit($sql =
"
91 select distinct(`$match[2]`) from `$match[1]`
92 where `$match[2]` like :this
93 order by `$match[2]`",
96 [
'this' => $value = $this->request->this .
'%']
97 ))) < $this->suggestLimit)
$suggest = array_merge(
$suggest,$this->db->record(
98 $this->db->limit($sql,$this->suggestLimit - $count),
99 [
'this' =>
'_%' . $value]
102 $this->request->result = [
'suggest' =>
$suggest];
106 return array_merge(parent::getParams(),[
'this' => $this->request->this]);