Perforce Chronicle 2012.2/486814
API Documentation

Flickr_ConfigureController Class Reference

Handles configuration of the flickr module. More...

List of all members.

Public Member Functions

 indexAction ()
 Show form, persist into module config (fetch module, set config)

Detailed Description

Handles configuration of the flickr module.

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

Flickr_ConfigureController::indexAction ( )

Show form, persist into module config (fetch module, set config)

    {
        $module = P4Cms_Module::fetch('Flickr');

        $form = new Flickr_Form_Configure();
        $this->view->form = $form;

        // if request, save; if error, show; if not, show form
        $request = $this->getRequest();
        if ($request->isPost()) {
            $unvalidatedValues = $request->getPost();

            if ($form->isValid($unvalidatedValues)) {
                $values = $form->getValues();
                // save configuration
                $module->saveConfig(
                    new Zend_Config(
                        array(
                            'key'       => $values['key']
                        )
                    )
                );

                // store stuff, redirect
                P4Cms_Notifications::add('Flickr API configuration stored.');
                $this->redirector->gotoSimple('index', 'module', 'site');
            } else {
                P4Cms_Notifications::add(
                    'Invalid value entered for Flickr module configuration.',
                    'error'
                );
                $form->populate($unvalidatedValues);
            }
        } else {
            $config = $module->getConfig();
            $values = $config->toArray();

            $form->populate(
                array(
                    'key' => isset($values['key']) ? $values['key'] : ''
                )
            );
        }
    }

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