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
    • 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
 47:      *        plaintext
 48:      * @param int $id ID of the content type, e.g. 3 if CMS_DATE[3] is
 49:      *        used
 50:      * @param array $contentTypes array containing the values of all content
 51:      *        types
 52:      */
 53:     function __construct($rawSettings, $id, array $contentTypes) {
 54: 
 55:         // set attributes of the parent class and call the parent constructor
 56:         $this->_type = 'CMS_PIFAFORM';
 57:         $this->_prefix = 'pifaform';
 58:         $this->_settingsType = self::SETTINGS_TYPE_XML;
 59:         $this->_formFields = array(
 60:             'pifaform_headline',
 61:             'pifaform_idform',
 62:             'pifaform_module',
 63:             'pifaform_processor',
 64:             'pifaform_template_get',
 65:             'pifaform_template_post',
 66:             'pifaform_mail_client_template',
 67:             'pifaform_mail_client_from_email',
 68:             'pifaform_mail_client_from_name',
 69:             'pifaform_mail_client_subject',
 70:             'pifaform_mail_system_template',
 71:             'pifaform_mail_system_from_email',
 72:             'pifaform_mail_system_from_name',
 73:             'pifaform_mail_system_recipient_email',
 74:             'pifaform_mail_system_subject'
 75:         );
 76: 
 77:         parent::__construct($rawSettings, $id, $contentTypes);
 78: 
 79:         // if form is submitted, store the current settings
 80:         // notice: also check the ID of the content type (there could be more
 81:         // than one content type of the same type on the same page!)
 82:         $action = isset($_POST['pifaform_action']) ? $_POST['pifaform_action'] : NULL;
 83:         $id = isset($_POST['pifaform_id']) ? $_POST['pifaform_id'] : NULL;
 84:         if ('store' === $action && $this->_id == $id) {
 85:             $this->_storeSettings();
 86:         }
 87:     }
 88: 
 89:     /**
 90:      * Generate the escaped HTML code for editor.
 91:      *
 92:      * @return string escaped HTML code for editor
 93:      */
 94:     public function generateEditCode() {
 95: 
 96:         // build top code
 97:         $tplTop = new cTemplate();
 98:         $tplTop->set('s', 'ICON', 'plugins/form_assistant/images/icon_form.png');
 99:         $tplTop->set('s', 'ID', $this->_id);
100:         $tplTop->set('s', 'PREFIX', $this->_prefix);
101:         $tplTop->set('s', 'HEADLINE', Pifa::i18n('form'));
102:         $codeTop = $tplTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
103: 
104:         // available tabs
105:         $tabMenu = array(
106:             'base' => Pifa::i18n('form')
107:         );
108: 
109:         // build tab code
110:         $tplPanel = new cTemplate();
111:         $tplPanel->set('s', 'PREFIX', $this->_prefix);
112:         $tplPanel->set('d', 'TAB_ID', 'base');
113:         $tplPanel->set('d', 'TAB_CLASS', 'base');
114:         $tplPanel->set('d', 'TAB_CONTENT', $this->_getPanel());
115:         $tplPanel->next();
116:         $codePanel = $tplPanel->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
117: 
118:         // build bottom code
119:         $tplBottom = new cTemplate();
120:         $tplBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
121:         $tplBottom->set('s', 'ID', $this->_id);
122:         $tplBottom->set('s', 'PREFIX', $this->_prefix);
123:         $tplBottom->set('s', 'IDARTLANG', $this->_idArtLang);
124:         $tplBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
125:         // encode dollar sign so that contained PHP style variable will not be
126:         // 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
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
465:      * client
466:      * mail.
467:      *
468:      * @return cHTMLDiv
469:      */
470:     private function _getSelectMailClientTemplate() {
471: 
472:         // attributes of form field elements
473:         $id = 'pifaform_mail_client_template_' . $this->_id;
474: 
475:         // build label element
476:         $label = new cHTMLLabel(Pifa::i18n('template'), $id);
477: 
478:         // build select element
479:         $select = new cHTMLSelectElement($id, '', $id);
480:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
481: 
482:         // get templates from client template folder
483:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_mail_client\.tpl/');
484: 
485:         // sort templates by their label
486:         usort($templates, 'cContentTypePifaForm::sortByLabel');
487: 
488:         // loop all templates
489:         foreach ($templates as $template) {
490: 
491:             // attributes of option element
492:             $title = $template['label'];
493:             $value = $template['value'];
494:             $selected = $template['value'] == $this->_settings['pifaform_mail_client_template'];
495: 
496:             // build option element
497:             $option = new cHTMLOptionElement($title, $value, $selected);
498: 
499:             // append option element to select element
500:             $select->addOptionElement(++$index, $option);
501:         }
502: 
503:         // build div element as wrapper
504:         $div = new cHTMLDiv(array(
505:             $label,
506:             $select
507:         ));
508: 
509:         // return div element
510:         return $div;
511:     }
512: 
513:     /**
514:      * Builds an input element allowing to set the client mail sender address.
515:      *
516:      * @return cHTMLDiv
517:      */
518:     private function _getInputMailClientFromEmail() {
519: 
520:         // attributes of form field elements
521:         $label = Pifa::i18n('sender email');
522:         $id = 'pifaform_mail_client_from_email_' . $this->_id;
523:         $value = $this->_settings['pifaform_mail_client_from_email'];
524: 
525:         // build label element, input element & div element as wrapper
526:         $div = new cHTMLDiv(array(
527:             new cHTMLLabel($label, $id),
528:             new cHTMLTextbox($id, $value, '', '', $id)
529:         ));
530: 
531:         // return div element
532:         return $div;
533:     }
534: 
535:     /**
536:      * Builds an input element allowing to set the client mail sender name.
537:      *
538:      * @return cHTMLDiv
539:      */
540:     private function _getInputMailClientFromName() {
541: 
542:         // attributes of form field elements
543:         $label = Pifa::i18n('sender name');
544:         $id = 'pifaform_mail_client_from_name_' . $this->_id;
545:         $value = $this->_settings['pifaform_mail_client_from_name'];
546: 
547:         // build label element, input element & div element as wrapper
548:         $div = new cHTMLDiv(array(
549:             new cHTMLLabel($label, $id),
550:             new cHTMLTextbox($id, $value, '', '', $id)
551:         ));
552: 
553:         // return div element
554:         return $div;
555:     }
556: 
557:     /**
558:      * Builds an input element allowing to set the client mail subject.
559:      *
560:      * @return cHTMLDiv
561:      */
562:     private function _getInputMailClientSubject() {
563: 
564:         // attributes of form field elements
565:         $label = Pifa::i18n('subject');
566:         $id = 'pifaform_mail_client_subject_' . $this->_id;
567:         $value = $this->_settings['pifaform_mail_client_subject'];
568:         // encode dollar sign so that contained PHP style variable will not be
569:         // interpreted
570:         $value = str_replace('$', '&#36;', $value);
571: 
572:         // build label element, input element & div element as wrapper
573:         $div = new cHTMLDiv(array(
574:             new cHTMLLabel($label, $id),
575:             new cHTMLTextbox($id, $value, '', '', $id)
576:         ));
577: 
578:         // return div element
579:         return $div;
580:     }
581: 
582:     /**
583:      * Builds a select element allowing to choose a single template the system
584:      * mail.
585:      *
586:      * @return cHTMLSelectElement
587:      */
588:     private function _getSelectMailSystemTemplate() {
589: 
590:         // attributes of form field elements
591:         $id = 'pifaform_mail_system_template_' . $this->_id;
592: 
593:         // build label element
594:         $label = new cHTMLLabel(Pifa::i18n('template'), $id);
595: 
596:         // build select element
597:         $select = new cHTMLSelectElement($id, '', $id);
598:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
599: 
600:         // get templates from client template folder
601:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_mail_system\.tpl/');
602: 
603:         // sort templates by their label
604:         usort($templates, 'cContentTypePifaForm::sortByLabel');
605: 
606:         // loop all templates
607:         foreach ($templates as $template) {
608: 
609:             // attributes of option element
610:             $title = $template['label'];
611:             $value = $template['value'];
612:             $selected = $template['value'] == $this->_settings['pifaform_mail_system_template'];
613: 
614:             // build option element
615:             $option = new cHTMLOptionElement($title, $value, $selected);
616: 
617:             // append option element to select element
618:             $select->addOptionElement(++$index, $option);
619:         }
620: 
621:         // build div element as wrapper
622:         $div = new cHTMLDiv(array(
623:             $label,
624:             $select
625:         ));
626: 
627:         // return div element
628:         return $div;
629:     }
630: 
631:     /**
632:      * Builds an input element allowing to set the system mail sender address.
633:      *
634:      * @return cHTMLDiv
635:      */
636:     private function _getInputMailSystemFromEmail() {
637: 
638:         // attributes of form field elements
639:         $label = Pifa::i18n('sender email');
640:         $id = 'pifaform_mail_system_from_email_' . $this->_id;
641:         $value = $this->_settings['pifaform_mail_system_from_email'];
642: 
643:         // build label element, input element & div element as wrapper
644:         $div = new cHTMLDiv(array(
645:             new cHTMLLabel($label, $id),
646:             new cHTMLTextbox($id, $value, '', '', $id)
647:         ));
648: 
649:         // return div element
650:         return $div;
651:     }
652: 
653:     /**
654:      * Builds an input element allowing to set the system mail sender name.
655:      *
656:      * @return cHTMLDiv
657:      */
658:     private function _getInputMailSystemFromName() {
659: 
660:         // attributes of form field elements
661:         $label = Pifa::i18n('sender name');
662:         $id = 'pifaform_mail_system_from_name_' . $this->_id;
663:         $value = $this->_settings['pifaform_mail_system_from_name'];
664: 
665:         // build label element, input element & div element as wrapper
666:         $div = new cHTMLDiv(array(
667:             new cHTMLLabel($label, $id),
668:             new cHTMLTextbox($id, $value, '', '', $id)
669:         ));
670: 
671:         // return div element
672:         return $div;
673:     }
674: 
675:     /**
676:      * Builds an input element allowing to set the system mail recipient
677:      * address.
678:      *
679:      * @return cHTMLDiv
680:      */
681:     private function _getInputMailSystemRecipientEmail() {
682: 
683:         // attributes of form field elements
684:         $label = Pifa::i18n('Recipient email');
685:         $id = 'pifaform_mail_system_recipient_email_' . $this->_id;
686:         $value = $this->_settings['pifaform_mail_system_recipient_email'];
687: 
688:         // build label element, input element & div element as wrapper
689:         $div = new cHTMLDiv(array(
690:             new cHTMLLabel($label, $id),
691:             new cHTMLTextbox($id, $value, '', '', $id)
692:         ));
693: 
694:         // return div element
695:         return $div;
696:     }
697: 
698:     /**
699:      * Builds an input element allowing to set the system mail subject.
700:      *
701:      * @return cHTMLDiv
702:      */
703:     private function _getInputMailSystemSubject() {
704: 
705:         // attributes of form field elements
706:         $label = Pifa::i18n('subject');
707:         $id = 'pifaform_mail_system_subject_' . $this->_id;
708:         $value = $this->_settings['pifaform_mail_system_subject'];
709:         // encode dollar sign so that contained PHP style variable will not be
710:         // interpreted
711:         $value = str_replace('$', '&#36;', $value);
712: 
713:         // build label element, input element & div element as wrapper
714:         $div = new cHTMLDiv(array(
715:             new cHTMLLabel($label, $id),
716:             new cHTMLTextbox($id, $value, '', '', $id)
717:         ));
718: 
719:         // return div element
720:         return $div;
721:     }
722: 
723:     /**
724:      * Generates the code which should be shown if this content type is shown in
725:      * the frontend.
726:      * This code is cached. Thatfor ist no more than the initialisation of this
727:      * class and the call of its method buildCode(). Otherwise the generated
728:      * HTML would have been cached.
729:      *
730:      * @return string escaped HTML code which sould be shown if content type is
731:      *         shown in frontend
732:      */
733:     public function generateViewCode() {
734:         $code = '";?' . '><' . '?php $form = new %s(\'%s\', %s, %s); echo $form->buildCode(); ?' . '><' . '?php echo "';
735:         $code = sprintf($code, get_class($this), $this->_rawSettings, $this->_id, 'array()');
736: 
737:         return $code;
738:     }
739: 
740:     /**
741:      * Get code of form (either GET or POST request).
742:      *
743:      * @return string escaped HTML code which sould be shown if content type is
744:      *         shown in frontend
745:      */
746:     public function buildCode() {
747:         $out = '';
748:         if (0 === cSecurity::toInteger($this->_settings['pifaform_idform'])) {
749:             // no form was selected
750:         } else if (0 === cString::getStringLength(trim($this->_settings['pifaform_module']))) {
751:             // no module was selected
752:         } else {
753:             $moduleClass = trim($this->_settings['pifaform_module']);
754:             try {
755:                 $filename = Pifa::fromCamelCase($moduleClass);
756:                 $filename = "extensions/class.pifa.$filename.php";
757:                 if (false === file_exists(Pifa::getPath() . $filename)) {
758:                     $msg = sprintf(Pifa::i18n('MISSING_MODULE_FILE'), $filename);
759:                     throw new PifaException($msg);
760:                 }
761:                 plugin_include(Pifa::getName(), $filename);
762:                 if (false === class_exists($moduleClass)) {
763:                     $msg = sprintf(Pifa::i18n('MISSING_MODULE_CLASS'), $moduleClass);
764:                     throw new PifaException($msg);
765:                 }
766:                 $mod = new $moduleClass($this->_settings);
767:                 $out = $mod->render(true);
768:             } catch (Exception $e) {
769:                 Pifa::logException($e);
770:                 // log but don't display exception
771:             }
772:         }
773: 
774:         // don't encode cached code for output
775:         // $out = $this->_encodeForOutput($out);
776: 
777:         return $out;
778:     }
779: }
780: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0