Added the option to customize the import of data per view.

This commit is contained in:
2016-05-04 05:53:33 +01:00
parent 951e0c1f5d
commit 6b70aa45e6
374 changed files with 4370 additions and 2718 deletions

View File

@ -1086,6 +1086,20 @@ class Get
}
}
// set custom import scripts
if (isset($view->add_custom_import) && $view->add_custom_import == 1)
{
$addImportArray = array('php_import_setdata','php_import_save','html_import_view');
foreach ($addImportArray as $importScripter)
{
if (isset($view->$importScripter) && strlen($view->$importScripter) > 0)
{
$this->customScriptBuilder[$importScripter]['import_'.$name_list] = $this->setCustomContentLang(base64_decode($view->$importScripter));
unset($view->$importScripter);
}
}
}
// add_Ajax for this view
if ($view->add_php_ajax == 1)
{
@ -1985,9 +1999,11 @@ class Get
*/
public function setCustomContentLang($content)
{
// insure string is not broken
$content = str_replace('COM_###COMPONENT###',$this->langPrefix,$content);
// set language data
$langCheck[] = ComponentbuilderHelper::getAllBetween($content, "JText::_('","')");
$langCheck[] = ComponentbuilderHelper::getAllBetween($content, 'JText::_("','")');
$langCheck[] = ComponentbuilderHelper::getAllBetween($content, "JText::_('","'");
$langCheck[] = ComponentbuilderHelper::getAllBetween($content, 'JText::_("','"');
$langCheck[] = ComponentbuilderHelper::getAllBetween($content, "JText::sprintf('","'");
$langCheck[] = ComponentbuilderHelper::getAllBetween($content, 'JText::sprintf("','"');
$langHolders = array();
@ -2003,6 +2019,7 @@ class Get
{
foreach ($lang as $string)
{
// this is there to insure we dont break already added Language strings
if (ComponentbuilderHelper::safeString($string,'U') == $string)
{
continue;

View File

@ -4736,7 +4736,7 @@ class Interpretation extends Fields
{
// add final list of needed lang strings
$componentName = JFilterOutput::cleanText($this->componentData->name);
$this->langContent['adminsys'][$this->langPrefix] =
$this->langContent['adminsys'][$this->langPrefix] = $componentName;
$this->langContent['adminsys'][$this->langPrefix.'_CONFIGURATION'] = $componentName.' Configuration';
$this->langContent[$this->lang][$this->langPrefix] = $componentName;
$this->langContent['admin'][$this->langPrefix.'_BACK'] = 'Back';
@ -6830,7 +6830,15 @@ class Interpretation extends Fields
$this->langContent[$this->lang][$selectImportFileNote] = 'Select the file to import data to '.$viewName_list.'.';
}
$method[] = "\t\t\t\t\$message = JText::_('".$selectImportFileNote."');";
$method[] = "\t\t\t\t\$this->setRedirect(JRoute::_('index.php?option=com_".$this->fileContentStatic['###component###']."&view=import', false), \$message);";
// if this view has custom script it must have as custom import (model, veiw, controller)
if (isset($this->importCustomScripts[$viewName_list]) && $this->importCustomScripts[$viewName_list])
{
$method[] = "\t\t\t\t\$this->setRedirect(JRoute::_('index.php?option=com_".$this->fileContentStatic['###component###']."&view=import_".$viewName_list."', false), \$message);";
}
else
{
$method[] = "\t\t\t\t\$this->setRedirect(JRoute::_('index.php?option=com_".$this->fileContentStatic['###component###']."&view=import', false), \$message);";
}
$method[] = "\t\t\t\treturn;";
$method[] = "\t\t\t}";
$method[] = "\t\t}";
@ -6888,6 +6896,39 @@ class Interpretation extends Fields
return $button;
}
public function setImportCustomScripts($viewName_list)
{
// setup Ajax files
$target = array('admin' => 'import_'.$viewName_list);
$this->buildDynamique($target,'customimport');
// load the custom script to the files
if (isset($this->customScriptBuilder['php_import_setdata']['import_'.$viewName_list]))
{
// ###IMPORT_SETDATE_METOD_CUSTOM### <<<DYNAMIC>>>
$this->fileContentDynamic['import_'.$viewName_list]['###IMPORT_SETDATE_METOD_CUSTOM###'] = "\n".str_replace(array_keys($this->placeholders),array_values($this->placeholders),$this->customScriptBuilder['php_import_setdata']['import_'.$viewName_list]);
unset($this->customScriptBuilder['php_import_setdata']['import_'.$viewName_list]);
}
if (isset($this->customScriptBuilder['php_import_save']['import_'.$viewName_list]))
{
// ###IMPORT_SAVE_METOD_CUSTOM### <<<DYNAMIC>>>
$this->fileContentDynamic['import_'.$viewName_list]['###IMPORT_SAVE_METOD_CUSTOM###'] = "\n".str_replace(array_keys($this->placeholders),array_values($this->placeholders),$this->customScriptBuilder['php_import_save']['import_'.$viewName_list]);
unset($this->customScriptBuilder['php_import_save']['import_'.$viewName_list]);
}
if (isset($this->customScriptBuilder['html_import_view']['import_'.$viewName_list]))
{
// ###IMPORT_DEFAULT_VIEW_CUSTOM### <<<DYNAMIC>>>
$this->fileContentDynamic['import_'.$viewName_list]['###IMPORT_DEFAULT_VIEW_CUSTOM###'] = "\n".str_replace(array_keys($this->placeholders),array_values($this->placeholders),$this->customScriptBuilder['html_import_view']['import_'.$viewName_list]);
unset($this->customScriptBuilder['html_import_view']['import_'.$viewName_list]);
}
// insure we have the view placeholders setup
$this->fileContentDynamic['import_'.$viewName_list]['###VIEW###'] = 'IMPORT_'.$this->placeholders['###VIEWS###'];
$this->fileContentDynamic['import_'.$viewName_list]['###View###'] = 'Import_'.$this->placeholders['###views###'];
$this->fileContentDynamic['import_'.$viewName_list]['###view###'] = 'import_'.$this->placeholders['###views###'];
$this->fileContentDynamic['import_'.$viewName_list]['###VIEWS###'] = 'IMPORT_'.$this->placeholders['###VIEWS###'];
$this->fileContentDynamic['import_'.$viewName_list]['###Views###'] = 'Import_'.$this->placeholders['###views###'];
$this->fileContentDynamic['import_'.$viewName_list]['###views###'] = 'import_'.$this->placeholders['###views###'];
}
public function setListQuery($viewName_single, $viewName_list)
{
// check if this view has category added
@ -12363,7 +12404,7 @@ for developing fast and powerful web interfaces. For more info visit <a href=\"h
public function buildPermissions(&$view, $nameView, $nameViews, $menuControllers, $type = 'admin')
{
if (ComponentbuilderHelper::checkArray($view['settings']->permissions) || (isset($view['port']) && $view['port']) || (isset($view['history']) && $view['history']))
if (isset($view['settings']->permissions) && ComponentbuilderHelper::checkArray($view['settings']->permissions) || (isset($view['port']) && $view['port']) || (isset($view['history']) && $view['history']))
{
// add export/import permissions to each view that has export/import options
if (isset($view['port']) && $view['port'])

View File

@ -32,7 +32,10 @@ defined('_JEXEC') or die('Restricted access');
*/
class Infusion extends Interpretation
{
public $eximportView = array();
public $importCustomScripts = array();
/**
* Constructor
*/
@ -192,15 +195,6 @@ class Infusion extends Interpretation
$site_edit_view_array[] = "\t\t\t\t'".$viewName_single."'";
$this->lang = 'both';
}
// set the export/import option
if ($view['port'])
{
$this->eximportView[$viewName_list] = true;
}
else
{
$this->eximportView[$viewName_list] = false;
}
// check if help is being loaded
$this->checkHelp($viewName_single);
// set custom admin view list links
@ -227,6 +221,8 @@ class Infusion extends Interpretation
// set some place holder for the views
$this->placeholders['###view###'] = $viewName_single;
$this->placeholders['###VIEW###'] = $viewName_u;
$this->placeholders['###View###'] = $viewName_f;
// set license per view if needed
$this->setLockLicensePer($viewName_single);
@ -349,6 +345,24 @@ class Infusion extends Interpretation
// set some place holder for the views
$this->placeholders['###views###'] = $viewName_list;
$this->placeholders['###VIEWS###'] = $viewsName_u;
$this->placeholders['###Views###'] = $viewsName_f;
// set the export/import option
if ($view['port'])
{
$this->eximportView[$viewName_list] = true;
if (1 == $view['settings']->add_custom_import)
{
// this view has custom import scripting
$this->importCustomScripts[$viewName_list] = true;
$this->setImportCustomScripts($viewName_list);
}
}
else
{
$this->eximportView[$viewName_list] = false;
}
// set Autocheckin function
if ($view['checkin'] == 1)