From 01149bfb7c3b26e6428949c8b789c2783ce9bed4 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 31 May 2018 12:31:44 +0200 Subject: [PATCH] Mode some improvements to the new relation area. Fixed the notice message regarding the linked fields. --- README.md | 4 +- admin/README.txt | 4 +- admin/helpers/compiler/e_Interpretation.php | 91 +++++++++++++++++-- .../en-GB/en-GB.com_componentbuilder.ini | 4 +- admin/models/ajax.php | 49 +++++----- componentbuilder.xml | 2 +- 6 files changed, 119 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 57d06d7cf..cf1e4283e 100644 --- a/README.md +++ b/README.md @@ -125,11 +125,11 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 30th May, 2018 ++ *Last Build*: 31st May, 2018 + *Version*: 2.8.0 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **185584** ++ *Line count*: **185591** + *Field count*: **1054** + *File count*: **1236** + *Folder count*: **197** diff --git a/admin/README.txt b/admin/README.txt index 57d06d7cf..cf1e4283e 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -125,11 +125,11 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 30th May, 2018 ++ *Last Build*: 31st May, 2018 + *Version*: 2.8.0 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **185584** ++ *Line count*: **185591** + *Field count*: **1054** + *File count*: **1236** + *Folder count*: **197** diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 5dee21f97..d406960a1 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -191,8 +191,7 @@ class Interpretation extends Fields * * @param int $nr The line number * - * @return void - * + * @return string */ private function setLine($nr) { @@ -254,7 +253,10 @@ class Interpretation extends Fields } /** - * @param $view + * set Lock License Per + * + * @param type $view + * @param type $target */ public function setLockLicensePer(&$view, $target) { @@ -280,6 +282,14 @@ class Interpretation extends Fields } } + /** + * Check statment license locked + * + * @param type $boolMethod + * @param type $thIIS + * + * @return string + */ public function checkStatmentLicenseLocked($boolMethod, $thIIS = '$this') { $statment[] = PHP_EOL . $this->_t(2) . "if (!" . $thIIS . "->" . $boolMethod . "())"; @@ -293,6 +303,14 @@ class Interpretation extends Fields return implode(PHP_EOL, $statment); } + /** + * set Bool License Lock + * + * @param type $boolMethod + * @param type $globalbool + * + * @return string + */ public function setBoolLicenseLock($boolMethod, $globalbool) { $bool[] = PHP_EOL . PHP_EOL . $this->_t(1) . "/**"; @@ -325,6 +343,14 @@ class Interpretation extends Fields return implode(PHP_EOL, $bool); } + /** + * set Helper License Lock + * + * @param type $_VDM + * @param type $target + * + * @return string + */ public function setHelperLicenseLock($_VDM, $target) { $helper[] = PHP_EOL . PHP_EOL . $this->_t(1) . "/**"; @@ -348,6 +374,13 @@ class Interpretation extends Fields return implode(PHP_EOL, $helper); } + /** + * set Init License Lock + * + * @param type $_VDM + * + * @return string + */ public function setInitLicenseLock($_VDM) { $init[] = PHP_EOL . "if (!defined('" . $_VDM . "'))"; @@ -362,6 +395,11 @@ class Interpretation extends Fields return implode(PHP_EOL, $init); } + /** + * set WHMCS Cryption + * + * @return string + */ public function setWHMCSCryption() { // make sure we have the correct file @@ -549,6 +587,11 @@ class Interpretation extends Fields return ''; } + /** + * set Get Crypt Key + * + * @return string + */ public function setGetCryptKey() { // ENCRYPT_FILE @@ -714,6 +757,9 @@ class Interpretation extends Fields return ''; } + /** + * set Version Controller + */ public function setVersionController() { if (ComponentbuilderHelper::checkArray($this->componentData->version_update) || ComponentbuilderHelper::checkArray($this->updateSQLBuilder)) @@ -821,6 +867,12 @@ class Interpretation extends Fields } } + /** + * set Dynamic Update XML SQL + * + * @param array $updateXML + * @param bool $current_version + */ public function setDynamicUpdateXMLSQL(&$updateXML, $current_version = false) { // start building the update @@ -864,6 +916,13 @@ class Interpretation extends Fields $this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL); } + /** + * set Update XML SQL + * + * @param array $update + * @param array $updateXML + * @param boolean $addDynamicSQL + */ public function setUpdateXMLSQL(&$update, &$updateXML, &$addDynamicSQL) { // ensure version naming is correct @@ -931,6 +990,11 @@ class Interpretation extends Fields } } + /** + * no Help + * + * @return string + */ public function noHelp() { $help = array(); @@ -6496,23 +6560,36 @@ class Interpretation extends Fields { // set the fields array $field = array(); + // use custom code + $useCustomCode = (isset($this->fieldRelations[$viewName_list][(int) $item['id']]['join_type']) && $this->fieldRelations[$viewName_list][(int) $item['id']]['join_type'] == 2 && + isset($this->fieldRelations[$viewName_list][(int) $item['id']]['set']) && ComponentbuilderHelper::checkString($this->fieldRelations[$viewName_list][(int) $item['id']]['set'])); // load the main list view field $field['[field=' . (int) $item['id'] . ']'] = $this->getListItem($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core, false, $ref, $escape, $user, $refview); + // code name + if (isset($item['code']) && $useCustomCode) + { + $field['$item->{' . (int) $item['id'] . '}'] = '$item->' . $item['code']; + } // now load the relations foreach ($this->fieldRelations[$viewName_list][(int) $item['id']]['joinfields'] as $join) { $blankClass = ''; if (isset($this->listJoinBuilder[$viewName_list]) && isset($this->listJoinBuilder[$viewName_list][(int) $join])) { + // code block $field['[field=' . (int) $join . ']'] = $this->getListItem($this->listJoinBuilder[$viewName_list][(int) $join], $viewName_single, $viewName_list, $blankClass, $doNotEscape, $coreLoad, $core, false, $ref, $escape, $user, $refview); + // code name + if (isset($this->listJoinBuilder[$viewName_list][(int) $join]['code']) && $useCustomCode) + { + $field['$item->{' . (int) $join . '}'] = '$item->' . $this->listJoinBuilder[$viewName_list][(int) $join]['code']; + } } } // join based on join type - if (isset($this->fieldRelations[$viewName_list][(int) $item['id']]['join_type']) && $this->fieldRelations[$viewName_list][(int) $item['id']]['join_type'] == 2 && - isset($this->fieldRelations[$viewName_list][(int) $item['id']]['set']) && ComponentbuilderHelper::checkString($this->fieldRelations[$viewName_list][(int) $item['id']]['set'])) + if ($useCustomCode) { // custom code - return PHP_EOL . $this->_t(3) . "
" . str_replace(array_keys($field), array_values($field), $this->fieldRelations[$viewName_list][(int) $item['id']]['set']) . PHP_EOL . $this->_t(3) . "
"; + return PHP_EOL . $this->_t(3) . "
" . $this->setPlaceholders(str_replace(array_keys($field), array_values($field), $this->fieldRelations[$viewName_list][(int) $item['id']]['set']), $this->placeholders) . PHP_EOL . $this->_t(3) . "
"; } elseif (isset($this->fieldRelations[$viewName_list][(int) $item['id']]['set']) && ComponentbuilderHelper::checkString($this->fieldRelations[$viewName_list][(int) $item['id']]['set'])) { @@ -6520,7 +6597,7 @@ class Interpretation extends Fields return PHP_EOL . $this->_t(3) . "
" . implode($this->fieldRelations[$viewName_list][(int) $item['id']]['set'], $field) . PHP_EOL . $this->_t(3) . "
"; } // default - return PHP_EOL . $this->_t(3) . "
" . implode(' ', $field) . PHP_EOL . $this->_t(3) . "
"; + return PHP_EOL . $this->_t(3) . "
" . implode('', $field) . PHP_EOL . $this->_t(3) . "
"; } return $this->getListItem($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core, $class, $ref, $escape, $user, $refview); } diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 6e5b5b4be..127af19e4 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -6796,8 +6796,8 @@ COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_ACCESS_THE_SERVER_DETAILS_BS_ COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_CLONE_A_COMPONENT_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP="You do not have permission to clone a component, please contact your system administrator for more help." COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_IMPORT_A_COMPONENT_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP="You do not have permission to import a component, please contact your system administrator for more help." COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_SHARE_THE_SNIPPETS_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP="You do not have permission to share the snippets, please contact your system administrator for more help." -COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_FIFTY_S_IS_CONSIDERED_BAD_PRACTICE="You have %s %s. Adding more then 50 %s is considered bad practice." -COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_FIFTY_S_IS_CONSIDERED_BAD_PRACTICE_YOUR_S_PAGE_LOAD_IN_JCB_WILL_SLOWDOWN_YOU_SHOULD_CONSIDER_DECOUPLING_SOME_OF_THESE_S="You have %s %s. Adding more then 50 %s is considered bad practice. Your %s page load in JCB will slowdown. You should consider decoupling some of these %s." +COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_S_S_IS_CONSIDERED_BAD_PRACTICE="You have %s %s. Adding more then %s %s is considered bad practice." +COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_S_S_IS_CONSIDERED_BAD_PRACTICE_YOUR_S_PAGE_LOAD_IN_JCB_WILL_SLOWDOWN_YOU_SHOULD_CONSIDER_DECOUPLING_SOME_OF_THESE_S="You have %s %s. Adding more then %s %s is considered bad practice. Your %s page load in JCB will slowdown. You should consider decoupling some of these %s." COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_FUNCTION_NAME="You must add an unique function name." COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_VALIDATION_RULE_NAME="You must add an unique validation rule name." COM_COMPONENTBUILDER_YOU_MUST_FIRST_LINK_AN_ADMIN_OR_A_CUSTOM_ADMIN_VIEW_TO_THIS_COMPONENT_THEN_YOU_CAN_SELECT_IT_HERE="You must first link an admin or a custom admin view to this component, then you can select it here" diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 0796869ff..9cd953e1f 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -233,24 +233,29 @@ class ComponentbuilderModelAjax extends JModelList return false; } + protected $rowNumbers = array( + 'admin_fields_conditions' => 80, + 'admin_fields' => 50 + ); + protected $buttonArray = array( - 'library_config' => 'libraries_config', - 'library_files_folders_urls' => 'libraries_files_folders_urls', - 'admin_fields' => 'admins_fields', - 'admin_fields_conditions' => 'admins_fields_conditions', - 'admin_fields_relations' => 'admins_fields_relations', - 'validation_rule' => 'validation_rules', - 'field' => 'fields', - 'component_admin_views' => 'components_admin_views' , - 'component_site_views' => 'components_site_views', - 'component_custom_admin_views' => 'components_custom_views', - 'component_updates' => 'components_updates', - 'component_mysql_tweaks' => 'components_mysql_tweaks', - 'component_custom_admin_menus' => 'components_custom_admin_menus', - 'component_config' => 'components_config', - 'component_dashboard' => 'components_dashboard', - 'component_files_folders' => 'components_files_folders', - 'language' => true); + 'library_config' => 'libraries_config', + 'library_files_folders_urls' => 'libraries_files_folders_urls', + 'admin_fields' => 'admins_fields', + 'admin_fields_conditions' => 'admins_fields_conditions', + 'admin_fields_relations' => 'admins_fields_relations', + 'validation_rule' => 'validation_rules', + 'field' => 'fields', + 'component_admin_views' => 'components_admin_views' , + 'component_site_views' => 'components_site_views', + 'component_custom_admin_views' => 'components_custom_views', + 'component_updates' => 'components_updates', + 'component_mysql_tweaks' => 'components_mysql_tweaks', + 'component_custom_admin_menus' => 'components_custom_admin_menus', + 'component_config' => 'components_config', + 'component_dashboard' => 'components_dashboard', + 'component_files_folders' => 'components_files_folders', + 'language' => true); public function getButton($type, $size) { @@ -702,15 +707,17 @@ class ComponentbuilderModelAjax extends JModelList $this->checkRepeatableConversion($fieldsData, $fieldName, $id, $idName); // get the table $table = $this->getSubformTable($type, $fieldsData); + // get row number + $number = (isset($this->rowNumbers[$type]) && $this->rowNumbers[$type]) ? $this->rowNumbers[$type] : false; // set notice of bad practice $notice = ''; - if ($idName === 'admin_view' && isset($this->rowNumber) && $this->rowNumber > 50) + if ($number && isset($this->rowNumber) && $this->rowNumber > $number) { - $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_FIFTY_S_IS_CONSIDERED_BAD_PRACTICE_YOUR_S_PAGE_LOAD_IN_JCB_WILL_SLOWDOWN_YOU_SHOULD_CONSIDER_DECOUPLING_SOME_OF_THESE_S', $this->rowNumber, $typeName, $typeName, $typeName, $typeName) . '
'; + $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_S_S_IS_CONSIDERED_BAD_PRACTICE_YOUR_S_PAGE_LOAD_IN_JCB_WILL_SLOWDOWN_YOU_SHOULD_CONSIDER_DECOUPLING_SOME_OF_THESE_S', $this->rowNumber, $typeName, $number, $typeName, $typeName, $typeName) . '
'; } - elseif ($idName === 'admin_view' && isset($this->rowNumber)) + elseif ($number && isset($this->rowNumber)) { - $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_FIFTY_S_IS_CONSIDERED_BAD_PRACTICE', $this->rowNumber, $typeName, $typeName) . '
'; + $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_S_S_IS_CONSIDERED_BAD_PRACTICE', $this->rowNumber, $typeName, $number, $typeName) . '
'; } // return table return $notice.$table; diff --git a/componentbuilder.xml b/componentbuilder.xml index b7492a831..1c2fd4371 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 30th May, 2018 + 31st May, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com