Fixed gh-255 to insure that the correct component name is used when building the button on the edit view where the custom field is used.
This commit is contained in:
parent
65e0a19dee
commit
07662a8a8b
@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env
|
||||
+ *Version*: 2.7.1
|
||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
+ *Line count*: **191428**
|
||||
+ *Line count*: **191473**
|
||||
+ *Field count*: **1011**
|
||||
+ *File count*: **1197**
|
||||
+ *Folder count*: **193**
|
||||
|
@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env
|
||||
+ *Version*: 2.7.1
|
||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
+ *Line count*: **191428**
|
||||
+ *Line count*: **191473**
|
||||
+ *Field count*: **1011**
|
||||
+ *File count*: **1197**
|
||||
+ *Folder count*: **193**
|
||||
|
@ -43,7 +43,7 @@ class JFormField###Type### extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = '###type###'; ###ADD_BUTTON###
|
||||
public $type = '###type###';###ADD_BUTTON###
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
|
@ -5490,13 +5490,12 @@ class Get
|
||||
* @param string $data The actual data
|
||||
* @param array $placeholder The placeholders
|
||||
* @param int $action The action to use
|
||||
* ===================================================
|
||||
*
|
||||
* THE ACTION OPTIONS ARE
|
||||
* ===================================================
|
||||
* 1 -> Just replace (default)
|
||||
* 2 -> Check if data string has placeholders
|
||||
* 3 -> Remove placeholders not in data string
|
||||
* ===================================================
|
||||
*
|
||||
* @param int $langSwitch The lang switch
|
||||
*
|
||||
* @return string
|
||||
|
@ -2647,6 +2647,16 @@ class Fields extends Structure
|
||||
$this->setLayoutBuilder($view_name_single, $tabName, $name, $field);
|
||||
}
|
||||
|
||||
/**
|
||||
* set Custom Field Type File
|
||||
*
|
||||
* @param array $data The field complete data set
|
||||
* @param string $view_name_list The list view code name
|
||||
* @param string $view_name_single The single view code name
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function setCustomFieldTypeFile($data, $view_name_list, $view_name_single)
|
||||
{
|
||||
// make sure it is not already been build or if it is prime
|
||||
@ -2700,11 +2710,12 @@ class Fields extends Structure
|
||||
{
|
||||
$phpCode = 'return null;';
|
||||
}
|
||||
// catch empty stuff
|
||||
if (!ComponentbuilderHelper::checkString($phpCode))
|
||||
{
|
||||
$phpCode = 'return null;';
|
||||
}
|
||||
|
||||
// some house cleaning for users
|
||||
if ($data['custom']['extends'] === 'user')
|
||||
{
|
||||
// now load the php xclude script
|
||||
@ -2761,10 +2772,177 @@ class Fields extends Structure
|
||||
// ###type### <<<DYNAMIC>>>
|
||||
$this->fileContentDynamic['customfield_' . $data['type']]['###type###'] = $data['custom']['type'];
|
||||
// ###type### <<<DYNAMIC>>>
|
||||
$this->fileContentDynamic['customfield_' . $data['type']]['###ADD_BUTTON###'] = $this->setAddButttonToListField($data['custom']['view'], $data['custom']['views']);
|
||||
$this->fileContentDynamic['customfield_' . $data['type']]['###ADD_BUTTON###'] = $this->setAddButtonToListField($data['custom']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set Add Button To List Field (getInput tweak)
|
||||
*
|
||||
* @param array $fieldData The field custom data
|
||||
*
|
||||
* @return string of getInput class on success empty string otherwise
|
||||
*
|
||||
*/
|
||||
protected function setAddButtonToListField($fieldData)
|
||||
{
|
||||
// make sure hte view values are set
|
||||
if (isset($fieldData['view']) && isset($fieldData['views']))
|
||||
{
|
||||
$addButton = array();
|
||||
$addButton[] = PHP_EOL . PHP_EOL . "\t/**";
|
||||
$addButton[] = "\t * Override to add new button";
|
||||
$addButton[] = "\t *";
|
||||
$addButton[] = "\t * @return string The field input markup.";
|
||||
$addButton[] = "\t *";
|
||||
$addButton[] = "\t * @since 3.2";
|
||||
$addButton[] = "\t */";
|
||||
$addButton[] = "\tprotected function getInput()";
|
||||
$addButton[] = "\t{";
|
||||
$addButton[] = "\t\t//" . $this->setLine(__LINE__) . " see if we should add buttons";
|
||||
$addButton[] = "\t\t\$setButton = \$this->getAttribute('button');";
|
||||
$addButton[] = "\t\t//" . $this->setLine(__LINE__) . " get html";
|
||||
$addButton[] = "\t\t\$html = parent::getInput();";
|
||||
$addButton[] = "\t\t//" . $this->setLine(__LINE__) . " if true set button";
|
||||
$addButton[] = "\t\tif (\$setButton === 'true')";
|
||||
$addButton[] = "\t\t{";
|
||||
$addButton[] = "\t\t\t\$button = array();";
|
||||
$addButton[] = "\t\t\t\$script = array();";
|
||||
$addButton[] = "\t\t\t\$buttonName = \$this->getAttribute('name');";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " get the input from url";
|
||||
$addButton[] = "\t\t\t\$app = JFactory::getApplication();";
|
||||
$addButton[] = "\t\t\t\$jinput = \$app->input;";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " get the view name & id";
|
||||
$addButton[] = "\t\t\t\$values = \$jinput->getArray(array(";
|
||||
$addButton[] = "\t\t\t\t'id' => 'int',";
|
||||
$addButton[] = "\t\t\t\t'view' => 'word'";
|
||||
$addButton[] = "\t\t\t));";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " check if new item";
|
||||
$addButton[] = "\t\t\t\$ref = '';";
|
||||
$addButton[] = "\t\t\t\$refJ = '';";
|
||||
$addButton[] = "\t\t\tif (!is_null(\$values['id']) && strlen(\$values['view']))";
|
||||
$addButton[] = "\t\t\t{";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " only load referal if not new item.";
|
||||
$addButton[] = "\t\t\t\t\$ref = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
|
||||
$addButton[] = "\t\t\t\t\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
|
||||
$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'];
|
||||
// check that the component value is set
|
||||
if (!isset($fieldData['component']) || !ComponentbuilderHelper::checkString($fieldData['component']))
|
||||
{
|
||||
$fieldData['component'] = "com_" . $this->fileContentStatic['###component###'];
|
||||
}
|
||||
// check that the componet has the com_ value in it
|
||||
if (strpos($fieldData['component'], 'com_') === false)
|
||||
{
|
||||
$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
|
||||
{
|
||||
$fieldData['component'] = $this->setPlaceholders($fieldData['component'], $this->placeholders);
|
||||
}
|
||||
// get core permissions
|
||||
$coreLoad = false;
|
||||
if (isset($this->permissionCore[$fieldData['view']]))
|
||||
{
|
||||
// get the core permission naming array
|
||||
$core = $this->permissionCore[$fieldData['view']];
|
||||
// set switch to activate easy update
|
||||
$coreLoad = true;
|
||||
// since the view is local to the component use this component name
|
||||
$component = "com_" . $this->fileContentStatic['###component###'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// fall back on the field component
|
||||
$component = $fieldData['component'];
|
||||
}
|
||||
// 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']]))
|
||||
{
|
||||
$addButton[] = "\t\t\tif (\$user->authorise('" . $core['core.create'] . "', '" . $component . "') && \$app->isAdmin()) // TODO for now only in admin area.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$addButton[] = "\t\t\tif (\$user->authorise('core.create', '" . $component . "') && \$app->isAdmin()) // TODO for now only in admin area.";
|
||||
}
|
||||
$addButton[] = "\t\t\t{";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " build Create button";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = trim(\$buttonName);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace('/_+/', ' ', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace('/\s+/', ' ', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace(\"/[^A-Za-z ]/\", '', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = ucfirst(strtolower(\$buttonNamee));";
|
||||
$addButton[] = "\t\t\t\t\$button[] = '<a id=\"'.\$buttonName.'Create\" class=\"btn btn-small btn-success hasTooltip\" title=\"'.JText:" . ":sprintf('" . $this->langPrefix . "_CREATE_NEW_S', \$buttonNamee).'\" style=\"border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;\"";
|
||||
$addButton[] = "\t\t\t\t\thref=\"index.php?option=" . $fieldData['component'] . "&view=" . $fieldData['view'] . "&layout=edit'.\$ref.'\" >";
|
||||
$addButton[] = "\t\t\t\t\t<span class=\"icon-new icon-white\"></span></a>';";
|
||||
$addButton[] = "\t\t\t}";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " only add if user allowed to edit " . $fieldData['view'];
|
||||
// check if the item has permissions.
|
||||
if ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder['global'][$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit']]) && in_array($fieldData['view'], $this->permissionBuilder['global'][$core['core.edit']]))
|
||||
{
|
||||
$addButton[] = "\t\t\tif ((\$buttonName === '" . $fieldData['view'] . "' || \$buttonName === '" . $fieldData['views'] . "') && \$user->authorise('" . $core['core.edit'] . "', '" . $component . "') && \$app->isAdmin()) // TODO for now only in admin area.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$addButton[] = "\t\t\tif ((\$buttonName === '" . $fieldData['view'] . "' || \$buttonName === '" . $fieldData['views'] . "') && \$user->authorise('core.edit', '" . $component . "') && \$app->isAdmin()) // TODO for now only in admin area.";
|
||||
}
|
||||
$addButton[] = "\t\t\t{";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " build edit button";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = trim(\$buttonName);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace('/_+/', ' ', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace('/\s+/', ' ', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace(\"/[^A-Za-z ]/\", '', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = ucfirst(strtolower(\$buttonNamee));";
|
||||
$addButton[] = "\t\t\t\t\$button[] = '<a id=\"'.\$buttonName.'Edit\" class=\"btn btn-small hasTooltip\" title=\"'.JText:" . ":sprintf('" . $this->langPrefix . "_EDIT_S', \$buttonNamee).'\" style=\"display: none; padding: 4px 4px 4px 7px;\" href=\"#\" >";
|
||||
$addButton[] = "\t\t\t\t\t<span class=\"icon-edit\"></span></a>';";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " build script";
|
||||
$addButton[] = "\t\t\t\t\$script[] = \"";
|
||||
$addButton[] = "\t\t\t\t\tjQuery(document).ready(function() {";
|
||||
$addButton[] = "\t\t\t\t\t\tjQuery('#adminForm').on('change', '#jform_\".\$buttonName.\"',function (e) {";
|
||||
$addButton[] = "\t\t\t\t\t\t\te.preventDefault();";
|
||||
$addButton[] = "\t\t\t\t\t\t\tvar \".\$buttonName.\"Value = jQuery('#jform_\".\$buttonName.\"').val();";
|
||||
$addButton[] = "\t\t\t\t\t\t\t\".\$buttonName.\"Button(\".\$buttonName.\"Value);";
|
||||
$addButton[] = "\t\t\t\t\t\t});";
|
||||
$addButton[] = "\t\t\t\t\t\tvar \".\$buttonName.\"Value = jQuery('#jform_\".\$buttonName.\"').val();";
|
||||
$addButton[] = "\t\t\t\t\t\t\".\$buttonName.\"Button(\".\$buttonName.\"Value);";
|
||||
$addButton[] = "\t\t\t\t\t});";
|
||||
$addButton[] = "\t\t\t\t\tfunction \".\$buttonName.\"Button(value) {";
|
||||
$addButton[] = "\t\t\t\t\t\tif (value > 0) {"; // TODO not ideal since value may not be an (int)
|
||||
$addButton[] = "\t\t\t\t\t\t\t// hide the create button";
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Create').hide();";
|
||||
$addButton[] = "\t\t\t\t\t\t\t// show edit button";
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Edit').show();";
|
||||
$addButton[] = "\t\t\t\t\t\t\tvar url = 'index.php?option=" . $fieldData['component'] . "&view=" . $fieldData['views'] . "&task=" . $fieldData['view'] . ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Edit').attr('href', url);";
|
||||
$addButton[] = "\t\t\t\t\t\t} else {";
|
||||
$addButton[] = "\t\t\t\t\t\t\t// show the create button";
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Create').show();";
|
||||
$addButton[] = "\t\t\t\t\t\t\t// hide edit button";
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Edit').hide();";
|
||||
$addButton[] = "\t\t\t\t\t\t}";
|
||||
$addButton[] = "\t\t\t\t\t}\";";
|
||||
$addButton[] = "\t\t\t}";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " check if button was created for " . $fieldData['view'] . " field.";
|
||||
$addButton[] = "\t\t\tif (is_array(\$button) && count(\$button) > 0)";
|
||||
$addButton[] = "\t\t\t{";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " Load the needed script.";
|
||||
$addButton[] = "\t\t\t\t\$document = JFactory::getDocument();";
|
||||
$addButton[] = "\t\t\t\t\$document->addScriptDeclaration(implode(' ',\$script));";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " return the button attached to input field.";
|
||||
$addButton[] = "\t\t\t\treturn '<div class=\"input-append\">' .\$html . implode('',\$button).'</div>';";
|
||||
$addButton[] = "\t\t\t}";
|
||||
$addButton[] = "\t\t}";
|
||||
$addButton[] = "\t\treturn \$html;";
|
||||
$addButton[] = "\t}";
|
||||
|
||||
return implode(PHP_EOL, $addButton);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* default Fields
|
||||
*
|
||||
|
@ -8676,136 +8676,6 @@ class Interpretation extends Fields
|
||||
}
|
||||
}
|
||||
|
||||
public function setAddButttonToListField($targetView, $targetViews)
|
||||
{
|
||||
$addButton = array();
|
||||
$addButton[] = PHP_EOL . "\t/**";
|
||||
$addButton[] = "\t * Override to add new button";
|
||||
$addButton[] = "\t *";
|
||||
$addButton[] = "\t * @return string The field input markup.";
|
||||
$addButton[] = "\t *";
|
||||
$addButton[] = "\t * @since 3.2";
|
||||
$addButton[] = "\t */";
|
||||
$addButton[] = "\tprotected function getInput()";
|
||||
$addButton[] = "\t{";
|
||||
$addButton[] = "\t\t//" . $this->setLine(__LINE__) . " see if we should add buttons";
|
||||
$addButton[] = "\t\t\$setButton = \$this->getAttribute('button');";
|
||||
$addButton[] = "\t\t//" . $this->setLine(__LINE__) . " get html";
|
||||
$addButton[] = "\t\t\$html = parent::getInput();";
|
||||
$addButton[] = "\t\t//" . $this->setLine(__LINE__) . " if true set button";
|
||||
$addButton[] = "\t\tif (\$setButton === 'true')";
|
||||
$addButton[] = "\t\t{";
|
||||
$addButton[] = "\t\t\t\$button = array();";
|
||||
$addButton[] = "\t\t\t\$script = array();";
|
||||
$addButton[] = "\t\t\t\$buttonName = \$this->getAttribute('name');";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " get the input from url";
|
||||
$addButton[] = "\t\t\t\$app = JFactory::getApplication();";
|
||||
$addButton[] = "\t\t\t\$jinput = \$app->input;";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " get the view name & id";
|
||||
$addButton[] = "\t\t\t\$values = \$jinput->getArray(array(";
|
||||
$addButton[] = "\t\t\t\t'id' => 'int',";
|
||||
$addButton[] = "\t\t\t\t'view' => 'word'";
|
||||
$addButton[] = "\t\t\t));";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " check if new item";
|
||||
$addButton[] = "\t\t\t\$ref = '';";
|
||||
$addButton[] = "\t\t\t\$refJ = '';";
|
||||
$addButton[] = "\t\t\tif (!is_null(\$values['id']) && strlen(\$values['view']))";
|
||||
$addButton[] = "\t\t\t{";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " only load referal if not new item.";
|
||||
$addButton[] = "\t\t\t\t\$ref = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
|
||||
$addButton[] = "\t\t\t\t\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];";
|
||||
$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 " . $targetView;
|
||||
// get core permissions
|
||||
$coreLoad = false;
|
||||
if (isset($this->permissionCore[$targetView]))
|
||||
{
|
||||
$core = $this->permissionCore[$targetView];
|
||||
$coreLoad = true;
|
||||
}
|
||||
// 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($targetView, $this->permissionBuilder['global'][$core['core.create']]))
|
||||
{
|
||||
$addButton[] = "\t\t\tif (\$user->authorise('" . $core['core.create'] . "', 'com_" . $this->fileContentStatic['###component###'] . "') && \$app->isAdmin()) // TODO for now only in admin area.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$addButton[] = "\t\t\tif (\$user->authorise('core.create', 'com_" . $this->fileContentStatic['###component###'] . "') && \$app->isAdmin()) // TODO for now only in admin area.";
|
||||
}
|
||||
$addButton[] = "\t\t\t{";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " build Create button";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = trim(\$buttonName);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace('/_+/', ' ', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace('/\s+/', ' ', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace(\"/[^A-Za-z ]/\", '', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = ucfirst(strtolower(\$buttonNamee));";
|
||||
$addButton[] = "\t\t\t\t\$button[] = '<a id=\"'.\$buttonName.'Create\" class=\"btn btn-small btn-success hasTooltip\" title=\"'.JText:" . ":sprintf('" . $this->langPrefix . "_CREATE_NEW_S', \$buttonNamee).'\" style=\"border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;\"";
|
||||
$addButton[] = "\t\t\t\t\thref=\"index.php?option=com_" . $this->fileContentStatic['###component###'] . "&view=" . $targetView . "&layout=edit'.\$ref.'\" >";
|
||||
$addButton[] = "\t\t\t\t\t<span class=\"icon-new icon-white\"></span></a>';";
|
||||
$addButton[] = "\t\t\t}";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " only add if user allowed to edit " . $targetView;
|
||||
// check if the item has permissions.
|
||||
if ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder['global'][$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit']]) && in_array($targetView, $this->permissionBuilder['global'][$core['core.edit']]))
|
||||
{
|
||||
$addButton[] = "\t\t\tif ((\$buttonName === '" . $targetView . "' || \$buttonName === '" . $targetViews . "') && \$user->authorise('" . $core['core.edit'] . "', 'com_" . $this->fileContentStatic['###component###'] . "') && \$app->isAdmin()) // TODO for now only in admin area.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$addButton[] = "\t\t\tif ((\$buttonName === '" . $targetView . "' || \$buttonName === '" . $targetViews . "') && \$user->authorise('core.edit', 'com_" . $this->fileContentStatic['###component###'] . "') && \$app->isAdmin()) // TODO for now only in admin area.";
|
||||
}
|
||||
$addButton[] = "\t\t\t{";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " build edit button";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = trim(\$buttonName);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace('/_+/', ' ', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace('/\s+/', ' ', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = preg_replace(\"/[^A-Za-z ]/\", '', \$buttonNamee);";
|
||||
$addButton[] = "\t\t\t\t\$buttonNamee = ucfirst(strtolower(\$buttonNamee));";
|
||||
$addButton[] = "\t\t\t\t\$button[] = '<a id=\"'.\$buttonName.'Edit\" class=\"btn btn-small hasTooltip\" title=\"'.JText:" . ":sprintf('" . $this->langPrefix . "_EDIT_S', \$buttonNamee).'\" style=\"display: none; padding: 4px 4px 4px 7px;\" href=\"#\" >";
|
||||
$addButton[] = "\t\t\t\t\t<span class=\"icon-edit\"></span></a>';";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " build script";
|
||||
$addButton[] = "\t\t\t\t\$script[] = \"";
|
||||
$addButton[] = "\t\t\t\t\tjQuery(document).ready(function() {";
|
||||
$addButton[] = "\t\t\t\t\t\tjQuery('#adminForm').on('change', '#jform_\".\$buttonName.\"',function (e) {";
|
||||
$addButton[] = "\t\t\t\t\t\t\te.preventDefault();";
|
||||
$addButton[] = "\t\t\t\t\t\t\tvar \".\$buttonName.\"Value = jQuery('#jform_\".\$buttonName.\"').val();";
|
||||
$addButton[] = "\t\t\t\t\t\t\t\".\$buttonName.\"Button(\".\$buttonName.\"Value);";
|
||||
$addButton[] = "\t\t\t\t\t\t});";
|
||||
$addButton[] = "\t\t\t\t\t\tvar \".\$buttonName.\"Value = jQuery('#jform_\".\$buttonName.\"').val();";
|
||||
$addButton[] = "\t\t\t\t\t\t\".\$buttonName.\"Button(\".\$buttonName.\"Value);";
|
||||
$addButton[] = "\t\t\t\t\t});";
|
||||
$addButton[] = "\t\t\t\t\tfunction \".\$buttonName.\"Button(value) {";
|
||||
$addButton[] = "\t\t\t\t\t\tif (value > 0) {"; // TODO not ideal since value may not be an (int)
|
||||
$addButton[] = "\t\t\t\t\t\t\t// hide the create button";
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Create').hide();";
|
||||
$addButton[] = "\t\t\t\t\t\t\t// show edit button";
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Edit').show();";
|
||||
$addButton[] = "\t\t\t\t\t\t\tvar url = 'index.php?option=com_" . $this->fileContentStatic['###component###'] . "&view=" . $targetViews . "&task=" . $targetView . ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Edit').attr('href', url);";
|
||||
$addButton[] = "\t\t\t\t\t\t} else {";
|
||||
$addButton[] = "\t\t\t\t\t\t\t// show the create button";
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Create').show();";
|
||||
$addButton[] = "\t\t\t\t\t\t\t// hide edit button";
|
||||
$addButton[] = "\t\t\t\t\t\t\tjQuery('#\".\$buttonName.\"Edit').hide();";
|
||||
$addButton[] = "\t\t\t\t\t\t}";
|
||||
$addButton[] = "\t\t\t\t\t}\";";
|
||||
$addButton[] = "\t\t\t}";
|
||||
$addButton[] = "\t\t\t//" . $this->setLine(__LINE__) . " check if button was created for " . $targetView . " field.";
|
||||
$addButton[] = "\t\t\tif (is_array(\$button) && count(\$button) > 0)";
|
||||
$addButton[] = "\t\t\t{";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " Load the needed script.";
|
||||
$addButton[] = "\t\t\t\t\$document = JFactory::getDocument();";
|
||||
$addButton[] = "\t\t\t\t\$document->addScriptDeclaration(implode(' ',\$script));";
|
||||
$addButton[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " return the button attached to input field.";
|
||||
$addButton[] = "\t\t\t\treturn '<div class=\"input-append\">' .\$html . implode('',\$button).'</div>';";
|
||||
$addButton[] = "\t\t\t}";
|
||||
$addButton[] = "\t\t}";
|
||||
$addButton[] = "\t\treturn \$html;";
|
||||
$addButton[] = "\t}";
|
||||
|
||||
return implode(PHP_EOL, $addButton);
|
||||
}
|
||||
|
||||
public function setFilterQuery($viewName_list)
|
||||
{
|
||||
if (isset($this->filterBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->filterBuilder[$viewName_list]))
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldAdminsviews extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'adminsviews';
|
||||
public $type = 'adminsviews';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldAdminviewfolderlist extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'adminviewfolderlist';
|
||||
public $type = 'adminviewfolderlist';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldAdminviews extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'adminviews';
|
||||
public $type = 'adminviews';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldAdminviewsreadonly extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'adminviewsreadonly';
|
||||
public $type = 'adminviewsreadonly';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldAliasbuilder extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'aliasbuilder';
|
||||
public $type = 'aliasbuilder';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldArticles extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'articles';
|
||||
public $type = 'articles';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
@ -79,7 +80,7 @@ class JFormFieldArticles extends JFormFieldList
|
||||
}
|
||||
$user = JFactory::getUser();
|
||||
// only add if user allowed to create article
|
||||
if ($user->authorise('core.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
|
||||
if ($user->authorise('core.create', 'com_content') && $app->isAdmin()) // TODO for now only in admin area.
|
||||
{
|
||||
// build Create button
|
||||
$buttonNamee = trim($buttonName);
|
||||
@ -88,11 +89,11 @@ class JFormFieldArticles extends JFormFieldList
|
||||
$buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
|
||||
$buttonNamee = ucfirst(strtolower($buttonNamee));
|
||||
$button[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_COMPONENTBUILDER_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_componentbuilder&view=article&layout=edit'.$ref.'" >
|
||||
href="index.php?option=com_content&view=article&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// only add if user allowed to edit article
|
||||
if (($buttonName === 'article' || $buttonName === 'articles') && $user->authorise('core.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
|
||||
if (($buttonName === 'article' || $buttonName === 'articles') && $user->authorise('core.edit', 'com_content') && $app->isAdmin()) // TODO for now only in admin area.
|
||||
{
|
||||
// build edit button
|
||||
$buttonNamee = trim($buttonName);
|
||||
@ -119,7 +120,7 @@ class JFormFieldArticles extends JFormFieldList
|
||||
jQuery('#".$buttonName."Create').hide();
|
||||
// show edit button
|
||||
jQuery('#".$buttonName."Edit').show();
|
||||
var url = 'index.php?option=com_componentbuilder&view=articles&task=article.edit&id='+value+'".$refJ."';
|
||||
var url = 'index.php?option=com_content&view=articles&task=article.edit&id='+value+'".$refJ."';
|
||||
jQuery('#".$buttonName."Edit').attr('href', url);
|
||||
} else {
|
||||
// show the create button
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldComponent extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'component';
|
||||
public $type = 'component';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldComponentadminmenus extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'componentadminmenus';
|
||||
public $type = 'componentadminmenus';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldComponentadminviews extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'componentadminviews';
|
||||
public $type = 'componentadminviews';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldComponents extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'components';
|
||||
public $type = 'components';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldCustomadminviews extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'customadminviews';
|
||||
public $type = 'customadminviews';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldCustomfilelist extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'customfilelist';
|
||||
public $type = 'customfilelist';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldCustomfolderlist extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'customfolderlist';
|
||||
public $type = 'customfolderlist';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldCustomgets extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'customgets';
|
||||
public $type = 'customgets';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldDbtables extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'dbtables';
|
||||
public $type = 'dbtables';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
@ -79,7 +80,8 @@ class JFormFieldDbtables extends JFormFieldList
|
||||
}
|
||||
$user = JFactory::getUser();
|
||||
// only add if user allowed to create
|
||||
if ($user->authorise('core.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
|
||||
if ($user->authorise('core.create', 'com_
|
||||
view=') && $app->isAdmin()) // TODO for now only in admin area.
|
||||
{
|
||||
// build Create button
|
||||
$buttonNamee = trim($buttonName);
|
||||
@ -88,11 +90,13 @@ class JFormFieldDbtables extends JFormFieldList
|
||||
$buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
|
||||
$buttonNamee = ucfirst(strtolower($buttonNamee));
|
||||
$button[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_COMPONENTBUILDER_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
|
||||
href="index.php?option=com_componentbuilder&view=&layout=edit'.$ref.'" >
|
||||
href="index.php?option=com_
|
||||
view=&view=&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// only add if user allowed to edit
|
||||
if (($buttonName === '' || $buttonName === '') && $user->authorise('core.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
|
||||
if (($buttonName === '' || $buttonName === '') && $user->authorise('core.edit', 'com_
|
||||
view=') && $app->isAdmin()) // TODO for now only in admin area.
|
||||
{
|
||||
// build edit button
|
||||
$buttonNamee = trim($buttonName);
|
||||
@ -119,7 +123,8 @@ class JFormFieldDbtables extends JFormFieldList
|
||||
jQuery('#".$buttonName."Create').hide();
|
||||
// show edit button
|
||||
jQuery('#".$buttonName."Edit').show();
|
||||
var url = 'index.php?option=com_componentbuilder&view=&task=.edit&id='+value+'".$refJ."';
|
||||
var url = 'index.php?option=com_
|
||||
view=&view=&task=.edit&id='+value+'".$refJ."';
|
||||
jQuery('#".$buttonName."Edit').attr('href', url);
|
||||
} else {
|
||||
// show the create button
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldDynamicdashboard extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'dynamicdashboard';
|
||||
public $type = 'dynamicdashboard';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldDynamicget extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'dynamicget';
|
||||
public $type = 'dynamicget';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldDynamicgets extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'dynamicgets';
|
||||
public $type = 'dynamicgets';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldExistingvalidationrules extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'existingvalidationrules';
|
||||
public $type = 'existingvalidationrules';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldFields extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'fields';
|
||||
public $type = 'fields';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldFieldtypes extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'fieldtypes';
|
||||
public $type = 'fieldtypes';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldFilebehaviour extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'filebehaviour';
|
||||
public $type = 'filebehaviour';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldJoomlacomponents extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'joomlacomponents';
|
||||
public $type = 'joomlacomponents';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldLang extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'lang';
|
||||
public $type = 'lang';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldLibconfigfield extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'libconfigfield';
|
||||
public $type = 'libconfigfield';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldLibraries extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'libraries';
|
||||
public $type = 'libraries';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldLibrariesx extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'librariesx';
|
||||
public $type = 'librariesx';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldLibrary extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'library';
|
||||
public $type = 'library';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldLibraryfiles extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'libraryfiles';
|
||||
public $type = 'libraryfiles';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldLibraryreadonly extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'libraryreadonly';
|
||||
public $type = 'libraryreadonly';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldMaingets extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'maingets';
|
||||
public $type = 'maingets';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldMatchfield extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'matchfield';
|
||||
public $type = 'matchfield';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldServers extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'servers';
|
||||
public $type = 'servers';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldSiteviewfolderlist extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'siteviewfolderlist';
|
||||
public $type = 'siteviewfolderlist';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldSiteviews extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'siteviews';
|
||||
public $type = 'siteviews';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldSnippets extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'snippets';
|
||||
public $type = 'snippets';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldSnippettype extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'snippettype';
|
||||
public $type = 'snippettype';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldTargetfields extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'targetfields';
|
||||
public $type = 'targetfields';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
@ -40,7 +40,8 @@ class JFormFieldViewtabs extends JFormFieldList
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'viewtabs';
|
||||
public $type = 'viewtabs';
|
||||
|
||||
/**
|
||||
* Override to add new button
|
||||
*
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user