Added string manipulation back as a field building method, to insure JCB always works well accross shared server invironments. We did not remove the SimpleXMLElement method, but kept both options with a global selection option and internal error handeling. Resolved gh-197

This commit is contained in:
2018-03-18 06:28:54 +02:00
parent e715fa1614
commit 42ae72d97e
42 changed files with 15004 additions and 11887 deletions

View File

@@ -428,6 +428,16 @@ class Get
*/
private $_fieldData = array();
/**
* The field builder type
*
* 1 = StringManipulation
* 2 = SimpleXMLElement
*
* @var int
*/
public $fieldBuilderType;
/**
* Set unique Names
*
@@ -610,6 +620,16 @@ class Get
$this->tidy = extension_loaded('Tidy');
// Set the params
$this->params = JComponentHelper::getParams('com_componentbuilder');
// set the field type builder
$this->fieldBuilderType = $this->params->get('compiler_field_builder_type', 2);
// check the field builder type logic
if (!$this->tidy && $this->fieldBuilderType == 2)
{
// we do not have the tidy extention set fall back to StringManipulation
$this->fieldBuilderType = 1;
// load the sugestion to use string manipulation
$this->app->enqueueMessage(JText::_('Since you do not have <b>Tidy</b> extentsion setup on your system, we could not use the SimpleXMLElement class. We instead used <b>string manipulation</b> to build all your fields, this is a faster method, you must inspect the xml files in your component package to see if you are satisfied with the result.<br />You can make this method your default by opening the global options of JCB and under the <b>Global</b> tab set the <b>Field Builder Type</b> to string manipulation.<hr />'), 'Notice');
}
// load the compiler path
$this->compilerPath = $this->params->get('compiler_folder_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler');
// set the component ID

File diff suppressed because it is too large Load Diff

View File

@@ -12902,13 +12902,23 @@ class Interpretation extends Fields
$dbkey = 'g';
foreach ($this->componentData->config as $field)
{
$newxmlField = $this->setDynamicField($field, $view, $viewType, $lang, $viewName, $listViewName, $placeholders, $dbkey, false);
// tmp hack untill this whole area is also done in xml (TODO)
if (isset($newxmlField->fieldXML))
// check the field builder type
if ($this->fieldBuilderType == 1)
{
$xmlField = dom_import_simplexml($newxmlField->fieldXML);
$xmlField = PHP_EOL . "\t<!-- " . $newxmlField->comment . ' -->' . PHP_EOL . "\t" . $this->xmlPrettyPrint($xmlField, 'field');
// string manipulation
$xmlField = $this->setDynamicField($field, $view, $viewType, $lang, $viewName, $listViewName, $placeholders, $dbkey, false);
}
else
{
// simpleXMLElement class
$newxmlField = $this->setDynamicField($field, $view, $viewType, $lang, $viewName, $listViewName, $placeholders, $dbkey, false);
if (isset($newxmlField->fieldXML))
{
$xmlField = dom_import_simplexml($newxmlField->fieldXML);
$xmlField = PHP_EOL . "\t<!-- " . $newxmlField->comment . ' -->' . PHP_EOL . "\t" . $this->xmlPrettyPrint($xmlField, 'field');
}
}
// make sure the xml is set and a string
if (isset($xmlField) && ComponentbuilderHelper::checkString($xmlField))
{
$this->configFieldSetsCustomField[$field['tabname']][] = $xmlField;
@@ -13097,7 +13107,7 @@ class Interpretation extends Fields
}
}
// set the fields
$this->configFieldSets[] = implode("\t\t", $bucket);
$this->configFieldSets[] = implode("", $bucket);
// close field set
$this->configFieldSets[] = "\t</fieldset>";
// remove after loading
@@ -13135,7 +13145,7 @@ class Interpretation extends Fields
// add custom Target Groups fields
if (isset($this->configFieldSetsCustomField['Target Groups']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Target Groups']))
{
$this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Target Groups']);
$this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Target Groups']);
unset($this->configFieldSetsCustomField['Target Groups']);
}
// close that fieldse
@@ -13261,7 +13271,7 @@ class Interpretation extends Fields
// add custom global fields
if (isset($this->configFieldSetsCustomField['Global']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Global']))
{
$this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Global']);
$this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Global']);
unset($this->configFieldSetsCustomField['Global']);
}
// set the author details
@@ -13619,7 +13629,7 @@ for developing fast and powerful web interfaces. For more info visit <a href=\"h
// add custom Uikit Settings fields
if (isset($this->configFieldSetsCustomField['Uikit Settings']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Uikit Settings']))
{
$this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Uikit Settings']);
$this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Uikit Settings']);
unset($this->configFieldSetsCustomField['Uikit Settings']);
}
// close that fieldset
@@ -13643,7 +13653,7 @@ for developing fast and powerful web interfaces. For more info visit <a href=\"h
// add custom Mail Configurations
if (isset($this->configFieldSetsCustomField['Mail Configuration']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Mail Configuration']))
{
$this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Mail Configuration']);
$this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Mail Configuration']);
unset($this->configFieldSetsCustomField['Mail Configuration']);
}
else
@@ -13905,7 +13915,7 @@ for developing fast and powerful web interfaces. For more info visit <a href=\"h
// add custom DKIM fields
if (isset($this->configFieldSetsCustomField['DKIM']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['DKIM']))
{
$this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['DKIM']);
$this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['DKIM']);
unset($this->configFieldSetsCustomField['DKIM']);
}
else
@@ -14339,7 +14349,7 @@ function vdm_dkim() {
// add custom Encryption Settings fields
if (isset($this->configFieldSetsCustomField['Chart Settings']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Chart Settings']))
{
$this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Chart Settings']);
$this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Chart Settings']);
unset($this->configFieldSetsCustomField['Chart Settings']);
}
@@ -14540,7 +14550,7 @@ function vdm_dkim() {
// add custom Encryption Settings fields
if (isset($this->configFieldSetsCustomField[$dynamicAddField]) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField[$dynamicAddField]))
{
$this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField[$dynamicAddField]);
$this->configFieldSets[] = implode("", $this->configFieldSetsCustomField[$dynamicAddField]);
unset($this->configFieldSetsCustomField[$dynamicAddField]);
}
}

View File

@@ -1554,16 +1554,19 @@ abstract class ComponentbuilderHelper
}
/**
* get the localkey
* the basic localkey
**/
protected static $localkey = false;
/**
* get the localkey
**/
public static function getLocalKey()
{
if (!self::$localkey)
{
// get the main key
self::$localkey = md5(JComponentHelper::getParams('com_componentbuilder')->get('basic_key', 'localKey34fdWEkl'));
// get the basic key
self::$localkey = md5(self::getCryptKey('basic', 'localKey34fdWEkl'));
}
return self::$localkey;
}
@@ -1636,8 +1639,18 @@ abstract class ComponentbuilderHelper
}
return false;
}
public static function getBetween($content,$start,$end)
/**
* get between
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
*
* @return string On success / empty string on failure
*
*/
public static function getBetween($content, $start, $end)
{
$r = explode($start, $content);
if (isset($r[1]))
@@ -1647,17 +1660,32 @@ abstract class ComponentbuilderHelper
}
return '';
}
public static function getAllBetween($content,$start,$end)
/**
* get all between
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
*
* @return array On success
*
*/
public static function getAllBetween($content, $start, $end)
{
$buket = array();
// reset bucket
$bucket = array();
for ($i = 0; ; $i++)
{
// search for string
$found = self::getBetween($content,$start,$end);
if (self::checkString($found))
{
$buket[] = $found;
// add to bucket
$bucket[] = $found;
// build removal string
$remove = $start.$found.$end;
// remove from content
$content = str_replace($remove,'',$content);
}
else
@@ -1670,9 +1698,10 @@ abstract class ComponentbuilderHelper
break;
}
}
return array_unique($buket);
// only return unique array of values
return array_unique($bucket);
}
public static function typeField($type,$option = 'default')
{
// list of default fields
@@ -2494,6 +2523,7 @@ abstract class ComponentbuilderHelper
// return the object
return self::$CRYPT[$TYPE];
}
/**
* Load the Component xml manifest.
**/