Resolved gh-360 by adding the blob data type as an option for data types. Resolved gh-362 by adding the nested subform compatibility to subforms in JCB. Resolved gh-365 by improving the customscript validation search of save of custom code area. Added email validation to the email helper script.

This commit is contained in:
2019-01-14 17:32:23 +02:00
parent b7a5cb7285
commit 4e2c51c303
14 changed files with 310 additions and 33 deletions

View File

@@ -1427,18 +1427,18 @@ class Fields extends Structure
elseif ($typeName === 'subform')
{
// now add to the field set
$field .= PHP_EOL . $this->_t(2) . "<!--" . $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla) -->";
$field .= PHP_EOL . $this->_t(2) . "<field";
$field .= PHP_EOL . $this->_t(2) . $taber . "<!--" . $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla) -->";
$field .= PHP_EOL . $this->_t(2) . $taber . "<field";
$fieldsSet = array();
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'fields')
{
$field .= PHP_EOL . $this->_t(3) . $property . '="' . $value . '"';
$field .= PHP_EOL . $this->_t(3) . $taber . $property . '="' . $value . '"';
}
}
$field .= ">";
$field .= PHP_EOL . $this->_t(3) . '<form hidden="true" name="list_' . $fieldAttributes['name'] . '_modal" repeat="true">';
$field .= PHP_EOL . $this->_t(3) . $taber . '<form hidden="true" name="list_' . $fieldAttributes['name'] . '_modal" repeat="true">';
if (strpos($fieldAttributes['fields'], ',') !== false)
{
// mulitpal fields
@@ -1475,7 +1475,7 @@ class Fields extends Structure
$r_multiple = false;
$r_langLabel = '';
// add the tabs needed
$r_taber = $this->_t(2);
$r_taber = $this->_t(2) . $taber;
// get field values
$r_fieldValues = $this->setFieldAttributes($fieldData, $view, $r_name, $r_typeName, $r_multiple, $r_langLabel, $langView, $view_name_list, $view_name_single, $placeholders, true);
// check if values were set
@@ -1493,6 +1493,24 @@ class Fields extends Structure
// now add to the field set
$field .= $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
}
elseif ($r_typeName === 'subform')
{
// set nested depth
if (isset($fieldAttributes['nested_depth']))
{
$r_fieldValues['nested_depth'] = ++$fieldAttributes['nested_depth'];
}
else
{
$r_fieldValues['nested_depth'] = 1;
}
// only continue if nest is bellow 20 (this should be a safe limit)
if ($r_fieldValues['nested_depth'] <= 20)
{
// now add to the field set
$field .= $this->setField('special', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
}
}
elseif (ComponentbuilderHelper::checkArray($r_fieldValues['custom']))
{
// add to custom
@@ -1518,8 +1536,8 @@ class Fields extends Structure
}
}
}
$field .= PHP_EOL . $this->_t(3) . "</form>";
$field .= PHP_EOL . $this->_t(2) . "</field>";
$field .= PHP_EOL . $this->_t(3) . $taber . "</form>";
$field .= PHP_EOL . $this->_t(2) . $taber . "</field>";
}
}
elseif ($setType === 'custom')
@@ -1862,6 +1880,25 @@ class Fields extends Structure
// now add to the field set
ComponentbuilderHelper::xmlAppend($form, $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray));
}
elseif ($r_typeName === 'subform')
{
// set nested depth
if (isset($fieldAttributes['nested_depth']))
{
$r_fieldValues['nested_depth'] = ++$fieldAttributes['nested_depth'];
}
else
{
$r_fieldValues['nested_depth'] = 1;
}
// only continue if nest is bellow 20 (this should be a safe limit)
if ($r_fieldValues['nested_depth'] <= 20)
{
// now add to the field set
ComponentbuilderHelper::xmlAppend($form, $this->setField('special', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray));
}
}
elseif (ComponentbuilderHelper::checkArray($r_fieldValues['custom']))
{
// add to custom

View File

@@ -614,7 +614,7 @@ class Interpretation extends Fields
}
// give notice of this issue
$this->app->enqueueMessage(JText::_('<hr /><h3>WHMCS Error</h3>'), 'Error');
$this->app->enqueueMessage(JText::sprintf('The <b>WHMCS class</b> could not be added to this component. You will need to enable the add-on in the Joomla Component area (Add WHMCS)->Yes.', $this->libraries[$id]->name), 'Error');
$this->app->enqueueMessage(JText::sprintf('The <b>WHMCS class</b> could not be added to this component. You will need to enable the add-on in the Joomla Component area (Add WHMCS)->Yes. If you have done this, then please check that you have your own <b>Basic Encryption<b/> set in the global settings of JCB. Then open and save this component again, making sure that your WHMCS settings are still correct.', $this->libraries[$id]->name), 'Error');
return "//" . $this->setLine(__LINE__) . " The WHMCS class could not be added to this component." . PHP_EOL . "//" . $this->setLine(__LINE__) . " Please note that you will need to enable the add-on in the Joomla Component area (Add WHMCS)->Yes.";
}

View File

