Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: 
  3: /**
  4:  *
  5:  * @package Plugin
  6:  * @subpackage FormAssistant
  7:  * @version SVN Revision $Rev:$
  8:  * @author marcus.gnass
  9:  * @copyright four for business AG
 10:  * @link http://www.4fb.de
 11:  */
 12: 
 13: /**
 14:  * This class is the default implementation for PIFA form modules.
 15:  * On a GET request it displays a form. On a POST request the posted data is
 16:  * processed. If an error occurs the form is displayed again only that now all
 17:  * valid data is displayed in the form and error messages (if defined) are
 18:  * displayed for all invalid form fields.
 19:  *
 20:  * @author marcus.gnass
 21:  */
 22: class DefaultFormModule extends PifaAbstractFormModule {
 23: 
 24:     /**
 25:      * Handle GET request.
 26:      *
 27:      * @param array $values to be displayed in form
 28:      * @param array $errors to be displayed in form
 29:      * @throws Exception if form could not be loaded
 30:      * @see PifaAbstractFormModule::doGet()
 31:      */
 32:     protected function doGet(array $values = array(), array $errors = array()) {
 33: 
 34:         // set template to use
 35:         $this->setTemplateName($this->getSetting('pifaform_template_get'));
 36: 
 37:         // create and load form
 38:         $pifaForm = new PifaForm($this->getIdform());
 39: 
 40:         // catch error
 41:         if (true !== $pifaForm->isLoaded()) {
 42:             $msg = Pifa::i18n('FORM_LOAD_ERROR');
 43:             throw new PifaException($msg);
 44:         }
 45: 
 46:         // set values (keep default values if NULL!)
 47:         $pifaForm->setValues($values);
 48: 
 49:         // set errors
 50:         $pifaForm->setErrors($errors);
 51: 
 52:         $actionPath = cUri::getInstance()->build(array(
 53:             'idart' => cRegistry::getArticleId(),
 54:             'lang' => cRegistry::getLanguageId()
 55:         ), true);
 56: 
 57:         if (Pifa::isHttps()) {
 58:             $actionPath = str_replace('http://', 'https://', $actionPath);
 59:         }
 60: 
 61:         // assign rendered form
 62:         $this->getTpl()->assign('form', $pifaForm->toHtml(array(
 63:             'action' => $actionPath
 64:         )));
 65:     }
 66: 
 67:     /**
 68:      * Handle POST request.
 69:      *
 70:      * @see PifaAbstractFormModule::doPost()
 71:      */
 72:     protected function doPost() {
 73: 
 74:         // set template to use
 75:         $this->setTemplateName($this->getSetting('pifaform_template_post'));
 76: 
 77:         try {
 78: 
 79:             // get name of processor class
 80:             $processorClass = $this->getSetting('pifaform_processor');
 81: 
 82:             // get name of file in which processor class could be found
 83:             $filename = Pifa::fromCamelCase($processorClass);
 84:             $filename = "extensions/class.pifa.$filename.php";
 85:             if (false === file_exists(Pifa::getPath() . $filename)) {
 86:                 $msg = Pifa::i18n('MISSING_PROCESSOR_FILE');
 87:                 $msg = sprintf($msg, $filename);
 88:                 throw new PifaException($msg);
 89:             }
 90:             plugin_include(Pifa::getName(), $filename);
 91:             if (false === class_exists($processorClass)) {
 92:                 $msg = Pifa::i18n('MISSING_PROCESSOR_CLASS');
 93:                 $msg = sprintf($msg, $processorClass);
 94:                 throw new PifaException($msg);
 95:             }
 96: 
 97:             // create processor instance
 98:             // pass module in order to access its settings
 99:             // processorClass is subclass of PifaAbstractFormProcessor
100:             $postProcessor = new $processorClass($this);
101:             $postProcessor->process();
102: 
103:             // assign reply to post template
104:             $this->getTpl()->assign('reply', array(
105:                 'headline' => mi18n("REPLY_HEADLINE"),
106:                 'text' => mi18n("REPLY_TEXT")
107:             ));
108:         } catch (PifaValidationException $e) {
109: 
110:             // display form with valid values again
111:             $this->doGet($postProcessor->getForm()->getValues(), $e->getErrors());
112: 
113:             // store validation state as (global) application so another module
114:             // can show a reply text but when validation is successfull
115:             cRegistry::setAppVar('pifaFormValidity', 'invalid');
116:         } catch (PifaException $e) {
117:             // display form with valid values again
118:             $this->doGet($postProcessor->getForm()->getValues());
119: 
120:             Pifa::displayException($e);
121:         } catch (Exception $e) {
122: 
123:             Pifa::logException($e);
124:             Pifa::displayException($e);
125:         }
126:     }
127: }
128: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen