Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #9 from betweenbrain/develop
Browse files Browse the repository at this point in the history
Merge develop for 1.1.0 release
  • Loading branch information
betweenbrain committed Jul 7, 2015
2 parents 55cb43e + e2ba592 commit 98639a5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 9 deletions.
46 changes: 40 additions & 6 deletions emailadditionalfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,55 @@ class plgContactEmailadditionalfields extends JPlugin
*
* @since 1.0
*/
function onSubmitContact(&$contact, &$data)
public function onSubmitContact(&$contact, &$data)
{
$data['contact_message'] .= "\n";

foreach ($data as $field => $value)
{
if (!in_array($field, array('contact_name', 'contact_email', 'contact_subject', 'contact_message')))
{
$data['contact_message'] .= is_array($value) ?
"\n" . implode("\n", array_map(function ($v, $k)

if (is_array($value))
{
foreach ($value as $label => $input)
{
return ucfirst($k) . ': ' . $v;
}, $value, array_keys($value))) :
"\n" . ucfirst($field) . ': ' . $value;
$data['contact_message'] .= "\n" . $this->getLabel($label) . ': ' . $input;
}
}

if (!is_array($value))
{
$data['contact_message'] .= "\n" . $this->getLabel($field) . ': ' . $value;
}

}
}

return $data;
}

/**
* Checks if the JText translation of a dynamically generated constant has a value
*
* @param $label
*
* @return string
*
* @since 1.1.0
*/
private function getLabel($label)
{
$constant = 'PLG_CONTACT_EMAILADDITIONALFIELDS_' . strtoupper($label);

if (JText::_($constant) != $constant)
{
return JText::_('PLG_CONTACT_EMAILADDITIONALFIELDS_' . strtoupper($label));
}

if (JText::_($constant) == $constant)
{
return ucfirst($label);
}
}
}
15 changes: 12 additions & 3 deletions emailadditionalfields.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.2" type="plugin" group="contact" method="upgrade">
<extension version="3.2"
type="plugin"
group="contact"
method="upgrade">
<author>Matt Thomas</author>
<authorEmail>matt@betweenbrain.com</authorEmail>
<authorUrl>http://betweenbrain.com</authorUrl>
<copyright>(C) 2014, 2015 betweenbrain llc. All rights reserved.</copyright>
<creationDate>April 7, 2015</creationDate>
<creationDate>May 20, 2015</creationDate>
<description>PLG_CONTACT_EMAILADDITIONALFIELDS_DESC</description>
<license>GNU/GPL v2 or later</license>
<name>plg_contact_emailadditionalfields</name>
<version>1.0.2</version>
<version>1.1.0</version>

<files>
<filename plugin="emailadditionalfields">emailadditionalfields.php</filename>
<folder>language</folder>
</files>

<updateservers>
<server type="extension"
name="Email Additional Fields Updates">http://betweenbrain.com/updates/emailadditionalfields.xml
</server>
</updateservers>

</extension>

0 comments on commit 98639a5

Please sign in to comment.