";
- $script['view'][] = "\t";
+ $script['view'][] = PHP_EOL . self::_t(1) . "sidebar)) : ?>";
+ $script['view'][] = self::_t(2) . "";
+ $script['view'][] = self::_t(2) . "
";
+ $script['view'][] = self::_t(1) . "";
+ $script['view'][] = self::_t(2) . "
";
+ $script['view'][] = self::_t(1) . "";
$script['view'][] = "";
- $script['view'][] = "\n\thasPackage && [[[-#-#-Component]]]Helper::checkArray(\$this->headerList) && [[[-#-#-Component]]]Helper::checkArray(\$this->headers)) : ?>";
- $script['view'][] = "\t\t
";
- $script['view'][] = "\t\t
";
- $script['view'][] = "\t";
- $script['view'][] = "\t\t 'upload')); ?>";
- $script['view'][] = "\t\t";
- $script['view'][] = "\t\t";
- $script['view'][] = "\t\t\t
";
- $script['view'][] = "\t\t";
- $script['view'][] = "\t\t";
- $script['view'][] = "\t\t";
- $script['view'][] = "\t\t\t
";
- $script['view'][] = "\t\t";
+ $script['view'][] = PHP_EOL . self::_t(1) . "hasPackage && [[[-#-#-Component]]]Helper::checkArray(\$this->headerList) && [[[-#-#-Component]]]Helper::checkArray(\$this->headers)) : ?>";
+ $script['view'][] = self::_t(2) . "
";
+ $script['view'][] = self::_t(2) . "
";
+ $script['view'][] = self::_t(1) . "";
+ $script['view'][] = self::_t(2) . " 'upload')); ?>";
+ $script['view'][] = self::_t(2) . "";
+ $script['view'][] = self::_t(2) . "";
+ $script['view'][] = self::_t(3) . "
";
+ $script['view'][] = self::_t(2) . "";
+ $script['view'][] = self::_t(2) . "";
+ $script['view'][] = self::_t(2) . "";
+ $script['view'][] = self::_t(3) . "
";
+ $script['view'][] = self::_t(2) . "";
$script['view'][] = "";
- $script['view'][] = "\n\t\t";
- $script['view'][] = "\t\t\t
";
- $script['view'][] = "\t\t";
- $script['view'][] = "\t\t";
- $script['view'][] = "\t\t
";
- $script['view'][] = "\t";
- $script['view'][] = "\t
";
- $script['view'][] = "\t";
+ $script['view'][] = PHP_EOL . self::_t(2) . "";
+ $script['view'][] = self::_t(3) . "
";
+ $script['view'][] = self::_t(2) . "";
+ $script['view'][] = self::_t(2) . "";
+ $script['view'][] = self::_t(2) . "
";
+ $script['view'][] = self::_t(1) . "";
+ $script['view'][] = self::_t(1) . "
";
+ $script['view'][] = self::_t(1) . "";
$script['view'][] = "";
$script['view'][] = "
";
}
elseif ('import' === $type)
{
$script['import'] = array();
- $script['import'][] = "\t/**";
- $script['import'][] = "\t * Import an spreadsheet from either folder, url or upload.";
- $script['import'][] = "\t *";
- $script['import'][] = "\t * @return boolean result of import";
- $script['import'][] = "\t *";
- $script['import'][] = "\t */";
- $script['import'][] = "\tpublic function import()";
- $script['import'][] = "\t{";
- $script['import'][] = "\t\t\$this->setState('action', 'import');";
- $script['import'][] = "\t\t\$app \t\t= JFactory::getApplication();";
- $script['import'][] = "\t\t\$session \t= JFactory::getSession();";
- $script['import'][] = "\t\t\$package \t= null;";
- $script['import'][] = "\t\t\$continue\t= false;";
- $script['import'][] = "\t\t// get import type";
- $script['import'][] = "\t\t\$this->getType = \$app->input->getString('gettype', NULL);";
- $script['import'][] = "\t\t// get import type";
- $script['import'][] = "\t\t\$this->dataType\t= \$session->get('dataType_VDM_IMPORTINTO', NULL);";
- $script['import'][] = "\n\t\tif (\$package === null)";
- $script['import'][] = "\t\t{";
- $script['import'][] = "\t\t\tswitch (\$this->getType)";
- $script['import'][] = "\t\t\t{";
- $script['import'][] = "\t\t\t\tcase 'folder':";
- $script['import'][] = "\t\t\t\t\t// Remember the 'Import from Directory' path.";
- $script['import'][] = "\t\t\t\t\t\$app->getUserStateFromRequest(\$this->_context . '.import_directory', 'import_directory');";
- $script['import'][] = "\t\t\t\t\t\$package = \$this->_getPackageFromFolder();";
- $script['import'][] = "\t\t\t\t\tbreak;";
- $script['import'][] = "\n\t\t\t\tcase 'upload':";
- $script['import'][] = "\t\t\t\t\t\$package = \$this->_getPackageFromUpload();";
- $script['import'][] = "\t\t\t\t\tbreak;";
- $script['import'][] = "\n\t\t\t\tcase 'url':";
- $script['import'][] = "\t\t\t\t\t\$package = \$this->_getPackageFromUrl();";
- $script['import'][] = "\t\t\t\t\tbreak;";
- $script['import'][] = "\n\t\t\t\tcase 'continue':";
- $script['import'][] = "\t\t\t\t\t\$continue \t= true;";
- $script['import'][] = "\t\t\t\t\t\$package\t= \$session->get('package', null);";
- $script['import'][] = "\t\t\t\t\t\$package\t= json_decode(\$package, true);";
- $script['import'][] = "\t\t\t\t\t// clear session";
- $script['import'][] = "\t\t\t\t\t\$session->clear('package');";
- $script['import'][] = "\t\t\t\t\t\$session->clear('dataType');";
- $script['import'][] = "\t\t\t\t\t\$session->clear('hasPackage');";
- $script['import'][] = "\t\t\t\t\tbreak;";
- $script['import'][] = "\n\t\t\t\tdefault:";
- $script['import'][] = "\t\t\t\t\t\$app->setUserState('com_[[[-#-#-component]]].message', JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_NO_IMPORT_TYPE_FOUND'));";
- $script['import'][] = "\n\t\t\t\t\treturn false;";
- $script['import'][] = "\t\t\t\t\tbreak;";
- $script['import'][] = "\t\t\t}";
- $script['import'][] = "\t\t}";
- $script['import'][] = "\t\t// Was the package valid?";
- $script['import'][] = "\t\tif (!\$package || !\$package['type'])";
- $script['import'][] = "\t\t{";
- $script['import'][] = "\t\t\tif (in_array(\$this->getType, array('upload', 'url')))";
- $script['import'][] = "\t\t\t{";
- $script['import'][] = "\t\t\t\t\$this->remove(\$package['packagename']);";
- $script['import'][] = "\t\t\t}";
- $script['import'][] = "\n\t\t\t\$app->setUserState('com_[[[-#-#-component]]].message', JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE'));";
- $script['import'][] = "\t\t\treturn false;";
- $script['import'][] = "\t\t}";
- $script['import'][] = "\t\t";
- $script['import'][] = "\t\t// first link data to table headers";
- $script['import'][] = "\t\tif(!\$continue){";
- $script['import'][] = "\t\t\t\$package\t= json_encode(\$package);";
- $script['import'][] = "\t\t\t\$session->set('package', \$package);";
- $script['import'][] = "\t\t\t\$session->set('dataType', \$this->dataType);";
- $script['import'][] = "\t\t\t\$session->set('hasPackage', true);";
- $script['import'][] = "\t\t\treturn true;";
- $script['import'][] = "\t\t}";
- $script['import'][] = "\t\t// set the data";
- $script['import'][] = "\t\t\$headerList = json_decode(\$session->get(\$this->dataType.'_VDM_IMPORTHEADERS', false), true);";
- $script['import'][] = "\t\tif (!\$this->setData(\$package,\$this->dataType,\$headerList))";
- $script['import'][] = "\t\t{";
- $script['import'][] = "\t\t\t// There was an error importing the package";
- $script['import'][] = "\t\t\t\$msg = JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_ERROR');";
- $script['import'][] = "\t\t\t\$back = \$session->get('backto_VDM_IMPORT', NULL);";
- $script['import'][] = "\t\t\tif (\$back)";
- $script['import'][] = "\t\t\t{";
- $script['import'][] = "\t\t\t\t\$app->setUserState('com_[[[-#-#-component]]].redirect_url', 'index.php?option=com_[[[-#-#-component]]]&view='.\$back);";
- $script['import'][] = "\t\t\t\t\$session->clear('backto_VDM_IMPORT');";
- $script['import'][] = "\t\t\t}";
- $script['import'][] = "\t\t\t\$result = false;";
- $script['import'][] = "\t\t}";
- $script['import'][] = "\t\telse";
- $script['import'][] = "\t\t{";
- $script['import'][] = "\t\t\t// Package imported sucessfully";
- $script['import'][] = "\t\t\t\$msg = JTe-#-#-xt::sprintf('COM_[[[-#-#-COMPONENT]]]_IMPORT_SUCCESS', \$package['packagename']);";
- $script['import'][] = "\t\t\t\$back = \$session->get('backto_VDM_IMPORT', NULL);";
- $script['import'][] = "\t\t\tif (\$back)";
- $script['import'][] = "\t\t\t{";
- $script['import'][] = "\t\t\t \$app->setUserState('com_[[[-#-#-component]]].redirect_url', 'index.php?option=com_[[[-#-#-component]]]&view='.\$back);";
- $script['import'][] = "\t\t\t \$session->clear('backto_VDM_IMPORT');";
- $script['import'][] = "\t\t\t}";
- $script['import'][] = "\t\t\t\$result = true;";
- $script['import'][] = "\t\t}";
- $script['import'][] = "\n\t\t// Set some model state values";
- $script['import'][] = "\t\t\$app->enqueueMessage(\$msg);";
- $script['import'][] = "\n\t\t// remove file after import";
- $script['import'][] = "\t\t\$this->remove(\$package['packagename']);";
- $script['import'][] = "\t\t\$session->clear(\$this->getType.'_VDM_IMPORTHEADERS');";
- $script['import'][] = "\t\treturn \$result;";
- $script['import'][] = "\t}";
+ $script['import'][] = self::_t(1) . "/**";
+ $script['import'][] = self::_t(1) . " * Import an spreadsheet from either folder, url or upload.";
+ $script['import'][] = self::_t(1) . " *";
+ $script['import'][] = self::_t(1) . " * @return boolean result of import";
+ $script['import'][] = self::_t(1) . " *";
+ $script['import'][] = self::_t(1) . " */";
+ $script['import'][] = self::_t(1) . "public function import()";
+ $script['import'][] = self::_t(1) . "{";
+ $script['import'][] = self::_t(2) . "\$this->setState('action', 'import');";
+ $script['import'][] = self::_t(2) . "\$app" . self::_t(2) . "= JFactory::getApplication();";
+ $script['import'][] = self::_t(2) . "\$session" . self::_t(1) . "= JFactory::getSession();";
+ $script['import'][] = self::_t(2) . "\$package" . self::_t(1) . "= null;";
+ $script['import'][] = self::_t(2) . "\$continue" . self::_t(1) . "= false;";
+ $script['import'][] = self::_t(2) . "// get import type";
+ $script['import'][] = self::_t(2) . "\$this->getType = \$app->input->getString('gettype', NULL);";
+ $script['import'][] = self::_t(2) . "// get import type";
+ $script['import'][] = self::_t(2) . "\$this->dataType" . self::_t(1) . "= \$session->get('dataType_VDM_IMPORTINTO', NULL);";
+ $script['import'][] = PHP_EOL . self::_t(2) . "if (\$package === null)";
+ $script['import'][] = self::_t(2) . "{";
+ $script['import'][] = self::_t(3) . "switch (\$this->getType)";
+ $script['import'][] = self::_t(3) . "{";
+ $script['import'][] = self::_t(4) . "case 'folder':";
+ $script['import'][] = self::_t(5) . "// Remember the 'Import from Directory' path.";
+ $script['import'][] = self::_t(5) . "\$app->getUserStateFromRequest(\$this->_context . '.import_directory', 'import_directory');";
+ $script['import'][] = self::_t(5) . "\$package = \$this->_getPackageFromFolder();";
+ $script['import'][] = self::_t(5) . "break;";
+ $script['import'][] = PHP_EOL . self::_t(4) . "case 'upload':";
+ $script['import'][] = self::_t(5) . "\$package = \$this->_getPackageFromUpload();";
+ $script['import'][] = self::_t(5) . "break;";
+ $script['import'][] = PHP_EOL . self::_t(4) . "case 'url':";
+ $script['import'][] = self::_t(5) . "\$package = \$this->_getPackageFromUrl();";
+ $script['import'][] = self::_t(5) . "break;";
+ $script['import'][] = PHP_EOL . self::_t(4) . "case 'continue':";
+ $script['import'][] = self::_t(5) . "\$continue" . self::_t(1) . "= true;";
+ $script['import'][] = self::_t(5) . "\$package" . self::_t(1) . "= \$session->get('package', null);";
+ $script['import'][] = self::_t(5) . "\$package" . self::_t(1) . "= json_decode(\$package, true);";
+ $script['import'][] = self::_t(5) . "// clear session";
+ $script['import'][] = self::_t(5) . "\$session->clear('package');";
+ $script['import'][] = self::_t(5) . "\$session->clear('dataType');";
+ $script['import'][] = self::_t(5) . "\$session->clear('hasPackage');";
+ $script['import'][] = self::_t(5) . "break;";
+ $script['import'][] = PHP_EOL . self::_t(4) . "default:";
+ $script['import'][] = self::_t(5) . "\$app->setUserState('com_[[[-#-#-component]]].message', JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_NO_IMPORT_TYPE_FOUND'));";
+ $script['import'][] = PHP_EOL . self::_t(5) . "return false;";
+ $script['import'][] = self::_t(5) . "break;";
+ $script['import'][] = self::_t(3) . "}";
+ $script['import'][] = self::_t(2) . "}";
+ $script['import'][] = self::_t(2) . "// Was the package valid?";
+ $script['import'][] = self::_t(2) . "if (!\$package || !\$package['type'])";
+ $script['import'][] = self::_t(2) . "{";
+ $script['import'][] = self::_t(3) . "if (in_array(\$this->getType, array('upload', 'url')))";
+ $script['import'][] = self::_t(3) . "{";
+ $script['import'][] = self::_t(4) . "\$this->remove(\$package['packagename']);";
+ $script['import'][] = self::_t(3) . "}";
+ $script['import'][] = PHP_EOL . self::_t(3) . "\$app->setUserState('com_[[[-#-#-component]]].message', JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE'));";
+ $script['import'][] = self::_t(3) . "return false;";
+ $script['import'][] = self::_t(2) . "}";
+ $script['import'][] = self::_t(2) . "";
+ $script['import'][] = self::_t(2) . "// first link data to table headers";
+ $script['import'][] = self::_t(2) . "if(!\$continue){";
+ $script['import'][] = self::_t(3) . "\$package" . self::_t(1) . "= json_encode(\$package);";
+ $script['import'][] = self::_t(3) . "\$session->set('package', \$package);";
+ $script['import'][] = self::_t(3) . "\$session->set('dataType', \$this->dataType);";
+ $script['import'][] = self::_t(3) . "\$session->set('hasPackage', true);";
+ $script['import'][] = self::_t(3) . "return true;";
+ $script['import'][] = self::_t(2) . "}";
+ $script['import'][] = self::_t(2) . "// set the data";
+ $script['import'][] = self::_t(2) . "\$headerList = json_decode(\$session->get(\$this->dataType.'_VDM_IMPORTHEADERS', false), true);";
+ $script['import'][] = self::_t(2) . "if (!\$this->setData(\$package,\$this->dataType,\$headerList))";
+ $script['import'][] = self::_t(2) . "{";
+ $script['import'][] = self::_t(3) . "// There was an error importing the package";
+ $script['import'][] = self::_t(3) . "\$msg = JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_ERROR');";
+ $script['import'][] = self::_t(3) . "\$back = \$session->get('backto_VDM_IMPORT', NULL);";
+ $script['import'][] = self::_t(3) . "if (\$back)";
+ $script['import'][] = self::_t(3) . "{";
+ $script['import'][] = self::_t(4) . "\$app->setUserState('com_[[[-#-#-component]]].redirect_url', 'index.php?option=com_[[[-#-#-component]]]&view='.\$back);";
+ $script['import'][] = self::_t(4) . "\$session->clear('backto_VDM_IMPORT');";
+ $script['import'][] = self::_t(3) . "}";
+ $script['import'][] = self::_t(3) . "\$result = false;";
+ $script['import'][] = self::_t(2) . "}";
+ $script['import'][] = self::_t(2) . "else";
+ $script['import'][] = self::_t(2) . "{";
+ $script['import'][] = self::_t(3) . "// Package imported sucessfully";
+ $script['import'][] = self::_t(3) . "\$msg = JTe-#-#-xt::sprintf('COM_[[[-#-#-COMPONENT]]]_IMPORT_SUCCESS', \$package['packagename']);";
+ $script['import'][] = self::_t(3) . "\$back = \$session->get('backto_VDM_IMPORT', NULL);";
+ $script['import'][] = self::_t(3) . "if (\$back)";
+ $script['import'][] = self::_t(3) . "{";
+ $script['import'][] = self::_t(4) . "\$app->setUserState('com_[[[-#-#-component]]].redirect_url', 'index.php?option=com_[[[-#-#-component]]]&view='.\$back);";
+ $script['import'][] = self::_t(4) . "\$session->clear('backto_VDM_IMPORT');";
+ $script['import'][] = self::_t(3) . "}";
+ $script['import'][] = self::_t(3) . "\$result = true;";
+ $script['import'][] = self::_t(2) . "}";
+ $script['import'][] = PHP_EOL . self::_t(2) . "// Set some model state values";
+ $script['import'][] = self::_t(2) . "\$app->enqueueMessage(\$msg);";
+ $script['import'][] = PHP_EOL . self::_t(2) . "// remove file after import";
+ $script['import'][] = self::_t(2) . "\$this->remove(\$package['packagename']);";
+ $script['import'][] = self::_t(2) . "\$session->clear(\$this->getType.'_VDM_IMPORTHEADERS');";
+ $script['import'][] = self::_t(2) . "return \$result;";
+ $script['import'][] = self::_t(1) . "}";
}
elseif ('ext' === $type)
{
- $script['ext'][] = "\t/**";
- $script['ext'][] = "\t * Check the extension";
- $script['ext'][] = "\t *";
- $script['ext'][] = "\t * @param string \$file Name of the uploaded file";
- $script['ext'][] = "\t *";
- $script['ext'][] = "\t * @return boolean True on success";
- $script['ext'][] = "\t *";
- $script['ext'][] = "\t */";
- $script['ext'][] = "\tprotected function checkExtension(\$file)";
- $script['ext'][] = "\t{";
- $script['ext'][] = "\t\t// check the extention";
- $script['ext'][] = "\t\tswitch(strtolower(pathinfo(\$file, PATHINFO_EXTENSION)))";
- $script['ext'][] = "\t\t{";
- $script['ext'][] = "\t\t\tcase 'xls':";
- $script['ext'][] = "\t\t\tcase 'ods':";
- $script['ext'][] = "\t\t\tcase 'csv':";
- $script['ext'][] = "\t\t\treturn true;";
- $script['ext'][] = "\t\t\tbreak;";
- $script['ext'][] = "\t\t}";
- $script['ext'][] = "\t\treturn false;";
- $script['ext'][] = "\t}";
+ $script['ext'][] = self::_t(1) . "/**";
+ $script['ext'][] = self::_t(1) . " * Check the extension";
+ $script['ext'][] = self::_t(1) . " *";
+ $script['ext'][] = self::_t(1) . " * @param string \$file Name of the uploaded file";
+ $script['ext'][] = self::_t(1) . " *";
+ $script['ext'][] = self::_t(1) . " * @return boolean True on success";
+ $script['ext'][] = self::_t(1) . " *";
+ $script['ext'][] = self::_t(1) . " */";
+ $script['ext'][] = self::_t(1) . "protected function checkExtension(\$file)";
+ $script['ext'][] = self::_t(1) . "{";
+ $script['ext'][] = self::_t(2) . "// check the extention";
+ $script['ext'][] = self::_t(2) . "switch(strtolower(pathinfo(\$file, PATHINFO_EXTENSION)))";
+ $script['ext'][] = self::_t(2) . "{";
+ $script['ext'][] = self::_t(3) . "case 'xls':";
+ $script['ext'][] = self::_t(3) . "case 'ods':";
+ $script['ext'][] = self::_t(3) . "case 'csv':";
+ $script['ext'][] = self::_t(3) . "return true;";
+ $script['ext'][] = self::_t(3) . "break;";
+ $script['ext'][] = self::_t(2) . "}";
+ $script['ext'][] = self::_t(2) . "return false;";
+ $script['ext'][] = self::_t(1) . "}";
}
elseif ('routerparse' === $type)
{
- $script['routerparse'][] = "\t\t\t\t// default script in switch for this view";
- $script['routerparse'][] = "\t\t\t\t\$vars['view'] = '[[[-#-#-sview]]]';";
- $script['routerparse'][] = "\t\t\t\tif (is_numeric(\$segments[\$count-1]))";
- $script['routerparse'][] = "\t\t\t\t{";
- $script['routerparse'][] = "\t\t\t\t\t\$vars['id'] = (int) \$segments[\$count-1];";
- $script['routerparse'][] = "\t\t\t\t}";
- $script['routerparse'][] = "\t\t\t\telseif (\$segments[\$count-1])";
- $script['routerparse'][] = "\t\t\t\t{";
- $script['routerparse'][] = "\t\t\t\t\t\$id = \$this->getVar('[[[-#-#-sview]]]', \$segments[\$count-1], 'alias', 'id');";
- $script['routerparse'][] = "\t\t\t\t\tif(\$id)";
- $script['routerparse'][] = "\t\t\t\t\t{";
- $script['routerparse'][] = "\t\t\t\t\t\t\$vars['id'] = \$id;";
- $script['routerparse'][] = "\t\t\t\t\t}";
- $script['routerparse'][] = "\t\t\t\t}";
+ $script['routerparse'][] = self::_t(4) . "// default script in switch for this view";
+ $script['routerparse'][] = self::_t(4) . "\$vars['view'] = '[[[-#-#-sview]]]';";
+ $script['routerparse'][] = self::_t(4) . "if (is_numeric(\$segments[\$count-1]))";
+ $script['routerparse'][] = self::_t(4) . "{";
+ $script['routerparse'][] = self::_t(5) . "\$vars['id'] = (int) \$segments[\$count-1];";
+ $script['routerparse'][] = self::_t(4) . "}";
+ $script['routerparse'][] = self::_t(4) . "elseif (\$segments[\$count-1])";
+ $script['routerparse'][] = self::_t(4) . "{";
+ $script['routerparse'][] = self::_t(5) . "\$id = \$this->getVar('[[[-#-#-sview]]]', \$segments[\$count-1], 'alias', 'id');";
+ $script['routerparse'][] = self::_t(5) . "if(\$id)";
+ $script['routerparse'][] = self::_t(5) . "{";
+ $script['routerparse'][] = self::_t(6) . "\$vars['id'] = \$id;";
+ $script['routerparse'][] = self::_t(5) . "}";
+ $script['routerparse'][] = self::_t(4) . "}";
}
// return the needed script
if (isset($script[$type]))
{
- return str_replace('-#-#-', '', implode("\n",$script[$type]));
+ return str_replace('-#-#-', '', implode(PHP_EOL, $script[$type]));
}
return false;
}
-
/**
* get between
diff --git a/admin/models/admin_views.php b/admin/models/admin_views.php
index a39053ef8..9d28f3bc6 100644
--- a/admin/models/admin_views.php
+++ b/admin/models/admin_views.php
@@ -328,15 +328,18 @@ class ComponentbuilderModelAdmin_views extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/class_methods.php b/admin/models/class_methods.php
index fd5ee8b88..88964fd0b 100644
--- a/admin/models/class_methods.php
+++ b/admin/models/class_methods.php
@@ -255,15 +255,18 @@ class ComponentbuilderModelClass_methods extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/class_properties.php b/admin/models/class_properties.php
index e5d157df0..3ee8b17ad 100644
--- a/admin/models/class_properties.php
+++ b/admin/models/class_properties.php
@@ -255,15 +255,18 @@ class ComponentbuilderModelClass_properties extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/custom_admin_views.php b/admin/models/custom_admin_views.php
index f7f550de5..2e928d801 100644
--- a/admin/models/custom_admin_views.php
+++ b/admin/models/custom_admin_views.php
@@ -269,15 +269,18 @@ class ComponentbuilderModelCustom_admin_views extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/custom_codes.php b/admin/models/custom_codes.php
index 8dbebc9e2..d2be51bb2 100644
--- a/admin/models/custom_codes.php
+++ b/admin/models/custom_codes.php
@@ -302,15 +302,18 @@ class ComponentbuilderModelCustom_codes extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/dynamic_gets.php b/admin/models/dynamic_gets.php
index f1f5025d1..fade3ed2f 100644
--- a/admin/models/dynamic_gets.php
+++ b/admin/models/dynamic_gets.php
@@ -252,15 +252,18 @@ class ComponentbuilderModelDynamic_gets extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/fields.php b/admin/models/fields.php
index 3855f41f2..8083bb364 100644
--- a/admin/models/fields.php
+++ b/admin/models/fields.php
@@ -367,15 +367,18 @@ class ComponentbuilderModelFields extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/fieldtypes.php b/admin/models/fieldtypes.php
index 8d3c92d3f..e810a9be6 100644
--- a/admin/models/fieldtypes.php
+++ b/admin/models/fieldtypes.php
@@ -221,15 +221,18 @@ class ComponentbuilderModelFieldtypes extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/help_documents.php b/admin/models/help_documents.php
index 0e8478eba..2f3095dab 100644
--- a/admin/models/help_documents.php
+++ b/admin/models/help_documents.php
@@ -273,15 +273,18 @@ class ComponentbuilderModelHelp_documents extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php
index dbe8330ee..b750ba375 100644
--- a/admin/models/joomla_components.php
+++ b/admin/models/joomla_components.php
@@ -2137,15 +2137,18 @@ class ComponentbuilderModelJoomla_components extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/language_translations.php b/admin/models/language_translations.php
index 7a684bb66..42c6afea2 100644
--- a/admin/models/language_translations.php
+++ b/admin/models/language_translations.php
@@ -270,15 +270,18 @@ class ComponentbuilderModelLanguage_translations extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/languages.php b/admin/models/languages.php
index 60ed236d5..799112a9f 100644
--- a/admin/models/languages.php
+++ b/admin/models/languages.php
@@ -308,15 +308,18 @@ class ComponentbuilderModelLanguages extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/layouts.php b/admin/models/layouts.php
index f2fbd6069..c6144becf 100644
--- a/admin/models/layouts.php
+++ b/admin/models/layouts.php
@@ -241,15 +241,18 @@ class ComponentbuilderModelLayouts extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/placeholders.php b/admin/models/placeholders.php
index 0103ecd22..de2ccf7dd 100644
--- a/admin/models/placeholders.php
+++ b/admin/models/placeholders.php
@@ -187,15 +187,18 @@ class ComponentbuilderModelPlaceholders extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/servers.php b/admin/models/servers.php
index 7be26ad92..5b3bfc6bb 100644
--- a/admin/models/servers.php
+++ b/admin/models/servers.php
@@ -230,15 +230,18 @@ class ComponentbuilderModelServers extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/site_views.php b/admin/models/site_views.php
index e1760726e..7e23497a6 100644
--- a/admin/models/site_views.php
+++ b/admin/models/site_views.php
@@ -273,15 +273,18 @@ class ComponentbuilderModelSite_views extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/snippets.php b/admin/models/snippets.php
index 525176cb7..cae5329f7 100644
--- a/admin/models/snippets.php
+++ b/admin/models/snippets.php
@@ -329,15 +329,18 @@ class ComponentbuilderModelSnippets extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/templates.php b/admin/models/templates.php
index 93370276d..c9696442d 100644
--- a/admin/models/templates.php
+++ b/admin/models/templates.php
@@ -241,15 +241,18 @@ class ComponentbuilderModelTemplates extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/admin/models/validation_rules.php b/admin/models/validation_rules.php
index ecf17c402..cc1a7e768 100644
--- a/admin/models/validation_rules.php
+++ b/admin/models/validation_rules.php
@@ -185,15 +185,18 @@ class ComponentbuilderModelValidation_rules extends JModelList
*
* @return mixed An array of data items on success, false on failure.
*/
- public function getExportData($pks)
+ public function getExportData($pks, $user = null)
{
// setup the query
if (ComponentbuilderHelper::checkArray($pks))
{
- // Set a value to know this is exporting method.
+ // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)
$_export = true;
- // Get the user object.
- $user = JFactory::getUser();
+ // Get the user object if not set.
+ if (ComponentbuilderHelper::checkObject($user))
+ {
+ $user = JFactory::getUser();
+ }
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
diff --git a/componentbuilder.xml b/componentbuilder.xml
index d22bbe527..742f61104 100644
--- a/componentbuilder.xml
+++ b/componentbuilder.xml
@@ -1,7 +1,7 @@
COM_COMPONENTBUILDER
- 2nd September, 2019
+ 4th September, 2019
Llewellyn van der Merwe
llewellyn@joomlacomponentbuilder.com
http://www.joomlacomponentbuilder.com
diff --git a/script.php b/script.php
index f4219a64f..335f48ca0 100644
--- a/script.php
+++ b/script.php
@@ -3938,7 +3938,7 @@ class com_componentbuilderInstallerScript
}
- /// Remove Componentbuilder from the action_logs_extensions table
+ // Remove Componentbuilder from the action_logs_extensions table
$componentbuilder_action_logs_extensions = array( $db->quoteName('extension') . ' = ' . $db->quote('com_componentbuilder') );
// Create a new query object.
$query = $db->getQuery(true);
diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php
index b7b8b8d7a..89aefba5c 100644
--- a/site/helpers/componentbuilder.php
+++ b/site/helpers/componentbuilder.php
@@ -1996,6 +1996,41 @@ abstract class ComponentbuilderHelper
return $default;
}
+ /**
+ * Tab/spacer bucket (to speed-up the build)
+ *
+ * @var array
+ */
+ protected static $tabSpacerBucket = array();
+
+ /**
+ * Set tab/spacer
+ *
+ * @var string
+ */
+ protected static $tabSpacer = "\t";
+
+ /**
+ * Set the tab/space
+ *
+ * @param int $nr The number of tag/space
+ *
+ * @return string
+ *
+ */
+ public static function _t($nr)
+ {
+ // check if we already have the string
+ if (!isset(self::$tabSpacerBucket[$nr]))
+ {
+ // get the string
+ self::$tabSpacerBucket[$nr] = str_repeat(self::$tabSpacer, (int) $nr);
+ }
+ // return stored string
+ return self::$tabSpacerBucket[$nr];
+ }
+
+
/**
* the Butler
**/
@@ -2463,6 +2498,15 @@ abstract class ComponentbuilderHelper
}
+ /**
+ * get Dynamic Scripts
+ *
+ * @param string $type The target type of string
+ * @param string $fieldName The target field name of string
+ *
+ * @return void
+ *
+ */
public static function getDynamicScripts($type, $fieldName = false)
{
// if field name is passed the convert to type
@@ -2491,697 +2535,696 @@ abstract class ComponentbuilderHelper
if ('display' === $type)
{
// set the display script
- $script['display'][] = "\tprotected \$headerList;";
- $script['display'][] = "\tprotected \$hasPackage = false;";
- $script['display'][] = "\tprotected \$headers;";
- $script['display'][] = "\tprotected \$hasHeader = 0;";
- $script['display'][] = "\tprotected \$dataType;";
- $script['display'][] = "\n\tpublic function display(\$tpl = null)";
- $script['display'][] = "\t{";
- $script['display'][] = "\t\tif (\$this->getLayout() !== 'modal')";
- $script['display'][] = "\t\t{";
- $script['display'][] = "\t\t\t// Include helper submenu";
- $script['display'][] = "\t\t\t[[[-#-#-Component]]]Helper::addSubmenu('import');";
- $script['display'][] = "\t\t}";
- $script['display'][] = "\n\t\t\$paths = new stdClass;";
- $script['display'][] = "\t\t\$paths->first = '';";
- $script['display'][] = "\t\t\$state = \$this->get('state');";
- $script['display'][] = "\n\t\t\$this->paths = &\$paths;";
- $script['display'][] = "\t\t\$this->state = &\$state;";
- $script['display'][] = "\t\t// get global action permissions";
- $script['display'][] = "\t\t\$this->canDo = [[[-#-#-Component]]]Helper::getActions('import');";
- $script['display'][] = "\n\t\t// We don't need toolbar in the modal window.";
- $script['display'][] = "\t\tif (\$this->getLayout() !== 'modal')";
- $script['display'][] = "\t\t{";
- $script['display'][] = "\t\t\t\$this->addToolbar();";
- $script['display'][] = "\t\t\t\$this->sidebar = JHtmlSidebar::render();";
- $script['display'][] = "\t\t}";
- $script['display'][] = "\n\t\t// get the session object";
- $script['display'][] = "\t\t\$session = JFactory::getSession();";
- $script['display'][] = "\t\t// check if it has package";
- $script['display'][] = "\t\t\$this->hasPackage \t= \$session->get('hasPackage', false);";
- $script['display'][] = "\t\t\$this->dataType \t= \$session->get('dataType', false);";
- $script['display'][] = "\t\tif(\$this->hasPackage && \$this->dataType)";
- $script['display'][] = "\t\t{";
- $script['display'][] = "\t\t\t\$this->headerList \t= json_decode(\$session->get(\$this->dataType.'_VDM_IMPORTHEADERS', false),true);";
- $script['display'][] = "\t\t\t\$this->headers \t\t= [[[-#-#-Component]]]Helper::getFileHeaders(\$this->dataType);";
- $script['display'][] = "\t\t\t// clear the data type";
- $script['display'][] = "\t\t\t\$session->clear('dataType');";
- $script['display'][] = "\t\t}";
- $script['display'][] = "\n\t\t// Check for errors.";
- $script['display'][] = "\t\tif (count(\$errors = \$this->get('Errors'))){";
- $script['display'][] = "\t\t\tthrow new Exception(implode(".'"\n", $errors), 500);';
- $script['display'][] = "\t\t}";
- $script['display'][] = "\n\t\t// Display the template";
- $script['display'][] = "\t\tparent::display(\$tpl);";
- $script['display'][] = "\t}";
+ $script['display'][] = self::_t(1) . "protected \$headerList;";
+ $script['display'][] = self::_t(1) . "protected \$hasPackage = false;";
+ $script['display'][] = self::_t(1) . "protected \$headers;";
+ $script['display'][] = self::_t(1) . "protected \$hasHeader = 0;";
+ $script['display'][] = self::_t(1) . "protected \$dataType;";
+ $script['display'][] = self::_t(1) . "public function display(\$tpl = null)";
+ $script['display'][] = self::_t(1) . "{";
+ $script['display'][] = self::_t(2) . "if (\$this->getLayout() !== 'modal')";
+ $script['display'][] = self::_t(2) . "{";
+ $script['display'][] = self::_t(3) . "// Include helper submenu";
+ $script['display'][] = self::_t(3) . "[[[-#-#-Component]]]Helper::addSubmenu('import');";
+ $script['display'][] = self::_t(2) . "}";
+ $script['display'][] = PHP_EOL . self::_t(2) . "\$paths = new stdClass;";
+ $script['display'][] = self::_t(2) . "\$paths->first = '';";
+ $script['display'][] = self::_t(2) . "\$state = \$this->get('state');";
+ $script['display'][] = PHP_EOL . self::_t(2) . "\$this->paths = &\$paths;";
+ $script['display'][] = self::_t(2) . "\$this->state = &\$state;";
+ $script['display'][] = self::_t(2) . "// get global action permissions";
+ $script['display'][] = self::_t(2) . "\$this->canDo = [[[-#-#-Component]]]Helper::getActions('import');";
+ $script['display'][] = PHP_EOL . self::_t(2) . "// We don't need toolbar in the modal window.";
+ $script['display'][] = self::_t(2) . "if (\$this->getLayout() !== 'modal')";
+ $script['display'][] = self::_t(2) . "{";
+ $script['display'][] = self::_t(3) . "\$this->addToolbar();";
+ $script['display'][] = self::_t(3) . "\$this->sidebar = JHtmlSidebar::render();";
+ $script['display'][] = self::_t(2) . "}";
+ $script['display'][] = PHP_EOL . self::_t(2) . "// get the session object";
+ $script['display'][] = self::_t(2) . "\$session = JFactory::getSession();";
+ $script['display'][] = self::_t(2) . "// check if it has package";
+ $script['display'][] = self::_t(2) . "\$this->hasPackage" . self::_t(1) . "= \$session->get('hasPackage', false);";
+ $script['display'][] = self::_t(2) . "\$this->dataType" . self::_t(1) . "= \$session->get('dataType', false);";
+ $script['display'][] = self::_t(2) . "if(\$this->hasPackage && \$this->dataType)";
+ $script['display'][] = self::_t(2) . "{";
+ $script['display'][] = self::_t(3) . "\$this->headerList" . self::_t(1) . "= json_decode(\$session->get(\$this->dataType.'_VDM_IMPORTHEADERS', false),true);";
+ $script['display'][] = self::_t(3) . "\$this->headers" . self::_t(2) . "= [[[-#-#-Component]]]Helper::getFileHeaders(\$this->dataType);";
+ $script['display'][] = self::_t(3) . "// clear the data type";
+ $script['display'][] = self::_t(3) . "\$session->clear('dataType');";
+ $script['display'][] = self::_t(2) . "}";
+ $script['display'][] = PHP_EOL . self::_t(2) . "// Check for errors.";
+ $script['display'][] = self::_t(2) . "if (count(\$errors = \$this->get('Errors'))){";
+ $script['display'][] = self::_t(3) . "throw new Exception(implode(PHP_EOL, \$errors), 500);";
+ $script['display'][] = self::_t(2) . "}";
+ $script['display'][] = PHP_EOL . self::_t(2) . "// Display the template";
+ $script['display'][] = self::_t(2) . "parent::display(\$tpl);";
+ $script['display'][] = self::_t(1) . "}";
}
elseif ('setdata' === $type)
{
// set the setdata script
$script['setdata'] = array();
- $script['setdata'][] = "\t/**";
- $script['setdata'][] = "\t* Set the data from the spreadsheet to the database";
- $script['setdata'][] = "\t*";
- $script['setdata'][] = "\t* @param string \$package Paths to the uploaded package file";
- $script['setdata'][] = "\t*";
- $script['setdata'][] = "\t* @return boolean false on failure";
- $script['setdata'][] = "\t*";
- $script['setdata'][] = "\t**/";
- $script['setdata'][] = "\tprotected function setData(\$package,\$table,\$target_headers)";
- $script['setdata'][] = "\t{";
- $script['setdata'][] = "\t\tif ([[[-#-#-Component]]]Helper::checkArray(\$target_headers))";
- $script['setdata'][] = "\t\t{";
- $script['setdata'][] = "\t\t\t// make sure the file is loaded\t\t";
- $script['setdata'][] = "\t\t\tJLoader::import('PHPExcel', JPATH_COMPONENT_ADMINISTRATOR . '/helpers');";
- $script['setdata'][] = "\t\t\t\$jinput = JFactory::getApplication()->input;";
- $script['setdata'][] = "\t\t\tforeach(\$target_headers as \$header)";
- $script['setdata'][] = "\t\t\t{";
- $script['setdata'][] = "\t\t\t\t\$data['target_headers'][\$header] = \$jinput->getString(\$header, null);";
- $script['setdata'][] = "\t\t\t}";
- $script['setdata'][] = "\t\t\t// set the data";
- $script['setdata'][] = "\t\t\tif(isset(\$package['dir']))";
- $script['setdata'][] = "\t\t\t{";
- $script['setdata'][] = "\t\t\t\t\$inputFileType = PHPExcel_IOFactory::identify(\$package['dir']);";
- $script['setdata'][] = "\t\t\t\t\$excelReader = PHPExcel_IOFactory::createReader(\$inputFileType);";
- $script['setdata'][] = "\t\t\t\t\$excelReader->setReadDataOnly(true);";
- $script['setdata'][] = "\t\t\t\t\$excelObj = \$excelReader->load(\$package['dir']);";
- $script['setdata'][] = "\t\t\t\t\$data['array'] = \$excelObj->getActiveSheet()->toArray(null, true,true,true);";
- $script['setdata'][] = "\t\t\t\t\$excelObj->disconnectWorksheets();";
- $script['setdata'][] = "\t\t\t\tunset(\$excelObj);";
- $script['setdata'][] = "\t\t\t\treturn \$this->save(\$data,\$table);";
- $script['setdata'][] = "\t\t\t}";
- $script['setdata'][] = "\t\t}";
- $script['setdata'][] = "\t\treturn false;";
- $script['setdata'][] = "\t}";
+ $script['setdata'][] = self::_t(1) . "/**";
+ $script['setdata'][] = self::_t(1) . "* Set the data from the spreadsheet to the database";
+ $script['setdata'][] = self::_t(1) . "*";
+ $script['setdata'][] = self::_t(1) . "* @param string \$package Paths to the uploaded package file";
+ $script['setdata'][] = self::_t(1) . "*";
+ $script['setdata'][] = self::_t(1) . "* @return boolean false on failure";
+ $script['setdata'][] = self::_t(1) . "*";
+ $script['setdata'][] = self::_t(1) . "**/";
+ $script['setdata'][] = self::_t(1) . "protected function setData(\$package,\$table,\$target_headers)";
+ $script['setdata'][] = self::_t(1) . "{";
+ $script['setdata'][] = self::_t(2) . "if ([[[-#-#-Component]]]Helper::checkArray(\$target_headers))";
+ $script['setdata'][] = self::_t(2) . "{";
+ $script['setdata'][] = self::_t(3) . "// make sure the file is loaded" . self::_t(2) . "";
+ $script['setdata'][] = self::_t(3) . "JLoader::import('PHPExcel', JPATH_COMPONENT_ADMINISTRATOR . '/helpers');";
+ $script['setdata'][] = self::_t(3) . "\$jinput = JFactory::getApplication()->input;";
+ $script['setdata'][] = self::_t(3) . "foreach(\$target_headers as \$header)";
+ $script['setdata'][] = self::_t(3) . "{";
+ $script['setdata'][] = self::_t(4) . "\$data['target_headers'][\$header] = \$jinput->getString(\$header, null);";
+ $script['setdata'][] = self::_t(3) . "}";
+ $script['setdata'][] = self::_t(3) . "// set the data";
+ $script['setdata'][] = self::_t(3) . "if(isset(\$package['dir']))";
+ $script['setdata'][] = self::_t(3) . "{";
+ $script['setdata'][] = self::_t(4) . "\$inputFileType = PHPExcel_IOFactory::identify(\$package['dir']);";
+ $script['setdata'][] = self::_t(4) . "\$excelReader = PHPExcel_IOFactory::createReader(\$inputFileType);";
+ $script['setdata'][] = self::_t(4) . "\$excelReader->setReadDataOnly(true);";
+ $script['setdata'][] = self::_t(4) . "\$excelObj = \$excelReader->load(\$package['dir']);";
+ $script['setdata'][] = self::_t(4) . "\$data['array'] = \$excelObj->getActiveSheet()->toArray(null, true,true,true);";
+ $script['setdata'][] = self::_t(4) . "\$excelObj->disconnectWorksheets();";
+ $script['setdata'][] = self::_t(4) . "unset(\$excelObj);";
+ $script['setdata'][] = self::_t(4) . "return \$this->save(\$data,\$table);";
+ $script['setdata'][] = self::_t(3) . "}";
+ $script['setdata'][] = self::_t(2) . "}";
+ $script['setdata'][] = self::_t(2) . "return false;";
+ $script['setdata'][] = self::_t(1) . "}";
}
elseif ('headers' === $type)
{
$script['headers'] = array();
- $script['headers'][] = "\t/**";
- $script['headers'][] = "\t* Method to get header.";
- $script['headers'][] = "\t*";
- $script['headers'][] = "\t* @return mixed An array of data items on success, false on failure.";
- $script['headers'][] = "\t*/";
- $script['headers'][] = "\tpublic function getExImPortHeaders()";
- $script['headers'][] = "\t{";
- $script['headers'][] = "\t\t// Get a db connection.";
- $script['headers'][] = "\t\t\$db = JFactory::getDbo();";
- $script['headers'][] = "\t\t// get the columns";
- $script['headers'][] = "\t\t\$columns = \$db->getTableColumns(\"#__[[[-#-#-component]]]_[[[-#-#-view]]]\");";
- $script['headers'][] = "\t\tif ([[[-#-#-Component]]]Helper::checkArray(\$columns))";
- $script['headers'][] = "\t\t{";
- $script['headers'][] = "\t\t\t// remove the headers you don't import/export.";
- $script['headers'][] = "\t\t\tunset(\$columns['asset_id']);";
- $script['headers'][] = "\t\t\tunset(\$columns['checked_out']);";
- $script['headers'][] = "\t\t\tunset(\$columns['checked_out_time']);";
- $script['headers'][] = "\t\t\t\$headers = new stdClass();";
- $script['headers'][] = "\t\t\tforeach (\$columns as \$column => \$type)";
- $script['headers'][] = "\t\t\t{";
- $script['headers'][] = "\t\t\t\t\$headers->{\$column} = \$column;";
- $script['headers'][] = "\t\t\t}";
- $script['headers'][] = "\t\t\treturn \$headers;";
- $script['headers'][] = "\t\t}";
- $script['headers'][] = "\t\treturn false;";
- $script['headers'][] = "\t}";
+ $script['headers'][] = self::_t(1) . "/**";
+ $script['headers'][] = self::_t(1) . "* Method to get header.";
+ $script['headers'][] = self::_t(1) . "*";
+ $script['headers'][] = self::_t(1) . "* @return mixed An array of data items on success, false on failure.";
+ $script['headers'][] = self::_t(1) . "*/";
+ $script['headers'][] = self::_t(1) . "public function getExImPortHeaders()";
+ $script['headers'][] = self::_t(1) . "{";
+ $script['headers'][] = self::_t(2) . "// Get a db connection.";
+ $script['headers'][] = self::_t(2) . "\$db = JFactory::getDbo();";
+ $script['headers'][] = self::_t(2) . "// get the columns";
+ $script['headers'][] = self::_t(2) . "\$columns = \$db->getTableColumns(\"#__[[[-#-#-component]]]_[[[-#-#-view]]]\");";
+ $script['headers'][] = self::_t(2) . "if ([[[-#-#-Component]]]Helper::checkArray(\$columns))";
+ $script['headers'][] = self::_t(2) . "{";
+ $script['headers'][] = self::_t(3) . "// remove the headers you don't import/export.";
+ $script['headers'][] = self::_t(3) . "unset(\$columns['asset_id']);";
+ $script['headers'][] = self::_t(3) . "unset(\$columns['checked_out']);";
+ $script['headers'][] = self::_t(3) . "unset(\$columns['checked_out_time']);";
+ $script['headers'][] = self::_t(3) . "\$headers = new stdClass();";
+ $script['headers'][] = self::_t(3) . "foreach (\$columns as \$column => \$type)";
+ $script['headers'][] = self::_t(3) . "{";
+ $script['headers'][] = self::_t(4) . "\$headers->{\$column} = \$column;";
+ $script['headers'][] = self::_t(3) . "}";
+ $script['headers'][] = self::_t(3) . "return \$headers;";
+ $script['headers'][] = self::_t(2) . "}";
+ $script['headers'][] = self::_t(2) . "return false;";
+ $script['headers'][] = self::_t(1) . "}";
}
elseif ('save' === $type)
{
$script['save'] = array();
- $script['save'][] = "\t/**";
- $script['save'][] = "\t* Save the data from the file to the database";
- $script['save'][] = "\t*";
- $script['save'][] = "\t* @param string \$package Paths to the uploaded package file";
- $script['save'][] = "\t*";
- $script['save'][] = "\t* @return boolean false on failure";
- $script['save'][] = "\t*";
- $script['save'][] = "\t**/";
- $script['save'][] = "\tprotected function save(\$data,\$table)";
- $script['save'][] = "\t{";
- $script['save'][] = "\t\t// import the data if there is any";
- $script['save'][] = "\t\tif([[[-#-#-Component]]]Helper::checkArray(\$data['array']))";
- $script['save'][] = "\t\t{";
- $script['save'][] = "\t\t\t// get user object";
- $script['save'][] = "\t\t\t\$user \t\t= JFactory::getUser();";
- $script['save'][] = "\t\t\t// remove header if it has headers";
- $script['save'][] = "\t\t\t\$id_key \t= \$data['target_headers']['id'];";
- $script['save'][] = "\t\t\t\$published_key \t= \$data['target_headers']['published'];";
- $script['save'][] = "\t\t\t\$ordering_key \t= \$data['target_headers']['ordering'];";
- $script['save'][] = "\t\t\t// get the first array set";
- $script['save'][] = "\t\t\t\$firstSet = reset(\$data['array']);";
+ $script['save'][] = self::_t(1) . "/**";
+ $script['save'][] = self::_t(1) . "* Save the data from the file to the database";
+ $script['save'][] = self::_t(1) . "*";
+ $script['save'][] = self::_t(1) . "* @param string \$package Paths to the uploaded package file";
+ $script['save'][] = self::_t(1) . "*";
+ $script['save'][] = self::_t(1) . "* @return boolean false on failure";
+ $script['save'][] = self::_t(1) . "*";
+ $script['save'][] = self::_t(1) . "**/";
+ $script['save'][] = self::_t(1) . "protected function save(\$data,\$table)";
+ $script['save'][] = self::_t(1) . "{";
+ $script['save'][] = self::_t(2) . "// import the data if there is any";
+ $script['save'][] = self::_t(2) . "if([[[-#-#-Component]]]Helper::checkArray(\$data['array']))";
+ $script['save'][] = self::_t(2) . "{";
+ $script['save'][] = self::_t(3) . "// get user object";
+ $script['save'][] = self::_t(3) . "\$user" . self::_t(2) . "= JFactory::getUser();";
+ $script['save'][] = self::_t(3) . "// remove header if it has headers";
+ $script['save'][] = self::_t(3) . "\$id_key" . self::_t(1) . "= \$data['target_headers']['id'];";
+ $script['save'][] = self::_t(3) . "\$published_key" . self::_t(1) . "= \$data['target_headers']['published'];";
+ $script['save'][] = self::_t(3) . "\$ordering_key" . self::_t(1) . "= \$data['target_headers']['ordering'];";
+ $script['save'][] = self::_t(3) . "// get the first array set";
+ $script['save'][] = self::_t(3) . "\$firstSet = reset(\$data['array']);";
$script['save'][] = "";
- $script['save'][] = "\t\t\t// check if first array is a header array and remove if true";
- $script['save'][] = "\t\t\tif(\$firstSet[\$id_key] == 'id' || \$firstSet[\$published_key] == 'published' || \$firstSet[\$ordering_key] == 'ordering')";
- $script['save'][] = "\t\t\t{";
- $script['save'][] = "\t\t\t\tarray_shift(\$data['array']);";
- $script['save'][] = "\t\t\t}";
- $script['save'][] = "\t\t\t";
- $script['save'][] = "\t\t\t// make sure there is still values in array and that it was not only headers";
- $script['save'][] = "\t\t\tif([[[-#-#-Component]]]Helper::checkArray(\$data['array']) && \$user->authorise(\$table.'.import', 'com_[[[-#-#-component]]]') && \$user->authorise('core.import', 'com_[[[-#-#-component]]]'))";
- $script['save'][] = "\t\t\t{";
- $script['save'][] = "\t\t\t\t// set target.";
- $script['save'][] = "\t\t\t\t\$target\t= array_flip(\$data['target_headers']);";
- $script['save'][] = "\t\t\t\t// Get a db connection.";
- $script['save'][] = "\t\t\t\t\$db = JFactory::getDbo();";
- $script['save'][] = "\t\t\t\t// set some defaults";
- $script['save'][] = "\t\t\t\t\$todayDate\t\t= JFactory::getDate()->toSql();";
- $script['save'][] = "\t\t\t\t// get global action permissions";
- $script['save'][] = "\t\t\t\t\$canDo\t\t\t= [[[-#-#-Component]]]Helper::getActions(\$table);";
- $script['save'][] = "\t\t\t\t\$canEdit\t\t= \$canDo->get('core.edit');";
- $script['save'][] = "\t\t\t\t\$canState\t\t= \$canDo->get('core.edit.state');";
- $script['save'][] = "\t\t\t\t\$canCreate\t\t= \$canDo->get('core.create');";
- $script['save'][] = "\t\t\t\t\$hasAlias\t\t= \$this->getAliasesUsed(\$table);";
- $script['save'][] = "\t\t\t\t// prosses the data";
- $script['save'][] = "\t\t\t\tforeach(\$data['array'] as \$row)";
- $script['save'][] = "\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\$found = false;";
- $script['save'][] = "\t\t\t\t\tif (isset(\$row[\$id_key]) && is_numeric(\$row[\$id_key]) && \$row[\$id_key] > 0)";
- $script['save'][] = "\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t// raw items import & update!";
- $script['save'][] = "\t\t\t\t\t\t\$query = \$db->getQuery(true);";
- $script['save'][] = "\t\t\t\t\t\t\$query";
- $script['save'][] = "\t\t\t\t\t\t\t->select('version')";
- $script['save'][] = "\t\t\t\t\t\t\t->from(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))";
- $script['save'][] = "\t\t\t\t\t\t\t->where(\$db->quoteName('id') . ' = '. \$db->quote(\$row[\$id_key]));";
- $script['save'][] = "\t\t\t\t\t\t// Reset the query using our newly populated query object.";
- $script['save'][] = "\t\t\t\t\t\t\$db->setQuery(\$query);";
- $script['save'][] = "\t\t\t\t\t\t\$db->execute();";
- $script['save'][] = "\t\t\t\t\t\t\$found = \$db->getNumRows();";
- $script['save'][] = "\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t";
- $script['save'][] = "\t\t\t\t\tif(\$found && \$canEdit)";
- $script['save'][] = "\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t// update item";
- $script['save'][] = "\t\t\t\t\t\t\$id \t\t= \$row[\$id_key];";
- $script['save'][] = "\t\t\t\t\t\t\$version\t= \$db->loadResult();";
- $script['save'][] = "\t\t\t\t\t\t// reset all buckets";
- $script['save'][] = "\t\t\t\t\t\t\$query \t\t= \$db->getQuery(true);";
- $script['save'][] = "\t\t\t\t\t\t\$fields \t= array();";
- $script['save'][] = "\t\t\t\t\t\t// Fields to update.";
- $script['save'][] = "\t\t\t\t\t\tforeach(\$row as \$key => \$cell)";
- $script['save'][] = "\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t// ignore column";
- $script['save'][] = "\t\t\t\t\t\t\tif ('IGNORE' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// update modified";
- $script['save'][] = "\t\t\t\t\t\t\tif ('modified_by' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// update modified";
- $script['save'][] = "\t\t\t\t\t\t\tif ('modified' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// update version";
- $script['save'][] = "\t\t\t\t\t\t\tif ('version' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$cell = (int) \$version + 1;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// verify publish authority";
- $script['save'][] = "\t\t\t\t\t\t\tif ('published' == \$target[\$key] && !\$canState)";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// set to update array";
- $script['save'][] = "\t\t\t\t\t\t\tif(in_array(\$key, \$data['target_headers']) && is_numeric(\$cell))";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$fields[] = \$db->quoteName(\$target[\$key]) . ' = ' . \$cell;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\telseif(in_array(\$key, \$data['target_headers']) && is_string(\$cell))";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$fields[] = \$db->quoteName(\$target[\$key]) . ' = ' . \$db->quote(\$cell);";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\telseif(in_array(\$key, \$data['target_headers']) && is_null(\$cell))";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t// if import data is null then set empty";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$fields[] = \$db->quoteName(\$target[\$key]) . \" = ''\";";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t// load the defaults";
- $script['save'][] = "\t\t\t\t\t\t\$fields[]\t= \$db->quoteName('modified_by') . ' = ' . \$db->quote(\$user->id);";
- $script['save'][] = "\t\t\t\t\t\t\$fields[]\t= \$db->quoteName('modified') . ' = ' . \$db->quote(\$todayDate);";
- $script['save'][] = "\t\t\t\t\t\t// Conditions for which records should be updated.";
- $script['save'][] = "\t\t\t\t\t\t\$conditions = array(";
- $script['save'][] = "\t\t\t\t\t\t\t\$db->quoteName('id') . ' = ' . \$id";
- $script['save'][] = "\t\t\t\t\t\t);";
- $script['save'][] = "\t\t\t\t\t\t";
- $script['save'][] = "\t\t\t\t\t\t\$query->update(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))->set(\$fields)->where(\$conditions);";
- $script['save'][] = "\t\t\t\t\t\t\$db->setQuery(\$query);";
- $script['save'][] = "\t\t\t\t\t\t\$db->execute();";
- $script['save'][] = "\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\telseif (\$canCreate)";
- $script['save'][] = "\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t// insert item";
- $script['save'][] = "\t\t\t\t\t\t\$query = \$db->getQuery(true);";
- $script['save'][] = "\t\t\t\t\t\t// reset all buckets";
- $script['save'][] = "\t\t\t\t\t\t\$columns \t= array();";
- $script['save'][] = "\t\t\t\t\t\t\$values \t= array();";
- $script['save'][] = "\t\t\t\t\t\t\$version\t= false;";
- $script['save'][] = "\t\t\t\t\t\t// Insert columns. Insert values.";
- $script['save'][] = "\t\t\t\t\t\tforeach(\$row as \$key => \$cell)";
- $script['save'][] = "\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t// ignore column";
- $script['save'][] = "\t\t\t\t\t\t\tif ('IGNORE' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// remove id";
- $script['save'][] = "\t\t\t\t\t\t\tif ('id' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// update created";
- $script['save'][] = "\t\t\t\t\t\t\tif ('created_by' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// update created";
- $script['save'][] = "\t\t\t\t\t\t\tif ('created' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// Make sure the alias is incremented";
- $script['save'][] = "\t\t\t\t\t\t\tif ('alias' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$cell = \$this->getAlias(\$cell,\$table);";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// update version";
- $script['save'][] = "\t\t\t\t\t\t\tif ('version' == \$target[\$key])";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$cell = 1;";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$version = true;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\t// set to insert array";
- $script['save'][] = "\t\t\t\t\t\t\tif(in_array(\$key, \$data['target_headers']) && is_numeric(\$cell))";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$columns[] \t= \$target[\$key];";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$values[] \t= \$cell;";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\telseif(in_array(\$key, \$data['target_headers']) && is_string(\$cell))";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$columns[] \t= \$target[\$key];";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$values[] \t= \$db->quote(\$cell);";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t\telseif(in_array(\$key, \$data['target_headers']) && is_null(\$cell))";
- $script['save'][] = "\t\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\t// if import data is null then set empty";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$columns[] \t= \$target[\$key];";
- $script['save'][] = "\t\t\t\t\t\t\t\t\$values[] \t= \"''\";";
- $script['save'][] = "\t\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t// load the defaults";
- $script['save'][] = "\t\t\t\t\t\t\$columns[] \t= 'created_by';";
- $script['save'][] = "\t\t\t\t\t\t\$values[] \t= \$db->quote(\$user->id);";
- $script['save'][] = "\t\t\t\t\t\t\$columns[] \t= 'created';";
- $script['save'][] = "\t\t\t\t\t\t\$values[] \t= \$db->quote(\$todayDate);";
- $script['save'][] = "\t\t\t\t\t\tif (!\$version)";
- $script['save'][] = "\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\$columns[] \t= 'version';";
- $script['save'][] = "\t\t\t\t\t\t\t\$values[] \t= 1;";
- $script['save'][] = "\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t\t// Prepare the insert query.";
- $script['save'][] = "\t\t\t\t\t\t\$query";
- $script['save'][] = "\t\t\t\t\t\t\t->insert(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))";
- $script['save'][] = "\t\t\t\t\t\t\t->columns(\$db->quoteName(\$columns))";
- $script['save'][] = "\t\t\t\t\t\t\t->values(implode(',', \$values));";
- $script['save'][] = "\t\t\t\t\t\t// Set the query using our newly populated query object and execute it.";
- $script['save'][] = "\t\t\t\t\t\t\$db->setQuery(\$query);";
- $script['save'][] = "\t\t\t\t\t\t\$done = \$db->execute();";
- $script['save'][] = "\t\t\t\t\t\tif (\$done)";
- $script['save'][] = "\t\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\t\t\$aId = \$db->insertid();";
- $script['save'][] = "\t\t\t\t\t\t\t// make sure the access of asset is set";
- $script['save'][] = "\t\t\t\t\t\t\t[[[-#-#-Component]]]Helper::setAsset(\$aId,\$table);";
- $script['save'][] = "\t\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t\telse";
- $script['save'][] = "\t\t\t\t\t{";
- $script['save'][] = "\t\t\t\t\t\treturn false;";
- $script['save'][] = "\t\t\t\t\t}";
- $script['save'][] = "\t\t\t\t}";
- $script['save'][] = "\t\t\t\treturn true;";
- $script['save'][] = "\t\t\t}";
- $script['save'][] = "\t\t}";
- $script['save'][] = "\t\treturn false;";
- $script['save'][] = "\t}";
+ $script['save'][] = self::_t(3) . "// check if first array is a header array and remove if true";
+ $script['save'][] = self::_t(3) . "if(\$firstSet[\$id_key] == 'id' || \$firstSet[\$published_key] == 'published' || \$firstSet[\$ordering_key] == 'ordering')";
+ $script['save'][] = self::_t(3) . "{";
+ $script['save'][] = self::_t(4) . "array_shift(\$data['array']);";
+ $script['save'][] = self::_t(3) . "}";
+ $script['save'][] = self::_t(3) . "";
+ $script['save'][] = self::_t(3) . "// make sure there is still values in array and that it was not only headers";
+ $script['save'][] = self::_t(3) . "if([[[-#-#-Component]]]Helper::checkArray(\$data['array']) && \$user->authorise(\$table.'.import', 'com_[[[-#-#-component]]]') && \$user->authorise('core.import', 'com_[[[-#-#-component]]]'))";
+ $script['save'][] = self::_t(3) . "{";
+ $script['save'][] = self::_t(4) . "// set target.";
+ $script['save'][] = self::_t(4) . "\$target" . self::_t(1) . "= array_flip(\$data['target_headers']);";
+ $script['save'][] = self::_t(4) . "// Get a db connection.";
+ $script['save'][] = self::_t(4) . "\$db = JFactory::getDbo();";
+ $script['save'][] = self::_t(4) . "// set some defaults";
+ $script['save'][] = self::_t(4) . "\$todayDate" . self::_t(2) . "= JFactory::getDate()->toSql();";
+ $script['save'][] = self::_t(4) . "// get global action permissions";
+ $script['save'][] = self::_t(4) . "\$canDo" . self::_t(3) . "= [[[-#-#-Component]]]Helper::getActions(\$table);";
+ $script['save'][] = self::_t(4) . "\$canEdit" . self::_t(2) . "= \$canDo->get('core.edit');";
+ $script['save'][] = self::_t(4) . "\$canState" . self::_t(2) . "= \$canDo->get('core.edit.state');";
+ $script['save'][] = self::_t(4) . "\$canCreate" . self::_t(2) . "= \$canDo->get('core.create');";
+ $script['save'][] = self::_t(4) . "\$hasAlias" . self::_t(2) . "= \$this->getAliasesUsed(\$table);";
+ $script['save'][] = self::_t(4) . "// prosses the data";
+ $script['save'][] = self::_t(4) . "foreach(\$data['array'] as \$row)";
+ $script['save'][] = self::_t(4) . "{";
+ $script['save'][] = self::_t(5) . "\$found = false;";
+ $script['save'][] = self::_t(5) . "if (isset(\$row[\$id_key]) && is_numeric(\$row[\$id_key]) && \$row[\$id_key] > 0)";
+ $script['save'][] = self::_t(5) . "{";
+ $script['save'][] = self::_t(6) . "// raw items import & update!";
+ $script['save'][] = self::_t(6) . "\$query = \$db->getQuery(true);";
+ $script['save'][] = self::_t(6) . "\$query";
+ $script['save'][] = self::_t(7) . "->select('version')";
+ $script['save'][] = self::_t(7) . "->from(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))";
+ $script['save'][] = self::_t(7) . "->where(\$db->quoteName('id') . ' = '. \$db->quote(\$row[\$id_key]));";
+ $script['save'][] = self::_t(6) . "// Reset the query using our newly populated query object.";
+ $script['save'][] = self::_t(6) . "\$db->setQuery(\$query);";
+ $script['save'][] = self::_t(6) . "\$db->execute();";
+ $script['save'][] = self::_t(6) . "\$found = \$db->getNumRows();";
+ $script['save'][] = self::_t(5) . "}";
+ $script['save'][] = self::_t(5) . "";
+ $script['save'][] = self::_t(5) . "if(\$found && \$canEdit)";
+ $script['save'][] = self::_t(5) . "{";
+ $script['save'][] = self::_t(6) . "// update item";
+ $script['save'][] = self::_t(6) . "\$id" . self::_t(2) . "= \$row[\$id_key];";
+ $script['save'][] = self::_t(6) . "\$version" . self::_t(1) . "= \$db->loadResult();";
+ $script['save'][] = self::_t(6) . "// reset all buckets";
+ $script['save'][] = self::_t(6) . "\$query" . self::_t(2) . "= \$db->getQuery(true);";
+ $script['save'][] = self::_t(6) . "\$fields" . self::_t(1) . "= array();";
+ $script['save'][] = self::_t(6) . "// Fields to update.";
+ $script['save'][] = self::_t(6) . "foreach(\$row as \$key => \$cell)";
+ $script['save'][] = self::_t(6) . "{";
+ $script['save'][] = self::_t(7) . "// ignore column";
+ $script['save'][] = self::_t(7) . "if ('IGNORE' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "continue;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// update modified";
+ $script['save'][] = self::_t(7) . "if ('modified_by' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "continue;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// update modified";
+ $script['save'][] = self::_t(7) . "if ('modified' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "continue;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// update version";
+ $script['save'][] = self::_t(7) . "if ('version' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "\$cell = (int) \$version + 1;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// verify publish authority";
+ $script['save'][] = self::_t(7) . "if ('published' == \$target[\$key] && !\$canState)";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "continue;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// set to update array";
+ $script['save'][] = self::_t(7) . "if(in_array(\$key, \$data['target_headers']) && is_numeric(\$cell))";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "\$fields[] = \$db->quoteName(\$target[\$key]) . ' = ' . \$cell;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "elseif(in_array(\$key, \$data['target_headers']) && is_string(\$cell))";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "\$fields[] = \$db->quoteName(\$target[\$key]) . ' = ' . \$db->quote(\$cell);";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "elseif(in_array(\$key, \$data['target_headers']) && is_null(\$cell))";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "// if import data is null then set empty";
+ $script['save'][] = self::_t(8) . "\$fields[] = \$db->quoteName(\$target[\$key]) . \" = ''\";";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(6) . "}";
+ $script['save'][] = self::_t(6) . "// load the defaults";
+ $script['save'][] = self::_t(6) . "\$fields[]" . self::_t(1) . "= \$db->quoteName('modified_by') . ' = ' . \$db->quote(\$user->id);";
+ $script['save'][] = self::_t(6) . "\$fields[]" . self::_t(1) . "= \$db->quoteName('modified') . ' = ' . \$db->quote(\$todayDate);";
+ $script['save'][] = self::_t(6) . "// Conditions for which records should be updated.";
+ $script['save'][] = self::_t(6) . "\$conditions = array(";
+ $script['save'][] = self::_t(7) . "\$db->quoteName('id') . ' = ' . \$id";
+ $script['save'][] = self::_t(6) . ");";
+ $script['save'][] = self::_t(6) . "";
+ $script['save'][] = self::_t(6) . "\$query->update(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))->set(\$fields)->where(\$conditions);";
+ $script['save'][] = self::_t(6) . "\$db->setQuery(\$query);";
+ $script['save'][] = self::_t(6) . "\$db->execute();";
+ $script['save'][] = self::_t(5) . "}";
+ $script['save'][] = self::_t(5) . "elseif (\$canCreate)";
+ $script['save'][] = self::_t(5) . "{";
+ $script['save'][] = self::_t(6) . "// insert item";
+ $script['save'][] = self::_t(6) . "\$query = \$db->getQuery(true);";
+ $script['save'][] = self::_t(6) . "// reset all buckets";
+ $script['save'][] = self::_t(6) . "\$columns" . self::_t(1) . "= array();";
+ $script['save'][] = self::_t(6) . "\$values" . self::_t(1) . "= array();";
+ $script['save'][] = self::_t(6) . "\$version" . self::_t(1) . "= false;";
+ $script['save'][] = self::_t(6) . "// Insert columns. Insert values.";
+ $script['save'][] = self::_t(6) . "foreach(\$row as \$key => \$cell)";
+ $script['save'][] = self::_t(6) . "{";
+ $script['save'][] = self::_t(7) . "// ignore column";
+ $script['save'][] = self::_t(7) . "if ('IGNORE' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "continue;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// remove id";
+ $script['save'][] = self::_t(7) . "if ('id' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "continue;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// update created";
+ $script['save'][] = self::_t(7) . "if ('created_by' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "continue;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// update created";
+ $script['save'][] = self::_t(7) . "if ('created' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "continue;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// Make sure the alias is incremented";
+ $script['save'][] = self::_t(7) . "if ('alias' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "\$cell = \$this->getAlias(\$cell,\$table);";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// update version";
+ $script['save'][] = self::_t(7) . "if ('version' == \$target[\$key])";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "\$cell = 1;";
+ $script['save'][] = self::_t(8) . "\$version = true;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "// set to insert array";
+ $script['save'][] = self::_t(7) . "if(in_array(\$key, \$data['target_headers']) && is_numeric(\$cell))";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "\$columns[]" . self::_t(1) . "= \$target[\$key];";
+ $script['save'][] = self::_t(8) . "\$values[]" . self::_t(1) . "= \$cell;";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "elseif(in_array(\$key, \$data['target_headers']) && is_string(\$cell))";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "\$columns[]" . self::_t(1) . "= \$target[\$key];";
+ $script['save'][] = self::_t(8) . "\$values[]" . self::_t(1) . "= \$db->quote(\$cell);";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(7) . "elseif(in_array(\$key, \$data['target_headers']) && is_null(\$cell))";
+ $script['save'][] = self::_t(7) . "{";
+ $script['save'][] = self::_t(8) . "// if import data is null then set empty";
+ $script['save'][] = self::_t(8) . "\$columns[]" . self::_t(1) . "= \$target[\$key];";
+ $script['save'][] = self::_t(8) . "\$values[]" . self::_t(1) . "= \"''\";";
+ $script['save'][] = self::_t(7) . "}";
+ $script['save'][] = self::_t(6) . "}";
+ $script['save'][] = self::_t(6) . "// load the defaults";
+ $script['save'][] = self::_t(6) . "\$columns[]" . self::_t(1) . "= 'created_by';";
+ $script['save'][] = self::_t(6) . "\$values[]" . self::_t(1) . "= \$db->quote(\$user->id);";
+ $script['save'][] = self::_t(6) . "\$columns[]" . self::_t(1) . "= 'created';";
+ $script['save'][] = self::_t(6) . "\$values[]" . self::_t(1) . "= \$db->quote(\$todayDate);";
+ $script['save'][] = self::_t(6) . "if (!\$version)";
+ $script['save'][] = self::_t(6) . "{";
+ $script['save'][] = self::_t(7) . "\$columns[]" . self::_t(1) . "= 'version';";
+ $script['save'][] = self::_t(7) . "\$values[]" . self::_t(1) . "= 1;";
+ $script['save'][] = self::_t(6) . "}";
+ $script['save'][] = self::_t(6) . "// Prepare the insert query.";
+ $script['save'][] = self::_t(6) . "\$query";
+ $script['save'][] = self::_t(7) . "->insert(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))";
+ $script['save'][] = self::_t(7) . "->columns(\$db->quoteName(\$columns))";
+ $script['save'][] = self::_t(7) . "->values(implode(',', \$values));";
+ $script['save'][] = self::_t(6) . "// Set the query using our newly populated query object and execute it.";
+ $script['save'][] = self::_t(6) . "\$db->setQuery(\$query);";
+ $script['save'][] = self::_t(6) . "\$done = \$db->execute();";
+ $script['save'][] = self::_t(6) . "if (\$done)";
+ $script['save'][] = self::_t(6) . "{";
+ $script['save'][] = self::_t(7) . "\$aId = \$db->insertid();";
+ $script['save'][] = self::_t(7) . "// make sure the access of asset is set";
+ $script['save'][] = self::_t(7) . "[[[-#-#-Component]]]Helper::setAsset(\$aId,\$table);";
+ $script['save'][] = self::_t(6) . "}";
+ $script['save'][] = self::_t(5) . "}";
+ $script['save'][] = self::_t(5) . "else";
+ $script['save'][] = self::_t(5) . "{";
+ $script['save'][] = self::_t(6) . "return false;";
+ $script['save'][] = self::_t(5) . "}";
+ $script['save'][] = self::_t(4) . "}";
+ $script['save'][] = self::_t(4) . "return true;";
+ $script['save'][] = self::_t(3) . "}";
+ $script['save'][] = self::_t(2) . "}";
+ $script['save'][] = self::_t(2) . "return false;";
+ $script['save'][] = self::_t(1) . "}";
}
elseif ('view' === $type)
{
$script['view'] = array();
$script['view'][] = "";
+ $script['view'][] = PHP_EOL . "";
$script['view'][] = "";
- $script['view'][] = "\n";
+ $script['view'][] = PHP_EOL . "