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
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SIWECOS
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cContentTypePifaForm
  • DefaultFormModule
  • DefaultFormProcessor
  • ExampleOptionsDatasource
  • MailedFormProcessor
  • Pifa
  • PifaAbstractFormModule
  • PifaAbstractFormProcessor
  • PifaAjaxHandler
  • PifaExporter
  • PifaExternalOptionsDatasourceInterface
  • PifaField
  • PifaFieldCollection
  • PifaForm
  • PifaFormCollection
  • PifaImporter
  • PifaLeftBottomPage
  • PifaRightBottomFormDataPage
  • PifaRightBottomFormExportPage
  • PifaRightBottomFormFieldsPage
  • PifaRightBottomFormImportPage
  • PifaRightBottomFormPage

Exceptions

  • PifaDatabaseException
  • PifaException
  • PifaIllegalStateException
  • PifaMailException
  • PifaNotImplementedException
  • PifaNotYetStoredException
  • PifaValidationException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the PifaAbstractFormModule class.
  5:  *
  6:  * @package Plugin
  7:  * @subpackage FormAssistant
  8:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
  9:  * @copyright four for business AG
 10:  * @link http://www.4fb.de
 11:  */
 12: 
 13: // assert CONTENIDO framework
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * Abstract base class for all classes that are used as PIFA form module.
 18:  *
 19:  * In order for an extension class to be displayed in the CMS_PIFAFORM's editor
 20:  * as module class it has to extend this class and implement its abstract
 21:  * methods doGet() & doPost().
 22:  *
 23:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
 24:  */
 25: abstract class PifaAbstractFormModule {
 26: 
 27:     /**
 28:      * The HTTP GET request method.
 29:      *
 30:      * @var string
 31:      */
 32:     const GET = 'GET';
 33: 
 34:     /**
 35:      * The HTTP POST request method.
 36:      *
 37:      * @var string
 38:      */
 39:     const POST = 'POST';
 40: 
 41:     /**
 42:      * Array of settings as defined for a content type CMS_PIFAFORM.
 43:      *
 44:      * @var array
 45:      */
 46:     protected $_settings = array();
 47: 
 48:     /**
 49:      * The unique ID of the form to be displayed and processed by this module.
 50:      * This ID is read from the given settings (pifaform_idform).
 51:      *
 52:      * @var int
 53:      */
 54:     private $_idform = 0;
 55: 
 56:     /**
 57:      * The current template name to be used when displaying the form.
 58:      * This name usually depends upon the request method to be used.
 59:      * These names are read from the given settings.
 60:      *
 61:      * @var string
 62:      */
 63:     private $_templateName = '';
 64: 
 65:     /**
 66:      * @var cSmartyWrapper
 67:      */
 68:     private $_tpl = NULL;
 69: 
 70:     /**
 71:      * @param array $settings as defined for cContentTypePifaForm
 72:      *
 73:      * @throws cException
 74:      */
 75:     public function __construct(array $settings = NULL) {
 76:         $this->_settings = $settings;
 77:         $this->_idform = cSecurity::toInteger($this->_settings['pifaform_idform']);
 78:         $this->_tpl = cSmartyFrontend::getInstance(true);
 79:     }
 80: 
 81:     /**
 82:      * @return array
 83:      */
 84:     public function getSettings() {
 85:         return $this->_settings;
 86:     }
 87: 
 88:     /**
 89:      * @param string $key
 90:      * @return mixed
 91:      */
 92:     public function getSetting($key) {
 93:         return $this->_settings[$key];
 94:     }
 95: 
 96:     /**
 97:      * @param array $_settings
 98:      */
 99:     public function setSettings(array $_settings) {
100:         $this->_settings = $_settings;
101:     }
102: 
103:     /**
104:      * @return int
105:      */
106:     public function getIdform() {
107:         return $this->_idform;
108:     }
109: 
110:     /**
111:      * @param int $_idform
112:      */
113:     public function setIdform($_idform) {
114:         $this->_idform = $_idform;
115:     }
116: 
117:     /**
118:      * @return string
119:      */
120:     public function getTemplateName() {
121:         return $this->_templateName;
122:     }
123: 
124:     /**
125:      * @param string $_templateName
126:      */
127:     public function setTemplateName($_templateName) {
128:         $this->_templateName = $_templateName;
129:     }
130: 
131:     /**
132:      * @return cSmartyWrapper
133:      */
134:     public function getTpl() {
135:         return $this->_tpl;
136:     }
137: 
138:     /**
139:      * @param cSmartyWrapper $_tpl
140:      */
141:     public function setTpl(cSmartyWrapper $_tpl) {
142:         $this->_tpl = $_tpl;
143:     }
144: 
145:     /**
146:      * Helper method to determine the current request method.
147:      * The request method is returned as uppercase string.
148:      *
149:      * @return string
150:      */
151:     protected function _getRequestMethod() {
152:         $requestMethod = $_SERVER['REQUEST_METHOD'];
153:         $requestMethod = cString::toUpperCase($requestMethod);
154: 
155:         return $requestMethod;
156:     }
157: 
158:     /**
159:      * @param bool $return
160:      *
161:      * @return mixed|string
162:      *
163:      * @throws PifaException if request method is unknown
164:      */
165:     public function render($return = false) {
166: 
167:         // dispatch request method
168:         switch ($this->_getRequestMethod()) {
169:             case self::GET:
170: 
171:                 $this->doGet();
172:                 break;
173: 
174:             case self::POST:
175: 
176:                 // always handle POST method in backend edit mode as GET action
177:                 if (cRegistry::isBackendEditMode()) {
178:                     $this->doGet();
179:                     break;
180:                 }
181: 
182:                 // execute POST only if current form has been submitted
183:                 // and just GET form if POST has another reason (other form etc.)
184:                 if (isset($_POST['idform']) && $_POST['idform'] != $this->getSetting('pifaform_idform')) {
185:                     $this->doGet();
186:                     break;
187:                 }
188: 
189:                 // handle form as if it were posted
190:                 $this->doPost();
191:                 break;
192: 
193:             default:
194:                 $msg = Pifa::i18n('UNKNOWN_REQUEST_METHOD');
195:                 throw new PifaException($msg);
196:         }
197: 
198:         // fetch || display template
199:         $clientConfig = cRegistry::getClientConfig(cRegistry::getClientId());
200:         $path = $clientConfig['template']['path'];
201:         if (true === $return) {
202:             return $this->_tpl->fetch($path . $this->getTemplateName());
203:         } else {
204:             $this->_tpl->display($path . $this->getTemplateName());
205:         }
206:     }
207: 
208:     /**
209:      * Handle GET request.
210:      *
211:      * @param array $values
212:      * @param array $errors
213:      */
214:     abstract protected function doGet(array $values = array(), array $errors = array());
215: 
216:     /**
217:      * Handle POST request.
218:      */
219:     abstract protected function doPost();
220: }
221: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0