From a310efaf6170681401b86412da34bb908766ce60 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 18 Jan 2018 04:20:20 +0200 Subject: [PATCH] Removed some duplications in the compiler --- admin/helpers/compiler/e_Interpretation.php | 32 ++------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index fb64ff103..9e6bd2de5 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -8103,34 +8103,6 @@ class Interpretation extends Fields $query .= PHP_EOL . "\t\t}"; $query .= PHP_EOL . "\t\treturn false;"; $query .= PHP_EOL . "\t}"; - - // set a default script for those with no custom script - $default = PHP_EOL . PHP_EOL . "\t/**"; - $default .= PHP_EOL . "\t* Method to get header."; - $default .= PHP_EOL . "\t*"; - $default .= PHP_EOL . "\t* @return mixed An array of data items on success, false on failure."; - $default .= PHP_EOL . "\t*/"; - $default .= PHP_EOL . "\tpublic function getExImPortHeaders()"; - $default .= PHP_EOL . "\t{"; - $default .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get a db connection."; - $default .= PHP_EOL . "\t\t\$db = JFactory::getDbo();"; - $default .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " get the columns"; - $default .= PHP_EOL . "\t\t\$columns = \$db->getTableColumns(" . '"#__' . $this->fileContentStatic['###component###'] . '_' . $viewName_single . '");'; - $default .= PHP_EOL . "\t\tif (" . $this->fileContentStatic['###Component###'] . "Helper::checkArray(\$columns))"; - $default .= PHP_EOL . "\t\t{"; - $default .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " remove the headers you don't import/export."; - $default .= PHP_EOL . "\t\t\tunset(\$columns['asset_id']);"; - $default .= PHP_EOL . "\t\t\tunset(\$columns['checked_out']);"; - $default .= PHP_EOL . "\t\t\tunset(\$columns['checked_out_time']);"; - $default .= PHP_EOL . "\t\t\t\$headers = new stdClass();"; - $default .= PHP_EOL . "\t\t\tforeach (\$columns as \$column => \$type)"; - $default .= PHP_EOL . "\t\t\t{"; - $default .= PHP_EOL . "\t\t\t\t\$headers->{\$column} = \$column;"; - $default .= PHP_EOL . "\t\t\t}"; - $default .= PHP_EOL . "\t\t\treturn \$headers;"; - $default .= PHP_EOL . "\t\t}"; - $default .= PHP_EOL . "\t\treturn false;"; - $default .= PHP_EOL . "\t}"; // set some placeholders just incase if (!isset($this->placeholders['###view###']) && !isset($this->placeholders['[[[view]]]'])) @@ -8147,7 +8119,9 @@ class Interpretation extends Fields } // add getExImPortHeaders - $query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true, $default); + $query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true, + // set a default script for those with no custom script + PHP_EOL . PHP_EOL . $this->setPlaceholders(ComponentbuilderHelper::getImportScripts('headers'), $this->placeholders)); // remove place holders if not needed (to not be suprized) if (isset($_viewSet))