Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

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

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:  * @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 int $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', 'ICON', 'plugins/form_assistant/images/icon_form.png');
103:         $tplTop->set('s', 'ID', $this->_id);
104:         $tplTop->set('s', 'PREFIX', $this->_prefix);
105:         $tplTop->set('s', 'HEADLINE', Pifa::i18n('form'));
106:         $codeTop = $tplTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
107: 
108:         // available tabs
109:         $tabMenu = array(
110:             'base' => Pifa::i18n('form')
111:         );
112: 
113:         // build tab code
114:         $tplPanel = new cTemplate();
115:         $tplPanel->set('s', 'PREFIX', $this->_prefix);
116:         $tplPanel->set('d', 'TAB_ID', 'base');
117:         $tplPanel->set('d', 'TAB_CLASS', 'base');
118:         $tplPanel->set('d', 'TAB_CONTENT', $this->_getPanel());
119:         $tplPanel->next();
120:         $codePanel = $tplPanel->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
121: 
122:         // build bottom code
123:         $tplBottom = new cTemplate();
124:         $tplBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
125:         $tplBottom->set('s', 'ID', $this->_id);
126:         $tplBottom->set('s', 'PREFIX', $this->_prefix);
127:         $tplBottom->set('s', 'IDARTLANG', $this->_idArtLang);
128:         $tplBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
129:         // encode dollar sign so that contained PHP style variable will not be
130:         // interpreted
131:         $tplBottom->set('s', 'SETTINGS', json_encode(str_replace('$', '&#36;', $this->_settings)));
132:         $tplBottom->set('s', 'JS_CLASS_SCRIPT', Pifa::getUrl() . 'scripts/cmsPifaform.js');
133:         $tplBottom->set('s', 'JS_CLASS_NAME', get_class($this));
134: 
135:         $codeBottom = $tplBottom->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_bottom.html', true);
136: 
137:         // build template code
138:         $code = $this->_encodeForOutput($codeTop);
139:         // $code .= $this->_generateTabMenuCode($tabMenu);
140:         $code .= $this->_encodeForOutput($codePanel);
141:         $code .= $this->_generateActionCode();
142:         $code .= $this->_encodeForOutput($codeBottom);
143:         $code .= $this->generateViewCode();
144: 
145:         return $code;
146:     }
147: 
148:     /**
149:      * Generates code for the base panel in which all data can be specified.
150:      *
151:      * @return string - the code for the base panel
152:      */
153:     private function _getPanel() {
154:         $wrapper = new cHTMLDiv(array(
155: 
156:             // form
157:             $this->_getSelectForm(),
158: 
159:             // module & processor class and GET & POST templates
160:             new cHTMLFieldset(array(
161:                 new cHTMLLegend(Pifa::i18n('classes & templates')),
162:                 $this->_getSelectModule(),
163:                 $this->_getSelectProcessor(),
164:                 $this->_getSelectTemplateGet(),
165:                 $this->_getSelectTemplatePost()
166:             )),
167: 
168:             // client mail settings
169:             new cHTMLFieldset(array(
170:                 new cHTMLLegend(Pifa::i18n('client mail')),
171:                 $this->_getSelectMailClientTemplate(),
172:                 $this->_getInputMailClientFromEmail(),
173:                 $this->_getInputMailClientFromName(),
174:                 $this->_getInputMailClientSubject()
175:             )),
176: 
177:             // system mail settings
178:             new cHTMLFieldset(array(
179:                 new cHTMLLegend(Pifa::i18n('system mail')),
180:                 $this->_getSelectMailSystemTemplate(),
181:                 $this->_getInputMailSystemFromEmail(),
182:                 $this->_getInputMailSystemFromName(),
183:                 $this->_getInputMailSystemRecipientEmail(),
184:                 $this->_getInputMailSystemSubject()
185:             ))
186:         ), $this->_prefix . '_panel_base', $this->_prefix . '_panel_base_' . $this->_id);
187:         $wrapper->setStyle('clear:both');
188: 
189:         return $wrapper->render();
190:     }
191: 
192:     /**
193:      * Builds a select element allowing to choose a single form that was created
194:      * for the current client.
195:      *
196:      * @return cHTMLDiv
197:      */
198:     private function _getSelectForm() {
199: 
200:         // attributes of form field elements
201:         $id = 'pifaform_idform_' . $this->_id;
202: 
203:         // build label element
204:         $label = new cHTMLLabel(Pifa::i18n('form'), $id);
205: 
206:         // build select element
207:         $select = new cHTMLSelectElement($id, '', $id);
208:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
209: 
210:         // get all forms of current client & validate result
211:         $idclient = cRegistry::getClientId();
212:         $forms = PifaFormCollection::getByClient($idclient);
213:         if (false === $forms) {
214:             return $select;
215:         }
216: 
217:         // loop all forms
218:         while (false !== $form = $forms->next()) {
219: 
220:             // attributes of option element
221:             $title = $form->get('name');
222:             $value = $form->get('idform');
223:             $selected = $form->get('idform') == $this->_settings['pifaform_idform'];
224: 
225:             // build option element
226:             $option = new cHTMLOptionElement($title, $value, $selected);
227: 
228:             // append option element to select element
229:             $select->addOptionElement(++$index, $option);
230:         }
231: 
232:         // build div element as wrapper
233:         $div = new cHTMLDiv(array(
234:             $label,
235:             $select
236:         ));
237: 
238:         // return div element
239:         return $div;
240:     }
241: 
242:     /**
243:      * Builds a select element allowing to choose a single module that handles
244:      * the chosen form.
245:      *
246:      * @return cHTMLDiv
247:      */
248:     private function _getSelectModule() {
249: 
250:         // attributes of form field elements
251:         $id = 'pifaform_module_' . $this->_id;
252: 
253:         // build label element
254:         $label = new cHTMLLabel(Pifa::i18n('module'), $id);
255: 
256:         // build select element
257:         $select = new cHTMLSelectElement($id, '', $id);
258:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
259: 
260:         // get all modules from extensions & validate result
261:         $modules = Pifa::getExtensionClasses('PifaAbstractFormModule');
262: 
263:         // sort modules by their label
264:         usort($modules, 'cContentTypePifaForm::sortByLabel');
265: 
266:         // loop all forms
267:         foreach ($modules as $module) {
268: 
269:             // attributes of option element
270:             $title = $module['label'];
271:             $value = $module['value'];
272:             $selected = $module['value'] == $this->_settings['pifaform_module'];
273: 
274:             // build option element
275:             $option = new cHTMLOptionElement($title, $value, $selected);
276: 
277:             // append option element to select element
278:             $select->addOptionElement(++$index, $option);
279:         }
280: 
281:         // build div element as wrapper
282:         $div = new cHTMLDiv(array(
283:             $label,
284:             $select
285:         ));
286: 
287:         // return div element
288:         return $div;
289:     }
290: 
291:     /**
292:      * Builds a select element allowing to choose a single class that
293:      * postprocesses the sent data.
294:      *
295:      * @return cHTMLDiv
296:      */
297:     private function _getSelectProcessor() {
298: 
299:         // attributes of form field elements
300:         $id = 'pifaform_processor_' . $this->_id;
301: 
302:         // build label element
303:         $label = new cHTMLLabel(Pifa::i18n('processor'), $id);
304: 
305:         // build select element
306:         $select = new cHTMLSelectElement($id, '', $id);
307:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
308: 
309:         // get all processors from extensions & validate result
310:         $processors = Pifa::getExtensionClasses('PifaAbstractFormProcessor');
311: 
312:         // sort processors by their label
313:         usort($processors, 'cContentTypePifaForm::sortByLabel');
314: 
315:         // loop all forms
316:         foreach ($processors as $processor) {
317: 
318:             // attributes of option element
319:             $title = $processor['label'];
320:             $value = $processor['value'];
321:             $selected = $processor['value'] == $this->_settings['pifaform_processor'];
322: 
323:             // build option element
324:             $option = new cHTMLOptionElement($title, $value, $selected);
325: 
326:             // append option element to select element
327:             $select->addOptionElement(++$index, $option);
328:         }
329: 
330:         // build div element as wrapper
331:         $div = new cHTMLDiv(array(
332:             $label,
333:             $select
334:         ));
335: 
336:         // return div element
337:         return $div;
338:     }
339: 
340:     /**
341:      * Builds a select element allowing to choose a single template to respond a
342:      * GET request.
343:      *
344:      * @return cHTMLDiv
345:      */
346:     private function _getSelectTemplateGet() {
347: 
348:         // attributes of form field elements
349:         $id = 'pifaform_template_get_' . $this->_id;
350: 
351:         // build label element
352:         $label = new cHTMLLabel(Pifa::i18n('template') . ' &ndash; ' . Pifa::i18n('GET'), $id);
353: 
354:         // build select element
355:         $select = new cHTMLSelectElement($id, '', $id);
356:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
357: 
358:         // get templates from client template folder
359:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_get\.tpl/');
360: 
361:         // sort templates by their label
362:         usort($templates, 'cContentTypePifaForm::sortByLabel');
363: 
364:         // loop all templates
365:         foreach ($templates as $template) {
366: 
367:             // attributes of option element
368:             $title = $template['label'];
369:             $value = $template['value'];
370:             $selected = $template['value'] == $this->_settings['pifaform_template_get'];
371: 
372:             // build option element
373:             $option = new cHTMLOptionElement($title, $value, $selected);
374: 
375:             // append option element to select element
376:             $select->addOptionElement(++$index, $option);
377:         }
378: 
379:         // build div element as wrapper
380:         $div = new cHTMLDiv(array(
381:             $label,
382:             $select
383:         ));
384: 
385:         // return div element
386:         return $div;
387:     }
388: 
389:     /**
390:      * Builds a select element allowing to choose a single template to respond a
391:      * POST request.
392:      *
393:      * @return cHTMLDiv
394:      */
395:     private function _getSelectTemplatePost() {
396: 
397:         // attributes of form field elements
398:         $id = 'pifaform_template_post_' . $this->_id;
399: 
400:         // build label element
401:         $label = new cHTMLLabel(Pifa::i18n('template') . ' &ndash; ' . Pifa::i18n('POST'), $id);
402: 
403:         // build select element
404:         $select = new cHTMLSelectElement($id, '', $id);
405:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
406: 
407:         // get templates from client template folder
408:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_post\.tpl/');
409: 
410:         // sort templates by their label
411:         usort($templates, 'cContentTypePifaForm::sortByLabel');
412: 
413:         // loop all templates
414:         foreach ($templates as $template) {
415: 
416:             // attributes of option element
417:             $title = $template['label'];
418:             $value = $template['value'];
419:             $selected = $template['value'] == $this->_settings['pifaform_template_post'];
420: 
421:             // build option element
422:             $option = new cHTMLOptionElement($title, $value, $selected);
423: 
424:             // append option element to select element
425:             $select->addOptionElement(++$index, $option);
426:         }
427: 
428:         // build div element as wrapper
429:         $div = new cHTMLDiv(array(
430:             $label,
431:             $select
432:         ));
433: 
434:         // return div element
435:         return $div;
436:     }
437: 
438:     /**
439:      * Builds a select element allowing to choose a single template for the
440:      * client
441:      * mail.
442:      *
443:      * @return cHTMLDiv
444:      */
445:     private function _getSelectMailClientTemplate() {
446: 
447:         // attributes of form field elements
448:         $id = 'pifaform_mail_client_template_' . $this->_id;
449: 
450:         // build label element
451:         $label = new cHTMLLabel(Pifa::i18n('template'), $id);
452: 
453:         // build select element
454:         $select = new cHTMLSelectElement($id, '', $id);
455:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
456: 
457:         // get templates from client template folder
458:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_mail_client\.tpl/');
459: 
460:         // sort templates by their label
461:         usort($templates, 'cContentTypePifaForm::sortByLabel');
462: 
463:         // loop all templates
464:         foreach ($templates as $template) {
465: 
466:             // attributes of option element
467:             $title = $template['label'];
468:             $value = $template['value'];
469:             $selected = $template['value'] == $this->_settings['pifaform_mail_client_template'];
470: 
471:             // build option element
472:             $option = new cHTMLOptionElement($title, $value, $selected);
473: 
474:             // append option element to select element
475:             $select->addOptionElement(++$index, $option);
476:         }
477: 
478:         // build div element as wrapper
479:         $div = new cHTMLDiv(array(
480:             $label,
481:             $select
482:         ));
483: 
484:         // return div element
485:         return $div;
486:     }
487: 
488:     /**
489:      * Builds an input element allowing to set the client mail sender address.
490:      *
491:      * @return cHTMLDiv
492:      */
493:     private function _getInputMailClientFromEmail() {
494: 
495:         // attributes of form field elements
496:         $label = Pifa::i18n('sender email');
497:         $id = 'pifaform_mail_client_from_email_' . $this->_id;
498:         $value = $this->_settings['pifaform_mail_client_from_email'];
499: 
500:         // build label element, input element & div element as wrapper
501:         $div = new cHTMLDiv(array(
502:             new cHTMLLabel($label, $id),
503:             new cHTMLTextbox($id, $value, '', '', $id)
504:         ));
505: 
506:         // return div element
507:         return $div;
508:     }
509: 
510:     /**
511:      * Builds an input element allowing to set the client mail sender name.
512:      *
513:      * @return cHTMLDiv
514:      */
515:     private function _getInputMailClientFromName() {
516: 
517:         // attributes of form field elements
518:         $label = Pifa::i18n('sender name');
519:         $id = 'pifaform_mail_client_from_name_' . $this->_id;
520:         $value = $this->_settings['pifaform_mail_client_from_name'];
521: 
522:         // build label element, input element & div element as wrapper
523:         $div = new cHTMLDiv(array(
524:             new cHTMLLabel($label, $id),
525:             new cHTMLTextbox($id, $value, '', '', $id)
526:         ));
527: 
528:         // return div element
529:         return $div;
530:     }
531: 
532:     /**
533:      * Builds an input element allowing to set the client mail subject.
534:      *
535:      * @return cHTMLDiv
536:      */
537:     private function _getInputMailClientSubject() {
538: 
539:         // attributes of form field elements
540:         $label = Pifa::i18n('subject');
541:         $id = 'pifaform_mail_client_subject_' . $this->_id;
542:         $value = $this->_settings['pifaform_mail_client_subject'];
543:         // encode dollar sign so that contained PHP style variable will not be
544:         // interpreted
545:         $value = str_replace('$', '&#36;', $value);
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 a select element allowing to choose a single template the system
559:      * mail.
560:      *
561:      * @return cHTMLSelectElement
562:      */
563:     private function _getSelectMailSystemTemplate() {
564: 
565:         // attributes of form field elements
566:         $id = 'pifaform_mail_system_template_' . $this->_id;
567: 
568:         // build label element
569:         $label = new cHTMLLabel(Pifa::i18n('template'), $id);
570: 
571:         // build select element
572:         $select = new cHTMLSelectElement($id, '', $id);
573:         $select->addOptionElement($index = 0, new cHTMLOptionElement(Pifa::i18n('none'), ''));
574: 
575:         // get templates from client template folder
576:         $templates = Pifa::getTemplates('/cms_pifaform_[^\.]+_mail_system\.tpl/');
577: 
578:         // sort templates by their label
579:         usort($templates, 'cContentTypePifaForm::sortByLabel');
580: 
581:         // loop all templates
582:         foreach ($templates as $template) {
583: 
584:             // attributes of option element
585:             $title = $template['label'];
586:             $value = $template['value'];
587:             $selected = $template['value'] == $this->_settings['pifaform_mail_system_template'];
588: 
589:             // build option element
590:             $option = new cHTMLOptionElement($title, $value, $selected);
591: 
592:             // append option element to select element
593:             $select->addOptionElement(++$index, $option);
594:         }
595: 
596:         // build div element as wrapper
597:         $div = new cHTMLDiv(array(
598:             $label,
599:             $select
600:         ));
601: 
602:         // return div element
603:         return $div;
604:     }
605: 
606:     /**
607:      * Builds an input element allowing to set the system mail sender address.
608:      *
609:      * @return cHTMLDiv
610:      */
611:     private function _getInputMailSystemFromEmail() {
612: 
613:         // attributes of form field elements
614:         $label = Pifa::i18n('sender email');
615:         $id = 'pifaform_mail_system_from_email_' . $this->_id;
616:         $value = $this->_settings['pifaform_mail_system_from_email'];
617: 
618:         // build label element, input element & div element as wrapper
619:         $div = new cHTMLDiv(array(
620:             new cHTMLLabel($label, $id),
621:             new cHTMLTextbox($id, $value, '', '', $id)
622:         ));
623: 
624:         // return div element
625:         return $div;
626:     }
627: 
628:     /**
629:      * Builds an input element allowing to set the system mail sender name.
630:      *
631:      * @return cHTMLDiv
632:      */
633:     private function _getInputMailSystemFromName() {
634: 
635:         // attributes of form field elements
636:         $label = Pifa::i18n('sender name');
637:         $id = 'pifaform_mail_system_from_name_' . $this->_id;
638:         $value = $this->_settings['pifaform_mail_system_from_name'];
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 recipient
652:      * address.
653:      *
654:      * @return cHTMLDiv
655:      */
656:     private function _getInputMailSystemRecipientEmail() {
657: 
658:         // attributes of form field elements
659:         $label = Pifa::i18n('Recipient email');
660:         $id = 'pifaform_mail_system_recipient_email_' . $this->_id;
661:         $value = $this->_settings['pifaform_mail_system_recipient_email'];
662: 
663:         // build label element, input element & div element as wrapper
664:         $div = new cHTMLDiv(array(
665:             new cHTMLLabel($label, $id),
666:             new cHTMLTextbox($id, $value, '', '', $id)
667:         ));
668: 
669:         // return div element
670:         return $div;
671:     }
672: 
673:     /**
674:      * Builds an input element allowing to set the system mail subject.
675:      *
676:      * @return cHTMLDiv
677:      */
678:     private function _getInputMailSystemSubject() {
679: 
680:         // attributes of form field elements
681:         $label = Pifa::i18n('subject');
682:         $id = 'pifaform_mail_system_subject_' . $this->_id;
683:         $value = $this->_settings['pifaform_mail_system_subject'];
684:         // encode dollar sign so that contained PHP style variable will not be
685:         // interpreted
686:         $value = str_replace('$', '&#36;', $value);
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:      * Generates the code which should be shown if this content type is shown in
700:      * the frontend.
701:      * This code is cached. Thatfor ist no more than the initialisation of this
702:      * class and the call of its method buildCode(). Otherwise the generated
703:      * HTML would have been cached.
704:      *
705:      * @return string escaped HTML code which sould be shown if content type is
706:      *         shown in frontend
707:      */
708:     public function generateViewCode() {
709:         $code = '";?' . '><' . '?php $form = new %s(\'%s\', %s, %s); echo $form->buildCode(); ?' . '><' . '?php echo "';
710:         $code = sprintf($code, get_class($this), $this->_rawSettings, $this->_id, 'array()');
711: 
712:         return $code;
713:     }
714: 
715:     /**
716:      * Get code of form (either GET or POST request).
717:      *
718:      * @return string escaped HTML code which sould be shown if content type is
719:      *         shown in frontend
720:      */
721:     public function buildCode() {
722:         $out = '';
723:         if (0 === cSecurity::toInteger($this->_settings['pifaform_idform'])) {
724:             // no form was selected
725:         } else if (0 === strlen(trim($this->_settings['pifaform_module']))) {
726:             // no module was selected
727:         } else {
728:             $moduleClass = trim($this->_settings['pifaform_module']);
729:             try {
730:                 $filename = Pifa::fromCamelCase($moduleClass);
731:                 $filename = "extensions/class.pifa.$filename.php";
732:                 if (false === file_exists(Pifa::getPath() . $filename)) {
733:                     $msg = sprintf(Pifa::i18n('MISSING_MODULE_FILE'), $filename);
734:                     throw new PifaException($msg);
735:                 }
736:                 plugin_include(Pifa::getName(), $filename);
737:                 if (false === class_exists($moduleClass)) {
738:                     $msg = sprintf(Pifa::i18n('MISSING_MODULE_CLASS'), $moduleClass);
739:                     throw new PifaException($msg);
740:                 }
741:                 $mod = new $moduleClass($this->_settings);
742:                 $out = $mod->render(true);
743:             } catch (Exception $e) {
744:                 Pifa::logException($e);
745:                 // log but don't display exception
746:             }
747:         }
748: 
749:         // don't encode cached code for output
750:         // $out = $this->_encodeForOutput($out);
751: 
752:         return $out;
753:     }
754: }
755: 
CMS CONTENIDO 4.9.5 API documentation generated by ApiGen 2.8.0