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
    • NavigationMain
    • 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

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