Importing bits and pieces
This is the initial import based on a few files I had around.
This commit is contained in:
commit
871d28cd16
20 changed files with 1994 additions and 0 deletions
includes/form
26
includes/form/modifiers.inc.php
Normal file
26
includes/form/modifiers.inc.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
class Modifier_TrimString
|
||||
implements FieldModifier
|
||||
{
|
||||
private $removeDuplicateSpaces;
|
||||
|
||||
|
||||
public function __construct( $removeDuplicateSpaces = true )
|
||||
{
|
||||
$this->removeDuplicateSpaces = $removeDuplicateSpaces;
|
||||
}
|
||||
|
||||
|
||||
public function replace( $value )
|
||||
{
|
||||
if ( $value === null ) {
|
||||
return '';
|
||||
}
|
||||
$value = trim( $value );
|
||||
if ( $this->removeDuplicateSpaces ) {
|
||||
$value = preg_replace( '/\s\s+/' , ' ' , $value );
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue