Major improment to user helper methods. Fixed custom field building options to allow options to be set. Fixed gh-569 to use correct paths in module custom fields and rules. Imporved the fancy date helper methods. Added the new Text::_() languange string search for language strings. Add the option to add header custom code to custom fields.

This commit is contained in:
Llewellyn van der Merwe 2020-07-07 17:13:04 +02:00
parent e86ab88f5c
commit 354565d96a
Signed by untrusted user: Llewellyn
GPG Key ID: EFC0C720A240551C
24 changed files with 2242 additions and 1755 deletions

View File

@ -144,11 +144,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 24th June, 2020
+ *Last Build*: 7th July, 2020
+ *Version*: 2.11.2
+ *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **282642**
+ *Line count*: **282473**
+ *Field count*: **1522**
+ *File count*: **1785**
+ *Folder count*: **295**

View File

@ -144,11 +144,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 24th June, 2020
+ *Last Build*: 7th July, 2020
+ *Version*: 2.11.2
+ *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **282642**
+ *Line count*: **282473**
+ *Field count*: **1522**
+ *File count*: **1785**
+ *Folder count*: **295**

View File

@ -17,9 +17,7 @@ defined('_JEXEC') or die('Restricted access');
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the ###JFORM_extends### field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('###JFORM_extends###');
###JFORM_TYPE_HEADER###
/**
* ###Type### Form Field class for the ###Component### component

View File

@ -322,8 +322,8 @@ class Get
= array(
'Joomla' . '.JText._(',
'JText:' . ':script(',
'JText:' . ':_(',
'JText:' . ':sprintf(',
'Text:' . ':_(', // namespace and J version will be found
'Text:' . ':sprintf(', // namespace and J version will be found
'JustTEXT:' . ':_('
);
@ -1201,7 +1201,7 @@ class Get
array(&$this->componentContext, &$component)
);
// set upater
// set updater
$updater = array(
'unique' => array(
'addadmin_views' => array('table' => 'component_admin_views',
@ -1281,7 +1281,8 @@ class Get
);
// set the add targets
$addArrayF = array('files' => 'files', 'folders' => 'folders',
$addArrayF = array('files' => 'files',
'folders' => 'folders',
'filesfullpath' => 'files',
'foldersfullpath' => 'folders');
foreach ($addArrayF as $addTarget => $targetHere)
@ -10370,7 +10371,7 @@ class Get
$locker['LOCKBASE64((((' . $value . '))))'] = "base64_decode( preg_replace('/\s+/', ''," .
PHP_EOL . $this->_t(2) . "'" .
wordwrap(base64_encode($value), 64, PHP_EOL . $this->_t(2), true) .
"'));";
"'))";
}
// update the script
return $this->setPlaceholders($script, $locker);

View File

@ -2328,6 +2328,7 @@ class Fields extends Structure
. ComponentbuilderHelper::safeString($typeName, 'F')
. ". (custom) -->";
$field .= PHP_EOL . $this->_t(2) . $taber . "<field";
$optionSet = '';
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
@ -2335,8 +2336,274 @@ class Fields extends Structure
$field .= PHP_EOL . $this->_t(2) . $taber . $this->_t(1)
. $property . '="' . $value . '"';
}
elseif ($property === 'option')
{
$optionSet = '';
if (strtolower($typeName) === 'groupedlist'
&& strpos(
$value, ','
) !== false
&& strpos($value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
$grouped_ = array('group' => array(),
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
{
// set the group label
$valueKeyArray = explode('@@', $option);
if (count((array) $valueKeyArray) == 2)
{
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$valueKeyArray[0], true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue,
$valueKeyArray[0]
);
// now add group label
$groups_[$valueKeyArray[1]] = PHP_EOL
. $this->_t(1) . $taber . $this->_t(2)
. '<group label="' . $langValue . '">';
// set order
$order_['group' . $valueKeyArray[1]]
= $valueKeyArray[1];
}
}
elseif (strpos($option, '|') !== false)
{
// has other value then text
$valueKeyArray = explode('|', $option);
if (count((array) $valueKeyArray) == 3)
{
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$valueKeyArray[1], true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['group'][$valueKeyArray[2]][]
= PHP_EOL . $this->_t(1) . $taber
. $this->_t(3) . '<option value="'
. $valueKeyArray[0] . '">' . PHP_EOL
. $this->_t(1) . $taber . $this->_t(4)
. $langValue . '</option>';
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['group' . $valueKeyArray[2]]
= $valueKeyArray[2];
}
else
{
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$valueKeyArray[1], true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['option'][$valueKeyArray[0]]
= PHP_EOL . $this->_t(1) . $taber
. $this->_t(2) . '<option value="'
. $valueKeyArray[0] . '">' . PHP_EOL
. $this->_t(1) . $taber . $this->_t(3)
. $langValue . '</option>';
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['option' . $valueKeyArray[0]]
= $valueKeyArray[0];
}
}
else
{
// text is also the value
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$option, true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue, $option
);
// now add to option set
$grouped_['option'][$option] = PHP_EOL
. $this->_t(1) . $taber . $this->_t(2)
. '<option value="' . $option . '">'
. PHP_EOL . $this->_t(1) . $taber
. $this->_t(3) . $langValue . '</option>';
$optionArray[$option] = $langValue;
// set order
$order_['option' . $option] = $option;
}
}
// now build the groups
foreach ($order_ as $pointer_ => $_id)
{
// load the default key
$key_ = 'group';
if (strpos($pointer_, 'option') !== false)
{
// load the option field
$key_ = 'option';
}
// check if this is a group loader
if ('group' === $key_ && isset($groups_[$_id])
&& isset($grouped_[$key_][$_id])
&& ComponentbuilderHelper::checkArray(
$grouped_[$key_][$_id]
))
{
// set group label
$optionSet .= $groups_[$_id];
foreach ($grouped_[$key_][$_id] as $option_)
{
$optionSet .= $option_;
}
unset($groups_[$_id]);
unset($grouped_[$key_][$_id]);
// close the group
$optionSet .= PHP_EOL . $this->_t(1) . $taber
. $this->_t(2) . '</group>';
}
elseif (isset($grouped_[$key_][$_id])
&& ComponentbuilderHelper::checkString(
$grouped_[$key_][$_id]
))
{
$optionSet .= $grouped_[$key_][$_id];
}
}
}
elseif (strpos($value, ',') !== false)
{
// mulitpal options
$options = explode(',', $value);
foreach ($options as $option)
{
if (strpos($option, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $option);
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$t, true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue, $t
);
// now add to option set
$optionSet .= PHP_EOL . $this->_t(1)
. $taber . $this->_t(2) . '<option value="'
. $v . '">' . PHP_EOL . $this->_t(1)
. $taber . $this->_t(3) . $langValue
. '</option>';
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$option, true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue, $option
);
// now add to option set
$optionSet .= PHP_EOL . $this->_t(2)
. $taber . $this->_t(1) . '<option value="'
. $option . '">' . PHP_EOL . $this->_t(2)
. $taber . $this->_t(2) . $langValue
. '</option>';
$optionArray[$option] = $langValue;
}
}
}
else
{
// one option
if (strpos($value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $value);
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$t, true
);
// add to lang array
$this->setLangContent($this->lang, $langValue, $t);
// now add to option set
$optionSet .= PHP_EOL . $this->_t(2) . $taber
. $this->_t(1) . '<option value="' . $v . '">'
. PHP_EOL . $this->_t(2) . $taber . $this->_t(2)
. $langValue . '</option>';
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$value, true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue, $value
);
// now add to option set
$optionSet .= PHP_EOL . $this->_t(2)
. $taber . $this->_t(1) . '<option value="'
. $value . '">' . PHP_EOL . $this->_t(2)
. $taber . $this->_t(2) . $langValue
. '</option>';
$optionArray[$value] = $langValue;
}
}
}
}
// if options were found
if (ComponentbuilderHelper::checkString($optionSet))
{
$field .= '>';
$field .= PHP_EOL . $this->_t(3) . $taber . "<!--"
. $this->setLine(__LINE__) . " Option Set. -->";
$field .= $optionSet;
$field .= PHP_EOL . $this->_t(2) . $taber . "</field>";
}
// if no options found and must have a list of options
elseif (ComponentbuilderHelper::fieldCheck($typeName, 'list'))
{
$optionArray = false;
$field .= PHP_EOL . $this->_t(2) . $taber . "/>";
$field .= PHP_EOL . $this->_t(2) . $taber . "<!--"
. $this->setLine(__LINE__)
. " No Manual Options Were Added In Field Settings. -->"
. PHP_EOL;
}
else
{
$optionArray = false;
$field .= PHP_EOL . $this->_t(2) . $taber . "/>";
}
$field .= PHP_EOL . $this->_t(2) . $taber . "/>";
// incase the field is in the config and has not been set
if ('config' === $view_name_single && 'configs' === $view_name_list
|| (strpos($view_name_single, 'P|uG!n') !== false
@ -3083,6 +3350,244 @@ class Fields extends Structure
{
$field->fieldXML->addAttribute($property, $value);
}
elseif ($property === 'option')
{
ComponentbuilderHelper::xmlComment(
$field->fieldXML,
$this->setLine(__LINE__) . " Option Set."
);
if (strtolower($typeName) === 'groupedlist'
&& strpos(
$value, ','
) !== false
&& strpos($value, '@@') !== false)
{
// reset the group temp arrays
$groups_ = array();
$grouped_ = array('group' => array(),
'option' => array());
$order_ = array();
// mulitpal options
$options = explode(',', $value);
foreach ($options as $option)
{
if (strpos($option, '@@') !== false)
{
// set the group label
$valueKeyArray = explode('@@', $option);
if (count((array) $valueKeyArray) == 2)
{
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$valueKeyArray[0], true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue,
$valueKeyArray[0]
);
// now add group label
$groups_[$valueKeyArray[1]] = $langValue;
// set order
$order_['group' . $valueKeyArray[1]]
= $valueKeyArray[1];
}
}
elseif (strpos($option, '|') !== false)
{
// has other value then text
$valueKeyArray = explode('|', $option);
if (count((array) $valueKeyArray) == 3)
{
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$valueKeyArray[1], true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['group'][$valueKeyArray[2]][]
= array('value' => $valueKeyArray[0],
'text' => $langValue);
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['group' . $valueKeyArray[2]]
= $valueKeyArray[2];
}
else
{
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$valueKeyArray[1], true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue,
$valueKeyArray[1]
);
// now add to option set
$grouped_['option'][$valueKeyArray[0]]
= array('value' => $valueKeyArray[0],
'text' => $langValue);
$optionArray[$valueKeyArray[0]]
= $langValue;
// set order
$order_['option' . $valueKeyArray[0]]
= $valueKeyArray[0];
}
}
else
{
// text is also the value
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$option, true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue, $option
);
// now add to option set
$grouped_['option'][$option]
= array('value' => $option,
'text' => $langValue);
$optionArray[$option] = $langValue;
// set order
$order_['option' . $option] = $option;
}
}
// now build the groups
foreach ($order_ as $pointer_ => $_id)
{
// load the default key
$key_ = 'group';
if (strpos($pointer_, 'option') !== false)
{
// load the option field
$key_ = 'option';
}
// check if this is a group loader
if ('group' === $key_ && isset($groups_[$_id])
&& isset($grouped_[$key_][$_id])
&& ComponentbuilderHelper::checkArray(
$grouped_[$key_][$_id]
))
{
// set group label
$groupXML = $field->fieldXML->addChild('group');
$groupXML->addAttribute(
'label', $groups_[$_id]
);
foreach ($grouped_[$key_][$_id] as $option_)
{
$groupOptionXML = $groupXML->addChild(
'option'
);
$groupOptionXML->addAttribute(
'value', $option_['value']
);
$groupOptionXML[] = $option_['text'];
}
unset($groups_[$_id]);
unset($grouped_[$key_][$_id]);
}
elseif (isset($grouped_[$key_][$_id])
&& ComponentbuilderHelper::checkString(
$grouped_[$key_][$_id]
))
{
$optionXML = $field->fieldXML->addChild(
'option'
);
$optionXML->addAttribute(
'value', $grouped_[$key_][$_id]['value']
);
$optionXML[] = $grouped_[$key_][$_id]['text'];
}
}
}
elseif (strpos($value, ',') !== false)
{
// mulitpal options
$options = explode(',', $value);
foreach ($options as $option)
{
$optionXML = $field->fieldXML->addChild('option');
if (strpos($option, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $option);
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$t, true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue, $t
);
// now add to option set
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$option, true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue, $option
);
// now add to option set
$optionXML->addAttribute('value', $option);
$optionArray[$option] = $langValue;
}
$optionXML[] = $langValue;
}
}
else
{
// one option
$optionXML = $field->fieldXML->addChild('option');
if (strpos($value, '|') !== false)
{
// has other value then text
list($v, $t) = explode('|', $value);
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$t, true
);
// add to lang array
$this->setLangContent($this->lang, $langValue, $t);
// now add to option set
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
{
// text is also the value
$langValue = $langView . '_'
. ComponentbuilderHelper::safeFieldName(
$value, true
);
// add to lang array
$this->setLangContent(
$this->lang, $langValue, $value
);
// now add to option set
$optionXML->addAttribute('value', $value);
$optionArray[$value] = $langValue;
}
$optionXML[] = $langValue;
}
}
}
// incase the field is in the config and has not been set (or is part of a plugin or module)
if (('config' === $view_name_single
@ -4149,9 +4654,10 @@ class Fields extends Structure
if ($target_view !== $otherView)
{
$target_extension = trim(explode('.', $_extension)[0]);
$correction = $target_extension . '.' . $otherView;
$correction = $target_extension . '.' . $otherView;
$this->app->enqueueMessage(
JText::sprintf('<hr /><h3>Category targeting view mismatch</h3>
JText::sprintf(
'<hr /><h3>Category targeting view mismatch</h3>
<a>The <a href="index.php?option=com_componentbuilder&view=fields&task=field.edit&id=%s" target="_blank" title="open field">
category field</a> in <b>(%s) admin view</b> has a mismatching target view.
<br />To correct the mismatch, the <b>extension</b> value <code>%s</code> in the <a href="index.php?option=com_componentbuilder&view=fields&task=field.edit&id=%s" target="_blank" title="open category field">
@ -4160,7 +4666,10 @@ class Fields extends Structure
best category integration with Joomla</a>.
<br /><b>Please watch <a href="https://youtu.be/R4WQgcu6Xns" target="_blank" title="very important info on the topic">
this tutorial</a> before proceeding!!!</b>,
<a href="https://gist.github.com/Llewellynvdm/e053dc39ae3b2bf769c76a3e62c75b95" target="_blank" title="first watch the tutorial to understand how to use this code">code fix</a></p>', $field['field'], $view_name_single, $_extension, $field['field'], $correction), 'Error'
<a href="https://gist.github.com/Llewellynvdm/e053dc39ae3b2bf769c76a3e62c75b95" target="_blank" title="first watch the tutorial to understand how to use this code">code fix</a></p>',
$field['field'], $view_name_single, $_extension,
$field['field'], $correction
), 'Error'
);
}
}
@ -4369,15 +4878,15 @@ class Fields extends Structure
&& $typeName != 'repeatable'
&& $typeName != 'subform'))
{
$this->filterBuilder[$view_name_list][] = array('type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'database' => $view_name_single,
'function' => ComponentbuilderHelper::safeString(
$this->filterBuilder[$view_name_list][] = array('type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'database' => $view_name_single,
'function' => ComponentbuilderHelper::safeString(
$name, 'F'
),
'custom' => $custom,
'options' => $options);
'custom' => $custom,
'options' => $options);
}
// build the layout
@ -4442,21 +4951,21 @@ class Fields extends Structure
);
// set the [[[PLACEHOLDER]]] options
$replace = array(
$this->bbb . 'JPREFIX' . $this->ddd => $jprefix,
$this->bbb . 'JPREFIX' . $this->ddd => $jprefix,
$this->bbb . 'TABLE'
. $this->ddd => $data['custom']['table'],
. $this->ddd => $data['custom']['table'],
$this->bbb . 'ID'
. $this->ddd => $data['custom']['id'],
. $this->ddd => $data['custom']['id'],
$this->bbb . 'TEXT'
. $this->ddd => $data['custom']['text'],
$this->bbb . 'CODE_TEXT' . $this->ddd => $data['code'] . '_'
. $this->ddd => $data['custom']['text'],
$this->bbb . 'CODE_TEXT' . $this->ddd => $data['code'] . '_'
. $data['custom']['text'],
$this->bbb . 'CODE' . $this->ddd => $data['code'],
$this->bbb . 'view_type' . $this->ddd => $view_name_single
$this->bbb . 'CODE' . $this->ddd => $data['code'],
$this->bbb . 'view_type' . $this->ddd => $view_name_single
. '_' . $data['type'],
$this->bbb . 'type' . $this->ddd => $data['type'],
$this->bbb . 'type' . $this->ddd => $data['type'],
$this->bbb . 'com_component'
. $this->ddd => (isset($data['custom']['component'])
. $this->ddd => (isset($data['custom']['component'])
&& ComponentbuilderHelper::checkString(
$data['custom']['component']
)) ? ComponentbuilderHelper::safeString(
@ -4464,19 +4973,19 @@ class Fields extends Structure
) : 'com_' . $this->componentCodeName,
// set the generic values
$this->bbb . 'component'
. $this->ddd => $this->componentCodeName,
. $this->ddd => $this->componentCodeName,
$this->bbb . 'Component'
. $this->ddd => $this->fileContentStatic[$this->hhh
. $this->ddd => $this->fileContentStatic[$this->hhh
. 'Component' . $this->hhh],
$this->bbb . 'view'
. $this->ddd => (isset($data['custom']['view'])
. $this->ddd => (isset($data['custom']['view'])
&& ComponentbuilderHelper::checkString(
$data['custom']['view']
)) ? ComponentbuilderHelper::safeString(
$data['custom']['view']
) : $view_name_single,
$this->bbb . 'views'
. $this->ddd => (isset($data['custom']['views'])
. $this->ddd => (isset($data['custom']['views'])
&& ComponentbuilderHelper::checkString(
$data['custom']['views']
)) ? ComponentbuilderHelper::safeString(
@ -4544,12 +5053,21 @@ class Fields extends Structure
$this->buildDynamique(
$target, 'fieldcustom', $data['custom']['type']
);
// get the extends name
$JFORM_extends = ComponentbuilderHelper::safeString(
$data['custom']['extends']
);
// JFORM_TYPE_HEADER <<<DYNAMIC>>>
$add_default_header = true;
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_TYPE_HEADER' . $this->hhh]
= "//" . $this->setLine(
__LINE__
) . " Import the " . $JFORM_extends . " field type classes needed";
// JFORM_extens <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_extends' . $this->hhh]
= ComponentbuilderHelper::safeString(
$data['custom']['extends']
);
= $JFORM_extends;
// JFORM_EXTENDS <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_EXTENDS' . $this->hhh]
@ -4582,15 +5100,56 @@ class Fields extends Structure
);
}
}
// JFORM_TYPE_PHP <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_TYPE_PHP'
. $this->hhh]
.= PHP_EOL . $this->setPlaceholders(
$phpBucket, $replace
);
// check if this is header text
if('HEADER' === $x)
{
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_TYPE_HEADER'
. $this->hhh]
.= PHP_EOL . $this->setPlaceholders(
$phpBucket, $replace
);
// stop default headers from loading
$add_default_header = false;
}
else
{
// JFORM_TYPE_PHP <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_TYPE_PHP'
. $this->hhh]
.= PHP_EOL . $this->setPlaceholders(
$phpBucket, $replace
);
}
}
}
// check if we should add default header
if ($add_default_header)
{
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_TYPE_HEADER'
. $this->hhh]
.= PHP_EOL . "jimport('joomla.form.helper');";
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_TYPE_HEADER'
. $this->hhh]
.= PHP_EOL . "JFormHelper::loadFieldClass('"
. $JFORM_extends . "');";
}
// check the the JFormHelper::loadFieldClass(..) was set
elseif (strpos(
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_TYPE_HEADER'
. $this->hhh], 'JFormHelper::loadFieldClass('
) === false)
{
$this->fileContentDynamic['customfield_'
. $data['type']][$this->hhh . 'JFORM_TYPE_HEADER'
. $this->hhh]
.= PHP_EOL . "JFormHelper::loadFieldClass('"
. $JFORM_extends . "');";
}
}
else
{

View File

@ -1849,9 +1849,20 @@ class Interpretation extends Fields
$method = array();
$method[] = PHP_EOL . PHP_EOL . $this->_t(1) . "/**";
$method[] = $this->_t(1) . " * Greate user and update given table";
$method[] = $this->_t(1) . " *";
$method[] = $this->_t(1) . " * @param array \$credentials Array('name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string)";
$method[] = $this->_t(1) . " * @param int \$autologin";
$method[] = $this->_t(1) . " * @param array \$params Array('useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int)";
$method[] = $this->_t(1) . " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration";
$method[] = $this->_t(1) . " *";
$method[] = $this->_t(1) . " * @return int|Error User ID on success, or an error.";
$method[] = $this->_t(1) . " */";
$method[] = $this->_t(1)
. "public static function createUser(\$new)";
. "public static function createUser(\$credentials, \$autologin = 0,";
$method[] = $this->_t(2) . "\$params = array(";
$method[] = $this->_t(3) . "'useractivation' => 0, 'sendpassword' => 1";
$method[] = $this->_t(2) . "), \$mode = 1";
$method[] = $this->_t(1) . ")";
$method[] = $this->_t(1) . "{";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " load the user component language files if there is an error.";
@ -1864,75 +1875,144 @@ class Interpretation extends Fields
$method[] = $this->_t(2)
. "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " load the user regestration model";
$method[] = $this->_t(2)
. "\$model = self::getModel('registration', JPATH_ROOT. '/components/com_users', 'Users');";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " make sure no activation is needed";
$method[] = $this->_t(2)
. "\$useractivation = self::setParams('com_users','useractivation',0);";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " make sure password is send";
$method[] = $this->_t(2)
. "\$sendpassword = self::setParams('com_users','sendpassword',1);";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Check if password was set";
$method[] = $this->_t(2)
. "if (isset(\$new['password']) && isset(\$new['password2']) && self::checkString(\$new['password']) && self::checkString(\$new['password2']))";
. " Load the correct user model.";
$method[] = $this->_t(2) . "if (\$mode == 1)";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Use the users passwords";
$method[] = $this->_t(3) . "\$password = \$new['password'];";
$method[] = $this->_t(3) . "\$password2 = \$new['password2'];";
. " Load the backend-user model";
$method[] = $this->_t(3)
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users');";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "else";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Set random password";
$method[] = $this->_t(3) . "\$password = self::randomkey(8);";
$method[] = $this->_t(3) . "\$password2 = \$password;";
. " Load the user site-registration model";
$method[] = $this->_t(3)
. "\$model = self::getModel('registration', JPATH_ROOT. '/components/com_users', 'Users');";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " set username if not set";
. " Check if we have params/config";
$method[] = $this->_t(2) . "if (self::checkArray(\$params))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Make changes to user config";
$method[] = $this->_t(3)
. "foreach (\$params as \$param => \$set)";
$method[] = $this->_t(3) . "{";
$method[] = $this->_t(4) . "//" . $this->setLine(__LINE__)
. " If you know of a better path, let me know";
$method[] = $this->_t(4)
."\$params[\$param] = self::setParams('com_users', \$param, \$set);";
$method[] = $this->_t(3) . "}";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Set username to email if not set";
$method[] = $this->_t(2)
. "if (!isset(\$new['username']) || !self::checkString(\$new['username']))";
. "if (!isset(\$credentials['username']) || !self::checkString(\$credentials['username']))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3)
. "\$new['username'] = self::safeString(\$new['name']);";
. "\$credentials['username'] = \$credentials['email'];";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " linup new user data";
. " Lineup new user data array";
$method[] = $this->_t(2) . "\$data = array(";
$method[] = $this->_t(3) . "'username' => \$new['username'],";
$method[] = $this->_t(3) . "'name' => \$new['name'],";
$method[] = $this->_t(3) . "'email1' => \$new['email'],";
$method[] = $this->_t(3)
. "'password1' => \$password, // First password field";
$method[] = $this->_t(3)
. "'password2' => \$password2, // Confirm password field";
$method[] = $this->_t(3) . "'username' => \$credentials['username'],";
$method[] = $this->_t(3) . "'name' => \$credentials['name']";
$method[] = $this->_t(3) . "'block' => 0 );";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " register the new user";
$method[] = $this->_t(2) . "\$userId = \$model->register(\$data);";
. " Added details based on mode";
$method[] = $this->_t(2) . "if (\$mode == 1)";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Site-registration mode";
$method[] = $this->_t(3) . "\$data['email1'] = \$credentials['email'];";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "else";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Admin-registration mode";
$method[] = $this->_t(3) . "\$data['email'] = \$credentials['email'];";
$method[] = $this->_t(3) . "\$data['registerDate'] = JFactory::getDate()->toSql();";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " set activation back to default";
. " Check if password was set";
$method[] = $this->_t(2)
. "self::setParams('com_users','useractivation',\$useractivation);";
. "if (\$mode = 1 && (!isset(\$credentials['password']) || !isset(\$credentials['password2']) || !self::checkString(\$credentials['password']) || !self::checkString(\$credentials['password2'])))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Set random password when empty password was submitted,";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " and we are using the site-registration mode";
$method[] = $this->_t(3) . "\$credentials['password'] = self::randomkey(8);";
$method[] = $this->_t(3) . "\$credentials['password2'] = \$credentials['password'];";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " set send password back to default";
. " Now Add password if set";
$method[] = $this->_t(2)
. "self::setParams('com_users','sendpassword',\$sendpassword);";
. "if (isset(\$credentials['password']) && isset(\$credentials['password2']) && self::checkString(\$credentials['password']) && self::checkString(\$credentials['password2'])))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "if (\$mode = 1)";
$method[] = $this->_t(3) . "{";
$method[] = $this->_t(4) . "\$data['password1'] = \$credentials['password'];";
$method[] = $this->_t(3) . "}";
$method[] = $this->_t(3) . "else";
$method[] = $this->_t(3) . "{";
$method[] = $this->_t(4) . "\$data['password'] = \$credentials['password'];";
$method[] = $this->_t(3) . "}";
$method[] = $this->_t(3) . "\$data['password2'] = \$credentials['password2'];";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Create the new user";
$method[] = $this->_t(2) . "if (\$mode = 1)";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Site-registration mode";
$method[] = $this->_t(3) . "\$userId = \$model->register(\$data);";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "else";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Admin-registration mode";
$method[] = $this->_t(3) . "\$model->save(\$data);";
$method[] = $this->_t(3) . "\$userId = \$model->getState('user.id', 0);";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Check if we have params";
$method[] = $this->_t(2) . "if (self::checkArray(\$params))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Change user params/config back";
$method[] = $this->_t(3)
. "foreach (\$params as \$param => \$set)";
$method[] = $this->_t(3) . "{";
$method[] = $this->_t(4) . "//" . $this->setLine(__LINE__)
. " If you know of a better path, let me know";
$method[] = $this->_t(4)
."self::setParams('com_users', \$param, \$set);";
$method[] = $this->_t(3) . "}";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " if user is created";
$method[] = $this->_t(2) . "if (\$userId > 0)";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Auto Login if Needed";
$method[] = $this->_t(3) . "if (\$autologin && isset(\$credentials['password']))";
$method[] = $this->_t(3) . "{";
$method[] = $this->_t(4) . "JFactory::getApplication()->login(\$credentials);";
$method[] = $this->_t(3) . "}";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Return ID";
$method[] = $this->_t(3) . "return \$userId;";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "return \$model->getError();";
$method[] = $this->_t(1) . "}";
$method[] = PHP_EOL . $this->_t(1)
. "protected static function setParams(\$component,\$target,\$value)";
. "public static function setParams(\$component,\$target,\$value)";
$method[] = $this->_t(1) . "{";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Get the params and set the new values";
@ -5663,10 +5743,16 @@ class Interpretation extends Fields
// return buttons if they were build
if (ComponentbuilderHelper::checkArray($buttons))
{
// set the custom get form method JAVASCRIPT_FOR_BUTTONS
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. $TARGET . '_JAVASCRIPT_FOR_BUTTONS' . $this->hhh]
= $this->setJavaScriptForButtons();
// just to check if the submission script is manually added
if (!isset($view['settings']->php_document) ||
strpos(implode(' ', $view['settings']->php_document),
'/submitbutton.js') === false)
{
// set the custom get form method JAVASCRIPT_FOR_BUTTONS
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. $TARGET . '_JAVASCRIPT_FOR_BUTTONS' . $this->hhh]
= $this->setJavaScriptForButtons();
}
// insure the form is added (only if no form exist)
if (isset($view['settings']->default)
&& strpos(
@ -26396,10 +26482,10 @@ function vdm_dkim() {
$xml .= PHP_EOL . $this->_t(1) . '<config';
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="/administrator/components/com_'
. $this->componentCodeName . '/modules/rules"';
. $this->componentCodeName . '/models/rules"';
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="/administrator/components/com_'
. $this->componentCodeName . '/modules/fields"';
. $this->componentCodeName . '/models/fields"';
$xml .= PHP_EOL . $this->_t(1) . '>';
}
else
@ -26432,12 +26518,24 @@ function vdm_dkim() {
. $fieldset . ' fieldset points to the module -->';
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '"';
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="/modules/' . $module->file_name
. '/rules"';
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="/modules/' . $module->file_name
. '/fields"';
if ($module->target == 2)
{
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="/administrator/modules/' . $module->file_name
. '/rules"';
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="/administrator/modules/' . $module->file_name
. '/fields"';
}
else
{
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="/modules/' . $module->file_name
. '/rules"';
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="/modules/' . $module->file_name
. '/fields"';
}
$xml .= PHP_EOL . $this->_t(1) . '>';
}
else

View File

@ -5535,14 +5535,61 @@ abstract class ComponentbuilderHelper
*
*/
public static function getEditURL(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $jRoute = true)
{
// build record
$record = new stdClass();
// check if user can edit
if (self::canEditItem($record, $item, $view, $views, $component))
{
// set the edit link
if ($jRoute)
{
return JRoute::_("index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref);
}
return "index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref;
}
return false;
}
/**
* Can Edit (either any, or own)
*
* @param int $item The item to edit
* @param string $view The type of item to edit
* @param string $views The list view controller name
* @param string $component The component these views belong to
*
* @return bool if user can edit returns true els
*
*/
public static function allowEdit(&$item, $view, $views, $component = 'com_componentbuilder')
{
// build record
$record = new stdClass();
return self::canEditItem($record, $item, $view, $views, $component);
}
/**
* Can Edit (either any, or own)
*
* @param int $item The item to edit
* @param string $view The type of item to edit
* @param string $views The list view controller name
* @param string $component The component these views belong to
*
* @return bool if user can edit returns true els
*
*/
protected static function canEditItem(&$record, &$item, $view, $views, $component = 'com_componentbuilder')
{
// make sure the user has access to view
if (!JFactory::getUser()->authorise($view. '.access', $component))
{
return false;
}
// build record
$record = new stdClass();
// we start with false.
$can_edit = false;
// check that we have the ID
if (self::checkObject($item) && isset($item->id))
{
@ -5572,25 +5619,14 @@ abstract class ComponentbuilderHelper
// get user action permission to edit
$action = self::getActions($view, $record, $views, 'edit', str_replace('com_', '', $component));
// check if the view permission is set
if (($edit = $action->get($view . '.edit', 'none-set')) === 'none-set')
if (($can_edit = $action->get($view . '.edit', 'none-set')) === 'none-set')
{
// fall back on the core permission then
$edit = $action->get('core.edit', 'none-set');
}
// can edit
if ($edit)
{
// set the edit link
if ($jRoute)
{
return JRoute::_("index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref);
}
return "index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref;
// fall back on the core permission then (this can be an issue)
$can_edit = ($action->get('core.edit', false) || $action->get('core.edit.own', false));
}
}
return false;
return $can_edit;
}
/**
* set subform type table
@ -5633,9 +5669,9 @@ abstract class ComponentbuilderHelper
/**
* Change to nice fancy date
*/
public static function fancyDate($date)
public static function fancyDate($date, $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5645,9 +5681,9 @@ abstract class ComponentbuilderHelper
/**
* get date based in period past
*/
public static function fancyDynamicDate($date)
public static function fancyDynamicDate($date, $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5671,9 +5707,9 @@ abstract class ComponentbuilderHelper
/**
* Change to nice fancy day time and date
*/
public static function fancyDayTimeDate($time)
public static function fancyDayTimeDate($time, $check_stamp = true)
{
if (!self::isValidTimeStamp($time))
if ($check_stamp && !self::isValidTimeStamp($time))
{
$time = strtotime($time);
}
@ -5683,9 +5719,9 @@ abstract class ComponentbuilderHelper
/**
* Change to nice fancy time and date
*/
public static function fancyDateTime($time)
public static function fancyDateTime($time, $check_stamp = true)
{
if (!self::isValidTimeStamp($time))
if ($check_stamp && !self::isValidTimeStamp($time))
{
$time = strtotime($time);
}
@ -5695,9 +5731,9 @@ abstract class ComponentbuilderHelper
/**
* Change to nice hour:minutes time
*/
public static function fancyTime($time)
public static function fancyTime($time, $check_stamp = true)
{
if (!self::isValidTimeStamp($time))
if ($check_stamp && !self::isValidTimeStamp($time))
{
$time = strtotime($time);
}
@ -5707,9 +5743,9 @@ abstract class ComponentbuilderHelper
/**
* set the date day as Sunday through Saturday
*/
public static function setDayName($date)
public static function setDayName($date, $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5719,9 +5755,9 @@ abstract class ComponentbuilderHelper
/**
* set the date month as January through December
*/
public static function setMonthName($date)
public static function setMonthName($date, $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5731,9 +5767,9 @@ abstract class ComponentbuilderHelper
/**
* set the date day as 1st
*/
public static function setDay($date)
public static function setDay($date, $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5743,9 +5779,9 @@ abstract class ComponentbuilderHelper
/**
* set the date month as 5
*/
public static function setMonth($date)
public static function setMonth($date, $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5755,9 +5791,9 @@ abstract class ComponentbuilderHelper
/**
* set the date year as 2004 (for charts)
*/
public static function setYear($date)
public static function setYear($date, $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5767,9 +5803,9 @@ abstract class ComponentbuilderHelper
/**
* set the date as 2004/05 (for charts)
*/
public static function setYearMonth($date, $spacer = '/')
public static function setYearMonth($date, $spacer = '/', $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5779,9 +5815,9 @@ abstract class ComponentbuilderHelper
/**
* set the date as 2004/05/03 (for charts)
*/
public static function setYearMonthDay($date, $spacer = '/')
public static function setYearMonthDay($date, $spacer = '/', $check_stamp = true)
{
if (!self::isValidTimeStamp($date))
if ($check_stamp && !self::isValidTimeStamp($date))
{
$date = strtotime($date);
}
@ -5791,9 +5827,9 @@ abstract class ComponentbuilderHelper
/**
* set the date as 03/05/2004
*/<