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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

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