Skip to content

Commit

Permalink
2016-12-25 AC: Adds the main implementation of the SEFv2's form objec…
Browse files Browse the repository at this point in the history
…t. Fixes issues #5, #6, #7 and #8.
  • Loading branch information
andrewscaya committed Dec 25, 2016
1 parent c30b815 commit 2a8f46b
Show file tree
Hide file tree
Showing 13 changed files with 2,176 additions and 101 deletions.
22 changes: 11 additions & 11 deletions language_files/fr-FR.mod_simpleemailform.ini
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
; 2010-09-13 thanks to Jean-Michel Delor
MOD_SIMPLEEMAILFORM_upload_success = "Transfert du fichier réussi."
MOD_SIMPLEEMAILFORM_upload_unable = "Impossible de transférer ce fichier."
MOD_SIMPLEEMAILFORM_upload_success = "Transfert du fichier réussi."
MOD_SIMPLEEMAILFORM_upload_unable = "Impossible de transférer ce fichier."
MOD_SIMPLEEMAILFORM_upload_failure = "Echec de transfert du fichier."
MOD_SIMPLEEMAILFORM_upload_error = "Erreur lors du transfert de fichier."
MOD_SIMPLEEMAILFORM_unable_clean_captcha = "Impossible de supprimer les anciens CAPTCHAs"
MOD_SIMPLEEMAILFORM_form_success = "Votre demande de contact a bien été enregistrée."
MOD_SIMPLEEMAILFORM_form_success = "Votre demande de contact a bien été enregistrée."
MOD_SIMPLEEMAILFORM_form_unable = "Erreur : Impossible de soumettre le formulaire."
MOD_SIMPLEEMAILFORM_form_reenter = "ATTENTION : Veuillez entrer les lettres dans le champ juste au dessus du bouton Valider."
MOD_SIMPLEEMAILFORM_email_invalid = "ATTENTION : Cette adresse email n´est pas valide ! Veuillez saisir à nouveau votre email."
MOD_SIMPLEEMAILFORM_attachment = "Pièce jointe"
MOD_SIMPLEEMAILFORM_captcha_error_gen = "Erreur de génération du CAPTCHA !"
MOD_SIMPLEEMAILFORM_email_invalid = "ATTENTION : Cette adresse email n'est pas valide ! Veuillez saisir à nouveau votre email."
MOD_SIMPLEEMAILFORM_attachment = "Pièce jointe"
MOD_SIMPLEEMAILFORM_captcha_error_gen = "Erreur de génération du CAPTCHA !"
MOD_SIMPLEEMAILFORM_captcha_error_init = "Erreur d'initialisation du CAPTCHA !"
MOD_SIMPLEEMAILFORM_captcha_please_enter = "Recopiez les caractères de l'image ci-dessous"
MOD_SIMPLEEMAILFORM_captcha_please_help = "(en vous remerciant de nous aider à lutter contre le SPAM !)"
MOD_SIMPLEEMAILFORM_captcha_please_enter = "Recopiez les caractères de l'image ci-dessous"
MOD_SIMPLEEMAILFORM_captcha_please_help = "(en vous remerciant de nous aider à lutter contre le SPAM !)"
MOD_SIMPLEEMAILFORM_click_submit = "Cliquer ici pour soumettre votre demande."
MOD_SIMPLEEMAILFORM_button_submit = "Valider"
MOD_SIMPLEEMAILFORM_button_reset = "Effacer"
MOD_SIMPLEEMAILFORM_error = "Erreur"
MOD_SIMPLEEMAILFORM_make_captcha_dir = "Répertoire de CAPTCHA recommandé à créer et utiliser"
MOD_SIMPLEEMAILFORM_make_captcha_url = "URL de CAPTCHA à utiliser"
MOD_SIMPLEEMAILFORM_make_captcha_dir = "Répertoire de CAPTCHA recommandé à créer et utiliser"
MOD_SIMPLEEMAILFORM_make_captcha_url = "URL de CAPTCHA à utiliser"
MOD_SIMPLEEMAILFORM_required_field = "Veuillez saisir une valeur pour ce champ obligatoire,"
MOD_SIMPLEEMAILFORM_disallowed_filename = "ATTENTION : Ce type de fichier n´est pas autorisé !"
MOD_SIMPLEEMAILFORM_disallowed_filename = "ATTENTION : Ce type de fichier n'est pas autorisé !"
5 changes: 3 additions & 2 deletions mod_simpleemailform.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* mod_simpleemailform.php
*
* Copyright 2010 - 2017 D. Bierer <doug@unlikelysource.com>
* Version 2.0
* Version 2.0.0
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -43,10 +43,11 @@
\JLoader::discover('sef', MOD_SIMPLEEMAILFORM_DIR . DIRECTORY_SEPARATOR . 'sef', true, true);
\JLoader::discover('sefv2', MOD_SIMPLEEMAILFORM_DIR . DIRECTORY_SEPARATOR . 'sefv2', true, true);

// Get the module helper (must be a helperfactoryinterface).
$sefv2helper = \sefv2helper::getInstance();

// Build the form and render the form's output in order to send it to the view.
$form = $sefv2helper->buildForm($params);

$view = $form->render();

