forked from joomla/Component-Builder
Added some error handeling in respons to the gh-148 issue, to help insure we know why the dynamic dashboard did not get added
This commit is contained in:
parent
34efe32002
commit
de14f5d422
@ -126,7 +126,7 @@ Component Builder is mapped as a component in itself on my local development env
|
|||||||
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
||||||
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
|
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
|
||||||
+ *First Build*: 30th April, 2015
|
+ *First Build*: 30th April, 2015
|
||||||
+ *Last Build*: 9th March, 2018
|
+ *Last Build*: 10th March, 2018
|
||||||
+ *Version*: 2.6.18
|
+ *Version*: 2.6.18
|
||||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||||
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
@ -126,7 +126,7 @@ Component Builder is mapped as a component in itself on my local development env
|
|||||||
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
|
||||||
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
|
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
|
||||||
+ *First Build*: 30th April, 2015
|
+ *First Build*: 30th April, 2015
|
||||||
+ *Last Build*: 9th March, 2018
|
+ *Last Build*: 10th March, 2018
|
||||||
+ *Version*: 2.6.18
|
+ *Version*: 2.6.18
|
||||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||||
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
@ -541,7 +541,7 @@ class Structure extends Get
|
|||||||
*/
|
*/
|
||||||
private function setDynamicDashboard()
|
private function setDynamicDashboard()
|
||||||
{
|
{
|
||||||
// only do the dashboard stuff it the default is used
|
// only add the dynamic dashboard if all checks out
|
||||||
if (isset($this->componentData->dashboard_type) && 2 == $this->componentData->dashboard_type
|
if (isset($this->componentData->dashboard_type) && 2 == $this->componentData->dashboard_type
|
||||||
&& isset($this->componentData->dashboard) && ComponentbuilderHelper::checkString($this->componentData->dashboard)
|
&& isset($this->componentData->dashboard) && ComponentbuilderHelper::checkString($this->componentData->dashboard)
|
||||||
&& strpos($this->componentData->dashboard, '_') !== false)
|
&& strpos($this->componentData->dashboard, '_') !== false)
|
||||||
@ -550,39 +550,59 @@ class Structure extends Get
|
|||||||
$getter = explode('_',$this->componentData->dashboard);
|
$getter = explode('_',$this->componentData->dashboard);
|
||||||
if (count($getter) == 2 && is_numeric($getter[1]))
|
if (count($getter) == 2 && is_numeric($getter[1]))
|
||||||
{
|
{
|
||||||
$id = $getter[1];
|
// the pointers
|
||||||
// custom admin view
|
$id = (int) $getter[1];
|
||||||
if ('C' === $getter[0])
|
$t = ComponentbuilderHelper::safeString($getter[0], 'U');
|
||||||
|
// the dynamic stuff
|
||||||
|
$targets = array('A' => 'admin_views', 'C' => 'custom_admin_views');
|
||||||
|
$names = array('A' => 'admin view', 'C' => 'custom admin view');
|
||||||
|
$types = array('A' => 'adminview', 'C' => 'customadminview');
|
||||||
|
$keys = array('A' => 'name_list', 'C' => 'code');
|
||||||
|
// check the target values
|
||||||
|
if (isset($targets[$t]) && $id > 0)
|
||||||
{
|
{
|
||||||
$dashboard = array_filter($this->componentData->custom_admin_views, function($view) use($id){
|
// set the dynamic dash
|
||||||
if (isset($view['customadminview']) && $id == $view['customadminview'])
|
if (isset($this->componentData->{$targets[$t]}) && ComponentbuilderHelper::checkArray($this->componentData->{$targets[$t]}))
|
||||||
|
{
|
||||||
|
// search the target views
|
||||||
|
$dashboard = (array) array_filter($this->componentData->{$targets[$t]}, function($view) use($id, $t, $types){
|
||||||
|
if (isset($view[$types[$t]]) && $id == (int) $view[$types[$t]])
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// check if somthing was returned
|
// check if view was found (this should be true)
|
||||||
if (count($dashboard) && isset($dashboard[0]['settings']) && isset($dashboard[0]['settings']->code))
|
if (count($dashboard) && isset($dashboard[0]['settings']) && isset($dashboard[0]['settings']->{$keys[$t]}))
|
||||||
{
|
{
|
||||||
$this->dynamicDashboard = $dashboard[0]['settings']->code;
|
$this->dynamicDashboard = ComponentbuilderHelper::safeString($dashboard[0]['settings']->{$keys[$t]});
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
// admin view
|
|
||||||
elseif ('A' === $getter[0])
|
|
||||||
{
|
{
|
||||||
$dashboard = array_filter($this->componentData->admin_views, function($view) use($id){
|
// set the type name
|
||||||
if (isset($view['adminview']) && $id == $view['adminview'])
|
$type_names = ComponentbuilderHelper::safeString($targets[$t], 'w');
|
||||||
|
// set massage that something is wrong
|
||||||
|
$this->app->enqueueMessage(JText::sprintf('The <b>%s</b> (<b>%s</b>) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.', $names[$t], $this->componentData->dashboard, $type_names), 'Error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return true;
|
// set the type name
|
||||||
|
$type_names = ComponentbuilderHelper::safeString($targets[$t], 'w');
|
||||||
|
// set massage that something is wrong
|
||||||
|
$this->app->enqueueMessage(JText::sprintf('The <b>%s</b> (<b>%s</b>) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.', $names[$t], $this->componentData->dashboard, $type_names), 'Error');
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
});
|
else
|
||||||
// check if somthing was returned
|
|
||||||
if (count($dashboard) && isset($dashboard[0]['settings']) && isset($dashboard[0]['settings']->name_list))
|
|
||||||
{
|
{
|
||||||
$this->dynamicDashboard = ComponentbuilderHelper::safeString($dashboard[0]['settings']->name_list);
|
// the target value is wrong
|
||||||
|
$this->app->enqueueMessage(JText::sprintf('The <b>%s</b> value for the dynamic dashboard is invalid.', $this->componentData->dashboard), 'Error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// the target value is wrong
|
||||||
|
$this->app->enqueueMessage(JText::sprintf('The <b>%s</b> value for the dynamic dashboard is invalid.', $this->componentData->dashboard), 'Error');
|
||||||
}
|
}
|
||||||
// if default was changed to dynamic dashboard the remove default tab and methods
|
// if default was changed to dynamic dashboard the remove default tab and methods
|
||||||
if (ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
if (ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<extension type="component" version="3.2" method="upgrade">
|
<extension type="component" version="3.2" method="upgrade">
|
||||||
<name>COM_COMPONENTBUILDER</name>
|
<name>COM_COMPONENTBUILDER</name>
|
||||||
<creationDate>9th March, 2018</creationDate>
|
<creationDate>10th March, 2018</creationDate>
|
||||||
<author>Llewellyn van der Merwe</author>
|
<author>Llewellyn van der Merwe</author>
|
||||||
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
|
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
|
||||||
<authorUrl>http://joomlacomponentbuilder.com</authorUrl>
|
<authorUrl>http://joomlacomponentbuilder.com</authorUrl>
|
||||||
|
Loading…
Reference in New Issue
Block a user