public function convertBackgroundPosition($css, &$res)
    {
        // init the res
        $res = false;

        // explode the value
        $css = explode(' ', $css);

        // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
        if (count($css)<2) {
            if (!$css[0]) return null;
            $css[1] = 'center';
        }
        if (count($css)>2) return null;

        // prepare the values
        $x = 0;
        $y = 0;
        $res = true;

        // convert the first value
        if ($css[0]=='left')        $x = '0%';
        else if ($css[0]=='center') $x = '50%';
        else if ($css[0]=='right')  $x = '100%';
        else if ($css[0]=='top')    $y = '0%';
        else if ($css[0]=='bottom') $y = '100%';
        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
        else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
        else $res = false;

        // convert the second value
        if ($css[1]=='left')        $x = '0%';
        else if ($css[1]=='right')  $x = '100%';
        else if ($css[1]=='top')    $y = '0%';
        else if ($css[1]=='center') $y = '50%';
        else if ($css[1]=='bottom') $y = '100%';
        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
        else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
        else $res = false;

        // return the values
        return array($x, $y);
    }
public function convertBackgroundPosition($css, &$res)
    {
        // init the res
        $res = false;

        // explode the value
        $css = explode(' ', $css);

        // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2
        if (count($css)<2) {
            if (!$css[0]) return null;
            $css[1] = 'center';
        }
        if (count($css)>2) return null;

        // prepare the values
        $x = 0;
        $y = 0;
        $res = true;

        // convert the first value
        if ($css[0]=='left')        $x = '0%';
        else if ($css[0]=='center') $x = '50%';
        else if ($css[0]=='right')  $x = '100%';
        else if ($css[0]=='top')    $y = '0%';
        else if ($css[0]=='bottom') $y = '100%';
        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[0])) $x = $css[0];
        else if ($this->convertToMM($css[0])) $x = $this->convertToMM($css[0]);
        else $res = false;

        // convert the second value
        if ($css[1]=='left')        $x = '0%';
        else if ($css[1]=='right')  $x = '100%';
        else if ($css[1]=='top')    $y = '0%';
        else if ($css[1]=='center') $y = '50%';
        else if ($css[1]=='bottom') $y = '100%';
        else if (preg_match('/^[-]?[0-9\.]+%$/isU', $css[1])) $y = $css[1];
        else if ($this->convertToMM($css[1])) $y = $this->convertToMM($css[1]);
        else $res = false;

        // return the values
        return array($x, $y);
    }
public function convertBackgroundPosition ( $ css , & $ res ) { // init the res $ res = false ; // explode the value $ css = explode ( ' ' , $ css ) ; // we must have 2 values. if 0 or >2 : error. if 1 => put center for 2 if ( count ( $ css ) < 2 ) { if ( ! $ css [ 0 ] ) return null ; $ css [ 1 ] = 'center' ; } if ( count ( $ css ) > 2 ) return null ; // prepare the values $ x = 0 ; $ y = 0 ; $ res = true ; // convert the first value if ( $ css [ 0 ] == 'left' ) $ x = '0%' ; else if ( $ css [ 0 ] == 'center' ) $ x = '50%' ; else if ( $ css [ 0 ] == 'right' ) $ x = '100%' ; else if ( $ css [ 0 ] == 'top' ) $ y = '0%' ; else if ( $ css [ 0 ] == 'bottom' ) $ y = '100%' ; else if ( preg_match ( '/^[-]?[0-9\.]+%$/isU' , $ css [ 0 ] ) ) $ x = $ css [ 0 ] ; else if ( $ this -> convertToMM ( $ css [ 0 ] ) ) $ x = $ this -> convertToMM ( $ css [ 0 ] ) ; else $ res = false ; // convert the second value if ( $ css [ 1 ] == 'left' ) $ x = '0%' ; else if ( $ css [ 1 ] == 'right' ) $ x = '100%' ; else if ( $ css [ 1 ] == 'top' ) $ y = '0%' ; else if ( $ css [ 1 ] == 'center' ) $ y = '50%' ; else if ( $ css [ 1 ] == 'bottom' ) $ y = '100%' ; else if ( preg_match ( '/^[-]?[0-9\.]+%$/isU' , $ css [ 1 ] ) ) $ y = $ css [ 1 ] ; else if ( $ this -> convertToMM ( $ css [ 1 ] ) ) $ y = $ this -> convertToMM ( $ css [ 1 ] ) ; else $ res = false ; // return the values return array ( $ x , $ y ) ; }
parse a background position

@access public
@param  string $css
@param  &boolean $res flag if conver is ok or not
@return array ($x, $y)
parse a background position