require(JModuleHelper::getLayoutPath('mod_simpleemailform'));
6 changes: 3 additions & 3 deletions mod_simpleemailform.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" client="site" method="upgrade" version="2.5">
<name>Simple Email Form</name>
<author>unlikelysource.com</author>
<author>joomla.unlikelysource.org</author>
<creationDate>2014-05-21</creationDate>
<copyright>All rights reserved by unlikelysource.com (c) 2010 - 2016</copyright>
<copyright>All rights reserved by unlikelysource.com (c) 2010 - 2017</copyright>
<license>GNU General Public License version 2</license>
<authorEmail>info@unlikelysource.org</authorEmail>
<authorUrl>www.unlikelysource.com</authorUrl>
<version>1.8.9</version>
<version>2.0.0</version>
<description><![CDATA[
A simple email form from unlikelysource.com with up to 8 fields + CAPTCHA + 28 languages.
<br />Version 1.8.9 -- works on Joomla 2.x and 3.x (1.8.1-1x supports Joomla 1.x)!
Expand Down
4 changes: 3 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<!-- <directory suffix=".php">.</directory> -->
<file>helper.php</file>
<file>sefv2/helper.php</file>
<file>sefv2/modsimpleemailform.php</file>
<file>sef/modsimpleemailform.php</file>
</whitelist>
</filter>
<!-- <logging>
Expand Down
10 changes: 5 additions & 5 deletions sef/modsimpleemailform.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function __construct($params)
}

// Set email object params
$this->_msg = new _SimpleEmailForm();
$this->_msg = new sefv2simpleemailformemailmsg();
$this->_msg->dir = $params->get('mod_simpleemailform_emailFile');
$this->_msg->subject = $params->get('mod_simpleemailform_subjectline');
$this->_msg->copyMe = 0; // NOTE: depends on what user selects
Expand All @@ -259,7 +259,7 @@ public function __construct($params)
if ($bcc) {
$this->_msg->bcc = (preg_match('/[\s,]+/', $bcc)) ? preg_split('/[\s,]+/', $bcc) : array($bcc);
}
// 2012-2-7 DB: add optional Reply-To field
// 2012-02-07 DB: add optional Reply-To field
$this->_msg->replyToActive = $params->get('mod_simpleemailform_replytoActive');
if ($this->_msg->replyToActive == 'Y') {
// 2016-04-18 DB: replyTo no longer needs to be an array
Expand Down Expand Up @@ -561,7 +561,7 @@ protected function padVisible($visible)
return '&nbsp;&nbsp;' . $visible . '&nbsp;&nbsp;';
}

public function sendResults(_SimpleEmailForm &$msg, $field)
public function sendResults(sefv2simpleemailformemailmsg &$msg, $field)
{
// 2012-02-15 db: override unwanted error messages originating from JMail
ob_start();
Expand Down Expand Up @@ -1144,8 +1144,8 @@ public function main()
$this->_output .= (strlen($this->_anchor) > 1) ? "<a name='" . substr($this->_anchor, 1) . "'>&nbsp;</a>\n" : '';
$this->_output .= "<form method='post' "
. "action='" . $this->_anchor . "' "
. "name='_SimpleEmailForm_" . $this->_instance . "' "
. "id='_SimpleEmailForm_" . $this->_instance . "' "
. "name='mod_simpleemailform_" . $this->_instance . "' "
. "id='mod_simpleemailform_" . $this->_instance . "' "
. "enctype='multipart/form-data'>\n";
$this->_output .= "<table class='" . $this->_tableClass . "'>\n";
// 2010-11-28 DB: all fields are now included in $this->_field[]
Expand Down
15 changes: 11 additions & 4 deletions sefv2/formfactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,24 @@ class sefv2formfactory implements sefv2formfactoryinterface
*/
public function createSefv2FormObject(\Joomla\Registry\Registry $params)
{
$jForm = \JForm::getInstance();
$jMail = JFactory::getMailer();

$jMail = \JMail::getInstance();
$emailMsg = new sefv2simpleemailformemailmsg();

$jDocument = \JFactory::getDocument();

$jLanguage = \JFactory::getLanguage();

$jInput = \JFactory::getApplication()->input;

return new sefv2modsimpleemailform(
$jForm,
new \JForm('simpleemailform'),
$jMail,
$emailMsg,
$jDocument,
$params
$jLanguage,
$params,
$jInput
);
}
}
13 changes: 9 additions & 4 deletions sefv2/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* helper.php
*
* Copyright 2010 - 2017 D. Bierer <doug@unlikelysource.com>
* Version 2.0
* Version 2.0.0
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -27,8 +27,6 @@
* @license GNU/GPLv2, see above
*/

require_once __DIR__ . DIRECTORY_SEPARATOR . '_SimpleEmailForm.php';

class sefv2helper implements sefv2helperfactoryinterface
{
private static $instance = null;
Expand All @@ -37,10 +35,18 @@ private function __construct()
{
}

/**
* @codeCoverageIgnoreStart
*/

private function __clone()
{
}

/**
* @codeCoverageIgnoreEnd
*/

public static function getInstance()
{
if (static::$instance == null) {
Expand All @@ -50,7 +56,6 @@ public static function getInstance()
return static::$instance;
}

// @TODO Create object abstraction (DIP) with appropriate interface(s)
public function buildForm(\Joomla\Registry\Registry $params)
{
if ($params->get('mod_simpleemailform_formType') === 'jform') {
Expand Down
18 changes: 9 additions & 9 deletions sefv2/jformproxyinterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

interface sefv2jformproxyinterface
{
public function bind();
public function bind($data);

public function filter();
public function filter(array $data, $group = null);

public function getData();

public function getField();
public function getField($name, $group = null, $value = null);

public function addField();
public function removeField($name, $group = null);

public function removeField();
public function getErrors();

public function getFieldset();
public function getFieldset($set);

public function load();
public function load($xmlConfigString);

public function reset();
public function reset($xml = false);

public function validate();
public function validate(array $data, $group = null);
}
Loading

0 comments on commit 2a8f46b

Please sign in to comment.