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 cContentTypePifaForm 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: cInclude('includes', 'functions.con.php');
 17: cInclude('includes', 'functions.upl.php');
 18: 
 19: /**
 20:  * Content type CMS_PIFAFORM which lets the editor configure a PIFA form to be
 21:  * displayed in frontend.
 22:  *
 23:  * This content type offers several choices:
 24:  * - select a form of those created in the PIFA backend for the current client
 25:  * - select a module class located in plugins/form_assistant/extensions
 26:  * - select a processor class located in plugins/form_assistant/extensions
 27:  * - DOCME several client & system mail settings
 28:  */
 29: class cContentTypePifaForm extends cContentTypeAbstractTabbed {
 30: 
 31:     /**
 32:      * Callback function that is capable of sorting items that are arrays by
 33:      * comparing their value for the key 'label'.
 34:      *
 35:      * @param array $a
 36:      * @param array $b
 37:      * @return number as expected for a comparision function used for sorting
 38:      */
 39:     public static function sortByLabel($a, $b) {
 40:         return ($a['label'] == $b['label']) ? 0 : (($a['label'] < $b['label']) ? -1 : 1);
 41:     }
 42: 
 43:     /**
 44:      * Initialize class attributes and handles store events.
 45:      *
 46:      * @param string $rawSettings  the raw settings in an XML structure or as plaintext
 47:      * @param int    $id           ID of the content type, e.g. 3 if CMS_DATE[3] is used
 48:      * @param array  $contentTypes array containing the values of all content types
 49:      *
 50:      * @throws cDbException
 51:      */
 52:     function __construct($rawSettings, $id, array $contentTypes) {
 53: 
 54:         // set attributes of the parent class and call the parent constructor
 55:         $this->_type = 'CMS_PIFAFORM';
 56:         $this->_prefix = 'pifaform';
 57:         $this->_settingsType = self::SETTINGS_TYPE_XML;
 58:         $this->_formFields = array(
 59:             'pifaform_headline',
 60:             'pifaform_idform',
 61:             'pifaform_module',
 62:             'pifaform_processor',
 63:             'pifaform_template_get',
 64:             'pifaform_template_post',
 65:             'pifaform_mail_client_template',
 66:             'pifaform_mail_client_from_email',
 67:             'pifaform_mail_client_from_name',
 68:             'pifaform_mail_client_subject',
 69:             'pifaform_mail_system_template',
 70:             'pifaform_mail_system_from_email',
 71:             'pifaform_mail_system_from_name',
 72:             'pifaform_mail_system_recipient_email',
 73:             'pifaform_mail_system_subject'
 74:         );
 75: 
 76:         parent::__construct($rawSettings, $id, $contentTypes);
 77: 
 78:         // if form is submitted, store the current settings
 79:         // notice: also check the ID of the content type (there could be more
 80:         // than one content type of the same type on the same page!)
 81:         $action = isset($_POST['pifaform_action']) ? $_POST['pifaform_action'] : NULL;
 82:         $id = isset($_POST['pifaform_id']) ? $_POST['pifaform_id'] : NULL;
 83:         if ('store' === $action && $this->_id == $id) {
 84:             $this->_storeSettings();
 85:         }
 86:     }
 87: 
 88:     /**
 89:      * Generate the escaped HTML code for editor.
 90:      *
 91:      * @return string escaped HTML code for editor
 92:      *
 93:      * @throws cInvalidArgumentException
 94:      */
 95:     public function generateEditCode() {
 96: 
 97:         // build top code
 98:         $tplTop = new cTemplate();
 99:         $tplTop->set('s', 'ICON', 'plugins/form_assistant/images/icon_form.png');
100:         $tplTop->set('s', 'ID', $this->_id);
101:         $tplTop->set('s', 'PREFIX', $this->_prefix);
102:         $tplTop->set('s', 'HEADLINE', Pifa::i18n('form'));
103:         $codeTop = $tplTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
104: 
105:         // available tabs
106:         $tabMenu = array(
107:             'base' => Pifa::i18n('form')
108:         );
109: 
110:         // build tab code
111:         $tplPanel = new cTemplate();
112:         $tplPanel->set('s', 'PREFIX', $this->_prefix);
113:         $tplPanel->set('d', 'TAB_ID', 'base');
114:         $tplPanel->set('d', 'TAB_CLASS', 'base');
115:         $tplPanel->set('d', 'TAB_CONTENT', $this->_getPanel());
116:         $tplPanel->next();
117:         $codePanel = $tplPanel->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
118: 
119:         // build bottom code
120:         $tplBottom = new cTemplate();
121:         $tplBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
122:         $tplBottom->set('s', 'ID', $this->_id);
123:         $tplBottom->set('s', 'PREFIX', $this->_prefix);
124:         $tplBottom->set('s', 'IDARTLANG', $this->_idArtLang);
125:         $tplBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
126:         // encode dollar sign so that contained PHP style variable will not be interpreted
127:         $tplBottom->set('s', 'SETTINGS', json_encode(str_replace('$', '&#36;', $this->_settings)));
128:         $tplBottom->set('s', 'JS_CLASS_SCRIPT', Pifa::getUrl() . 'scripts/cmsPifaform.js');
129:         $tplBottom->set('s', 'JS_CLASS_NAME', 'Con.' . get_class($this));
130: 
131:         $codeBottom = $tplBottom->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_bottom.html', true);
132: 
133:         // build template code
134:         $code = $this->_encodeForOutput($codeTop);
135:         // $code .= $this->_generateTabMenuCode($tabMenu);
136:         $code .= $this->_encodeForOutput($codePanel);
137:         $code .= $this->_generateActionCode();
138:         $code .= $this->_encodeForOutput($codeBottom);
139:         $code .= $this->generateViewCode();
140: 
141:         return $code;
142:     }
143: 
144:     /**
145:      * Generates code for the base panel in which all data can be specified.
146:      *
147:      * @return string - the code for the base panel
148:      */
149:     private function _getPanel() {
150:         $wrapper = new cHTMLDiv(array(
151: 
152:             // headline
153:             $this->_getHeadline(),
154:             // form
155:             $this->_getSelectForm(),
156: 
157:             // module & processor class and GET & POST templates
158:             new cHTMLFieldset(array(
159:                 new cHTMLLegend(Pifa::i18n('classes & templates')),
160:                 $this->_getSelectModule(),
161:                 $this->_getSelectProcessor(),
162:                 $this->_getSelectTemplateGet(),
163:                 $this->_getSelectTemplatePost()
164:             )),
165: 
166:             // client mail settings
167:             new cHTMLFieldset(array(
168:                 new cHTMLLegend(Pifa::i18n('client mail')),
169:                 $this->_getSelectMailClientTemplate(),
170:                 $this->_getInputMailClientFromEmail(),
171:                 $this->_getInputMailClientFromName(),
172:                 $this->_getInputMailClientSubject()
173:             )),
174: 
175:             // system mail settings
176:             new cHTMLFieldset(array(
177:                 new cHTMLLegend(Pifa::i18n('system mail')),
178:                 $this->_getSelectMailSystemTemplate(),
179:                 $this->_getInputMailSystemFromEmail(),
180:                 $this->_getInputMailSystemFromName(),
181:                 $this->_getInputMailSystemRecipientEmail(),
182:                 $this->_getInputMailSystemSubject()
183:             ))
184:         ), $this->_prefix . '_panel_base', $this->_prefix . '_panel_base_' . $this->_id);
185:         $wrapper->setStyle('clear:both');
186: 
187:         return $wrapper->render();
188:     }
189: 
190:     /**
191:      * Builds a select element allowing to choose a single form that was created
192:      * for the current client.
193:      *
194:      * @return cHTMLDiv|cHTMLFormElement
195:      */
196:     private function _getSelectForm() {
197: 
198:         // attributes of form field elements
199:         $id = 'pifaform_idform_' . $this->_id;
200: 
201:         // build label element
202:         $label = new cHTMLLabel(Pifa::i18n('form'), $id);
203: 
204:         // build select element
205:         $select = new cHTMLSelectElement($id, '', $id);
206:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
207: 
208:         // get all forms of current client & language
209:         $idclient = cRegistry::getClientId();
210:         $idlang = cRegistry::getLanguageId();
211:         $forms = PifaFormCollection::getByClientAndLang($idclient, $idlang);
212:         if (false === $forms) {
213:             return $select;
214:         }
215: 
216:         // loop all forms
217:         while (false !== $form = $forms->next()) {
218: 
219:             // attributes of option element
220:             $title = $form->get('name');
221:             $value = $form->get('idform');
222:             $selected = $form->get('idform') == $this->_settings['pifaform_idform'];
223: 
224:             // build option element
225:             $option = new cHTMLOptionElement($title, $value, $selected);
226: 
227:             // append option element to select element
228:             $select->addOptionElement(++$index, $option);
229:         }
230: 
231:         // build div element as wrapper
232:         $div = new cHTMLDiv(array(
233:             $label,
234:             $select
235:         ));
236: 
237:         // return div element
238:         return $div;
239:     }
240: 
241:     /**
242:      * Builds input field for the form headline
243:      *
244:      * @return cHTMLDiv
245:      */
246:     private function _getHeadline() {
247:         // attributes of form field elements
248:         $id = 'pifaform_idform_' . $this->_id;
249: 
250:         // build label element
251:         $label = new cHTMLLabel(Pifa::i18n('form_headline'), $id);
252:         // builds input element
253:         $id = 'pifaform_headline_' . $this->_id;
254:         $value = $this->_settings['pifaform_headline'];
255:         $input = new cHTMLTextbox($id, $value, '', '', $id);
256: 
257:         // build div element as wrapper
258:         $div = new cHTMLDiv(array(
259:             $label,
260:             $input
261:         ));
262: 
263:         // return div element
264:         return $div;
265:     }
266: 
267:     /**
268:      * Builds a select element allowing to choose a single module that handles
269:      * the chosen form.
270:      *
271:      * @return cHTMLDiv
272:      */
273:     private function _getSelectModule() {
274: 
275:         // attributes of form field elements
276:         $id = 'pifaform_module_' . $this->_id;
277: 
278:         // build label element
279:         $label = new cHTMLLabel(Pifa::i18n('module'), $id);
280: 
281:         // build select element
282:         $select = new cHTMLSelectElement($id, '', $id);
283:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
284: 
285:         // get all modules from extensions & validate result
286:         $modules = Pifa::getExtensionClasses('PifaAbstractFormModule');
287: 
288:         // sort modules by their label
289:         usort($modules, 'cContentTypePifaForm::sortByLabel');
290: 
291:         // loop all forms
292:         foreach ($modules as $module) {
293: 
294:             // attributes of option element
295:             $title = $module['label'];
296:             $value = $module['value'];
297:             $selected = $module['value'] == $this->_settings['pifaform_module'];
298: 
299:             // build option element
300:             $option = new cHTMLOptionElement($title, $value, $selected);
301: 
302:             // append option element to select element
303:             $select->addOptionElement(++$index, $option);
304:         }
305: 
306:         // build div element as wrapper
307:         $div = new cHTMLDiv(array(
308:             $label,
309:             $select
310:         ));
311: 
312:         // return div element
313:         return $div;
314:     }
315: 
316:     /**
317:      * Builds a select element allowing to choose a single class that
318:      * postprocesses the sent data.
319:      *
320:      * @return cHTMLDiv
321:      */
322:     private function _getSelectProcessor() {
323: 
324:         // attributes of form field elements
325:         $id = 'pifaform_processor_' . $this->_id;
326: 
327:         // build label element
328:         $label = new cHTMLLabel(Pifa::i18n('processor'), $id);
329: 
330:         // build select element
331:         $select = new cHTMLSelectElement($id, '', $id);
332:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
333: 
334:         // get all processors from extensions & validate result
335:         $processors = Pifa::getExtensionClasses('PifaAbstractFormProcessor');
336: 
337:         // sort processors by their label
338:         usort($processors, 'cContentTypePifaForm::sortByLabel');
339: 
340:         // loop all forms
341:         foreach ($processors as $processor) {
342: 
343:             // attributes of option element
344:             $title = $processor['label'];
345:             $value = $processor['value'];
346:             $selected = $processor['value'] == $this->_settings['pifaform_processor'];
347: 
348:             // build option element
349:             $option = new cHTMLOptionElement($title, $value, $selected);
350: 
351:             // append option element to select element
352:             $select->addOptionElement(++$index, $option);
353:         }
354: 
355:         // build div element as wrapper
356:         $div = new cHTMLDiv(array(
357:             $label,
358:             $select
359:         ));
360: 
361:         // return div element
362:         return $div;
363:     }
364: 
365:     /**
366:      * Builds a select element allowing to choose a single template to respond a
367:      * GET request.
368:      *
369:      * @return cHTMLDiv
370:      */
371:     private function _getSelectTemplateGet() {
372: 
373:         // attributes of form field elements
374:         $id = 'pifaform_template_get_' . $this->_id;
375: 
376:         // build label element
377:         $label = new cHTMLLabel(Pifa::i18n('template') . ' &ndash; ' . Pifa::i18n('GET'), $id);
378: 
379:         // build select element
380:         $select = new cHTMLSelectElement($id, '', $id);
381:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
382: 
383:         // get templates from client template folder
384:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_get\.tpl/');
385: 
386:         // sort templates by their label
387:         usort($templates, 'cContentTypePifaForm::sortByLabel');
388: 
389:         // loop all templates
390:         foreach ($templates as $template) {
391: 
392:             // attributes of option element
393:             $title = $template['label'];
394:             $value = $template['value'];
395:             $selected = $template['value'] == $this->_settings['pifaform_template_get'];
396: 
397:             // build option element
398:             $option = new cHTMLOptionElement($title, $value, $selected);
399: 
400:             // append option element to select element
401:             $select->addOptionElement(++$index, $option);
402:         }
403: 
404:         // build div element as wrapper
405:         $div = new cHTMLDiv(array(
406:             $label,
407:             $select
408:         ));
409: 
410:         // return div element
411:         return $div;
412:     }
413: 
414:     /**
415:      * Builds a select element allowing to choose a single template to respond a
416:      * POST request.
417:      *
418:      * @return cHTMLDiv
419:      */
420:     private function _getSelectTemplatePost() {
421: 
422:         // attributes of form field elements
423:         $id = 'pifaform_template_post_' . $this->_id;
424: 
425:         // build label element
426:         $label = new cHTMLLabel(Pifa::i18n('template') . ' &ndash; ' . Pifa::i18n('POST'), $id);
427: 
428:         // build select element
429:         $select = new cHTMLSelectElement($id, '', $id);
430:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
431: 
432:         // get templates from client template folder
433:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_post\.tpl/');
434: 
435:         // sort templates by their label
436:         usort($templates, 'cContentTypePifaForm::sortByLabel');
437: 
438:         // loop all templates
439:         foreach ($templates as $template) {
440: 
441:             // attributes of option element
442:             $title = $template['label'];
443:             $value = $template['value'];
444:             $selected = $template['value'] == $this->_settings['pifaform_template_post'];
445: 
446:             // build option element
447:             $option = new cHTMLOptionElement($title, $value, $selected);
448: 
449:             // append option element to select element
450:             $select->addOptionElement(++$index, $option);
451:         }
452: 
453:         // build div element as wrapper
454:         $div = new cHTMLDiv(array(
455:             $label,
456:             $select
457:         ));
458: 
459:         // return div element
460:         return $div;
461:     }
462: 
463:     /**
464:      * Builds a select element allowing to choose a single template for the client mail.
465:      *
466:      * @return cHTMLDiv
467:      */
468:     private function _getSelectMailClientTemplate() {
469: 
470:         // attributes of form field elements
471:         $id = 'pifaform_mail_client_template_' . $this->_id;
472: 
473:         // build label element
474:         $label = new cHTMLLabel(Pifa::i18n('template'), $id);
475: 
476:         // build select element
477:         $select = new cHTMLSelectElement($id, '', $id);
478:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
479: 
480:         // get templates from client template folder
481:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_mail_client\.tpl/');
482: 
483:         // sort templates by their label
484:         usort($templates, 'cContentTypePifaForm::sortByLabel');
485: 
486:         // loop all templates
487:         foreach ($templates as $template) {
488: 
489:             // attributes of option element
490:             $title = $template['label'];
491:             $value = $template['value'];
492:             $selected = $template['value'] == $this->_settings['pifaform_mail_client_template'];
493: 
494:             // build option element
495:             $option = new cHTMLOptionElement($title, $value, $selected);
496: 
497:             // append option element to select element
498:             $select->addOptionElement(++$index, $option);
499:         }
500: 
501:         // build div element as wrapper
502:         $div = new cHTMLDiv(array(
503:             $label,
504:             $select
505:         ));
506: 
507:         // return div element
508:         return $div;
509:     }
510: 
511:     /**
512:      * Builds an input element allowing to set the client mail sender address.
513:      *
514:      * @return cHTMLDiv
515:      */
516:     private function _getInputMailClientFromEmail() {
517: 
518:         // attributes of form field elements
519:         $label = Pifa::i18n('sender email');
520:         $id = 'pifaform_mail_client_from_email_' . $this->_id;
521:         $value = $this->_settings['pifaform_mail_client_from_email'];
522: 
523:         // build label element, input element & div element as wrapper
524:         $div = new cHTMLDiv(array(
525:             new cHTMLLabel($label, $id),
526:             new cHTMLTextbox($id, $value, '', '', $id)
527:         ));
528: 
529:         // return div element
530:         return $div;
531:     }
532: 
533:     /**
534:      * Builds an input element allowing to set the client mail sender name.
535:      *
536:      * @return cHTMLDiv
537:      */
538:     private function _getInputMailClientFromName() {
539: 
540:         // attributes of form field elements
541:         $label = Pifa::i18n('sender name');
542:         $id = 'pifaform_mail_client_from_name_' . $this->_id;
543:         $value = $this->_settings['pifaform_mail_client_from_name'];
544: 
545:         // build label element, input element & div element as wrapper
546:         $div = new cHTMLDiv(array(
547:             new cHTMLLabel($label, $id),
548:             new cHTMLTextbox($id, $value, '', '', $id)
549:         ));
550: 
551:         // return div element
552:         return $div;
553:     }
554: 
555:     /**
556:      * Builds an input element allowing to set the client mail subject.
557:      *
558:      * @return cHTMLDiv
559:      */
560:     private function _getInputMailClientSubject() {
561: 
562:         // attributes of form field elements
563:         $label = Pifa::i18n('subject');
564:         $id = 'pifaform_mail_client_subject_' . $this->_id;
565:         $value = $this->_settings['pifaform_mail_client_subject'];
566:         // encode dollar sign so that contained PHP style variable will not be
567:         // interpreted
568:         $value = str_replace('$', '&#36;', $value);
569: 
570:         // build label element, input element & div element as wrapper
571:         $div = new cHTMLDiv(array(
572:             new cHTMLLabel($label, $id),
573:             new cHTMLTextbox($id, $value, '', '', $id)
574:         ));
575: 
576:         // return div element
577:         return $div;
578:     }
579: 
580:     /**
581:      * Builds a select element allowing to choose a single template the system mail.
582:      *
583:      * @return cHTMLDiv
584:      */
585:     private function _getSelectMailSystemTemplate() {
586: 
587:         // attributes of form field elements
588:         $id = 'pifaform_mail_system_template_' . $this->_id;
589: 
590:         // build label element
591:         $label = new cHTMLLabel(Pifa::i18n('template'), $id);
592: 
593:         // build select element
594:         $select = new cHTMLSelectElement($id, '', $id);
595:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
596: 
597:         // get templates from client template folder
598:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_mail_system\.tpl/');
599: 
600:         // sort templates by their label
601:         usort($templates, 'cContentTypePifaForm::sortByLabel');
602: 
603:         // loop all templates
604:         foreach ($templates as $template) {
605: 
606:             // attributes of option element
607:             $title = $template['label'];
608:             $value = $template['value'];
609:             $selected = $template['value'] == $this->_settings['pifaform_mail_system_template'];
610: 
611:             // build option element
612:             $option = new cHTMLOptionElement($title, $value, $selected);
613: 
614:             // append option element to select element
615:             $select->addOptionElement(++$index, $option);
616:         }
617: 
618:         // build div element as wrapper
619:         $div = new cHTMLDiv(array(
620:             $label,
621:             $select
622:         ));
623: 
624:         // return div element
625:         return $div;
626:     }
627: 
628:     /**
629:      * Builds an input element allowing to set the system mail sender address.
630:      *
631:      * @return cHTMLDiv
632:      */
633:     private function _getInputMailSystemFromEmail() {
634: 
635:         // attributes of form field elements
636:         $label = Pifa::i18n('sender email');
637:         $id = 'pifaform_mail_system_from_email_' . $this->_id;
638:         $value = $this->_settings['pifaform_mail_system_from_email'];
639: 
640:         // build label element, input element & div element as wrapper
641:         $div = new cHTMLDiv(array(
642:             new cHTMLLabel($label, $id),
643:             new cHTMLTextbox($id, $value, '', '', $id)
644:         ));
645: 
646:         // return div element
647:         return $div;
648:     }
649: 
650:     /**
651:      * Builds an input element allowing to set the system mail sender name.
652:      *
653:      * @return cHTMLDiv
654:      */
655:     private function _getInputMailSystemFromName() {
656: 
657:         // attributes of form field elements
658:         $label = Pifa::i18n('sender name');
659:         $id = 'pifaform_mail_system_from_name_' . $this->_id;
660:         $value = $this->_settings['pifaform_mail_system_from_name'];
661: 
662:         // build label element, input element & div element as wrapper
663:         $div = new cHTMLDiv(array(
664:             new cHTMLLabel($label, $id),
665:             new cHTMLTextbox($id, $value, '', '', $id)
666:         ));
667: 
668:         // return div element
669:         return $div;
670:     }
671: 
672:     /**
673:      * Builds an input element allowing to set the system mail recipient address.
674:      *
675:      * @return cHTMLDiv
676:      */
677:     private function _getInputMailSystemRecipientEmail() {
678: 
679:         // attributes of form field elements
680:         $label = Pifa::i18n('Recipient email');
681:         $id = 'pifaform_mail_system_recipient_email_' . $this->_id;
682:         $value = $this->_settings['pifaform_mail_system_recipient_email'];
683: 
684:         // build label element, input element & div element as wrapper
685:         $div = new cHTMLDiv(array(
686:             new cHTMLLabel($label, $id),
687:             new cHTMLTextbox($id, $value, '', '', $id)
688:         ));
689: 
690:         // return div element
691:         return $div;
692:     }
693: 
694:     /**
695:      * Builds an input element allowing to set the system mail subject.
696:      *
697:      * @return cHTMLDiv
698:      */
699:     private function _getInputMailSystemSubject() {
700: 
701:         // attributes of form field elements
702:         $label = Pifa::i18n('subject');
703:         $id = 'pifaform_mail_system_subject_' . $this->_id;
704:         $value = $this->_settings['pifaform_mail_system_subject'];
705:         // encode dollar sign so that contained PHP style variable will not be
706:         // interpreted
707:         $value = str_replace('$', '&#36;', $value);
708: 
709:         // build label element, input element & div element as wrapper
710:         $div = new cHTMLDiv(array(
711:             new cHTMLLabel($label, $id),
712:             new cHTMLTextbox($id, $value, '', '', $id)
713:         ));
714: 
715:         // return div element
716:         return $div;
717:     }
718: 
719:     /**
720:      * Generates the code which should be shown if this content type is shown in
721:      * the frontend.
722:      * This code is cached. Thatfor ist no more than the initialisation of this
723:      * class and the call of its method buildCode(). Otherwise the generated
724:      * HTML would have been cached.
725:      *
726:      * @return string escaped HTML code which sould be shown if content type is
727:      *         shown in frontend
728:      */
729:     public function generateViewCode() {
730:         $code = '";?' . '><' . '?php $form = new %s(\'%s\', %s, %s); echo $form->buildCode(); ?' . '><' . '?php echo "';
731:         $code = sprintf($code, get_class($this), $this->_rawSettings, $this->_id, 'array()');
732: 
733:         return $code;
734:     }
735: 
736:     /**
737:      * Get code of form (either GET or POST request).
738:      *
739:      * @return string escaped HTML code which sould be shown if content type is shown in frontend
740:      */
741:     public function buildCode() {
742:         $out = '';
743:         if (0 === cSecurity::toInteger($this->_settings['pifaform_idform'])) {
744:             // no form was selected
745:         } elseif (0 === cString::getStringLength(trim($this->_settings['pifaform_module']))) {
746:             // no module was selected
747:         } else {
748:             $moduleClass = trim($this->_settings['pifaform_module']);
749:             try {
750:                 $filename = Pifa::fromCamelCase($moduleClass);
751:                 $filename = "extensions/class.pifa.$filename.php";
752:                 if (false === file_exists(Pifa::getPath() . $filename)) {
753:                     $msg = sprintf(Pifa::i18n('MISSING_MODULE_FILE'), $filename);
754:                     throw new PifaException($msg);
755:                 }
756:                 plugin_include(Pifa::getName(), $filename);
757:                 if (false === class_exists($moduleClass)) {
758:                     $msg = sprintf(Pifa::i18n('MISSING_MODULE_CLASS'), $moduleClass);
759:                     throw new PifaException($msg);
760:                 }
761:                 /** @var PifaAbstractFormModule $mod */
762:                 $mod = new $moduleClass($this->_settings);
763:                 $out = $mod->render(true);
764:             } catch (Exception $e) {
765:                 Pifa::logException($e);
766:                 // log but don't display exception
767:             }
768:         }
769: 
770:         // don't encode cached code for output
771:         // $out = $this->_encodeForOutput($out);
772: 
773:         return $out;
774:     }
775: }
776: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0