code/dispatcher/request/abstract.php
public function getFormat($mediatype = false)
    {
        if (!isset($this->_format))
        {
            if(!$this->query->has('format'))
            {
                $format = pathinfo($this->getUrl()->getPath(), PATHINFO_EXTENSION);

                if(empty($format) || !isset(static::$_formats[$format]))
                {
                    $format = 'html'; //define html default

                    if ($this->_headers->has('Accept'))
                    {
                        $accept  = $this->_headers->get('Accept');
                        $formats = $this->__parseAccept($accept);

                        /**
                         * If the browser is requested text/html serve it at all times
                         *
                         * @hotfix #409 : Android 2.3 requesting application/xml
                         */
                        if (!isset($formats['text/html']))
                        {
                            //Get the highest quality format
                            $mime_type = key($formats);

                            foreach (static::$_formats as $value => $mime_types)
                            {
                                if (in_array($mime_type, (array)$mime_types)) {
                                    $format = $value;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else $format = $this->query->get('format', 'word');

            $this->setFormat($format);
        }

        return $mediatype ? static::$_formats[$this->_format][0] : $this->_format;
    }
public function getFormat($mediatype = false)
    {
        if (!isset($this->_format))
        {
            if(!$this->query->has('format'))
            {
                $format = pathinfo($this->getUrl()->getPath(), PATHINFO_EXTENSION);

                if(empty($format) || !isset(static::$_formats[$format]))
                {
                    $format = 'html'; //define html default

                    if ($this->_headers->has('Accept'))
                    {
                        $accept  = $this->_headers->get('Accept');
                        $formats = $this->__parseAccept($accept);

                        /**
                         * If the browser is requested text/html serve it at all times
                         *
                         * @hotfix #409 : Android 2.3 requesting application/xml
                         */
                        if (!isset($formats['text/html']))
                        {
                            //Get the highest quality format
                            $mime_type = key($formats);

                            foreach (static::$_formats as $value => $mime_types)
                            {
                                if (in_array($mime_type, (array)$mime_types)) {
                                    $format = $value;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else $format = $this->query->get('format', 'word');

            $this->setFormat($format);
        }

        return $mediatype ? static::$_formats[$this->_format][0] : $this->_format;
    }
public function getFormat ( $ mediatype = false ) { if ( ! isset ( $ this -> _format ) ) { if ( ! $ this -> query -> has ( 'format' ) ) { $ format = pathinfo ( $ this -> getUrl ( ) -> getPath ( ) , PATHINFO_EXTENSION ) ; if ( empty ( $ format ) || ! isset ( static :: $ _formats [ $ format ] ) ) { $ format = 'html' ; //define html default if ( $ this -> _headers -> has ( 'Accept' ) ) { $ accept = $ this -> _headers -> get ( 'Accept' ) ; $ formats = $ this -> __parseAccept ( $ accept ) ; /**
                         * If the browser is requested text/html serve it at all times
                         *
                         * @hotfix #409 : Android 2.3 requesting application/xml
                         */ if ( ! isset ( $ formats [ 'text/html' ] ) ) { //Get the highest quality format $ mime_type = key ( $ formats ) ; foreach ( static :: $ _formats as $ value => $ mime_types ) { if ( in_array ( $ mime_type , ( array ) $ mime_types ) ) { $ format = $ value ; break ; } } } } } } else $ format = $ this -> query -> get ( 'format' , 'word' ) ; $ this -> setFormat ( $ format ) ; } return $ mediatype ? static :: $ _formats [ $ this -> _format ] [ 0 ] : $ this -> _format ; }
Return the request format or mediatype

Find the format by using following sequence :

1. Use the the 'format' request parameter
2. Use the URL path extension
3. Use the accept header with the highest quality apply the reverse format map to find the format.

@param   bool    $mediatype Get the media type
@return  string  The request format or NULL if no format could be found
Return the request format or mediatype