Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • 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

Classes

  • cContentTypePifaForm
  • DefaultFormModule
  • DefaultFormProcessor
  • ExampleOptionsDatasource
  • MailedFormProcessor
  • Pifa
  • PifaAbstractFormModule
  • PifaAbstractFormProcessor
  • PifaAjaxHandler
  • PifaExternalOptionsDatasourceInterface
  • PifaField
  • PifaFieldCollection
  • PifaForm
  • PifaFormCollection
  • PifaLeftBottomPage
  • PifaRightBottomFormDataPage
  • PifaRightBottomFormFieldsPage
  • PifaRightBottomFormPage
  • SolrRightBottomPage

Exceptions

  • PifaDatabaseException
  • PifaException
  • PifaIllegalStateException
  • PifaMailException
  • PifaNotImplementedException
  • PifaNotYetStoredException
  • PifaValidationException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  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:  *
 15:  * @author marcus.gnass
 16:  */
 17: class DefaultFormModule extends PifaAbstractFormModule {
 18: 
 19:     /**
 20:      *
 21:      * @param array $values
 22:      * @param array $errors TODO not yet implemented
 23:      * @throws Exception if form could not be loaded
 24:      */
 25:     protected function doGet(array $values = array(), array $errors = array()) {
 26: 
 27:         // set template to use
 28:         $this->setTemplateName($this->getSetting('pifaform_template_get'));
 29: 
 30:         // create and load form
 31:         $pifaForm = new PifaForm($this->getIdform());
 32: 
 33:         // catch error
 34:         if (true !== $pifaForm->isLoaded()) {
 35:             $msg = Pifa::i18n('FORM_LOAD_ERROR');
 36:             throw new PifaException($msg);
 37:         }
 38: 
 39:         // set values (keep default values if NULL!)
 40:         $pifaForm->setValues($values);
 41: 
 42:         // set errors
 43:         $pifaForm->setErrors($errors);
 44: 
 45:         $actionPath = cUri::getInstance()->build(array(
 46:             'idart' => cRegistry::getArticleId(),
 47:             'lang' => cRegistry::getLanguageId()
 48:         ), true);
 49: 
 50:         if (Pifa::isHttps()) {
 51:             $actionPath = str_replace('http://', 'https://', $actionPath);
 52:         }
 53: 
 54:         // assign rendered form
 55:         $this->getTpl()->assign('form', $pifaForm->toHtml(array(
 56:             'action' => $actionPath
 57:         )));
 58:     }
 59: 
 60:     /**
 61:      *
 62:      * @see PifaAbstractFormModule::doPost()
 63:      */
 64:     protected function doPost() {
 65: 
 66:         // set template to use
 67:         $this->setTemplateName($this->getSetting('pifaform_template_post'));
 68: 
 69:         try {
 70: 
 71:             // get name of processor class
 72:             $processorClass = $this->getSetting('pifaform_processor');
 73: 
 74:             // get name of file in which processor class could be found
 75:             $filename = Pifa::fromCamelCase($processorClass);
 76:             $filename = "extensions/class.pifa.$filename.php";
 77:             if (false === file_exists(Pifa::getPath() . $filename)) {
 78:                 $msg = Pifa::i18n('MISSING_PROCESSOR_FILE');
 79:                 $msg = sprintf($msg, $filename);
 80:                 throw new PifaException($msg);
 81:             }
 82:             plugin_include(Pifa::getName(), $filename);
 83:             if (false === class_exists($processorClass)) {
 84:                 $msg = Pifa::i18n('MISSING_PROCESSOR_CLASS');
 85:                 $msg = sprintf($msg, $processorClass);
 86:                 throw new PifaException($msg);
 87:             }
 88: 
 89:             // create processor instance
 90:             // pass module in order to access its settings
 91:             // processorClass is subclass of PifaAbstractFormProcessor
 92:             $postProcessor = new $processorClass($this);
 93:             $postProcessor->process();
 94: 
 95:             // assign reply to post template
 96:             $this->getTpl()->assign('reply', array(
 97:                 'headline' => mi18n("REPLY_HEADLINE"),
 98:                 'text' => mi18n("REPLY_TEXT")
 99:             ));
100:         } catch (PifaValidationException $e) {
101: 
102:             // display form with valid values again
103:             $this->doGet($postProcessor->getForm()->getValues(), $e->getErrors());
104: 
105:             // store validation state as (global) application so another module
106:             // can show a reply text but when validation is successfull
107:             cRegistry::setAppVar('pifaFormValidity', 'invalid');
108:         } catch (Exception $e) {
109: 
110:             Pifa::logException($e);
111:             Pifa::displayException($e);
112:         }
113:     }
114: }
115: 
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0