@@ -1354,9 +1354,15 @@ abstract class ComponentbuilderHelper
{
$it = new RecursiveDirectoryIterator($dir);
$it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
// remove ending /
$dir = rtrim($dir, '/');
// now loop the files & folders
foreach ($it as $file)
{
if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue;
// set file dir
$file_dir = $file->getPathname();
// check if this is a dir or a file
if ($file->isDir())
{
$keeper = false;
@@ -1364,7 +1370,7 @@ abstract class ComponentbuilderHelper
{
foreach ($ignore as $keep)
{
if (strpos($file->getPathname(), $dir.'/'.$keep) !== false)
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
@@ -1374,7 +1380,7 @@ abstract class ComponentbuilderHelper
{
continue;
}
JFolder::delete($file->getPathname());
JFolder::delete($file_dir);
}
else
{
@@ -1383,7 +1389,7 @@ abstract class ComponentbuilderHelper
{
foreach ($ignore as $keep)
{
if (strpos($file->getPathname(), $dir.'/'.$keep) !== false)
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
@@ -1393,9 +1399,10 @@ abstract class ComponentbuilderHelper
{
continue;
}
JFile::delete($file->getPathname());
JFile::delete($file_dir);
}
}
// delete the root folder if not ignore found
if (!self::checkArray($ignore))
{
return JFolder::delete($dir);

View File

@@ -14,6 +14,13 @@
*/
abstract class ComponentbuilderEmail
{
/**
* The active recipient
*
* @var activeRecipient (array)
*/
public static $active = array();
/**
* Configuraiton object
*
@@ -49,6 +56,44 @@ abstract class ComponentbuilderEmail
return self::$config;
}
/**
* Returns the global mailer object, only creating it if it doesn't already exist.
*
*/
public static function getMailerInstance()
{
if (!self::$mailer)
{
self::$mailer = self::createMailer();
}
return self::$mailer;
}
/**
* Check that a string looks like an email address.
* @param string $address The email address to check
* @param string|callable $patternselect A selector for the validation pattern to use :
* * `auto` Pick best pattern automatically;
* * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
* * `pcre` Use old PCRE implementation;
* * `php` Use PHP built-in FILTER_VALIDATE_EMAIL;
* * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
* * `noregex` Don't use a regex: super fast, really dumb.
* Alternatively you may pass in a callable to inject your own validator, for example:
* PHPMailer::validateAddress('user@example.com', function($address) {
* return (strpos($address, '@') !== false);
* });
* You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator.
* @return boolean
* @static
* @access public
*/
public static function validateAddress($address, $patternselect = null)
{
return self::getMailerInstance()->validateAddress($address, $patternselect);
}
/**
* Get a mailer object.
*
@@ -277,13 +322,70 @@ abstract class ComponentbuilderEmail
if (method_exists('ComponentbuilderHelper','storeMessage'))
{
// store the massage if the method is set
ComponentbuilderHelper::storeMessage($sendmail, $recipient, $subject, $body, $textonly, $mode, 'email');
// if we have active recipient details
if (isset(self::$active[$recipient]))
{
// store the massage if the method is set
ComponentbuilderHelper::storeMessage($sendmail, self::$active[$recipient], $subject, $body, $textonly, $mode, 'email');
// clear memory
unset(self::$active[$recipient]);
}
else
{
// store the massage if the method is set
ComponentbuilderHelper::storeMessage($sendmail, $recipient, $subject, $body, $textonly, $mode, 'email');
}
}
return $sendmail;
}
/**
* Set html text (in a row) and subject (as title) to a email table.
* do not use <p> instead use <br />
* in your html that you pass to this method
* since it is a table row it does not
* work well with paragraphs
*
* @return string on success
*
*/
public static function setBasicBody($html, $subject)
{
$body = array();
$body[] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
$body[] = "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
$body[] = "<head>";
$body[] = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
$body[] = "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>";
$body[] = "<title>" . $subject . "</title>";
$body[] = "<style type=\"text/css\">";
$body[] = "#outlook a {padding:0;}";
$body[] = ".ExternalClass {width:100%;}";
$body[] = ".ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;} ";
$body[] = "p {margin: 0; padding: 0; font-size: 0px; line-height: 0px;} ";
$body[] = "table td {border-collapse: collapse;}";
$body[] = "table {border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; }";
$body[] = "img {display: block; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic;}";
$body[] = "a img {border: none;}";
$body[] = "a {text-decoration: none; color: #000001;}";
$body[] = "a.phone {text-decoration: none; color: #000001 !important; pointer-events: auto; cursor: default;}";
$body[] = "span {font-size: 13px; line-height: 17px; font-family: monospace; color: #000001;}";
$body[] = "</style>";
$body[] = "<!--[if gte mso 9]>";
$body[] = "<style>";
$body[] = "/* Target Outlook 2007 and 2010 */";
$body[] = "</style>";
$body[] = "<![endif]-->";
$body[] = "</head>";
$body[] = "<body style=\"width:100%; margin:0; padding:0; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%;\">";
$body[] = $html;
$body[] = "</body>";
$body[] = "</html>";
return implode("\n", $body);
}
/**
* Set html text (in a row) and subject (as title) to a email table.
* do not use <p> instead use <br />