Public Member Functions | Protected Attributes

Robo47_Controller_Plugin_Tidy Class Reference

List of all members.

Public Member Functions

 __construct (Robo47_Filter_Tidy $tidyFilter=null, Zend_Log $log=null, $logPriority=Zend_Log::INFO, $logCategory= 'tidy')
 dispatchLoopShutdown ()
 getLog ()
 Get Log.
 getLogCategory ()
 Get Log Category.
 getLogPriority ()
 Get Log Category.
 getTidyFilter ()
 Get Tidy Filter.
 isHtmlResponse (Zend_Controller_Response_Abstract $response)
 Is a Html Response.
 setLog (Zend_Log $log=null)
 Set Log.
 setLogCategory ($logCategory)
 Set Log Category.
 setLogPriority ($logPriority)
 Set Log Category.
 setTidyFilter (Robo47_Filter_Tidy $tidyFilter=null)
 Set Tidy Filter.

Protected Attributes

 $_tidyFilter = null

Detailed Description

Definition at line 34 of file Tidy.php.


Constructor & Destructor Documentation

Robo47_Controller_Plugin_Tidy::__construct ( Robo47_Filter_Tidy tidyFilter = null,
Zend_Log $  log = null,
logPriority = Zend_Log::INFO,
logCategory = 'tidy' 
)
Parameters:
Robo47_Filter_Tidy $tidyFilter
Zend_Log $log
integer $logPriority
string $logCategory

Definition at line 51 of file Tidy.php.

References setLog(), setLogCategory(), setLogPriority(), and setTidyFilter().

    {
        $this->setTidyFilter($tidyFilter);
        $this->setLog($log);
        $this->setLogPriority($logPriority);
        $this->setLogCategory($logCategory);
    }

Here is the call graph for this function:


Member Function Documentation

Robo47_Controller_Plugin_Tidy::dispatchLoopShutdown (  ) 

Definition at line 184 of file Tidy.php.

References getLogCategory(), getTidyFilter(), and isHtmlResponse().

    {
        $response = $this->getResponse();
        // only tidy content recognized als text/html
        if ($this->isHtmlResponse($response)) {
            $tidyFilter = $this->getTidyFilter();
            // filter body and set it as new body again
            $response->setBody($tidyFilter->filter($response->getBody()));
            if (null !== $this->_log) {
                $tidy = $tidyFilter->getTidy();
                $tidy->diagnose();
                // log only if errors / warnings found
                $pos = strpos(
                    $tidy->errorBuffer,
                    'No warnings or errors were found'
                );
                if (false === $pos) {
                    $this->_log->log(
                        'Url: ' . $this->getRequest()->getRequestUri() .
                        PHP_EOL . $tidy->errorBuffer,
                        $this->getLogPriority(),
                        array('category' => $this->getLogCategory())
                    );
                }
            }
        }
    }

Here is the call graph for this function:

Robo47_Controller_Plugin_Tidy::getLog (  ) 

Get Log.

Returns:
Robo47_Log

Definition at line 104 of file Tidy.php.

    {
        return $this->_log;
    }

Robo47_Controller_Plugin_Tidy::getLogCategory (  ) 

Get Log Category.

Returns:
string

Definition at line 126 of file Tidy.php.

Referenced by dispatchLoopShutdown().

    {
        return $this->_logCategory;
    }

Here is the caller graph for this function:

Robo47_Controller_Plugin_Tidy::getLogPriority (  ) 

Get Log Category.

Returns:
integer

Definition at line 148 of file Tidy.php.

    {
        return $this->_logPriority;
    }

Robo47_Controller_Plugin_Tidy::getTidyFilter (  ) 

Get Tidy Filter.

Returns:
Robo47_Filter_Tidy

Definition at line 82 of file Tidy.php.

Referenced by dispatchLoopShutdown().

    {
        return $this->_tidyFilter;
    }

Here is the caller graph for this function:

Robo47_Controller_Plugin_Tidy::isHtmlResponse ( Zend_Controller_Response_Abstract $  response  ) 

Is a Html Response.

Checks if it finds a Content-Type-header with the value text/html

Parameters:
Zend_Controller_Response_Abstract $response
Returns:
bool

Definition at line 161 of file Tidy.php.

Referenced by dispatchLoopShutdown().

    {
        foreach ($response->getHeaders() as $value) {
            if ('content-type' == trim(strtolower($value['name'])) &&
                false !== strpos(strtolower($value['value']), 'text/html')) {
                return true;
            }

        }

        foreach ($response->getRawHeaders() as $value) {
            $regex = preg_quote('content-type: text/html', '/');
            if (preg_match('/' . $regex . '/i', $value)) {
                return true;
            }
        }

        return false;
    }

Here is the caller graph for this function:

Robo47_Controller_Plugin_Tidy::setLog ( Zend_Log $  log = null  ) 

Set Log.

Parameters:
Zend_Log $log
Returns:
Robo47_Controller_Plugin_Tidy *Provides Fluent Interface*

Definition at line 93 of file Tidy.php.

Referenced by __construct().

    {
        $this->_log = $log;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Controller_Plugin_Tidy::setLogCategory ( logCategory  ) 

Set Log Category.

Parameters:
string $category
Returns:
Robo47_Controller_Plugin_Tidy *Provides Fluent Interface*

Definition at line 115 of file Tidy.php.

Referenced by __construct().

    {
        $this->_logCategory = $logCategory;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Controller_Plugin_Tidy::setLogPriority ( logPriority  ) 

Set Log Category.

Parameters:
integer $logPriority
Returns:
Robo47_Controller_Plugin_Tidy *Provides Fluent Interface*

Definition at line 137 of file Tidy.php.

Referenced by __construct().

    {
        $this->_logPriority = (int) $logPriority;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Controller_Plugin_Tidy::setTidyFilter ( Robo47_Filter_Tidy tidyFilter = null  ) 

Set Tidy Filter.

Parameters:
Robo47_Filter_Tidy $tidyFilter
Returns:
Robo47_Controller_Plugin_Tidy *Provides Fluent Interface*

Definition at line 68 of file Tidy.php.

Referenced by __construct().

    {
        if (null === $tidyFilter) {
            $tidyFilter = new Robo47_Filter_Tidy();
        }
        $this->_tidyFilter = $tidyFilter;
        return $this;
    }

Here is the caller graph for this function:


Member Data Documentation

Robo47_Controller_Plugin_Tidy::$_tidyFilter = null [protected]

Definition at line 42 of file Tidy.php.


The documentation for this class was generated from the following file: