Components/Filter.php
public function getFormattedInput($operator, $input)
    {
        // if we use custom formatter
        if (is_callable($this->inputFormatter)) {
            $function = $this->inputFormatter;

            return $function($this, $operator, $input);
        } // else, use standard input converter

            switch ($this->getDataFormat()) {
                // date/time format dd/mm/YYYY HH:ii:ss
                case self::FORMAT_DATE:
                    $params = explode('/', str_replace(array('-', ' ',':'), '/', $input));
                    // only year ?
                    if (count($params) == 1) {
                        $fInput = $params[0];
                    } // month/year ?
                    elseif (count($params) == 2) {
                        $fInput = sprintf('%04d-%02d', $params[1], $params[0]);
                    } // day/month/year ?
                    elseif (count($params) == 3) {
                        $fInput = sprintf('%04d-%02d-%02d', $params[2], $params[1], $params[0]);
                    } // day/month/year hour ?
                    elseif (count($params) == 4) {
                        $fInput = sprintf('%04d-%02d-%02d %02d', $params[2], $params[1], $params[0], $params[3]);
                    } // day/month/year hour:minute ?
                    elseif (count($params) == 5) {
                        $fInput = sprintf(
                            '%04d-%02d-%02d %02d:%02d',
                            $params[2],
                            $params[1],
                            $params[0],
                            $params[3],
                            $params[4]
                        );
                    } // day/month/year hour:minute:second ?
                    elseif (count($params) == 6) {
                        $fInput = sprintf(
                            '%04d-%02d-%02d %02d:%02d:%02d',
                            $params[2],
                            $params[1],
                            $params[0],
                            $params[3],
                            $params[4],
                            $params[5]
                        );
                    } // default, same has raw value
                    else {
                        $fInput = $input;
                    }
                    break;
                case self::FORMAT_INTEGER:
                    $fInput = (int) $input;
                    switch ($operator) {
                        case self::TYPE_NOT_LIKE:
                            $operator = self::TYPE_NOT_EQUAL;
                            break;
                        case self::TYPE_LIKE:
                        case self::TYPE_LIKE_WORDS_AND:
                        case self::TYPE_LIKE_WORDS_OR:
                        case self::TYPE_AUTO:
                            $operator = self::TYPE_EQUAL_STRICT;
                            break;
                    }
                    break;
                case self::FORMAT_TEXT:
                default:
                    $fInput = $input;
                    break;
            }

        return array($operator, $fInput);
    }
public function getFormattedInput($operator, $input)
    {
        // if we use custom formatter
        if (is_callable($this->inputFormatter)) {
            $function = $this->inputFormatter;

            return $function($this, $operator, $input);
        } // else, use standard input converter

            switch ($this->getDataFormat()) {
                // date/time format dd/mm/YYYY HH:ii:ss
                case self::FORMAT_DATE:
                    $params = explode('/', str_replace(array('-', ' ',':'), '/', $input));
                    // only year ?
                    if (count($params) == 1) {
                        $fInput = $params[0];
                    } // month/year ?
                    elseif (count($params) == 2) {
                        $fInput = sprintf('%04d-%02d', $params[1], $params[0]);
                    } // day/month/year ?
                    elseif (count($params) == 3) {
                        $fInput = sprintf('%04d-%02d-%02d', $params[2], $params[1], $params[0]);
                    } // day/month/year hour ?
                    elseif (count($params) == 4) {
                        $fInput = sprintf('%04d-%02d-%02d %02d', $params[2], $params[1], $params[0], $params[3]);
                    } // day/month/year hour:minute ?
                    elseif (count($params) == 5) {
                        $fInput = sprintf(
                            '%04d-%02d-%02d %02d:%02d',
                            $params[2],
                            $params[1],
                            $params[0],
                            $params[3],
                            $params[4]
                        );
                    } // day/month/year hour:minute:second ?
                    elseif (count($params) == 6) {
                        $fInput = sprintf(
                            '%04d-%02d-%02d %02d:%02d:%02d',
                            $params[2],
                            $params[1],
                            $params[0],
                            $params[3],
                            $params[4],
                            $params[5]
                        );
                    } // default, same has raw value
                    else {
                        $fInput = $input;
                    }
                    break;
                case self::FORMAT_INTEGER:
                    $fInput = (int) $input;
                    switch ($operator) {
                        case self::TYPE_NOT_LIKE:
                            $operator = self::TYPE_NOT_EQUAL;
                            break;
                        case self::TYPE_LIKE:
                        case self::TYPE_LIKE_WORDS_AND:
                        case self::TYPE_LIKE_WORDS_OR:
                        case self::TYPE_AUTO:
                            $operator = self::TYPE_EQUAL_STRICT;
                            break;
                    }
                    break;
                case self::FORMAT_TEXT:
                default:
                    $fInput = $input;
                    break;
            }

        return array($operator, $fInput);
    }
public function getFormattedInput ( $ operator , $ input ) { // if we use custom formatter if ( is_callable ( $ this -> inputFormatter ) ) { $ function = $ this -> inputFormatter ; return $ function ( $ this , $ operator , $ input ) ; } // else, use standard input converter switch ( $ this -> getDataFormat ( ) ) { // date/time format dd/mm/YYYY HH:ii:ss case self :: FORMAT_DATE : $ params = explode ( '/' , str_replace ( array ( '-' , ' ' , ':' ) , '/' , $ input ) ) ; // only year ? if ( count ( $ params ) == 1 ) { $ fInput = $ params [ 0 ] ; } // month/year ? elseif ( count ( $ params ) == 2 ) { $ fInput = sprintf ( '%04d-%02d' , $ params [ 1 ] , $ params [ 0 ] ) ; } // day/month/year ? elseif ( count ( $ params ) == 3 ) { $ fInput = sprintf ( '%04d-%02d-%02d' , $ params [ 2 ] , $ params [ 1 ] , $ params [ 0 ] ) ; } // day/month/year hour ? elseif ( count ( $ params ) == 4 ) { $ fInput = sprintf ( '%04d-%02d-%02d %02d' , $ params [ 2 ] , $ params [ 1 ] , $ params [ 0 ] , $ params [ 3 ] ) ; } // day/month/year hour:minute ? elseif ( count ( $ params ) == 5 ) { $ fInput = sprintf ( '%04d-%02d-%02d %02d:%02d' , $ params [ 2 ] , $ params [ 1 ] , $ params [ 0 ] , $ params [ 3 ] , $ params [ 4 ] ) ; } // day/month/year hour:minute:second ? elseif ( count ( $ params ) == 6 ) { $ fInput = sprintf ( '%04d-%02d-%02d %02d:%02d:%02d' , $ params [ 2 ] , $ params [ 1 ] , $ params [ 0 ] , $ params [ 3 ] , $ params [ 4 ] , $ params [ 5 ] ) ; } // default, same has raw value else { $ fInput = $ input ; } break ; case self :: FORMAT_INTEGER : $ fInput = ( int ) $ input ; switch ( $ operator ) { case self :: TYPE_NOT_LIKE : $ operator = self :: TYPE_NOT_EQUAL ; break ; case self :: TYPE_LIKE : case self :: TYPE_LIKE_WORDS_AND : case self :: TYPE_LIKE_WORDS_OR : case self :: TYPE_AUTO : $ operator = self :: TYPE_EQUAL_STRICT ; break ; } break ; case self :: FORMAT_TEXT : default : $ fInput = $ input ; break ; } return array ( $ operator , $ fInput ) ; }
Get formatted input.

@param string $operator
@param string $input

@return array searchOperator, formatted input
Get formatted input .