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)
|
||||
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
|
||||
+ *First Build*: 30th April, 2015
|
||||
+ *Last Build*: 9th March, 2018
|
||||
+ *Last Build*: 10th March, 2018
|
||||
+ *Version*: 2.6.18
|
||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||
+ *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)
|
||||
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
|
||||
+ *First Build*: 30th April, 2015
|
||||
+ *Last Build*: 9th March, 2018
|
||||
+ *Last Build*: 10th March, 2018
|
||||
+ *Version*: 2.6.18
|
||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||
+ *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()
|
||||
{
|
||||
// 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
|
||||
&& isset($this->componentData->dashboard) && ComponentbuilderHelper::checkString($this->componentData->dashboard)
|
||||
&& strpos($this->componentData->dashboard, '_') !== false)
|
||||
@ -550,40 +550,60 @@ class Structure extends Get
|
||||
$getter = explode('_',$this->componentData->dashboard);
|
||||
if (count($getter) == 2 && is_numeric($getter[1]))
|
||||
{
|
||||
$id = $getter[1];
|
||||
// custom admin view
|
||||
if ('C' === $getter[0])
|
||||
// the pointers
|
||||
$id = (int) $getter[1];
|
||||
$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){
|
||||
if (isset($view['customadminview']) && $id == $view['customadminview'])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
// check if somthing was returned
|
||||
if (count($dashboard) && isset($dashboard[0]['settings']) && isset($dashboard[0]['settings']->code))
|
||||
// set the dynamic dash
|
||||
if (isset($this->componentData->{$targets[$t]}) && ComponentbuilderHelper::checkArray($this->componentData->{$targets[$t]}))
|
||||
{
|
||||
$this->dynamicDashboard = $dashboard[0]['settings']->code;
|
||||
// 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 false;
|
||||
});
|
||||
// check if view was found (this should be true)
|
||||
if (count($dashboard) && isset($dashboard[0]['settings']) && isset($dashboard[0]['settings']->{$keys[$t]}))
|
||||
{
|
||||
$this->dynamicDashboard = ComponentbuilderHelper::safeString($dashboard[0]['settings']->{$keys[$t]});
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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');
|
||||
}
|
||||
}
|
||||
// admin view
|
||||
elseif ('A' === $getter[0])
|
||||
else
|
||||
{
|
||||
$dashboard = array_filter($this->componentData->admin_views, function($view) use($id){
|
||||
if (isset($view['adminview']) && $id == $view['adminview'])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
// 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 (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"?>
|
||||
<extension type="component" version="3.2" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>9th March, 2018</creationDate>
|
||||
<creationDate>10th March, 2018</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
|
||||
<authorUrl>http://joomlacomponentbuilder.com</authorUrl>
|
||||
|
Loading…
Reference in New Issue
Block a user