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:
2018-03-30 06:41:33 +02:00
parent 65e0a19dee
commit 07662a8a8b
46 changed files with 276 additions and 186 deletions

View File

@ -40,7 +40,8 @@ class JFormFieldAdminsviews extends JFormFieldList
*
* @var string
*/
public $type = 'adminsviews';
public $type = 'adminsviews';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldAdminviewfolderlist extends JFormFieldList
*
* @var string
*/
public $type = 'adminviewfolderlist';
public $type = 'adminviewfolderlist';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldAdminviews extends JFormFieldList
*
* @var string
*/
public $type = 'adminviews';
public $type = 'adminviews';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldAdminviewsreadonly extends JFormFieldList
*
* @var string
*/
public $type = 'adminviewsreadonly';
public $type = 'adminviewsreadonly';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldAliasbuilder extends JFormFieldList
*
* @var string
*/
public $type = 'aliasbuilder';
public $type = 'aliasbuilder';
/**
* Override to add new button
*

View File

@ -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&amp;view=article&amp;layout=edit'.$ref.'" >
href="index.php?option=com_content&amp;view=article&amp;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

View File

@ -40,7 +40,8 @@ class JFormFieldComponent extends JFormFieldList
*
* @var string
*/
public $type = 'component';
public $type = 'component';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldComponentadminmenus extends JFormFieldList
*
* @var string
*/
public $type = 'componentadminmenus';
public $type = 'componentadminmenus';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldComponentadminviews extends JFormFieldList
*
* @var string
*/
public $type = 'componentadminviews';
public $type = 'componentadminviews';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldComponents extends JFormFieldList
*
* @var string
*/
public $type = 'components';
public $type = 'components';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldCustomadminviews extends JFormFieldList
*
* @var string
*/
public $type = 'customadminviews';
public $type = 'customadminviews';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldCustomfilelist extends JFormFieldList
*
* @var string
*/
public $type = 'customfilelist';
public $type = 'customfilelist';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldCustomfolderlist extends JFormFieldList
*
* @var string
*/
public $type = 'customfolderlist';
public $type = 'customfolderlist';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldCustomgets extends JFormFieldList
*
* @var string
*/
public $type = 'customgets';
public $type = 'customgets';
/**
* Override to add new button
*

View File

@ -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&amp;view=&amp;layout=edit'.$ref.'" >
href="index.php?option=com_
view=&amp;view=&amp;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

View File

@ -40,7 +40,8 @@ class JFormFieldDynamicdashboard extends JFormFieldList
*
* @var string
*/
public $type = 'dynamicdashboard';
public $type = 'dynamicdashboard';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldDynamicget extends JFormFieldList
*
* @var string
*/
public $type = 'dynamicget';
public $type = 'dynamicget';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldDynamicgets extends JFormFieldList
*
* @var string
*/
public $type = 'dynamicgets';
public $type = 'dynamicgets';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldExistingvalidationrules extends JFormFieldList
*
* @var string
*/
public $type = 'existingvalidationrules';
public $type = 'existingvalidationrules';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldFields extends JFormFieldList
*
* @var string
*/
public $type = 'fields';
public $type = 'fields';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldFieldtypes extends JFormFieldList
*
* @var string
*/
public $type = 'fieldtypes';
public $type = 'fieldtypes';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldFilebehaviour extends JFormFieldList
*
* @var string
*/
public $type = 'filebehaviour';
public $type = 'filebehaviour';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldJoomlacomponents extends JFormFieldList
*
* @var string
*/
public $type = 'joomlacomponents';
public $type = 'joomlacomponents';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldLang extends JFormFieldList
*
* @var string
*/
public $type = 'lang';
public $type = 'lang';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldLibconfigfield extends JFormFieldList
*
* @var string
*/
public $type = 'libconfigfield';
public $type = 'libconfigfield';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldLibraries extends JFormFieldList
*
* @var string
*/
public $type = 'libraries';
public $type = 'libraries';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldLibrariesx extends JFormFieldList
*
* @var string
*/
public $type = 'librariesx';
public $type = 'librariesx';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldLibrary extends JFormFieldList
*
* @var string
*/
public $type = 'library';
public $type = 'library';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldLibraryfiles extends JFormFieldList
*
* @var string
*/
public $type = 'libraryfiles';
public $type = 'libraryfiles';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldLibraryreadonly extends JFormFieldList
*
* @var string
*/
public $type = 'libraryreadonly';
public $type = 'libraryreadonly';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldMaingets extends JFormFieldList
*
* @var string
*/
public $type = 'maingets';
public $type = 'maingets';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldMatchfield extends JFormFieldList
*
* @var string
*/
public $type = 'matchfield';
public $type = 'matchfield';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldServers extends JFormFieldList
*
* @var string
*/
public $type = 'servers';
public $type = 'servers';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldSiteviewfolderlist extends JFormFieldList
*
* @var string
*/
public $type = 'siteviewfolderlist';
public $type = 'siteviewfolderlist';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldSiteviews extends JFormFieldList
*
* @var string
*/
public $type = 'siteviews';
public $type = 'siteviews';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldSnippets extends JFormFieldList
*
* @var string
*/
public $type = 'snippets';
public $type = 'snippets';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldSnippettype extends JFormFieldList
*
* @var string
*/
public $type = 'snippettype';
public $type = 'snippettype';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldTargetfields extends JFormFieldList
*
* @var string
*/
public $type = 'targetfields';
public $type = 'targetfields';
/**
* Override to add new button
*

View File

@ -40,7 +40,8 @@ class JFormFieldViewtabs extends JFormFieldList
*
* @var string
*/
public $type = 'viewtabs';
public $type = 'viewtabs';
/**
* Override to add new button
*