Added the feature to use admin and custom admin views as the dashboard of the back-end of a component, requested in gh-148
This commit is contained in:
@ -1135,10 +1135,10 @@ class Get
|
||||
{
|
||||
$component->readme = '';
|
||||
}
|
||||
|
||||
// set lang now
|
||||
$nowLang = $this->lang;
|
||||
$this->lang = 'admin';
|
||||
|
||||
// dashboard methods
|
||||
$component->dashboard_tab = (isset($component->dashboard_tab) && ComponentbuilderHelper::checkJson($component->dashboard_tab)) ? json_decode($component->dashboard_tab, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($component->dashboard_tab))
|
||||
|
@ -320,6 +320,13 @@ class Structure extends Get
|
||||
*/
|
||||
protected $lastModifiedDate = array();
|
||||
|
||||
/**
|
||||
* The default view switch
|
||||
*
|
||||
* @var bool/string
|
||||
*/
|
||||
public $dynamicDashboard = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -349,6 +356,8 @@ class Structure extends Get
|
||||
$this->setLibaries();
|
||||
// set the Joomla Version Data
|
||||
$this->joomlaVersionData = $this->setJoomlaVersionData();
|
||||
// set the dashboard
|
||||
$this->setDynamicDashboard();
|
||||
// set the new folders
|
||||
if (!$this->setFolders())
|
||||
{
|
||||
@ -524,6 +533,67 @@ class Structure extends Get
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set the dynamic dashboard if set
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
private function setDynamicDashboard()
|
||||
{
|
||||
// only do the dashboard stuff it the default is used
|
||||
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)
|
||||
{
|
||||
// set the default view
|
||||
$getter = explode('_',$this->componentData->dashboard);
|
||||
if (count($getter) == 2 && is_numeric($getter[1]))
|
||||
{
|
||||
$id = $getter[1];
|
||||
// custom admin view
|
||||
if ('C' === $getter[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))
|
||||
{
|
||||
$this->dynamicDashboard = $dashboard[0]['settings']->code;
|
||||
}
|
||||
}
|
||||
// admin view
|
||||
elseif ('A' === $getter[0])
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if default was changed to dynamic dashboard the remove default tab and methods
|
||||
if (ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
||||
{
|
||||
// dynamic dashboard is used
|
||||
$this->componentData->dashboard_tab = '';
|
||||
$this->componentData->php_dashboard_methods = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to file
|
||||
*
|
||||
@ -797,9 +867,12 @@ class Structure extends Get
|
||||
$front = false;
|
||||
if ((isset($this->joomlaVersionData->move->dynamic) && ComponentbuilderHelper::checkObject($this->joomlaVersionData->move->dynamic)) && (isset($this->componentData->admin_views) && ComponentbuilderHelper::checkArray($this->componentData->admin_views)))
|
||||
{
|
||||
// setup dashboard
|
||||
$target = array('admin' => $this->componentData->name_code);
|
||||
$this->buildDynamique($target, 'dashboard');
|
||||
if (!ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
||||
{
|
||||
// setup dashboard
|
||||
$target = array('admin' => $this->componentData->name_code);
|
||||
$this->buildDynamique($target, 'dashboard');
|
||||
}
|
||||
// now the rest of the views
|
||||
foreach ($this->componentData->admin_views as $nr => $view)
|
||||
{
|
||||
|
@ -678,17 +678,17 @@ class Interpretation extends Fields
|
||||
$function[] = "\tpublic static function getMediumCryptKey(\$path)";
|
||||
$function[] = "\t{";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Prep the path a little";
|
||||
$function[] = "\t\t\$path = '/'. trim('/', str_replace('//', '/', \$path));";
|
||||
$function[] = "\t\t/jimport('joomla.filesystem.folder');";
|
||||
$function[] = "\t\t\$path = '/'. trim(str_replace('//', '/', \$path), '/');";
|
||||
$function[] = "\t\tjimport('joomla.filesystem.folder');";
|
||||
$function[] = "\t\t///" . $this->setLine(__LINE__) . " Check if folder exist";
|
||||
$function[] = "\t\t/if (!JFolder::exists(\$path))";
|
||||
$function[] = "\t\t/{";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Lock key.";
|
||||
$function[] = "\t\tif (!JFolder::exists(\$path))";
|
||||
$function[] = "\t\t{";
|
||||
$function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Lock key.";
|
||||
$function[] = "\t\t\tself::\$mediumCryptKey = 'none';";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Set the error message.";
|
||||
$function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Set the error message.";
|
||||
$function[] = "\t\t\tJFactory::getApplication()->enqueueMessage(JText::_('" . $this->langPrefix . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');";
|
||||
$function[] = "\t\t\treturn false;";
|
||||
$function[] = "\t\t/}";
|
||||
$function[] = "\t\t}";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Create FileName and set file path";
|
||||
$function[] = "\t\t\$filePath = \$path.'/.'.md5('medium_crypt_key_file');";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Check if we already have the file set";
|
||||
@ -699,30 +699,30 @@ class Interpretation extends Fields
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Set the key for the first time";
|
||||
$function[] = "\t\tself::\$mediumCryptKey = self::randomkey(128);";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Open the key file";
|
||||
$function[] = "\t\t\$fh = fopen(\$filePath, 'w');";
|
||||
$function[] = "\t\t\$fh = @fopen(\$filePath, 'w');";
|
||||
$function[] = "\t\tif (!is_resource(\$fh))";
|
||||
$function[] = "\t\t{";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Lock key.";
|
||||
$function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Lock key.";
|
||||
$function[] = "\t\t\tself::\$mediumCryptKey = 'none';";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Set the error message.";
|
||||
$function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Set the error message.";
|
||||
$function[] = "\t\t\tJFactory::getApplication()->enqueueMessage(JText::_('" . $this->langPrefix . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');";
|
||||
$function[] = "\t\t\treturn false;";
|
||||
$function[] = "\t\t}";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Write to the key file";
|
||||
$function[] = "\t\tif (!fwrite(\$fh, self::\$mediumCryptKey))";
|
||||
$function[] = "\t\t{";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Close key file.";
|
||||
$function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Close key file.";
|
||||
$function[] = "\t\t\tfclose(\$fh);";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Lock key.";
|
||||
$function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Lock key.";
|
||||
$function[] = "\t\t\tself::\$mediumCryptKey = 'none';";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Set the error message.";
|
||||
$function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Set the error message.";
|
||||
$function[] = "\t\t\tJFactory::getApplication()->enqueueMessage(JText::_('" . $this->langPrefix . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');";
|
||||
$function[] = "\t\t\treturn false;";
|
||||
$function[] = "\t\t}";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Close key file.";
|
||||
$function[] = "\t\tfclose(\$fh);";
|
||||
$function[] = "\t\t//" . $this->setLine(__LINE__) . " Key is set.";
|
||||
$function[] = PHP_EOL . "\t\treturn true;";
|
||||
$function[] = "\t\treturn true;";
|
||||
$function[] = "\t}";
|
||||
}
|
||||
// return the help methods
|
||||
@ -11772,7 +11772,7 @@ class Interpretation extends Fields
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($item['method'] == 2 || $item['method'] == 3 || $item['method'] == 4)
|
||||
if ($item['method'] == 2 || $item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5)
|
||||
{
|
||||
$taber = '';
|
||||
if ($item['method'] == 3)
|
||||
@ -11803,7 +11803,7 @@ class Interpretation extends Fields
|
||||
}
|
||||
$fix .= PHP_EOL . "\t" . $tab . $taber . "\t\t\t\$item->" . $item['name'] . " = " . $decode . "(\$item->" . $item['name'] . ");";
|
||||
|
||||
if ($item['method'] == 3 || $item['method'] == 4)
|
||||
if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5)
|
||||
{
|
||||
$fix .= PHP_EOL . "\t" . $tab . "\t\t\t}";
|
||||
}
|
||||
@ -12486,9 +12486,12 @@ class Interpretation extends Fields
|
||||
$lang = $this->langPrefix . '_SUBMENU';
|
||||
// set the code name
|
||||
$codeName = ComponentbuilderHelper::safeString($this->componentData->name_code);
|
||||
// set dashboard
|
||||
$menus .= "JHtmlSidebar::addEntry(JText:".":_('" . $lang . "_DASHBOARD'), 'index.php?option=com_" . $codeName . "&view=" . $codeName . "', \$submenu === '" . $codeName . "');";
|
||||
$this->langContent[$this->lang][$lang . '_DASHBOARD'] = 'Dashboard';
|
||||
// set default dashboard
|
||||
if (!ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
||||
{
|
||||
$menus .= "JHtmlSidebar::addEntry(JText:".":_('" . $lang . "_DASHBOARD'), 'index.php?option=com_" . $codeName . "&view=" . $codeName . "', \$submenu === '" . $codeName . "');";
|
||||
$this->langContent[$this->lang][$lang . '_DASHBOARD'] = 'Dashboard';
|
||||
}
|
||||
$catArray = array();
|
||||
foreach ($this->componentData->admin_views as $view)
|
||||
{
|
||||
|
@ -752,21 +752,33 @@ class Infusion extends Interpretation
|
||||
|
||||
// ###UPDATE_VERSION_MYSQL###
|
||||
$this->setVersionController();
|
||||
|
||||
// only set these if default dashboard it used
|
||||
if (!ComponentbuilderHelper::checkString($this->dynamicDashboard))
|
||||
{
|
||||
// ###DASHBOARDVIEW###
|
||||
$this->fileContentStatic['###DASHBOARDVIEW###'] = $this->fileContentStatic['###component###'];
|
||||
|
||||
// ###DASHBOARDICONS###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASHBOARDICONS###'] = $this->setDashboardIcons();
|
||||
|
||||
// ###DASHBOARDICONS###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASHBOARDICONS###'] = $this->setDashboardIcons();
|
||||
// ###DASHBOARDICONACCESS###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASHBOARDICONACCESS###'] = $this->setDashboardIconAccess();
|
||||
|
||||
// ###DASHBOARDICONACCESS###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASHBOARDICONACCESS###'] = $this->setDashboardIconAccess();
|
||||
// ###DASH_MODEL_METHODS###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASH_MODEL_METHODS###'] = $this->setDashboardModelMethods();
|
||||
|
||||
// ###DASH_MODEL_METHODS###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASH_MODEL_METHODS###'] = $this->setDashboardModelMethods();
|
||||
// ###DASH_GET_CUSTOM_DATA###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASH_GET_CUSTOM_DATA###'] = $this->setDashboardGetCustomData();
|
||||
|
||||
// ###DASH_GET_CUSTOM_DATA###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASH_GET_CUSTOM_DATA###'] = $this->setDashboardGetCustomData();
|
||||
|
||||
// ###DASH_DISPLAY_DATA###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASH_DISPLAY_DATA###'] = $this->setDashboardDisplayData();
|
||||
// ###DASH_DISPLAY_DATA###
|
||||
$this->fileContentDynamic[$this->fileContentStatic['###component###']]['###DASH_DISPLAY_DATA###'] = $this->setDashboardDisplayData();
|
||||
}
|
||||
else
|
||||
{
|
||||
// ###DASHBOARDVIEW###
|
||||
$this->fileContentStatic['###DASHBOARDVIEW###'] = $this->dynamicDashboard;
|
||||
}
|
||||
|
||||
// add import
|
||||
if (isset($this->addEximport) && $this->addEximport)
|
||||
|
Reference in New Issue
Block a user