Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_Form_Element_Captcha Class Reference

Extends Zend_Form_Element_Captcha. More...

List of all members.

Public Member Functions

 render (Zend_View_Interface $view=null)
 Extends render to cancel caching and ignore any new session variables.

Detailed Description

Extends Zend_Form_Element_Captcha.

Our version extends the render method to abort page caching and attempts to ignore any new sessions variables to protect future requests.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

P4Cms_Form_Element_Captcha::render ( Zend_View_Interface $  view = null)

Extends render to cancel caching and ignore any new session variables.

Parameters:
Zend_View_Interface$viewthe view we are rendering under
Returns:
string the result
    {
        // simply return parent if no page cache is in use
        if (!P4Cms_Cache::canCache('page')) {
            return parent::render($view);
        }

        // we have a page cache; determine starting values
        // and cancel the caching of this request
        $existing = array_keys($_SESSION);
        $cache    = P4Cms_Cache::getCache('page');
        $cache->cancel();

        // let parent do the rendering and add any session variables
        $value = parent::render($view);

        // detect any new session variables and ignore them
        $added = array_diff(array_keys($_SESSION), $existing);
        foreach ($added as $ignored) {
            $cache->addIgnoredSessionVariable($ignored);
        }

        return $value;
    }

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