From f692e573f61d2424480178ee400b6b2344f1e352 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 18 Jan 2018 01:28:44 +0200 Subject: [PATCH] Fixed the compiler to insure the getExImPortHeaders method is added even when no custom script has been set --- README.md | 2 +- admin/README.txt | 2 +- admin/helpers/compiler/e_Interpretation.php | 30 ++++++++++++++++++++- admin/models/admin_views.php | 27 +++++++++++++++++++ admin/models/custom_admin_views.php | 27 +++++++++++++++++++ admin/models/custom_codes.php | 27 +++++++++++++++++++ admin/models/dynamic_gets.php | 27 +++++++++++++++++++ admin/models/fields.php | 27 +++++++++++++++++++ admin/models/fieldtypes.php | 27 +++++++++++++++++++ admin/models/ftps.php | 27 +++++++++++++++++++ admin/models/help_documents.php | 27 +++++++++++++++++++ admin/models/languages.php | 27 +++++++++++++++++++ admin/models/layouts.php | 27 +++++++++++++++++++ admin/models/site_views.php | 27 +++++++++++++++++++ admin/models/snippets.php | 27 +++++++++++++++++++ admin/models/templates.php | 27 +++++++++++++++++++ 16 files changed, 382 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1f3d65f83..1a5b2d5eb 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.6.12 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **180823** ++ *Line count*: **181174** + *Field count*: **1573** + *File count*: **1160** + *Folder count*: **186** diff --git a/admin/README.txt b/admin/README.txt index 1f3d65f83..1a5b2d5eb 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.6.12 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **180823** ++ *Line count*: **181174** + *Field count*: **1573** + *File count*: **1160** + *Folder count*: **186** diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index ef1917127..fb64ff103 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -8103,6 +8103,34 @@ 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]]]'])) @@ -8119,7 +8147,7 @@ class Interpretation extends Fields } // add getExImPortHeaders - $query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true); + $query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true, $default); // remove place holders if not needed (to not be suprized) if (isset($_viewSet)) diff --git a/admin/models/admin_views.php b/admin/models/admin_views.php index 258ab9079..ddba14a1f 100644 --- a/admin/models/admin_views.php +++ b/admin/models/admin_views.php @@ -346,6 +346,33 @@ class ComponentbuilderModelAdmin_views extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_admin_view"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/custom_admin_views.php b/admin/models/custom_admin_views.php index 43849e1b3..b4b6f9f8b 100644 --- a/admin/models/custom_admin_views.php +++ b/admin/models/custom_admin_views.php @@ -306,6 +306,33 @@ class ComponentbuilderModelCustom_admin_views extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_custom_admin_view"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/custom_codes.php b/admin/models/custom_codes.php index 2e32d19ee..e7b32d13a 100644 --- a/admin/models/custom_codes.php +++ b/admin/models/custom_codes.php @@ -406,6 +406,33 @@ class ComponentbuilderModelCustom_codes extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_custom_code"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/dynamic_gets.php b/admin/models/dynamic_gets.php index c89189dce..c1895652e 100644 --- a/admin/models/dynamic_gets.php +++ b/admin/models/dynamic_gets.php @@ -351,6 +351,33 @@ class ComponentbuilderModelDynamic_gets extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_dynamic_get"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/fields.php b/admin/models/fields.php index 71e5b6e49..6666d984b 100644 --- a/admin/models/fields.php +++ b/admin/models/fields.php @@ -454,6 +454,33 @@ class ComponentbuilderModelFields extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_field"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/fieldtypes.php b/admin/models/fieldtypes.php index 2b038b530..bbab3cca7 100644 --- a/admin/models/fieldtypes.php +++ b/admin/models/fieldtypes.php @@ -306,6 +306,33 @@ class ComponentbuilderModelFieldtypes extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_fieldtype"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/ftps.php b/admin/models/ftps.php index d289e4b24..e68b7ffbe 100644 --- a/admin/models/ftps.php +++ b/admin/models/ftps.php @@ -281,6 +281,33 @@ class ComponentbuilderModelFtps extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_ftp"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/help_documents.php b/admin/models/help_documents.php index 33503384b..808dea4bc 100644 --- a/admin/models/help_documents.php +++ b/admin/models/help_documents.php @@ -373,6 +373,33 @@ class ComponentbuilderModelHelp_documents extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_help_document"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/languages.php b/admin/models/languages.php index ba08ed3b4..ad1fbc323 100644 --- a/admin/models/languages.php +++ b/admin/models/languages.php @@ -270,6 +270,33 @@ class ComponentbuilderModelLanguages extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_language"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/layouts.php b/admin/models/layouts.php index 28452ebc9..65f4e353d 100644 --- a/admin/models/layouts.php +++ b/admin/models/layouts.php @@ -291,6 +291,33 @@ class ComponentbuilderModelLayouts extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_layout"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/site_views.php b/admin/models/site_views.php index dd188e40a..74c5ed598 100644 --- a/admin/models/site_views.php +++ b/admin/models/site_views.php @@ -306,6 +306,33 @@ class ComponentbuilderModelSite_views extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_site_view"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/snippets.php b/admin/models/snippets.php index 973cd18a2..82533d38a 100644 --- a/admin/models/snippets.php +++ b/admin/models/snippets.php @@ -416,6 +416,33 @@ class ComponentbuilderModelSnippets extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_snippet"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /** diff --git a/admin/models/templates.php b/admin/models/templates.php index 918a67a49..0a7f244e0 100644 --- a/admin/models/templates.php +++ b/admin/models/templates.php @@ -282,6 +282,33 @@ class ComponentbuilderModelTemplates extends JModelList } } return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + // Get a db connection. + $db = JFactory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_template"); + if (ComponentbuilderHelper::checkArray($columns)) + { + // remove the headers you don't import/export. + unset($columns['asset_id']); + unset($columns['checked_out']); + unset($columns['checked_out_time']); + $headers = new stdClass(); + foreach ($columns as $column => $type) + { + $headers->{$column} = $column; + } + return $headers; + } + return false; } /**