*/ class LSformElement_mail extends LSformElement_text { var $JSscripts = array( 'LSformElement_mail.js' ); var $fetchVariables = array( 'additionalCssClass' => array('LSformElement_mail'), 'uriPrefix' => 'mailto:' ); var $fieldTemplate = 'LSformElement_uri_field.tpl'; // Flag to trigger warning about old Autocomplete config style // (detect in constructor and show on getDisplay()) private $warnOldAutocompleteConfigStyle = false; /** * Constructor * * @author Benjamin Renard * * @param LSform &$form The LSform parent object * @param string $name The name of the element * @param string $label The label of the element * @param array $params The parameters of the element * @param LSattr_html &$attr_html The LSattr_html object of the corresponding attribute * * @return void */ public function __construct(&$form, $name, $label, $params, &$attr_html){ parent::__construct($form, $name, $label, $params, $attr_html); // Handle autocomplete retro-compatibility & default value attributes if ($this -> getParam('html_options.autocomplete')) { $mail_attributes = $this -> getParam('html_options.autocomplete.mail_attributes'); if ($mail_attributes) { $this -> params['html_options']['autocomplete']['value_attributes'] = $mail_attributes; $this -> warnOldAutocompleteConfigStyle = true; } elseif (!$this -> getParam('html_options.autocomplete.value_attributes')) { if (!is_array($this -> params['html_options']['autocomplete'])) $this -> params['html_options']['autocomplete'] = array(); $this -> params['html_options']['autocomplete']['value_attributes'] = array('mail'); $this -> warnOldAutocompleteConfigStyle = true; } } } public function getDisplay() { LStemplate :: addHelpInfo( 'LSformElement_mail', array( 'mail' => _("Send a mail from here.") ) ); if (LSsession :: loadLSclass('LSmail')) { LSmail :: loadDependenciesDisplay(); } if ($this -> warnOldAutocompleteConfigStyle) LSerror :: addErrorCode('LSformElement_mail_01'); return parent :: getDisplay(); } /** * Return HTML code of the LSformElement based on its (smarty) template file * * @param string $template The template filename (optional, default: $this -> template) * @param array $variables Array of template variables to assign before template compilation (optional) * * @return string HTML code of the LSformElement */ public function fetchTemplate($template=NULL,$variables=array()) { if ($this -> getParam('html_options.disableMailSending', false, 'bool')) { $this -> fetchVariables['additionalCssClass'][] = " LSformElement_mail_disableMailSending"; } return parent :: fetchTemplate($template,$variables); } } /** * Error Codes **/ LSerror :: defineError('LSformElement_mail_01', ___("LSformElement_mail: the autocomplete feature was moved to parent LSformElement_text class and you still use old configuration style with parameter mail_attributes (and its default value). Please upgrade your configuration by renaming (or setting) this parameter to value_attributes.") );