Added the email field type to resolve gh-283. Fixed the CSS inclution error to resolve gh-278. Added the option to add sql_uninstall dump value to a component. Did some class formating on the compiler.

This commit is contained in:
2018-05-11 06:08:14 +02:00
parent 476a0c525a
commit e04db1b5b2
51 changed files with 3782 additions and 3640 deletions

View File

@ -11,7 +11,7 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.6.x
@version 2.7.x
@created 30th April, 2015
@package Component Builder
@subpackage compiler.php

View File

@ -11,7 +11,7 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.6.x
@version 2.7.x
@created 30th April, 2015
@package Component Builder
@subpackage compiler.php
@ -947,7 +947,8 @@ class Get
// build the admin_views settings
$component->admin_views = array_map(function($array)
{
$array = array_map(function($value) {
$array = array_map(function($value)
{
if (!ComponentbuilderHelper::checkArray($value) && !ComponentbuilderHelper::checkObject($value) && strval($value) === strval(intval($value)))
{
return (int) $value;
@ -1213,6 +1214,12 @@ class Get
$this->customScriptBuilder['sql']['component_sql'] = base64_decode($component->sql);
}
unset($component->sql);
// add_sql_uninstall
if ($component->add_sql_uninstall == 1)
{
$this->customScriptBuilder['sql_uninstall'] = base64_decode($component->sql_uninstall);
}
unset($component->sql_uninstall);
// bom
if (ComponentbuilderHelper::checkString($component->bom))
{
@ -1783,27 +1790,28 @@ class Get
}
}
// activate alias builder
if (!isset($this->customAliasBuilder[$name_single]) && isset($view->alias_builder_type) && 2 == $view->alias_builder_type
&& isset($view->alias_builder) && ComponentbuilderHelper::checkJson($view->alias_builder))
if (!isset($this->customAliasBuilder[$name_single]) && isset($view->alias_builder_type) && 2 == $view->alias_builder_type && isset($view->alias_builder) && ComponentbuilderHelper::checkJson($view->alias_builder))
{
// get the aliasFields
$alias_fields = (array) json_decode($view->alias_builder, true);
// get the active fields
$alias_fields = (array) array_filter($view->fields, function($field) use($alias_fields) {
// check if field is in view fields
if (in_array($field['field'], $alias_fields))
$alias_fields = (array) array_filter($view->fields, function($field) use($alias_fields)
{
return true;
}
return false;
});
// check if field is in view fields
if (in_array($field['field'], $alias_fields))
{
return true;
}
return false;
});
// check if all is well
if (ComponentbuilderHelper::checkArray($alias_fields))
{
// load the field names
$this->customAliasBuilder[$name_single] = (array) array_map(function ($field) use($name_list) {
$this->customAliasBuilder[$name_single] = (array) array_map(function ($field) use($name_list)
{
return $this->getFieldName($field, $name_list);
},$alias_fields
}, $alias_fields
);
}
}
@ -2167,7 +2175,7 @@ class Get
if (!in_array($validationRule, (array) $coreValidationRules))
{
// get the class methods for this rule if it exists
if ($this->validationRules[$validationRule] = ComponentbuilderHelper::getVar('validation_rule', $validationRule, 'name','php'))
if ($this->validationRules[$validationRule] = ComponentbuilderHelper::getVar('validation_rule', $validationRule, 'name', 'php'))
{
// open and set the validation rule
$this->validationRules[$validationRule] = $this->setDynamicValues(base64_decode($this->validationRules[$validationRule]));
@ -5497,13 +5505,13 @@ class Get
// get targets to search for
$langStringTargets = array_filter(
$this->langStringTargets, function($get) use($string)
{
if (strpos($string, $get) !== false)
{
if (strpos($string, $get) !== false)
{
return true;
}
return false;
});
return true;
}
return false;
});
// check if we should continue
if (ComponentbuilderHelper::checkArray($langStringTargets))
{
@ -5745,31 +5753,31 @@ class Get
public function bcmath($type, $val1, $val2)
{
// build function name
$function = 'bc'.$type;
$function = 'bc' . $type;
// use the bcmath function of available
if (function_exists($function))
{
return $function($val1, $val2);
}
// if function does not exist we use +-*/ operators (since it realy not that serious)
switch($type)
switch ($type)
{
// Multiply two numbers
case 'mul':
return round($val1 * $val2);
break;
break;
// Divide of two numbers
case 'div':
return round($val1 / $val2);
break;
break;
// Adding two numbers
case 'add':
return round($val1 + $val2);
break;
break;
// Subtract one number from the other
case 'add':
return round($val1 - $val2);
break;
break;
}
return false;
}

View File

@ -11,7 +11,7 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.6.x
@version 2.7.x
@created 30th April, 2015
@package Component Builder
@subpackage compiler.php

View File

@ -11,7 +11,7 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.6.x
@version 2.7.x
@created 30th April, 2015
@package Component Builder
@subpackage compiler.php
@ -2179,7 +2179,7 @@ class Fields extends Structure
// dont load the button to repeatable
$xmlValue = (string) ComponentbuilderHelper::safeString(ComponentbuilderHelper::getBetween($field['settings']->xml, 'button="', '"'));
// add to custom values
$fieldAttributes['custom']['add_button'] = (ComponentbuilderHelper::checkString($xmlValue) || 1 == $xmlValue) ? $xmlValue: 'false';
$fieldAttributes['custom']['add_button'] = (ComponentbuilderHelper::checkString($xmlValue) || 1 == $xmlValue) ? $xmlValue : 'false';
}
elseif ($property['name'] === 'required' && $repeatable)
{
@ -2829,7 +2829,7 @@ class Fields extends Structure
if (isset($fieldData['add_button']) && ($fieldData['add_button'] === 'true' || 1 == $fieldData['add_button']) &&
isset($fieldData['view']) && isset($fieldData['views']) &&
ComponentbuilderHelper::checkString($fieldData['view']) && ComponentbuilderHelper::checkString($fieldData['views']))
{
{
// check that the component value is set
if (!isset($fieldData['component']) || !ComponentbuilderHelper::checkString($fieldData['component']))
{
@ -2841,7 +2841,7 @@ class Fields extends Structure
$fieldData['component'] = "com_" . $fieldData['component'];
}
// make sure the component is update if ### or [[[ component placeholder is used
if (strpos($fieldData['component'], '###') !== false || strpos($fieldData['component'], '[[[') !== false ) // should not be needed... but
if (strpos($fieldData['component'], '###') !== false || strpos($fieldData['component'], '[[[') !== false) // should not be needed... but
{
$fieldData['component'] = $this->setPlaceholders($fieldData['component'], $this->placeholders);
}
@ -2923,7 +2923,7 @@ class Fields extends Structure
$addButton[] = "\t\t\t}";
}
$addButton[] = "\t\t\t\$user = JFactory::getUser();";
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " only add if user allowed to create " . $fieldData['view'];
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " only add if user allowed to create " . $fieldData['view'];
// check if the item has permissions.
if ($coreLoad && isset($core['core.create']) && isset($this->permissionBuilder['global'][$core['core.create']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.create']]) && in_array($fieldData['view'], $this->permissionBuilder['global'][$core['core.create']]))
{

View File

@ -11,7 +11,7 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.6.x
@version 2.7.x
@created 30th April, 2015
@package Component Builder
@subpackage compiler.php
@ -1270,7 +1270,7 @@ class Interpretation extends Fields
$method[] = "\t\t\$lang = JFactory::getLanguage();";
$method[] = "\t\t\$extension = 'com_users';";
$method[] = "\t\t\$base_dir = JPATH_SITE;";
$method[] = "\t\t\$language_tag = '".$this->langTag."';";
$method[] = "\t\t\$language_tag = '" . $this->langTag . "';";
$method[] = "\t\t\$reload = true;";
$method[] = "\t\t\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);";
$method[] = "\t\t//" . $this->setLine(__LINE__) . " load the user regestration model";
@ -1351,7 +1351,7 @@ class Interpretation extends Fields
$method[] = "\t\t\$lang = JFactory::getLanguage();";
$method[] = "\t\t\$extension = 'com_users';";
$method[] = "\t\t\$base_dir = JPATH_ADMINISTRATOR;";
$method[] = "\t\t\$language_tag = '".$this->langTag."';";
$method[] = "\t\t\$language_tag = '" . $this->langTag . "';";
$method[] = "\t\t\$reload = true;";
$method[] = "\t\t\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);";
$method[] = "\t\t// load the user model";
@ -5472,7 +5472,7 @@ class Interpretation extends Fields
elseif (!$category && !$alias && ($title && count($titles) == 1 && !in_array('user', $titles) && !in_array('jobnumber', $titles))) // TODO [jobnumber] just for one project (not ideal)
{
$batchcopy[] = PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Only for strings";
$batchcopy[] = "\t\t\tif (" . $Helper . "::checkString(\$this->table->" . implode('', $titles). ") && !is_numeric(\$this->table->" . implode('', $titles) . "))";
$batchcopy[] = "\t\t\tif (" . $Helper . "::checkString(\$this->table->" . implode('', $titles) . ") && !is_numeric(\$this->table->" . implode('', $titles) . "))";
$batchcopy[] = "\t\t\t{";
$batchcopy[] = "\t\t\t\t\$this->table->" . implode('', $titles) . " = \$this->generateUniqe('" . implode('', $titles) . "',\$this->table->" . implode('', $titles) . ");";
$batchcopy[] = "\t\t\t}";
@ -5546,7 +5546,7 @@ class Interpretation extends Fields
{
$fixUniqe = array();
// only load this if these two items are set
if (array_key_exists($viewName_single, $this->aliasBuilder) &&
if (array_key_exists($viewName_single, $this->aliasBuilder) &&
(array_key_exists($viewName_single, $this->titleBuilder) || isset($this->customAliasBuilder[$viewName_single])))
{
// set needed defaults
@ -5572,7 +5572,7 @@ class Interpretation extends Fields
$titles = array($this->titleBuilder[$viewName_single]);
}
// start building the fix
$fixUniqe[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Alter the " . implode(', ',$titles) . " for save as copy";
$fixUniqe[] = PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Alter the " . implode(', ', $titles) . " for save as copy";
$fixUniqe[] = "\t\tif (\$input->get('task') === 'save2copy')";
$fixUniqe[] = "\t\t{";
$fixUniqe[] = "\t\t\t\$origTable = clone \$this->getTable();";
@ -5594,15 +5594,15 @@ class Interpretation extends Fields
$fixUniqe[] = "\t\t\t{";
if ($setCategory && count($titles) == 1)
{
$fixUniqe[] = "\t\t\t\tlist(" . implode('',$titleVars) . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" . $category . "'], \$data['" . $alias . "'], " . implode('',$titleData) . ");";
$fixUniqe[] = "\t\t\t\tlist(" . implode('', $titleVars) . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" . $category . "'], \$data['" . $alias . "'], " . implode('', $titleData) . ");";
}
elseif (count($titles) == 1)
{
$fixUniqe[] = "\t\t\t\tlist(" . implode(', ',$titleVars) . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" . $alias . "'], " . implode('',$titleData) . ");";
$fixUniqe[] = "\t\t\t\tlist(" . implode(', ', $titleVars) . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" . $alias . "'], " . implode('', $titleData) . ");";
}
else
{
$fixUniqe[] = "\t\t\t\tlist(" . implode(', ',$titleVars) . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" . $alias . "'], array(" . implode(', ',$titleData) . "));";
$fixUniqe[] = "\t\t\t\tlist(" . implode(', ', $titleVars) . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" . $alias . "'], array(" . implode(', ', $titleData) . "));";
}
$fixUniqe[] = implode("\n", $titleUpdate);
$fixUniqe[] = "\t\t\t\t\$data['" . $alias . "'] = \$" . $alias . ";";
@ -5627,7 +5627,7 @@ class Interpretation extends Fields
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = "\t\t\t\telse";
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\t\$data['" . $alias . "'] = JFilterOutput::stringURLSafe(". implode(' . " " . ', $titleData) .");";
$fixUniqe[] = "\t\t\t\t\t\$data['" . $alias . "'] = JFilterOutput::stringURLSafe(" . implode(' . " " . ', $titleData) . ");";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = PHP_EOL . "\t\t\t\t\$table = JTable::getInstance('" . $viewName_single . "', '" . $this->fileContentStatic['###component###'] . "Table');";
if ($setCategory && count($titles) == 1)
@ -5636,7 +5636,7 @@ class Interpretation extends Fields
$fixUniqe[] = "\t\t\t\t{";
$fixUniqe[] = "\t\t\t\t\t\$msg = JText:" . ":_('COM_" . $this->fileContentStatic['###COMPONENT###'] . "_" . $VIEW . "_SAVE_WARNING');";
$fixUniqe[] = "\t\t\t\t}";
$fixUniqe[] = PHP_EOL . "\t\t\t\tlist(" . implode('',$titleVars) . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" . $category . "'], \$data['" . $alias . "'], " . implode('',$titleData) . ");";
$fixUniqe[] = PHP_EOL . "\t\t\t\tlist(" . implode('', $titleVars) . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" . $category . "'], \$data['" . $alias . "'], " . implode('', $titleData) . ");";
$fixUniqe[] = "\t\t\t\t\$data['" . $alias . "'] = \$" . $alias . ";";
}
else
@ -5675,7 +5675,7 @@ class Interpretation extends Fields
public function setGenerateNewTitle($viewName_single)
{
// if category is added to this view then do nothing
if (array_key_exists($viewName_single, $this->aliasBuilder) &&
if (array_key_exists($viewName_single, $this->aliasBuilder) &&
(array_key_exists($viewName_single, $this->titleBuilder) || isset($this->customAliasBuilder[$viewName_single])))
{
// get component name
@ -5698,7 +5698,7 @@ class Interpretation extends Fields
$newFunction[] = PHP_EOL . "\t\twhile (\$table->load(array('alias' => \$alias)))";
$newFunction[] = "\t\t{";
$newFunction[] = "\t\t\t//" . $this->setLine(__LINE__) . " Check if this is an array of titles";
$newFunction[] = "\t\t\tif (".$Component."Helper::checkArray(\$title))";
$newFunction[] = "\t\t\tif (" . $Component . "Helper::checkArray(\$title))";
$newFunction[] = "\t\t\t{";
$newFunction[] = "\t\t\t\tforeach(\$title as \$nr => &\$_title)";
$newFunction[] = "\t\t\t\t{";
@ -5713,7 +5713,7 @@ class Interpretation extends Fields
$newFunction[] = "\t\t\t\$alias = JString::increment(\$alias, 'dash');";
$newFunction[] = "\t\t}";
$newFunction[] = "\t\t//" . $this->setLine(__LINE__) . " Check if this is an array of titles";
$newFunction[] = "\t\tif (".$Component."Helper::checkArray(\$title))";
$newFunction[] = "\t\tif (" . $Component . "Helper::checkArray(\$title))";
$newFunction[] = "\t\t{";
$newFunction[] = "\t\t\t\$title[] = \$alias;";
$newFunction[] = "\t\t\treturn \$title;";
@ -5794,14 +5794,14 @@ class Interpretation extends Fields
$newFunction[] = "\t{";
$newFunction[] = "\t\tif (empty(\$this->alias))";
$newFunction[] = "\t\t{";
$newFunction[] = "\t\t\t\$this->alias = ".implode(".' '.",$titleData).';';
$newFunction[] = "\t\t\t\$this->alias = " . implode(".' '.", $titleData) . ';';
$newFunction[] = "\t\t}";
$newFunction[] = PHP_EOL ."\t\t\$this->alias = JApplication::stringURLSafe(\$this->alias);";
$newFunction[] = PHP_EOL ."\t\tif (trim(str_replace('-', '', \$this->alias)) == '')";
$newFunction[] = PHP_EOL . "\t\t\$this->alias = JApplication::stringURLSafe(\$this->alias);";
$newFunction[] = PHP_EOL . "\t\tif (trim(str_replace('-', '', \$this->alias)) == '')";
$newFunction[] = "\t\t{";
$newFunction[] = "\t\t\t\$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');";
$newFunction[] = "\t\t}";
$newFunction[] = PHP_EOL ."\t\treturn \$this->alias;";
$newFunction[] = PHP_EOL . "\t\treturn \$this->alias;";
$newFunction[] = "\t}";
return implode(PHP_EOL, $newFunction);
}
@ -6048,6 +6048,7 @@ class Interpretation extends Fields
$placeholders = array('[[[component]]]' => $component, '[[[view]]]' => $for);
$db .= $this->setPlaceholders($customSql, $placeholders) . PHP_EOL . PHP_EOL;
}
unset($this->customScriptBuilder['sql']);
}
return $db;
}
@ -6056,16 +6057,21 @@ class Interpretation extends Fields
public function setUninstall()
{
$db = '';
if (isset($this->queryBuilder) && ComponentbuilderHelper::checkArray($this->queryBuilder))
{
$bd = '';
foreach ($this->uninstallBuilder as $line)
{
$bd .= $line . PHP_EOL;
$db .= $line . PHP_EOL;
}
return $bd;
}
return '';
// add custom sql uninstall dump to the file
if (isset($this->customScriptBuilder['sql_uninstall']) && ComponentbuilderHelper::checkString($this->customScriptBuilder['sql_uninstall']))
{
$db .= $this->setPlaceholders($this->customScriptBuilder['sql_uninstall'], $this->placeholders) . PHP_EOL;
unset($this->customScriptBuilder['sql_uninstall']);
}
return $db;
}
public function setLangAdmin()
@ -11924,7 +11930,7 @@ class Interpretation extends Fields
{
$keyTableNAme = $item['custom']['table'];
}
$fix .= PHP_EOL . "\t" . $tab . "\t\t\t\$item->" . $item['name'] . " = " . $Component . "Helper::jsonToString(\$item->" . $item['name'] . ", ', ', '" . $keyTableNAme . "', '".$item['custom']['id']."', '".$item['custom']['text']."');";
$fix .= PHP_EOL . "\t" . $tab . "\t\t\t\$item->" . $item['name'] . " = " . $Component . "Helper::jsonToString(\$item->" . $item['name'] . ", ', ', '" . $keyTableNAme . "', '" . $item['custom']['id'] . "', '" . $item['custom']['text'] . "');";
}
else
{

View File

@ -11,7 +11,7 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.6.x
@version 2.7.x
@created 30th April, 2015
@package Component Builder
@subpackage compiler.php
@ -479,10 +479,10 @@ class Infusion extends Interpretation
$this->fileContentDynamic[$viewName_list]['###JVIEWLISTCANDO###'] = $this->setJviewListCanDo($viewName_single, $viewName_list);
// ###VIEWSCSS### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_list]['###VIEWSCSS###'] = $this->getCustomScriptBuilder('css_views', $viewName_list, '', null, true);
$this->fileContentDynamic[$viewName_list]['###VIEWSCSS###'] = $this->getCustomScriptBuilder('css_views', $viewName_single, '', null, true);
// ###VIEWS_FOOTER_SCRIPT### <<<DYNAMIC>>>
$scriptNote = PHP_EOL . '//' . $this->setLine(__LINE__) . ' ' . $viewName_list.' footer script';
$scriptNote = PHP_EOL . '//' . $this->setLine(__LINE__) . ' ' . $viewName_list . ' footer script';
if ($footerScript = $this->getCustomScriptBuilder('views_footer', $viewName_single, '', $scriptNote, true, false, PHP_EOL))
{
// only minfy if no php is added to the footer script
@ -765,7 +765,7 @@ class Infusion extends Interpretation
// set the module
$this->fileContentDynamic['ajax']['###AJAX_SITE_MODEL_METHODS###'] = $this->setAjaxModelMethods('site');
}
// build the validation rules
if (isset($this->validationRules) && ComponentbuilderHelper::checkArray($this->validationRules))
{
@ -775,9 +775,9 @@ class Infusion extends Interpretation
$target = array('admin' => 'a_rule_zi');
$this->buildDynamique($target, 'rule', $rule);
// set the JFormRule Name
$this->fileContentDynamic['a_rule_zi_'.$rule]['###Name###'] = ucfirst($rule);
$this->fileContentDynamic['a_rule_zi_' . $rule]['###Name###'] = ucfirst($rule);
// set the JFormRule PHP
$this->fileContentDynamic['a_rule_zi_'.$rule]['###VALIDATION_RULE_METHODS###'] = PHP_EOL . $_php;
$this->fileContentDynamic['a_rule_zi_' . $rule]['###VALIDATION_RULE_METHODS###'] = PHP_EOL . $_php;
}
}
@ -1135,12 +1135,12 @@ class Infusion extends Interpretation
if ($percentage < $this->percentageLanguageAdd)
{
// dont add
$this->langNot[$area . ' ' . $tag] = '<b>' . $mainLangLoader[$area] . '</b>(total '.$this->langTag.' strings) only <b>' . $langStringNr . '</b>' . $stringNAme . ' = ' . $percentage;
$this->langNot[$area . ' ' . $tag] = '<b>' . $mainLangLoader[$area] . '</b>(total ' . $this->langTag . ' strings) only <b>' . $langStringNr . '</b>' . $stringNAme . ' = ' . $percentage;
continue;
}
}
// show if it was added as well
$this->langSet[$area . ' ' . $tag] = '<b>' . $mainLangLoader[$area] . '</b>(total '.$this->langTag.' strings) and <b>' . $langStringNr . '</b>' . $stringNAme . ' = ' . $percentage;
$this->langSet[$area . ' ' . $tag] = '<b>' . $mainLangLoader[$area] . '</b>(total ' . $this->langTag . ' strings) and <b>' . $langStringNr . '</b>' . $stringNAme . ' = ' . $percentage;
}
// set naming convention
$p = 'admin';
@ -1172,13 +1172,14 @@ class Infusion extends Interpretation
// count the file created
$this->fileCount++;
// add content to it
$lang = array_map(function ($langstring, $placeholder) {
$lang = array_map(function ($langstring, $placeholder)
{
return $placeholder . '="' . $langstring . '"';
}, $languageStrings, array_keys($languageStrings));
// add to language file
$this->writeFile($path . '/' . $fileName, implode(PHP_EOL, $lang));
// set the line counter
$this->lineCount = $this->lineCount + count((array)$lang);
$this->lineCount = $this->lineCount + count((array) $lang);
// build xml strings
if (!isset($langXML[$p]))
{
@ -1210,4 +1211,5 @@ class Infusion extends Interpretation
}
}
}
}